improve root access check for transproxy
This commit is contained in:
parent
7d8eea24b1
commit
c39cdcba60
|
@ -6,6 +6,7 @@ package org.torproject.android.settings;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.sufficientlysecure.rootcommands.RootCommands;
|
import org.sufficientlysecure.rootcommands.RootCommands;
|
||||||
|
import org.sufficientlysecure.rootcommands.Shell;
|
||||||
import org.torproject.android.R;
|
import org.torproject.android.R;
|
||||||
import org.torproject.android.service.TorServiceUtils;
|
import org.torproject.android.service.TorServiceUtils;
|
||||||
|
|
||||||
|
@ -146,16 +147,27 @@ public class SettingsPreferences
|
||||||
{
|
{
|
||||||
if (prefRequestRoot.isChecked())
|
if (prefRequestRoot.isChecked())
|
||||||
{
|
{
|
||||||
boolean canRoot = RootCommands.rootAccessGiven();
|
|
||||||
|
|
||||||
|
boolean canRoot = RootCommands.rootAccessGiven();
|
||||||
prefRequestRoot.setChecked(canRoot);
|
prefRequestRoot.setChecked(canRoot);
|
||||||
|
|
||||||
if (!canRoot)
|
if (!canRoot)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Shell shell = Shell.startRootShell();
|
||||||
|
shell.close();
|
||||||
|
|
||||||
|
prefRequestRoot.setChecked(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Toast.makeText(this, R.string.wizard_permissions_no_root_msg, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, R.string.wizard_permissions_no_root_msg, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (preference == prefTransProxyApps)
|
else if (preference == prefTransProxyApps)
|
||||||
{
|
{
|
||||||
startActivity(new Intent(this, AppManager.class));
|
startActivity(new Intent(this, AppManager.class));
|
||||||
|
|
Loading…
Reference in New Issue