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?
- Testing if
File.Exists("/system/bin/su")? Not sure, I think I cannot due to permissions - Testing if Superuser app is installed? Hmm, I think I need a special permission to use
PackageManagerand Superuser is not the onlu su manager (I know SuperSU for example) - Trying to run
suis 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 🙂
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.tagorandroid.os.Build.TAG) if it containstestkeysstring.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)