diff options
| author | jruesga <jorge@ruesga.com> | 2012-10-21 21:00:19 +0200 |
|---|---|---|
| committer | jruesga <jorge@ruesga.com> | 2012-10-21 21:00:19 +0200 |
| commit | 0b0f9fefe889a57d2866542bbc99a3adc9e059e4 (patch) | |
| tree | a42de72b0d3f73681a65be147ad83898ba61c545 /src | |
| parent | c48f71a4368310dbf37c70b194cdc629c4f8d8b3 (diff) | |
Don't allow advanced mode if device is not rooted
Diffstat (limited to 'src')
| -rw-r--r-- | src/com/cyanogenmod/explorer/ExplorerApplication.java | 19 | ||||
| -rw-r--r-- | src/com/cyanogenmod/explorer/activities/preferences/SettingsPreferences.java | 14 |
2 files changed, 21 insertions, 12 deletions
diff --git a/src/com/cyanogenmod/explorer/ExplorerApplication.java b/src/com/cyanogenmod/explorer/ExplorerApplication.java index 3629b5f..2544b5c 100644 --- a/src/com/cyanogenmod/explorer/ExplorerApplication.java +++ b/src/com/cyanogenmod/explorer/ExplorerApplication.java @@ -60,8 +60,8 @@ public final class ExplorerApplication extends Application { private static ExplorerApplication sApp; private static ConsoleHolder sBackgroundConsole; - private static boolean sDebuggable = false; - private static boolean sRootedDevice = false; + private static boolean sIsDebuggable = false; + private static boolean sIsDeviceRooted = false; private final BroadcastReceiver mOnSettingChangeReceiver = new BroadcastReceiver() { @Override @@ -179,10 +179,10 @@ public final class ExplorerApplication extends Application { sApp = this; // Check if the application is debuggable - sDebuggable = (0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)); + sIsDebuggable = (0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)); // Check if the device is rooted - sRootedDevice = new File(getString(R.string.su_binary)).exists(); + sIsDeviceRooted = new File(getString(R.string.su_binary)).exists(); // Register the broadcast receiver IntentFilter filter = new IntentFilter(); @@ -225,7 +225,7 @@ public final class ExplorerApplication extends Application { * @return boolean If the application is debuggable */ public static boolean isDebuggable() { - return sDebuggable; + return sIsDebuggable; } /** @@ -233,8 +233,8 @@ public final class ExplorerApplication extends Application { * * @return boolean If the device is rooted */ - public static boolean isRooted() { - return sRootedDevice; + public static boolean isDeviceRooted() { + return sIsDeviceRooted; } /** @@ -370,12 +370,15 @@ public final class ExplorerApplication extends Application { * @return boolean If the application is running in advanced mode */ public static boolean isAdvancedMode() { + // If device is not rooted, don't allow advanced mode + if (isDeviceRooted()) return false; + boolean defaultValue = ((Boolean)ExplorerSettings. SETTINGS_ADVANCE_MODE. getDefaultValue()).booleanValue(); String id = ExplorerSettings.SETTINGS_ADVANCE_MODE.getId(); - return Preferences.getSharedPreferences().getBoolean(id, defaultValue); + return Preferences.getSharedPreferences().getBoolean(id, defaultValue); } } diff --git a/src/com/cyanogenmod/explorer/activities/preferences/SettingsPreferences.java b/src/com/cyanogenmod/explorer/activities/preferences/SettingsPreferences.java index 21f1640..0bb6e43 100644 --- a/src/com/cyanogenmod/explorer/activities/preferences/SettingsPreferences.java +++ b/src/com/cyanogenmod/explorer/activities/preferences/SettingsPreferences.java @@ -33,6 +33,7 @@ import android.view.View; import android.widget.TextView; import android.widget.Toast; +import com.cyanogenmod.explorer.ExplorerApplication; import com.cyanogenmod.explorer.R; import com.cyanogenmod.explorer.preferences.ExplorerSettings; import com.cyanogenmod.explorer.preferences.ObjectStringIdentifier; @@ -120,7 +121,7 @@ public class SettingsPreferences extends PreferenceActivity { private ListPreference mDefaultLongClickAction; private ListPreference mFreeDiskSpaceWarningLevel; private CheckBoxPreference mComputeFolderStatistics; - private CheckBoxPreference mAllowConsoleSelection; + private CheckBoxPreference mAdvancedSettings; /** * @hide @@ -218,11 +219,16 @@ public class SettingsPreferences extends PreferenceActivity { ExplorerSettings.SETTINGS_COMPUTE_FOLDER_STATISTICS.getId()); this.mComputeFolderStatistics.setOnPreferenceChangeListener(this.mOnChangeListener); - // Allow console selection - this.mAllowConsoleSelection = + // Advanced settings + this.mAdvancedSettings = (CheckBoxPreference)findPreference( ExplorerSettings.SETTINGS_ADVANCE_MODE.getId()); - this.mAllowConsoleSelection.setOnPreferenceChangeListener(this.mOnChangeListener); + if (ExplorerApplication.isDeviceRooted()) { + this.mAdvancedSettings.setOnPreferenceChangeListener(this.mOnChangeListener); + } else { + // Disable the advanced mode + this.mAdvancedSettings.setEnabled(false); + } // Loaded this.mLoaded = true; |
