updated way for checking for ROOT

This commit is contained in:
Nathan Freitas 2012-02-11 22:41:25 -05:00
parent 3ea0d1dcc1
commit 790acb8a53
1 changed files with 15 additions and 1 deletions

View File

@ -118,7 +118,21 @@ public class SettingsPreferences
if (prefRequestRoot.isChecked()) if (prefRequestRoot.isChecked())
{ {
boolean canRoot = TorServiceUtils.isRootPossible(); //boolean canRoot = TorServiceUtils.isRootPossible();
boolean canRoot;
try
{
StringBuilder res = new StringBuilder();
String[] cmd = {"ls /data/data"}; //only root can do this!
int code = TorServiceUtils.doShellCommand(cmd, res, true, true);
canRoot = code > -1;
}
catch (Exception e)
{
//probably not root
canRoot = false;
}
getPreferenceScreen().getPreference(TRANSPROXY_GROUP_IDX).setEnabled(canRoot); getPreferenceScreen().getPreference(TRANSPROXY_GROUP_IDX).setEnabled(canRoot);
prefRequestRoot.setChecked(canRoot); prefRequestRoot.setChecked(canRoot);