From 16162a437e85218105a9a1e1129ddbd28b3f5ea9 Mon Sep 17 00:00:00 2001 From: Jaap Jan Meijer Date: Mon, 8 Aug 2016 16:14:19 +0200 Subject: [PATCH] Revert "Add preference for enabling root access (3/3)" This reverts commit b31f926061591bd0d2fab21150f2ac783d52b261. --- res/values/cm_arrays.xml | 32 -------- res/values/cm_strings.xml | 26 ------- res/xml/development_prefs.xml | 7 -- src/com/android/settings/DevelopmentSettings.java | 92 ----------------------- 4 files changed, 157 deletions(-) delete mode 100644 res/values/cm_arrays.xml delete mode 100644 res/values/cm_strings.xml diff --git a/res/values/cm_arrays.xml b/res/values/cm_arrays.xml deleted file mode 100644 index fd4f551e68..0000000000 --- a/res/values/cm_arrays.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - @string/root_access_none - @string/root_access_apps - @string/root_access_adb - @string/root_access_all - - - - 0 - 1 - 2 - 3 - - \ No newline at end of file diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml deleted file mode 100644 index 9cbd4d92da..0000000000 --- a/res/values/cm_strings.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - Root access - Allow root access? - Allowing applications to request root access is very dangerous and could compromise the security of your system! - Disabled - Apps only - ADB only - Apps and ADB - diff --git a/res/xml/development_prefs.xml b/res/xml/development_prefs.xml index ddc816c3cd..c74d3350c2 100644 --- a/res/xml/development_prefs.xml +++ b/res/xml/development_prefs.xml @@ -66,13 +66,6 @@ android:summary="@string/picture_color_mode_desc" android:persistent="false" /> - - diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java index 3372e51cca..8bb99c5381 100644 --- a/src/com/android/settings/DevelopmentSettings.java +++ b/src/com/android/settings/DevelopmentSettings.java @@ -162,9 +162,6 @@ public class DevelopmentSettings extends SettingsPreferenceFragment private static final String OPENGL_TRACES_KEY = "enable_opengl_traces"; - private static final String ROOT_ACCESS_KEY = "root_access"; - private static final String ROOT_ACCESS_PROPERTY = "persist.sys.root_access"; - private static final String IMMEDIATELY_DESTROY_ACTIVITIES_KEY = "immediately_destroy_activities"; private static final String APP_PROCESS_LIMIT_KEY = "app_process_limit"; @@ -259,10 +256,6 @@ public class DevelopmentSettings extends SettingsPreferenceFragment private ColorModePreference mColorModePreference; - private PreferenceScreen mProcessStats; - private ListPreference mRootAccess; - private Object mSelectedRootValue; - private final ArrayList mAllPrefs = new ArrayList(); private final ArrayList mResetSwitchPrefs @@ -276,7 +269,6 @@ public class DevelopmentSettings extends SettingsPreferenceFragment private Dialog mAdbKeysDialog; private boolean mUnavailable; - private Dialog mRootDialog; @Override protected int getMetricsCategory() { @@ -429,12 +421,6 @@ public class DevelopmentSettings extends SettingsPreferenceFragment removePreference(KEY_COLOR_MODE); mColorModePreference = null; } - - mRootAccess = (ListPreference) findPreference(ROOT_ACCESS_KEY); - mRootAccess.setOnPreferenceChangeListener(this); - if (!removeRootOptionsIfRequired()) { - mAllPrefs.add(mRootAccess); - } } private ListPreference addListPreference(String prefKey) { @@ -461,18 +447,6 @@ public class DevelopmentSettings extends SettingsPreferenceFragment return pref; } - private boolean removeRootOptionsIfRequired() { - // user builds don't get root, and eng always gets root - if (!(Build.IS_DEBUGGABLE || "eng".equals(Build.TYPE))) { - if (mRootAccess != null) { - getPreferenceScreen().removePreference(mRootAccess); - return true; - } - } - - return false; - } - @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); @@ -654,7 +628,6 @@ public class DevelopmentSettings extends SettingsPreferenceFragment updateMobileDataAlwaysOnOptions(); updateSimulateColorSpace(); updateUSBAudioOptions(); - updateRootAccessOptions(); } private void resetDangerousOptions() { @@ -668,7 +641,6 @@ public class DevelopmentSettings extends SettingsPreferenceFragment } resetDebuggerOptions(); writeLogdSizeOption(null); - resetRootAccessOptions(); writeAnimationScaleOption(0, mWindowAnimationScale, null); writeAnimationScaleOption(1, mTransitionAnimationScale, null); writeAnimationScaleOption(2, mAnimatorDurationScale, null); @@ -684,40 +656,6 @@ public class DevelopmentSettings extends SettingsPreferenceFragment pokeSystemProperties(); } - private void updateRootAccessOptions() { - String value = SystemProperties.get(ROOT_ACCESS_PROPERTY, "1"); - mRootAccess.setValue(value); - mRootAccess.setSummary(getResources() - .getStringArray(R.array.root_access_entries)[Integer.valueOf(value)]); - } - - private void writeRootAccessOptions(Object newValue) { - String oldValue = SystemProperties.get(ROOT_ACCESS_PROPERTY, "1"); - SystemProperties.set(ROOT_ACCESS_PROPERTY, newValue.toString()); - if (Integer.valueOf(newValue.toString()) < 2 && !oldValue.equals(newValue) - && "1".equals(SystemProperties.get("service.adb.root", "0"))) { - SystemProperties.set("service.adb.root", "0"); - Settings.Secure.putInt(getActivity().getContentResolver(), - Settings.Secure.ADB_ENABLED, 0); - Settings.Secure.putInt(getActivity().getContentResolver(), - Settings.Secure.ADB_ENABLED, 1); - } - updateRootAccessOptions(); - } - - private void resetRootAccessOptions() { - String oldValue = SystemProperties.get(ROOT_ACCESS_PROPERTY, "1"); - SystemProperties.set(ROOT_ACCESS_PROPERTY, "1"); - if (!oldValue.equals("1") && "1".equals(SystemProperties.get("service.adb.root", "0"))) { - SystemProperties.set("service.adb.root", "0"); - Settings.Secure.putInt(getActivity().getContentResolver(), - Settings.Secure.ADB_ENABLED, 0); - Settings.Secure.putInt(getActivity().getContentResolver(), - Settings.Secure.ADB_ENABLED, 1); - } - updateRootAccessOptions(); - } - private void updateHdcpValues() { ListPreference hdcpChecking = (ListPreference) findPreference(HDCP_CHECKING_KEY); if (hdcpChecking != null) { @@ -1832,25 +1770,6 @@ public class DevelopmentSettings extends SettingsPreferenceFragment } else if (preference == mSimulateColorSpace) { writeSimulateColorSpace(newValue); return true; - } else if (preference == mRootAccess) { - if ("0".equals(SystemProperties.get(ROOT_ACCESS_PROPERTY, "1")) - && !"0".equals(newValue)) { - mSelectedRootValue = newValue; - mDialogClicked = false; - if (mRootDialog != null) { - dismissDialogs(); - } - mRootDialog = new AlertDialog.Builder(getActivity()) - .setMessage(getResources().getString(R.string.root_access_warning_message)) - .setTitle(R.string.root_access_warning_title) - .setIcon(android.R.drawable.ic_dialog_alert) - .setPositiveButton(android.R.string.yes, this) - .setNegativeButton(android.R.string.no, this).show(); - mRootDialog.setOnDismissListener(this); - } else { - writeRootAccessOptions(newValue); - } - return true; } return false; } @@ -1868,10 +1787,6 @@ public class DevelopmentSettings extends SettingsPreferenceFragment mEnableDialog.dismiss(); mEnableDialog = null; } - if (mRootDialog != null) { - mRootDialog.dismiss(); - mRootDialog = null; - } } public void onClick(DialogInterface dialog, int which) { @@ -1908,13 +1823,6 @@ public class DevelopmentSettings extends SettingsPreferenceFragment // Reset the toggle mSwitchBar.setChecked(false); } - } else if (dialog == mRootDialog) { - if (which == DialogInterface.BUTTON_POSITIVE) { - writeRootAccessOptions(mSelectedRootValue); - } else { - // Reset the option - writeRootAccessOptions("0"); - } } } -- 2.11.0