From c39cdcba6040fc578fc9eb7f566bd7a542aaf6ec Mon Sep 17 00:00:00 2001 From: Nathan Freitas Date: Thu, 9 Apr 2015 09:14:12 -0400 Subject: [PATCH] improve root access check for transproxy --- .../android/settings/SettingsPreferences.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/org/torproject/android/settings/SettingsPreferences.java b/src/org/torproject/android/settings/SettingsPreferences.java index 147f84d6..339514ac 100644 --- a/src/org/torproject/android/settings/SettingsPreferences.java +++ b/src/org/torproject/android/settings/SettingsPreferences.java @@ -6,6 +6,7 @@ package org.torproject.android.settings; import java.util.Locale; import org.sufficientlysecure.rootcommands.RootCommands; +import org.sufficientlysecure.rootcommands.Shell; import org.torproject.android.R; import org.torproject.android.service.TorServiceUtils; @@ -146,13 +147,24 @@ public class SettingsPreferences { if (prefRequestRoot.isChecked()) { + boolean canRoot = RootCommands.rootAccessGiven(); - prefRequestRoot.setChecked(canRoot); if (!canRoot) { - Toast.makeText(this, R.string.wizard_permissions_no_root_msg, Toast.LENGTH_LONG).show(); + 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(); + } } } }