Loading src/com/android/settings/DevelopmentSettings.java +29 −7 Original line number Diff line number Diff line Loading @@ -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"; Loading Loading @@ -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; Loading @@ -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); Loading Loading @@ -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); Loading Loading @@ -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) { Loading Loading @@ -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; Loading src/com/android/settings/RestrictedSettingsFragment.java +51 −13 Original line number Diff line number Diff line Loading @@ -25,11 +25,16 @@ import android.os.UserManager; /** * Base class for settings activities that should be pin protected when in restricted mode. * The constructor for this class will take the restriction key that this screen should be * locked by. If {@link UserManager.hasRestrictionsPin()} and {@link UserManager.hasUserRestriction(String)} returns true for the * restriction key, then the user will hav * locked by. If {@link UserManager.hasRestrictionsPin()} and * {@link UserManager.hasUserRestriction(String)} returns true for the restriction key, then * the user will have to enter the restrictions pin before seeing the Settings screen. * * If this settings screen should be pin protected whenever * {@link UserManager.hasUserRestriction(String)} returns true, pass in * {@link RESTRICTIONS_PIN_SET} to the constructor instead of a restrictions key. */ public class RestrictedSettingsFragment extends SettingsPreferenceFragment { protected static final String RESTRICTIONS_PIN_SET = "restrictions_pin_set"; // Should be unique across all settings screens that use this. private static final int REQUEST_PIN_CHALLENGE = 12309; Loading @@ -45,21 +50,22 @@ public class RestrictedSettingsFragment extends SettingsPreferenceFragment { private final String mRestrictionKey; public RestrictedSettingsFragment(String restrictedFlag) { mRestrictionKey = restrictedFlag; } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mUserManager = (UserManager) getSystemService(Context.USER_SERVICE); /** * @param restrictionKey The restriction key to check before pin protecting * this settings page. Pass in {@link RESTRICTIONS_PIN_SET} if it should * be PIN protected whenever a restrictions pin is set. Pass in * null if it should never be PIN protected. */ public RestrictedSettingsFragment(String restrictionKey) { mRestrictionKey = restrictionKey; } @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); mUserManager = (UserManager) getSystemService(Context.USER_SERVICE); if (icicle != null) { mChallengeSucceeded = icicle.getBoolean(KEY_CHALLENGE_SUCCEEDED, false); mChallengeRequested = icicle.getBoolean(KEY_CHALLENGE_REQUESTED, false); Loading @@ -79,8 +85,7 @@ public class RestrictedSettingsFragment extends SettingsPreferenceFragment { @Override public void onResume() { super.onResume(); if (mUserManager.hasUserRestriction(mRestrictionKey) && mUserManager.hasRestrictionsPin()) { if (shouldBePinProtected(mRestrictionKey)) { ensurePin(); } } Loading Loading @@ -121,7 +126,40 @@ public class RestrictedSettingsFragment extends SettingsPreferenceFragment { * Used to determine if the settings UI should disable UI. */ protected boolean isRestrictedAndNotPinProtected() { if (mRestrictionKey == null || RESTRICTIONS_PIN_SET.equals(mRestrictionKey)) { return false; } return mUserManager.hasUserRestriction(mRestrictionKey) && !mUserManager.hasRestrictionsPin(); } /** * Called to trigger the pin entry if the given restriction key is locked down. * @param restrictionsKey The restriction key or {@link RESTRICTIONS_PIN_SET} if * pin entry should get triggered if there is a pin set. */ protected boolean restrictionsPinCheck(String restrictionsKey) { if (shouldBePinProtected(restrictionsKey) && !mChallengeSucceeded) { ensurePin(); return false; } else { return true; } } protected boolean hasChallengeSucceeded() { return mChallengeSucceeded; } /** * Returns true if this restrictions key is locked down. */ protected boolean shouldBePinProtected(String restrictionKey) { if (restrictionKey == null) { return false; } boolean restricted = RESTRICTIONS_PIN_SET.equals(restrictionKey) || mUserManager.hasUserRestriction(restrictionKey); return restricted && mUserManager.hasRestrictionsPin(); } } src/com/android/settings/SecuritySettings.java +23 −2 Original line number Diff line number Diff line Loading @@ -45,14 +45,14 @@ import android.util.Log; import com.android.internal.widget.LockPatternUtils; import java.util.ArrayList; import java.util.HashSet; import java.util.List; /** * Gesture lock pattern settings. */ public class SecuritySettings extends SettingsPreferenceFragment public class SecuritySettings extends RestrictedSettingsFragment implements OnPreferenceChangeListener, DialogInterface.OnClickListener { static final String TAG = "SecuritySettings"; // Lock Settings Loading Loading @@ -82,6 +82,8 @@ public class SecuritySettings extends SettingsPreferenceFragment private static final String KEY_NOTIFICATION_ACCESS = "manage_notification_access"; private static final String PACKAGE_MIME_TYPE = "application/vnd.android.package-archive"; private final HashSet<Preference> mProtectedByRestictionsPrefs = new HashSet<Preference>(); private PackageManager mPM; DevicePolicyManager mDPM; Loading @@ -106,6 +108,10 @@ public class SecuritySettings extends SettingsPreferenceFragment private boolean mIsPrimary; public SecuritySettings() { super(null /* Don't ask for restrictions pin on creation. */); } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Loading Loading @@ -303,9 +309,19 @@ public class SecuritySettings extends SettingsPreferenceFragment } } if (shouldBePinProtected(RESTRICTIONS_PIN_SET)) { protectByRestrictions(mToggleAppInstallation); protectByRestrictions(mToggleVerifyApps); } return root; } private void protectByRestrictions(Preference pref) { if (pref != null) { mProtectedByRestictionsPrefs.add(pref); } } private int getNumEnabledNotificationListeners() { final String flat = Settings.Secure.getString(getContentResolver(), Settings.Secure.ENABLED_NOTIFICATION_LISTENERS); Loading Loading @@ -471,6 +487,11 @@ public class SecuritySettings extends SettingsPreferenceFragment @Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { if (mProtectedByRestictionsPrefs.contains(preference) && !restrictionsPinCheck(RESTRICTIONS_PIN_SET)) { return false; } final String key = preference.getKey(); final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils(); Loading src/com/android/settings/WirelessSettings.java +26 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.settings; import java.util.HashSet; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; Loading Loading @@ -44,7 +46,7 @@ import com.android.internal.telephony.TelephonyProperties; import com.android.settings.nfc.NfcEnabler; import com.android.settings.NsdEnabler; public class WirelessSettings extends SettingsPreferenceFragment { public class WirelessSettings extends RestrictedSettingsFragment { private static final String TAG = "WirelessSettings"; private static final String KEY_TOGGLE_AIRPLANE = "toggle_airplane"; Loading Loading @@ -73,7 +75,11 @@ public class WirelessSettings extends SettingsPreferenceFragment { private static final int MANAGE_MOBILE_PLAN_DIALOG_ID = 1; private static final String SAVED_MANAGE_MOBILE_PLAN_MSG = "mManageMobilePlanMessage"; private final HashSet<Preference> mProtectedByRestictionsPrefs = new HashSet<Preference>(); public WirelessSettings() { super(null); } /** * Invoked on each preference click in this hierarchy, overrides * PreferenceActivity's implementation. Used to make sure we track the Loading @@ -81,6 +87,10 @@ public class WirelessSettings extends SettingsPreferenceFragment { */ @Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { if (mProtectedByRestictionsPrefs.contains(preference) && !hasChallengeSucceeded()) { restrictionsPinCheck(RESTRICTIONS_PIN_SET); return false; } log("onPreferenceTreeClick: preference=" + preference); if (preference == mAirplaneModePreference && Boolean.parseBoolean( SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE))) { Loading Loading @@ -145,6 +155,13 @@ public class WirelessSettings extends SettingsPreferenceFragment { } } private void protectByRestrictions(String key) { Preference pref = findPreference(key); if (pref != null) { mProtectedByRestictionsPrefs.add(pref); } } @Override public Dialog onCreateDialog(int dialogId) { log("onCreateDialog: dialogId=" + dialogId); Loading Loading @@ -225,6 +242,8 @@ public class WirelessSettings extends SettingsPreferenceFragment { ps.setDependency(KEY_TOGGLE_AIRPLANE); } } protectByRestrictions(KEY_WIMAX_SETTINGS); // Manually set dependencies for Wifi when not toggleable. if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_WIFI)) { findPreference(KEY_VPN_SETTINGS).setDependency(KEY_TOGGLE_AIRPLANE); Loading @@ -232,7 +251,7 @@ public class WirelessSettings extends SettingsPreferenceFragment { if (isSecondaryUser) { // Disable VPN removePreference(KEY_VPN_SETTINGS); } protectByRestrictions(KEY_VPN_SETTINGS); // Manually set dependencies for Bluetooth when not toggleable. if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_BLUETOOTH)) { // No bluetooth-dependent items in the list. Code kept in case one is added later. Loading @@ -257,6 +276,8 @@ public class WirelessSettings extends SettingsPreferenceFragment { removePreference(KEY_MOBILE_NETWORK_SETTINGS); removePreference(KEY_MANAGE_MOBILE_PLAN); } protectByRestrictions(KEY_MOBILE_NETWORK_SETTINGS); protectByRestrictions(KEY_MANAGE_MOBILE_PLAN); // Remove Airplane Mode settings if it's a stationary device such as a TV. if (getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEVISION)) { Loading @@ -280,6 +301,7 @@ public class WirelessSettings extends SettingsPreferenceFragment { Preference p = findPreference(KEY_TETHER_SETTINGS); p.setTitle(Utils.getTetheringLabel(cm)); } protectByRestrictions(KEY_TETHER_SETTINGS); // Enable link to CMAS app settings depending on the value in config.xml. boolean isCellBroadcastAppLinkEnabled = this.getResources().getBoolean( Loading @@ -300,6 +322,7 @@ public class WirelessSettings extends SettingsPreferenceFragment { Preference ps = findPreference(KEY_CELL_BROADCAST_SETTINGS); if (ps != null) root.removePreference(ps); } protectByRestrictions(KEY_CELL_BROADCAST_SETTINGS); } @Override Loading Loading @@ -345,6 +368,7 @@ public class WirelessSettings extends SettingsPreferenceFragment { mAirplaneModeEnabler.setAirplaneModeInECM(isChoiceYes, mAirplaneModePreference.isChecked()); } super.onActivityResult(requestCode, resultCode, data); } @Override Loading src/com/android/settings/bluetooth/BluetoothSettings.java +6 −8 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; import android.os.UserManager; import android.preference.Preference; import android.preference.PreferenceActivity; import android.preference.PreferenceCategory; Loading Loading @@ -74,7 +73,6 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment { private final IntentFilter mIntentFilter; private UserManager mUserManager; // accessed from inner class (not private to avoid thunks) Preference mMyDevicePreference; Loading @@ -96,13 +94,13 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment { }; public BluetoothSettings() { super(DISALLOW_CONFIG_BLUETOOTH); mIntentFilter = new IntentFilter(BluetoothAdapter.ACTION_LOCAL_NAME_CHANGED); } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mUserManager = (UserManager) getSystemService(Context.USER_SERVICE); mActivityStarted = (savedInstanceState == null); // don't auto start scan after rotation mEmptyView = (TextView) getView().findViewById(android.R.id.empty); Loading Loading @@ -171,7 +169,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { if (mLocalAdapter == null) return; // If the user is not allowed to configure bluetooth, do not show the menu. if (mUserManager.hasUserRestriction(DISALLOW_CONFIG_BLUETOOTH)) return; if (isRestrictedAndNotPinProtected()) return; boolean bluetoothIsEnabled = mLocalAdapter.getBluetoothState() == BluetoothAdapter.STATE_ON; boolean isDiscovering = mLocalAdapter.isDiscovering(); Loading Loading @@ -219,7 +217,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment { } private void startScanning() { if (mUserManager.hasUserRestriction(DISALLOW_CONFIG_BLUETOOTH)) return; if (isRestrictedAndNotPinProtected()) return; if (!mAvailableDevicesCategoryIsPresent) { getPreferenceScreen().addPreference(mAvailableDevicesCategory); } Loading Loading @@ -266,7 +264,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment { mMyDevicePreference.setEnabled(true); preferenceScreen.addPreference(mMyDevicePreference); if (! mUserManager.hasUserRestriction(DISALLOW_CONFIG_BLUETOOTH)) { if (!isRestrictedAndNotPinProtected()) { if (mDiscoverableEnabler == null) { mDiscoverableEnabler = new BluetoothDiscoverableEnabler(getActivity(), mLocalAdapter, mMyDevicePreference); Loading Loading @@ -297,7 +295,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment { } else { mAvailableDevicesCategory.removeAll(); } if (! mUserManager.hasUserRestriction(DISALLOW_CONFIG_BLUETOOTH)) { if (!isRestrictedAndNotPinProtected()) { addDeviceCategory(mAvailableDevicesCategory, R.string.bluetooth_preference_found_devices, BluetoothDeviceFilter.UNBONDED_DEVICE_FILTER); Loading Loading @@ -366,7 +364,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment { public void onClick(View v) { // User clicked on advanced options icon for a device in the list if (v.getTag() instanceof CachedBluetoothDevice) { if (mUserManager.hasUserRestriction(DISALLOW_CONFIG_BLUETOOTH)) return; if (isRestrictedAndNotPinProtected()) return; CachedBluetoothDevice device = (CachedBluetoothDevice) v.getTag(); Loading Loading
src/com/android/settings/DevelopmentSettings.java +29 −7 Original line number Diff line number Diff line Loading @@ -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"; Loading Loading @@ -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; Loading @@ -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); Loading Loading @@ -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); Loading Loading @@ -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) { Loading Loading @@ -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; Loading
src/com/android/settings/RestrictedSettingsFragment.java +51 −13 Original line number Diff line number Diff line Loading @@ -25,11 +25,16 @@ import android.os.UserManager; /** * Base class for settings activities that should be pin protected when in restricted mode. * The constructor for this class will take the restriction key that this screen should be * locked by. If {@link UserManager.hasRestrictionsPin()} and {@link UserManager.hasUserRestriction(String)} returns true for the * restriction key, then the user will hav * locked by. If {@link UserManager.hasRestrictionsPin()} and * {@link UserManager.hasUserRestriction(String)} returns true for the restriction key, then * the user will have to enter the restrictions pin before seeing the Settings screen. * * If this settings screen should be pin protected whenever * {@link UserManager.hasUserRestriction(String)} returns true, pass in * {@link RESTRICTIONS_PIN_SET} to the constructor instead of a restrictions key. */ public class RestrictedSettingsFragment extends SettingsPreferenceFragment { protected static final String RESTRICTIONS_PIN_SET = "restrictions_pin_set"; // Should be unique across all settings screens that use this. private static final int REQUEST_PIN_CHALLENGE = 12309; Loading @@ -45,21 +50,22 @@ public class RestrictedSettingsFragment extends SettingsPreferenceFragment { private final String mRestrictionKey; public RestrictedSettingsFragment(String restrictedFlag) { mRestrictionKey = restrictedFlag; } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mUserManager = (UserManager) getSystemService(Context.USER_SERVICE); /** * @param restrictionKey The restriction key to check before pin protecting * this settings page. Pass in {@link RESTRICTIONS_PIN_SET} if it should * be PIN protected whenever a restrictions pin is set. Pass in * null if it should never be PIN protected. */ public RestrictedSettingsFragment(String restrictionKey) { mRestrictionKey = restrictionKey; } @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); mUserManager = (UserManager) getSystemService(Context.USER_SERVICE); if (icicle != null) { mChallengeSucceeded = icicle.getBoolean(KEY_CHALLENGE_SUCCEEDED, false); mChallengeRequested = icicle.getBoolean(KEY_CHALLENGE_REQUESTED, false); Loading @@ -79,8 +85,7 @@ public class RestrictedSettingsFragment extends SettingsPreferenceFragment { @Override public void onResume() { super.onResume(); if (mUserManager.hasUserRestriction(mRestrictionKey) && mUserManager.hasRestrictionsPin()) { if (shouldBePinProtected(mRestrictionKey)) { ensurePin(); } } Loading Loading @@ -121,7 +126,40 @@ public class RestrictedSettingsFragment extends SettingsPreferenceFragment { * Used to determine if the settings UI should disable UI. */ protected boolean isRestrictedAndNotPinProtected() { if (mRestrictionKey == null || RESTRICTIONS_PIN_SET.equals(mRestrictionKey)) { return false; } return mUserManager.hasUserRestriction(mRestrictionKey) && !mUserManager.hasRestrictionsPin(); } /** * Called to trigger the pin entry if the given restriction key is locked down. * @param restrictionsKey The restriction key or {@link RESTRICTIONS_PIN_SET} if * pin entry should get triggered if there is a pin set. */ protected boolean restrictionsPinCheck(String restrictionsKey) { if (shouldBePinProtected(restrictionsKey) && !mChallengeSucceeded) { ensurePin(); return false; } else { return true; } } protected boolean hasChallengeSucceeded() { return mChallengeSucceeded; } /** * Returns true if this restrictions key is locked down. */ protected boolean shouldBePinProtected(String restrictionKey) { if (restrictionKey == null) { return false; } boolean restricted = RESTRICTIONS_PIN_SET.equals(restrictionKey) || mUserManager.hasUserRestriction(restrictionKey); return restricted && mUserManager.hasRestrictionsPin(); } }
src/com/android/settings/SecuritySettings.java +23 −2 Original line number Diff line number Diff line Loading @@ -45,14 +45,14 @@ import android.util.Log; import com.android.internal.widget.LockPatternUtils; import java.util.ArrayList; import java.util.HashSet; import java.util.List; /** * Gesture lock pattern settings. */ public class SecuritySettings extends SettingsPreferenceFragment public class SecuritySettings extends RestrictedSettingsFragment implements OnPreferenceChangeListener, DialogInterface.OnClickListener { static final String TAG = "SecuritySettings"; // Lock Settings Loading Loading @@ -82,6 +82,8 @@ public class SecuritySettings extends SettingsPreferenceFragment private static final String KEY_NOTIFICATION_ACCESS = "manage_notification_access"; private static final String PACKAGE_MIME_TYPE = "application/vnd.android.package-archive"; private final HashSet<Preference> mProtectedByRestictionsPrefs = new HashSet<Preference>(); private PackageManager mPM; DevicePolicyManager mDPM; Loading @@ -106,6 +108,10 @@ public class SecuritySettings extends SettingsPreferenceFragment private boolean mIsPrimary; public SecuritySettings() { super(null /* Don't ask for restrictions pin on creation. */); } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Loading Loading @@ -303,9 +309,19 @@ public class SecuritySettings extends SettingsPreferenceFragment } } if (shouldBePinProtected(RESTRICTIONS_PIN_SET)) { protectByRestrictions(mToggleAppInstallation); protectByRestrictions(mToggleVerifyApps); } return root; } private void protectByRestrictions(Preference pref) { if (pref != null) { mProtectedByRestictionsPrefs.add(pref); } } private int getNumEnabledNotificationListeners() { final String flat = Settings.Secure.getString(getContentResolver(), Settings.Secure.ENABLED_NOTIFICATION_LISTENERS); Loading Loading @@ -471,6 +487,11 @@ public class SecuritySettings extends SettingsPreferenceFragment @Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { if (mProtectedByRestictionsPrefs.contains(preference) && !restrictionsPinCheck(RESTRICTIONS_PIN_SET)) { return false; } final String key = preference.getKey(); final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils(); Loading
src/com/android/settings/WirelessSettings.java +26 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.settings; import java.util.HashSet; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; Loading Loading @@ -44,7 +46,7 @@ import com.android.internal.telephony.TelephonyProperties; import com.android.settings.nfc.NfcEnabler; import com.android.settings.NsdEnabler; public class WirelessSettings extends SettingsPreferenceFragment { public class WirelessSettings extends RestrictedSettingsFragment { private static final String TAG = "WirelessSettings"; private static final String KEY_TOGGLE_AIRPLANE = "toggle_airplane"; Loading Loading @@ -73,7 +75,11 @@ public class WirelessSettings extends SettingsPreferenceFragment { private static final int MANAGE_MOBILE_PLAN_DIALOG_ID = 1; private static final String SAVED_MANAGE_MOBILE_PLAN_MSG = "mManageMobilePlanMessage"; private final HashSet<Preference> mProtectedByRestictionsPrefs = new HashSet<Preference>(); public WirelessSettings() { super(null); } /** * Invoked on each preference click in this hierarchy, overrides * PreferenceActivity's implementation. Used to make sure we track the Loading @@ -81,6 +87,10 @@ public class WirelessSettings extends SettingsPreferenceFragment { */ @Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { if (mProtectedByRestictionsPrefs.contains(preference) && !hasChallengeSucceeded()) { restrictionsPinCheck(RESTRICTIONS_PIN_SET); return false; } log("onPreferenceTreeClick: preference=" + preference); if (preference == mAirplaneModePreference && Boolean.parseBoolean( SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE))) { Loading Loading @@ -145,6 +155,13 @@ public class WirelessSettings extends SettingsPreferenceFragment { } } private void protectByRestrictions(String key) { Preference pref = findPreference(key); if (pref != null) { mProtectedByRestictionsPrefs.add(pref); } } @Override public Dialog onCreateDialog(int dialogId) { log("onCreateDialog: dialogId=" + dialogId); Loading Loading @@ -225,6 +242,8 @@ public class WirelessSettings extends SettingsPreferenceFragment { ps.setDependency(KEY_TOGGLE_AIRPLANE); } } protectByRestrictions(KEY_WIMAX_SETTINGS); // Manually set dependencies for Wifi when not toggleable. if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_WIFI)) { findPreference(KEY_VPN_SETTINGS).setDependency(KEY_TOGGLE_AIRPLANE); Loading @@ -232,7 +251,7 @@ public class WirelessSettings extends SettingsPreferenceFragment { if (isSecondaryUser) { // Disable VPN removePreference(KEY_VPN_SETTINGS); } protectByRestrictions(KEY_VPN_SETTINGS); // Manually set dependencies for Bluetooth when not toggleable. if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_BLUETOOTH)) { // No bluetooth-dependent items in the list. Code kept in case one is added later. Loading @@ -257,6 +276,8 @@ public class WirelessSettings extends SettingsPreferenceFragment { removePreference(KEY_MOBILE_NETWORK_SETTINGS); removePreference(KEY_MANAGE_MOBILE_PLAN); } protectByRestrictions(KEY_MOBILE_NETWORK_SETTINGS); protectByRestrictions(KEY_MANAGE_MOBILE_PLAN); // Remove Airplane Mode settings if it's a stationary device such as a TV. if (getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEVISION)) { Loading @@ -280,6 +301,7 @@ public class WirelessSettings extends SettingsPreferenceFragment { Preference p = findPreference(KEY_TETHER_SETTINGS); p.setTitle(Utils.getTetheringLabel(cm)); } protectByRestrictions(KEY_TETHER_SETTINGS); // Enable link to CMAS app settings depending on the value in config.xml. boolean isCellBroadcastAppLinkEnabled = this.getResources().getBoolean( Loading @@ -300,6 +322,7 @@ public class WirelessSettings extends SettingsPreferenceFragment { Preference ps = findPreference(KEY_CELL_BROADCAST_SETTINGS); if (ps != null) root.removePreference(ps); } protectByRestrictions(KEY_CELL_BROADCAST_SETTINGS); } @Override Loading Loading @@ -345,6 +368,7 @@ public class WirelessSettings extends SettingsPreferenceFragment { mAirplaneModeEnabler.setAirplaneModeInECM(isChoiceYes, mAirplaneModePreference.isChecked()); } super.onActivityResult(requestCode, resultCode, data); } @Override Loading
src/com/android/settings/bluetooth/BluetoothSettings.java +6 −8 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; import android.os.UserManager; import android.preference.Preference; import android.preference.PreferenceActivity; import android.preference.PreferenceCategory; Loading Loading @@ -74,7 +73,6 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment { private final IntentFilter mIntentFilter; private UserManager mUserManager; // accessed from inner class (not private to avoid thunks) Preference mMyDevicePreference; Loading @@ -96,13 +94,13 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment { }; public BluetoothSettings() { super(DISALLOW_CONFIG_BLUETOOTH); mIntentFilter = new IntentFilter(BluetoothAdapter.ACTION_LOCAL_NAME_CHANGED); } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mUserManager = (UserManager) getSystemService(Context.USER_SERVICE); mActivityStarted = (savedInstanceState == null); // don't auto start scan after rotation mEmptyView = (TextView) getView().findViewById(android.R.id.empty); Loading Loading @@ -171,7 +169,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { if (mLocalAdapter == null) return; // If the user is not allowed to configure bluetooth, do not show the menu. if (mUserManager.hasUserRestriction(DISALLOW_CONFIG_BLUETOOTH)) return; if (isRestrictedAndNotPinProtected()) return; boolean bluetoothIsEnabled = mLocalAdapter.getBluetoothState() == BluetoothAdapter.STATE_ON; boolean isDiscovering = mLocalAdapter.isDiscovering(); Loading Loading @@ -219,7 +217,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment { } private void startScanning() { if (mUserManager.hasUserRestriction(DISALLOW_CONFIG_BLUETOOTH)) return; if (isRestrictedAndNotPinProtected()) return; if (!mAvailableDevicesCategoryIsPresent) { getPreferenceScreen().addPreference(mAvailableDevicesCategory); } Loading Loading @@ -266,7 +264,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment { mMyDevicePreference.setEnabled(true); preferenceScreen.addPreference(mMyDevicePreference); if (! mUserManager.hasUserRestriction(DISALLOW_CONFIG_BLUETOOTH)) { if (!isRestrictedAndNotPinProtected()) { if (mDiscoverableEnabler == null) { mDiscoverableEnabler = new BluetoothDiscoverableEnabler(getActivity(), mLocalAdapter, mMyDevicePreference); Loading Loading @@ -297,7 +295,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment { } else { mAvailableDevicesCategory.removeAll(); } if (! mUserManager.hasUserRestriction(DISALLOW_CONFIG_BLUETOOTH)) { if (!isRestrictedAndNotPinProtected()) { addDeviceCategory(mAvailableDevicesCategory, R.string.bluetooth_preference_found_devices, BluetoothDeviceFilter.UNBONDED_DEVICE_FILTER); Loading Loading @@ -366,7 +364,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment { public void onClick(View v) { // User clicked on advanced options icon for a device in the list if (v.getTag() instanceof CachedBluetoothDevice) { if (mUserManager.hasUserRestriction(DISALLOW_CONFIG_BLUETOOTH)) return; if (isRestrictedAndNotPinProtected()) return; CachedBluetoothDevice device = (CachedBluetoothDevice) v.getTag(); Loading