Wednesday, February 16, 2011

[android-developers] Re: Checking if phone is ROOTED

If you're trying to block features on a rooted phone, then as Dianne
said, there is no guaranteed way. Hackers aren't going to let you
block them.

If you just want to know for analytics or a warning or something a
simple test that still covers most rooted phones is checking for the
Superuser.apk package com.noshufou.android.su. Something like this:

public static String superuserVersion(PackageManager pm) {
try {
PackageInfo pi =
pm.getPackageInfo("com.noshufou.android.su", 0);
try {
return pi.versionName.substring(0,
pi.versionName.indexOf(' '));
} catch (Exception ex) {
return pi.versionName;
}
} catch (NameNotFoundException e) {
return "Not Found";
}
}


If you want to add features for root users then either just do your
exec with su and handle the case that the user denied you, or
initially do something like "su id", or "su" followed by an "exec id"
and check the return value. If it's successful then most likely the
user will allow your future su requests, but still check for errors
just in case they don't.

http://www.xda-developers.com/ is probably a better place for root
related questions. This list tends to be more focused on what's
included in the SDK.

-Kevin


On Feb 16, 9:06 pm, mikedroid <michan...@gmail.com> wrote:
> how to determine if the phone is rooted or not?
>
> does FACTORY_RESET flag can be useD?

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment