*/
public static final String PREF_SHOW = "show";
- private static final ComponentName SYSUI_TUNER = new ComponentName("com.android.systemui",
- "com.android.systemui.tuner.TunerActivity");
-
private static final String ENABLE_ADB = "enable_adb";
private static final String CLEAR_ADB_KEYS = "clear_adb_keys";
private static final String ENABLE_TERMINAL = "enable_terminal";
private static final String USB_CONFIGURATION_KEY = "select_usb_configuration";
private static final String WIFI_LEGACY_DHCP_CLIENT_KEY = "legacy_dhcp_client";
private static final String MOBILE_DATA_ALWAYS_ON = "mobile_data_always_on";
+ private static final String KEY_COLOR_MODE = "color_mode";
private static final String INACTIVE_APPS_KEY = "inactive_apps";
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";
private SwitchPreference mShowAllANRs;
+ private ColorModePreference mColorModePreference;
+
+ private PreferenceScreen mProcessStats;
+ private ListPreference mRootAccess;
+ private Object mSelectedRootValue;
+
private final ArrayList<Preference> mAllPrefs = new ArrayList<Preference>();
private final ArrayList<SwitchPreference> mResetSwitchPrefs
private Dialog mAdbKeysDialog;
private boolean mUnavailable;
-
- private SwitchPreference mTunerUiPref;
+ private Dialog mRootDialog;
@Override
protected int getMetricsCategory() {
mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
if (android.os.Process.myUserHandle().getIdentifier() != UserHandle.USER_OWNER
- || mUm.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES)) {
+ || mUm.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES)
+ || Settings.Global.getInt(getActivity().getContentResolver(),
+ Settings.Global.DEVICE_PROVISIONED, 0) == 0) {
+ // Block access to developer options if the user is not the owner, if user policy
+ // restricts it, or if the device has not been provisioned
mUnavailable = true;
setPreferenceScreen(new PreferenceScreen(getActivity(), null));
return;
mAllPrefs.add(mShowAllANRs);
mResetSwitchPrefs.add(mShowAllANRs);
- mTunerUiPref = findAndInitSwitchPref(TUNER_UI_KEY);
-
Preference hdcpChecking = findPreference(HDCP_CHECKING_KEY);
if (hdcpChecking != null) {
mAllPrefs.add(hdcpChecking);
removePreferenceForProduction(hdcpChecking);
}
+
+ mColorModePreference = (ColorModePreference) findPreference(KEY_COLOR_MODE);
+ mColorModePreference.updateCurrentAndSupported();
+ if (mColorModePreference.getTransformsCount() < 2) {
+ 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) {
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);
setPrefsEnabledState(mLastEnabledState);
}
mSwitchBar.show();
+
+ if (mColorModePreference != null) {
+ mColorModePreference.startListening();
+ mColorModePreference.updateCurrentAndSupported();
+ }
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ if (mColorModePreference != null) {
+ mColorModePreference.stopListening();
+ }
}
@Override
updateMobileDataAlwaysOnOptions();
updateSimulateColorSpace();
updateUSBAudioOptions();
- updateTweakUi();
+ updateRootAccessOptions();
}
private void resetDangerousOptions() {
}
resetDebuggerOptions();
writeLogdSizeOption(null);
+ resetRootAccessOptions();
writeAnimationScaleOption(0, mWindowAnimationScale, null);
writeAnimationScaleOption(1, mTransitionAnimationScale, null);
writeAnimationScaleOption(2, mAnimatorDurationScale, null);
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) {
}
}
- private void updateTweakUi() {
- updateSwitchPreference(mTunerUiPref, getActivity().getPackageManager()
- .getComponentEnabledSetting(SYSUI_TUNER)
- == PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
- mTunerUiPref.setOnPreferenceChangeListener(this);
- }
-
- private void writeTweakUi(Object newValue) {
- Boolean enabled = (Boolean) newValue;
- getActivity().getPackageManager().setComponentEnabledSetting(SYSUI_TUNER,
- enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
- : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
- PackageManager.DONT_KILL_APP);
- }
-
private void updateUSBAudioOptions() {
updateSwitchPreference(mUSBAudio, Settings.Secure.getInt(getContentResolver(),
Settings.Secure.USB_AUDIO_AUTOMATIC_ROUTING_DISABLED, 0) != 0);
} else if (preference == mSimulateColorSpace) {
writeSimulateColorSpace(newValue);
return true;
- } else if (preference == mTunerUiPref) {
- writeTweakUi(newValue);
+ } 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;
mEnableDialog.dismiss();
mEnableDialog = null;
}
+ if (mRootDialog != null) {
+ mRootDialog.dismiss();
+ mRootDialog = null;
+ }
}
public void onClick(DialogInterface dialog, int which) {
// Reset the toggle
mSwitchBar.setChecked(false);
}
+ } else if (dialog == mRootDialog) {
+ if (which == DialogInterface.BUTTON_POSITIVE) {
+ writeRootAccessOptions(mSelectedRootValue);
+ } else {
+ // Reset the option
+ writeRootAccessOptions("0");
+ }
}
}