3

Possible Duplicate:
Determine if running on a rooted device

I would like to know just whether or not a phone is rooted, without requesting root privileges. How can I do that?

  1. Testing if File.Exists("/system/bin/su")? Not sure, I think I cannot due to permissions
  2. Testing if Superuser app is installed? Hmm, I think I need a special permission to use PackageManager and Superuser is not the onlu su manager (I know SuperSU for example)
  3. Trying to run su is not an option because it triggers the su prompt which is something I don't want in a non-root app

Any idea? My purpose is to obtain anonymous statistics on how many devices are rooted, obviously with user's consent :)

Community
  • 1
  • 1
usr-local-ΕΨΗΕΛΩΝ
  • 26,101
  • 30
  • 154
  • 305

2 Answers2

0

Option 1. It is possible, it doesn't need any special permission.

Option 2. The rooted phone may not come with any Superuser manager application.

Option 3. As you said, it's not a good way to detect.

Besides, there's another option that is to check ro.build.tag (using getprop | grep ro.buil.tag or android.os.Build.TAG) if it contains testkeys string.

Edit: for option 1, I would suggest you find by setuid/setgid permission (i.e. find / -perm -2000 -o -perm -4000, and check if su is in the list)

Krypton
  • 3,337
  • 5
  • 32
  • 52
-3

You cannot reliably do this, as what it means for a phone to be "rooted" is not always the same. What all the proposals you will get do is test for some of the popular root-related tools. But it is not possible to detect if the phone has been rooted in a way that does not utilize those tools.

Chris Stratton
  • 39,853
  • 6
  • 84
  • 117