diff options
author | Geoffrey Borggaard <geoffreyb@google.com> | 2013-08-02 18:16:27 -0400 |
---|---|---|
committer | Geoffrey Borggaard <geoffreyb@google.com> | 2013-08-06 17:24:37 -0400 |
commit | fe21d9aaa8a8c7f8a759805ba021b59dd821e4fe (patch) | |
tree | 6ff78c7c639f19c38e8e9af211b27155eea0f3b9 /src/com/android/settings/DevelopmentSettings.java | |
parent | d98d2abda6ce097c6473bb40e36810fa13a66403 (diff) | |
download | packages_apps_Settings-fe21d9aaa8a8c7f8a759805ba021b59dd821e4fe.tar.gz packages_apps_Settings-fe21d9aaa8a8c7f8a759805ba021b59dd821e4fe.tar.bz2 packages_apps_Settings-fe21d9aaa8a8c7f8a759805ba021b59dd821e4fe.zip |
Pin protect more screens.
When these screens are locked down with user restrictions,
it should prompt the user for the restrictions pin before allowing
access to the settings screen.
Change-Id: Iadbb087da2d9470b855ea0bea89f2da1ffb9e854
Diffstat (limited to 'src/com/android/settings/DevelopmentSettings.java')
-rw-r--r-- | src/com/android/settings/DevelopmentSettings.java | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java index 8ed9a7e14..dd04cd9c1 100644 --- a/src/com/android/settings/DevelopmentSettings.java +++ b/src/com/android/settings/DevelopmentSettings.java @@ -79,7 +79,7 @@ import java.util.List; /* * Displays preferences for application developers. */ -public class DevelopmentSettings extends PreferenceFragment +public class DevelopmentSettings extends RestrictedSettingsFragment implements DialogInterface.OnClickListener, DialogInterface.OnDismissListener, OnPreferenceChangeListener, CompoundButton.OnCheckedChangeListener { private static final String TAG = "DevelopmentSettings"; @@ -210,6 +210,7 @@ public class DevelopmentSettings extends PreferenceFragment = new ArrayList<CheckBoxPreference>(); private final HashSet<Preference> mDisabledPrefs = new HashSet<Preference>(); + private final HashSet<Preference> mProtectedByRestrictionsPrefs = new HashSet<Preference>(); // To track whether a confirmation dialog was clicked. private boolean mDialogClicked; @@ -219,6 +220,10 @@ public class DevelopmentSettings extends PreferenceFragment private boolean mUnavailable; + public DevelopmentSettings() { + super(null /* Don't ask for restrictions pin on creation. */); + } + @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); @@ -268,6 +273,13 @@ public class DevelopmentSettings extends PreferenceFragment disableForUser(mPassword); } + if (shouldBePinProtected(RESTRICTIONS_PIN_SET)) { + protectByRestrictions(mEnableAdb); + protectByRestrictions(mClearAdbKeys); + protectByRestrictions(mEnableTerminal); + protectByRestrictions(mPassword); + } + mDebugAppPref = findPreference(DEBUG_APP_KEY); mAllPrefs.add(mDebugAppPref); mWaitForDebugger = findAndInitCheckboxPref(WAIT_FOR_DEBUGGER_KEY); @@ -350,6 +362,12 @@ public class DevelopmentSettings extends PreferenceFragment } } + private void protectByRestrictions(Preference pref) { + if (pref != null) { + mProtectedByRestrictionsPrefs.add(pref); + } + } + private CheckBoxPreference findAndInitCheckboxPref(String key) { CheckBoxPreference pref = (CheckBoxPreference) findPreference(key); if (pref == null) { @@ -793,7 +811,7 @@ public class DevelopmentSettings extends PreferenceFragment if (flinger != null) { Parcel data = Parcel.obtain(); data.writeInterfaceToken("android.ui.ISurfaceComposer"); - final int showUpdates = mShowScreenUpdates.isChecked() ? 1 : 0; + final int showUpdates = mShowScreenUpdates.isChecked() ? 1 : 0; data.writeInt(showUpdates); flinger.transact(1002, data, null, 0); data.recycle(); @@ -810,7 +828,7 @@ public class DevelopmentSettings extends PreferenceFragment if (flinger != null) { Parcel data = Parcel.obtain(); data.writeInterfaceToken("android.ui.ISurfaceComposer"); - final int disableOverlays = mDisableOverlays.isChecked() ? 1 : 0; + final int disableOverlays = mDisableOverlays.isChecked() ? 1 : 0; data.writeInt(disableOverlays); flinger.transact(1008, data, null, 0); data.recycle(); @@ -824,7 +842,7 @@ public class DevelopmentSettings extends PreferenceFragment private void updateHardwareUiOptions() { updateCheckBox(mForceHardwareUi, SystemProperties.getBoolean(HARDWARE_UI_PROPERTY, false)); } - + private void writeHardwareUiOptions() { SystemProperties.set(HARDWARE_UI_PROPERTY, mForceHardwareUi.isChecked() ? "true" : "false"); pokeSystemProperties(); @@ -952,7 +970,7 @@ public class DevelopmentSettings extends PreferenceFragment updateCheckBox(mShowCpuUsage, Settings.Global.getInt(getActivity().getContentResolver(), Settings.Global.SHOW_PROCESSES, 0) != 0); } - + private void writeCpuUsageOptions() { boolean value = mShowCpuUsage.isChecked(); Settings.Global.putInt(getActivity().getContentResolver(), @@ -1160,6 +1178,10 @@ public class DevelopmentSettings extends PreferenceFragment @Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { + if (mProtectedByRestrictionsPrefs.contains(preference) + && !restrictionsPinCheck(RESTRICTIONS_PIN_SET)) { + return false; + } if (Utils.isMonkeyRunning()) { return false; @@ -1198,12 +1220,12 @@ public class DevelopmentSettings extends PreferenceFragment : PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0); } else if (preference == mBugreportInPower) { Settings.Secure.putInt(getActivity().getContentResolver(), - Settings.Secure.BUGREPORT_IN_POWER_MENU, + Settings.Secure.BUGREPORT_IN_POWER_MENU, mBugreportInPower.isChecked() ? 1 : 0); } else if (preference == mKeepScreenOn) { Settings.Global.putInt(getActivity().getContentResolver(), Settings.Global.STAY_ON_WHILE_PLUGGED_IN, - mKeepScreenOn.isChecked() ? + mKeepScreenOn.isChecked() ? (BatteryManager.BATTERY_PLUGGED_AC | BatteryManager.BATTERY_PLUGGED_USB) : 0); } else if (preference == mBtHciSnoopLog) { writeBtHciSnoopLogOptions(); |