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
This commit is contained in:
@@ -79,7 +79,7 @@ import java.util.List;
|
|||||||
/*
|
/*
|
||||||
* Displays preferences for application developers.
|
* Displays preferences for application developers.
|
||||||
*/
|
*/
|
||||||
public class DevelopmentSettings extends PreferenceFragment
|
public class DevelopmentSettings extends RestrictedSettingsFragment
|
||||||
implements DialogInterface.OnClickListener, DialogInterface.OnDismissListener,
|
implements DialogInterface.OnClickListener, DialogInterface.OnDismissListener,
|
||||||
OnPreferenceChangeListener, CompoundButton.OnCheckedChangeListener {
|
OnPreferenceChangeListener, CompoundButton.OnCheckedChangeListener {
|
||||||
private static final String TAG = "DevelopmentSettings";
|
private static final String TAG = "DevelopmentSettings";
|
||||||
@@ -210,6 +210,7 @@ public class DevelopmentSettings extends PreferenceFragment
|
|||||||
= new ArrayList<CheckBoxPreference>();
|
= new ArrayList<CheckBoxPreference>();
|
||||||
|
|
||||||
private final HashSet<Preference> mDisabledPrefs = new HashSet<Preference>();
|
private final HashSet<Preference> mDisabledPrefs = new HashSet<Preference>();
|
||||||
|
private final HashSet<Preference> mProtectedByRestrictionsPrefs = new HashSet<Preference>();
|
||||||
|
|
||||||
// To track whether a confirmation dialog was clicked.
|
// To track whether a confirmation dialog was clicked.
|
||||||
private boolean mDialogClicked;
|
private boolean mDialogClicked;
|
||||||
@@ -219,6 +220,10 @@ public class DevelopmentSettings extends PreferenceFragment
|
|||||||
|
|
||||||
private boolean mUnavailable;
|
private boolean mUnavailable;
|
||||||
|
|
||||||
|
public DevelopmentSettings() {
|
||||||
|
super(null /* Don't ask for restrictions pin on creation. */);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
@@ -268,6 +273,13 @@ public class DevelopmentSettings extends PreferenceFragment
|
|||||||
disableForUser(mPassword);
|
disableForUser(mPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (shouldBePinProtected(RESTRICTIONS_PIN_SET)) {
|
||||||
|
protectByRestrictions(mEnableAdb);
|
||||||
|
protectByRestrictions(mClearAdbKeys);
|
||||||
|
protectByRestrictions(mEnableTerminal);
|
||||||
|
protectByRestrictions(mPassword);
|
||||||
|
}
|
||||||
|
|
||||||
mDebugAppPref = findPreference(DEBUG_APP_KEY);
|
mDebugAppPref = findPreference(DEBUG_APP_KEY);
|
||||||
mAllPrefs.add(mDebugAppPref);
|
mAllPrefs.add(mDebugAppPref);
|
||||||
mWaitForDebugger = findAndInitCheckboxPref(WAIT_FOR_DEBUGGER_KEY);
|
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) {
|
private CheckBoxPreference findAndInitCheckboxPref(String key) {
|
||||||
CheckBoxPreference pref = (CheckBoxPreference) findPreference(key);
|
CheckBoxPreference pref = (CheckBoxPreference) findPreference(key);
|
||||||
if (pref == null) {
|
if (pref == null) {
|
||||||
@@ -793,7 +811,7 @@ public class DevelopmentSettings extends PreferenceFragment
|
|||||||
if (flinger != null) {
|
if (flinger != null) {
|
||||||
Parcel data = Parcel.obtain();
|
Parcel data = Parcel.obtain();
|
||||||
data.writeInterfaceToken("android.ui.ISurfaceComposer");
|
data.writeInterfaceToken("android.ui.ISurfaceComposer");
|
||||||
final int showUpdates = mShowScreenUpdates.isChecked() ? 1 : 0;
|
final int showUpdates = mShowScreenUpdates.isChecked() ? 1 : 0;
|
||||||
data.writeInt(showUpdates);
|
data.writeInt(showUpdates);
|
||||||
flinger.transact(1002, data, null, 0);
|
flinger.transact(1002, data, null, 0);
|
||||||
data.recycle();
|
data.recycle();
|
||||||
@@ -810,7 +828,7 @@ public class DevelopmentSettings extends PreferenceFragment
|
|||||||
if (flinger != null) {
|
if (flinger != null) {
|
||||||
Parcel data = Parcel.obtain();
|
Parcel data = Parcel.obtain();
|
||||||
data.writeInterfaceToken("android.ui.ISurfaceComposer");
|
data.writeInterfaceToken("android.ui.ISurfaceComposer");
|
||||||
final int disableOverlays = mDisableOverlays.isChecked() ? 1 : 0;
|
final int disableOverlays = mDisableOverlays.isChecked() ? 1 : 0;
|
||||||
data.writeInt(disableOverlays);
|
data.writeInt(disableOverlays);
|
||||||
flinger.transact(1008, data, null, 0);
|
flinger.transact(1008, data, null, 0);
|
||||||
data.recycle();
|
data.recycle();
|
||||||
@@ -824,7 +842,7 @@ public class DevelopmentSettings extends PreferenceFragment
|
|||||||
private void updateHardwareUiOptions() {
|
private void updateHardwareUiOptions() {
|
||||||
updateCheckBox(mForceHardwareUi, SystemProperties.getBoolean(HARDWARE_UI_PROPERTY, false));
|
updateCheckBox(mForceHardwareUi, SystemProperties.getBoolean(HARDWARE_UI_PROPERTY, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeHardwareUiOptions() {
|
private void writeHardwareUiOptions() {
|
||||||
SystemProperties.set(HARDWARE_UI_PROPERTY, mForceHardwareUi.isChecked() ? "true" : "false");
|
SystemProperties.set(HARDWARE_UI_PROPERTY, mForceHardwareUi.isChecked() ? "true" : "false");
|
||||||
pokeSystemProperties();
|
pokeSystemProperties();
|
||||||
@@ -952,7 +970,7 @@ public class DevelopmentSettings extends PreferenceFragment
|
|||||||
updateCheckBox(mShowCpuUsage, Settings.Global.getInt(getActivity().getContentResolver(),
|
updateCheckBox(mShowCpuUsage, Settings.Global.getInt(getActivity().getContentResolver(),
|
||||||
Settings.Global.SHOW_PROCESSES, 0) != 0);
|
Settings.Global.SHOW_PROCESSES, 0) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeCpuUsageOptions() {
|
private void writeCpuUsageOptions() {
|
||||||
boolean value = mShowCpuUsage.isChecked();
|
boolean value = mShowCpuUsage.isChecked();
|
||||||
Settings.Global.putInt(getActivity().getContentResolver(),
|
Settings.Global.putInt(getActivity().getContentResolver(),
|
||||||
@@ -1160,6 +1178,10 @@ public class DevelopmentSettings extends PreferenceFragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
|
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
|
||||||
|
if (mProtectedByRestrictionsPrefs.contains(preference)
|
||||||
|
&& !restrictionsPinCheck(RESTRICTIONS_PIN_SET)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (Utils.isMonkeyRunning()) {
|
if (Utils.isMonkeyRunning()) {
|
||||||
return false;
|
return false;
|
||||||
@@ -1198,12 +1220,12 @@ public class DevelopmentSettings extends PreferenceFragment
|
|||||||
: PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
|
: PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
|
||||||
} else if (preference == mBugreportInPower) {
|
} else if (preference == mBugreportInPower) {
|
||||||
Settings.Secure.putInt(getActivity().getContentResolver(),
|
Settings.Secure.putInt(getActivity().getContentResolver(),
|
||||||
Settings.Secure.BUGREPORT_IN_POWER_MENU,
|
Settings.Secure.BUGREPORT_IN_POWER_MENU,
|
||||||
mBugreportInPower.isChecked() ? 1 : 0);
|
mBugreportInPower.isChecked() ? 1 : 0);
|
||||||
} else if (preference == mKeepScreenOn) {
|
} else if (preference == mKeepScreenOn) {
|
||||||
Settings.Global.putInt(getActivity().getContentResolver(),
|
Settings.Global.putInt(getActivity().getContentResolver(),
|
||||||
Settings.Global.STAY_ON_WHILE_PLUGGED_IN,
|
Settings.Global.STAY_ON_WHILE_PLUGGED_IN,
|
||||||
mKeepScreenOn.isChecked() ?
|
mKeepScreenOn.isChecked() ?
|
||||||
(BatteryManager.BATTERY_PLUGGED_AC | BatteryManager.BATTERY_PLUGGED_USB) : 0);
|
(BatteryManager.BATTERY_PLUGGED_AC | BatteryManager.BATTERY_PLUGGED_USB) : 0);
|
||||||
} else if (preference == mBtHciSnoopLog) {
|
} else if (preference == mBtHciSnoopLog) {
|
||||||
writeBtHciSnoopLogOptions();
|
writeBtHciSnoopLogOptions();
|
||||||
|
@@ -25,11 +25,16 @@ import android.os.UserManager;
|
|||||||
/**
|
/**
|
||||||
* Base class for settings activities that should be pin protected when in restricted mode.
|
* 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
|
* 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
|
* locked by. If {@link UserManager.hasRestrictionsPin()} and
|
||||||
* restriction key, then the user will hav
|
* {@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 {
|
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.
|
// Should be unique across all settings screens that use this.
|
||||||
private static final int REQUEST_PIN_CHALLENGE = 12309;
|
private static final int REQUEST_PIN_CHALLENGE = 12309;
|
||||||
@@ -45,21 +50,22 @@ public class RestrictedSettingsFragment extends SettingsPreferenceFragment {
|
|||||||
|
|
||||||
private final String mRestrictionKey;
|
private final String mRestrictionKey;
|
||||||
|
|
||||||
public RestrictedSettingsFragment(String restrictedFlag) {
|
/**
|
||||||
mRestrictionKey = restrictedFlag;
|
* @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
|
||||||
@Override
|
* null if it should never be PIN protected.
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
*/
|
||||||
super.onActivityCreated(savedInstanceState);
|
public RestrictedSettingsFragment(String restrictionKey) {
|
||||||
|
mRestrictionKey = restrictionKey;
|
||||||
mUserManager = (UserManager) getSystemService(Context.USER_SERVICE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
|
|
||||||
|
mUserManager = (UserManager) getSystemService(Context.USER_SERVICE);
|
||||||
|
|
||||||
if (icicle != null) {
|
if (icicle != null) {
|
||||||
mChallengeSucceeded = icicle.getBoolean(KEY_CHALLENGE_SUCCEEDED, false);
|
mChallengeSucceeded = icicle.getBoolean(KEY_CHALLENGE_SUCCEEDED, false);
|
||||||
mChallengeRequested = icicle.getBoolean(KEY_CHALLENGE_REQUESTED, false);
|
mChallengeRequested = icicle.getBoolean(KEY_CHALLENGE_REQUESTED, false);
|
||||||
@@ -79,8 +85,7 @@ public class RestrictedSettingsFragment extends SettingsPreferenceFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
if (mUserManager.hasUserRestriction(mRestrictionKey)
|
if (shouldBePinProtected(mRestrictionKey)) {
|
||||||
&& mUserManager.hasRestrictionsPin()) {
|
|
||||||
ensurePin();
|
ensurePin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,7 +126,40 @@ public class RestrictedSettingsFragment extends SettingsPreferenceFragment {
|
|||||||
* Used to determine if the settings UI should disable UI.
|
* Used to determine if the settings UI should disable UI.
|
||||||
*/
|
*/
|
||||||
protected boolean isRestrictedAndNotPinProtected() {
|
protected boolean isRestrictedAndNotPinProtected() {
|
||||||
|
if (mRestrictionKey == null || RESTRICTIONS_PIN_SET.equals(mRestrictionKey)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return mUserManager.hasUserRestriction(mRestrictionKey)
|
return mUserManager.hasUserRestriction(mRestrictionKey)
|
||||||
&& !mUserManager.hasRestrictionsPin();
|
&& !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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -45,14 +45,14 @@ import android.util.Log;
|
|||||||
import com.android.internal.widget.LockPatternUtils;
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gesture lock pattern settings.
|
* Gesture lock pattern settings.
|
||||||
*/
|
*/
|
||||||
public class SecuritySettings extends SettingsPreferenceFragment
|
public class SecuritySettings extends RestrictedSettingsFragment
|
||||||
implements OnPreferenceChangeListener, DialogInterface.OnClickListener {
|
implements OnPreferenceChangeListener, DialogInterface.OnClickListener {
|
||||||
|
|
||||||
static final String TAG = "SecuritySettings";
|
static final String TAG = "SecuritySettings";
|
||||||
|
|
||||||
// Lock Settings
|
// Lock Settings
|
||||||
@@ -82,6 +82,8 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
private static final String KEY_NOTIFICATION_ACCESS = "manage_notification_access";
|
private static final String KEY_NOTIFICATION_ACCESS = "manage_notification_access";
|
||||||
private static final String PACKAGE_MIME_TYPE = "application/vnd.android.package-archive";
|
private static final String PACKAGE_MIME_TYPE = "application/vnd.android.package-archive";
|
||||||
|
|
||||||
|
private final HashSet<Preference> mProtectedByRestictionsPrefs = new HashSet<Preference>();
|
||||||
|
|
||||||
private PackageManager mPM;
|
private PackageManager mPM;
|
||||||
DevicePolicyManager mDPM;
|
DevicePolicyManager mDPM;
|
||||||
|
|
||||||
@@ -106,6 +108,10 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
private boolean mIsPrimary;
|
private boolean mIsPrimary;
|
||||||
|
|
||||||
|
public SecuritySettings() {
|
||||||
|
super(null /* Don't ask for restrictions pin on creation. */);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -303,9 +309,19 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (shouldBePinProtected(RESTRICTIONS_PIN_SET)) {
|
||||||
|
protectByRestrictions(mToggleAppInstallation);
|
||||||
|
protectByRestrictions(mToggleVerifyApps);
|
||||||
|
}
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void protectByRestrictions(Preference pref) {
|
||||||
|
if (pref != null) {
|
||||||
|
mProtectedByRestictionsPrefs.add(pref);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private int getNumEnabledNotificationListeners() {
|
private int getNumEnabledNotificationListeners() {
|
||||||
final String flat = Settings.Secure.getString(getContentResolver(),
|
final String flat = Settings.Secure.getString(getContentResolver(),
|
||||||
Settings.Secure.ENABLED_NOTIFICATION_LISTENERS);
|
Settings.Secure.ENABLED_NOTIFICATION_LISTENERS);
|
||||||
@@ -471,6 +487,11 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
|
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
|
||||||
|
if (mProtectedByRestictionsPrefs.contains(preference)
|
||||||
|
&& !restrictionsPinCheck(RESTRICTIONS_PIN_SET)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
final String key = preference.getKey();
|
final String key = preference.getKey();
|
||||||
|
|
||||||
final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
|
final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
@@ -44,7 +46,7 @@ import com.android.internal.telephony.TelephonyProperties;
|
|||||||
import com.android.settings.nfc.NfcEnabler;
|
import com.android.settings.nfc.NfcEnabler;
|
||||||
import com.android.settings.NsdEnabler;
|
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 TAG = "WirelessSettings";
|
||||||
|
|
||||||
private static final String KEY_TOGGLE_AIRPLANE = "toggle_airplane";
|
private static final String KEY_TOGGLE_AIRPLANE = "toggle_airplane";
|
||||||
@@ -73,7 +75,11 @@ public class WirelessSettings extends SettingsPreferenceFragment {
|
|||||||
|
|
||||||
private static final int MANAGE_MOBILE_PLAN_DIALOG_ID = 1;
|
private static final int MANAGE_MOBILE_PLAN_DIALOG_ID = 1;
|
||||||
private static final String SAVED_MANAGE_MOBILE_PLAN_MSG = "mManageMobilePlanMessage";
|
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
|
* Invoked on each preference click in this hierarchy, overrides
|
||||||
* PreferenceActivity's implementation. Used to make sure we track the
|
* PreferenceActivity's implementation. Used to make sure we track the
|
||||||
@@ -81,6 +87,10 @@ public class WirelessSettings extends SettingsPreferenceFragment {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
|
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
|
||||||
|
if (mProtectedByRestictionsPrefs.contains(preference) && !hasChallengeSucceeded()) {
|
||||||
|
restrictionsPinCheck(RESTRICTIONS_PIN_SET);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
log("onPreferenceTreeClick: preference=" + preference);
|
log("onPreferenceTreeClick: preference=" + preference);
|
||||||
if (preference == mAirplaneModePreference && Boolean.parseBoolean(
|
if (preference == mAirplaneModePreference && Boolean.parseBoolean(
|
||||||
SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE))) {
|
SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE))) {
|
||||||
@@ -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
|
@Override
|
||||||
public Dialog onCreateDialog(int dialogId) {
|
public Dialog onCreateDialog(int dialogId) {
|
||||||
log("onCreateDialog: dialogId=" + dialogId);
|
log("onCreateDialog: dialogId=" + dialogId);
|
||||||
@@ -225,6 +242,8 @@ public class WirelessSettings extends SettingsPreferenceFragment {
|
|||||||
ps.setDependency(KEY_TOGGLE_AIRPLANE);
|
ps.setDependency(KEY_TOGGLE_AIRPLANE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
protectByRestrictions(KEY_WIMAX_SETTINGS);
|
||||||
|
|
||||||
// Manually set dependencies for Wifi when not toggleable.
|
// Manually set dependencies for Wifi when not toggleable.
|
||||||
if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_WIFI)) {
|
if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_WIFI)) {
|
||||||
findPreference(KEY_VPN_SETTINGS).setDependency(KEY_TOGGLE_AIRPLANE);
|
findPreference(KEY_VPN_SETTINGS).setDependency(KEY_TOGGLE_AIRPLANE);
|
||||||
@@ -232,7 +251,7 @@ public class WirelessSettings extends SettingsPreferenceFragment {
|
|||||||
if (isSecondaryUser) { // Disable VPN
|
if (isSecondaryUser) { // Disable VPN
|
||||||
removePreference(KEY_VPN_SETTINGS);
|
removePreference(KEY_VPN_SETTINGS);
|
||||||
}
|
}
|
||||||
|
protectByRestrictions(KEY_VPN_SETTINGS);
|
||||||
// Manually set dependencies for Bluetooth when not toggleable.
|
// Manually set dependencies for Bluetooth when not toggleable.
|
||||||
if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_BLUETOOTH)) {
|
if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_BLUETOOTH)) {
|
||||||
// No bluetooth-dependent items in the list. Code kept in case one is added later.
|
// No bluetooth-dependent items in the list. Code kept in case one is added later.
|
||||||
@@ -257,6 +276,8 @@ public class WirelessSettings extends SettingsPreferenceFragment {
|
|||||||
removePreference(KEY_MOBILE_NETWORK_SETTINGS);
|
removePreference(KEY_MOBILE_NETWORK_SETTINGS);
|
||||||
removePreference(KEY_MANAGE_MOBILE_PLAN);
|
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.
|
// Remove Airplane Mode settings if it's a stationary device such as a TV.
|
||||||
if (getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEVISION)) {
|
if (getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEVISION)) {
|
||||||
@@ -280,6 +301,7 @@ public class WirelessSettings extends SettingsPreferenceFragment {
|
|||||||
Preference p = findPreference(KEY_TETHER_SETTINGS);
|
Preference p = findPreference(KEY_TETHER_SETTINGS);
|
||||||
p.setTitle(Utils.getTetheringLabel(cm));
|
p.setTitle(Utils.getTetheringLabel(cm));
|
||||||
}
|
}
|
||||||
|
protectByRestrictions(KEY_TETHER_SETTINGS);
|
||||||
|
|
||||||
// Enable link to CMAS app settings depending on the value in config.xml.
|
// Enable link to CMAS app settings depending on the value in config.xml.
|
||||||
boolean isCellBroadcastAppLinkEnabled = this.getResources().getBoolean(
|
boolean isCellBroadcastAppLinkEnabled = this.getResources().getBoolean(
|
||||||
@@ -300,6 +322,7 @@ public class WirelessSettings extends SettingsPreferenceFragment {
|
|||||||
Preference ps = findPreference(KEY_CELL_BROADCAST_SETTINGS);
|
Preference ps = findPreference(KEY_CELL_BROADCAST_SETTINGS);
|
||||||
if (ps != null) root.removePreference(ps);
|
if (ps != null) root.removePreference(ps);
|
||||||
}
|
}
|
||||||
|
protectByRestrictions(KEY_CELL_BROADCAST_SETTINGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -345,6 +368,7 @@ public class WirelessSettings extends SettingsPreferenceFragment {
|
|||||||
mAirplaneModeEnabler.setAirplaneModeInECM(isChoiceYes,
|
mAirplaneModeEnabler.setAirplaneModeInECM(isChoiceYes,
|
||||||
mAirplaneModePreference.isChecked());
|
mAirplaneModePreference.isChecked());
|
||||||
}
|
}
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -27,7 +27,6 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.UserManager;
|
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
import android.preference.PreferenceCategory;
|
import android.preference.PreferenceCategory;
|
||||||
@@ -74,7 +73,6 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment {
|
|||||||
|
|
||||||
private final IntentFilter mIntentFilter;
|
private final IntentFilter mIntentFilter;
|
||||||
|
|
||||||
private UserManager mUserManager;
|
|
||||||
|
|
||||||
// accessed from inner class (not private to avoid thunks)
|
// accessed from inner class (not private to avoid thunks)
|
||||||
Preference mMyDevicePreference;
|
Preference mMyDevicePreference;
|
||||||
@@ -96,13 +94,13 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public BluetoothSettings() {
|
public BluetoothSettings() {
|
||||||
|
super(DISALLOW_CONFIG_BLUETOOTH);
|
||||||
mIntentFilter = new IntentFilter(BluetoothAdapter.ACTION_LOCAL_NAME_CHANGED);
|
mIntentFilter = new IntentFilter(BluetoothAdapter.ACTION_LOCAL_NAME_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
mUserManager = (UserManager) getSystemService(Context.USER_SERVICE);
|
|
||||||
mActivityStarted = (savedInstanceState == null); // don't auto start scan after rotation
|
mActivityStarted = (savedInstanceState == null); // don't auto start scan after rotation
|
||||||
|
|
||||||
mEmptyView = (TextView) getView().findViewById(android.R.id.empty);
|
mEmptyView = (TextView) getView().findViewById(android.R.id.empty);
|
||||||
@@ -171,7 +169,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment {
|
|||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
if (mLocalAdapter == null) return;
|
if (mLocalAdapter == null) return;
|
||||||
// If the user is not allowed to configure bluetooth, do not show the menu.
|
// 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 bluetoothIsEnabled = mLocalAdapter.getBluetoothState() == BluetoothAdapter.STATE_ON;
|
||||||
boolean isDiscovering = mLocalAdapter.isDiscovering();
|
boolean isDiscovering = mLocalAdapter.isDiscovering();
|
||||||
@@ -219,7 +217,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void startScanning() {
|
private void startScanning() {
|
||||||
if (mUserManager.hasUserRestriction(DISALLOW_CONFIG_BLUETOOTH)) return;
|
if (isRestrictedAndNotPinProtected()) return;
|
||||||
if (!mAvailableDevicesCategoryIsPresent) {
|
if (!mAvailableDevicesCategoryIsPresent) {
|
||||||
getPreferenceScreen().addPreference(mAvailableDevicesCategory);
|
getPreferenceScreen().addPreference(mAvailableDevicesCategory);
|
||||||
}
|
}
|
||||||
@@ -266,7 +264,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment {
|
|||||||
mMyDevicePreference.setEnabled(true);
|
mMyDevicePreference.setEnabled(true);
|
||||||
preferenceScreen.addPreference(mMyDevicePreference);
|
preferenceScreen.addPreference(mMyDevicePreference);
|
||||||
|
|
||||||
if (! mUserManager.hasUserRestriction(DISALLOW_CONFIG_BLUETOOTH)) {
|
if (!isRestrictedAndNotPinProtected()) {
|
||||||
if (mDiscoverableEnabler == null) {
|
if (mDiscoverableEnabler == null) {
|
||||||
mDiscoverableEnabler = new BluetoothDiscoverableEnabler(getActivity(),
|
mDiscoverableEnabler = new BluetoothDiscoverableEnabler(getActivity(),
|
||||||
mLocalAdapter, mMyDevicePreference);
|
mLocalAdapter, mMyDevicePreference);
|
||||||
@@ -297,7 +295,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment {
|
|||||||
} else {
|
} else {
|
||||||
mAvailableDevicesCategory.removeAll();
|
mAvailableDevicesCategory.removeAll();
|
||||||
}
|
}
|
||||||
if (! mUserManager.hasUserRestriction(DISALLOW_CONFIG_BLUETOOTH)) {
|
if (!isRestrictedAndNotPinProtected()) {
|
||||||
addDeviceCategory(mAvailableDevicesCategory,
|
addDeviceCategory(mAvailableDevicesCategory,
|
||||||
R.string.bluetooth_preference_found_devices,
|
R.string.bluetooth_preference_found_devices,
|
||||||
BluetoothDeviceFilter.UNBONDED_DEVICE_FILTER);
|
BluetoothDeviceFilter.UNBONDED_DEVICE_FILTER);
|
||||||
@@ -366,7 +364,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment {
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
// User clicked on advanced options icon for a device in the list
|
// User clicked on advanced options icon for a device in the list
|
||||||
if (v.getTag() instanceof CachedBluetoothDevice) {
|
if (v.getTag() instanceof CachedBluetoothDevice) {
|
||||||
if (mUserManager.hasUserRestriction(DISALLOW_CONFIG_BLUETOOTH)) return;
|
if (isRestrictedAndNotPinProtected()) return;
|
||||||
|
|
||||||
CachedBluetoothDevice device = (CachedBluetoothDevice) v.getTag();
|
CachedBluetoothDevice device = (CachedBluetoothDevice) v.getTag();
|
||||||
|
|
||||||
|
@@ -26,6 +26,7 @@ import android.preference.PreferenceScreen;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.settings.ProgressCategory;
|
import com.android.settings.ProgressCategory;
|
||||||
|
import com.android.settings.RestrictedSettingsFragment;
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
import com.android.settings.SettingsPreferenceFragment;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -39,7 +40,7 @@ import java.util.WeakHashMap;
|
|||||||
* @see DevicePickerFragment
|
* @see DevicePickerFragment
|
||||||
*/
|
*/
|
||||||
public abstract class DeviceListPreferenceFragment extends
|
public abstract class DeviceListPreferenceFragment extends
|
||||||
SettingsPreferenceFragment implements BluetoothCallback {
|
RestrictedSettingsFragment implements BluetoothCallback {
|
||||||
|
|
||||||
private static final String TAG = "DeviceListPreferenceFragment";
|
private static final String TAG = "DeviceListPreferenceFragment";
|
||||||
|
|
||||||
@@ -58,7 +59,8 @@ public abstract class DeviceListPreferenceFragment extends
|
|||||||
final WeakHashMap<CachedBluetoothDevice, BluetoothDevicePreference> mDevicePreferenceMap =
|
final WeakHashMap<CachedBluetoothDevice, BluetoothDevicePreference> mDevicePreferenceMap =
|
||||||
new WeakHashMap<CachedBluetoothDevice, BluetoothDevicePreference>();
|
new WeakHashMap<CachedBluetoothDevice, BluetoothDevicePreference>();
|
||||||
|
|
||||||
DeviceListPreferenceFragment() {
|
DeviceListPreferenceFragment(String restrictedKey) {
|
||||||
|
super(restrictedKey);
|
||||||
mFilter = BluetoothDeviceFilter.ALL_FILTER;
|
mFilter = BluetoothDeviceFilter.ALL_FILTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -34,6 +34,10 @@ import com.android.settings.R;
|
|||||||
*/
|
*/
|
||||||
public final class DevicePickerFragment extends DeviceListPreferenceFragment {
|
public final class DevicePickerFragment extends DeviceListPreferenceFragment {
|
||||||
|
|
||||||
|
DevicePickerFragment() {
|
||||||
|
super(null /* Not tied to any user restrictions. */);
|
||||||
|
}
|
||||||
|
|
||||||
private boolean mNeedAuth;
|
private boolean mNeedAuth;
|
||||||
private String mLaunchPackage;
|
private String mLaunchPackage;
|
||||||
private String mLaunchClass;
|
private String mLaunchClass;
|
||||||
|
@@ -16,6 +16,10 @@
|
|||||||
|
|
||||||
package com.android.settings.users;
|
package com.android.settings.users;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
import android.accounts.AccountManager;
|
import android.accounts.AccountManager;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
@@ -42,8 +46,8 @@ import android.os.RemoteException;
|
|||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceActivity;
|
|
||||||
import android.preference.Preference.OnPreferenceClickListener;
|
import android.preference.Preference.OnPreferenceClickListener;
|
||||||
|
import android.preference.PreferenceActivity;
|
||||||
import android.preference.PreferenceGroup;
|
import android.preference.PreferenceGroup;
|
||||||
import android.provider.ContactsContract;
|
import android.provider.ContactsContract;
|
||||||
import android.provider.ContactsContract.Contacts;
|
import android.provider.ContactsContract.Contacts;
|
||||||
@@ -59,19 +63,13 @@ import android.widget.SimpleAdapter;
|
|||||||
|
|
||||||
import com.android.internal.widget.LockPatternUtils;
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
import com.android.settings.ChooseLockGeneric;
|
import com.android.settings.ChooseLockGeneric;
|
||||||
import com.android.settings.ChooseLockGeneric.ChooseLockGenericFragment;
|
|
||||||
import com.android.settings.OwnerInfoSettings;
|
import com.android.settings.OwnerInfoSettings;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.RestrictedSettingsFragment;
|
||||||
import com.android.settings.SelectableEditTextPreference;
|
import com.android.settings.SelectableEditTextPreference;
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
public class UserSettings extends RestrictedSettingsFragment
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class UserSettings extends SettingsPreferenceFragment
|
|
||||||
implements OnPreferenceClickListener, OnClickListener, DialogInterface.OnDismissListener,
|
implements OnPreferenceClickListener, OnClickListener, DialogInterface.OnDismissListener,
|
||||||
Preference.OnPreferenceChangeListener {
|
Preference.OnPreferenceChangeListener {
|
||||||
|
|
||||||
@@ -136,6 +134,9 @@ public class UserSettings extends SettingsPreferenceFragment
|
|||||||
private SparseArray<Bitmap> mUserIcons = new SparseArray<Bitmap>();
|
private SparseArray<Bitmap> mUserIcons = new SparseArray<Bitmap>();
|
||||||
private boolean mIsOwner = UserHandle.myUserId() == UserHandle.USER_OWNER;
|
private boolean mIsOwner = UserHandle.myUserId() == UserHandle.USER_OWNER;
|
||||||
|
|
||||||
|
public UserSettings() {
|
||||||
|
super(null);
|
||||||
|
}
|
||||||
|
|
||||||
private Handler mHandler = new Handler() {
|
private Handler mHandler = new Handler() {
|
||||||
@Override
|
@Override
|
||||||
@@ -717,6 +718,9 @@ public class UserSettings extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(Preference pref) {
|
public boolean onPreferenceClick(Preference pref) {
|
||||||
|
if (pref == mAddUser && !restrictionsPinCheck(RESTRICTIONS_PIN_SET)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (pref == mMePreference) {
|
if (pref == mMePreference) {
|
||||||
Intent editProfile;
|
Intent editProfile;
|
||||||
if (!mProfileExists) {
|
if (!mProfileExists) {
|
||||||
@@ -776,7 +780,9 @@ public class UserSettings extends SettingsPreferenceFragment
|
|||||||
int userId = ((UserPreference) v.getTag()).getUserId();
|
int userId = ((UserPreference) v.getTag()).getUserId();
|
||||||
switch (v.getId()) {
|
switch (v.getId()) {
|
||||||
case UserPreference.DELETE_ID:
|
case UserPreference.DELETE_ID:
|
||||||
onRemoveUserClicked(userId);
|
if (restrictionsPinCheck(RESTRICTIONS_PIN_SET)) {
|
||||||
|
onRemoveUserClicked(userId);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case UserPreference.SETTINGS_ID:
|
case UserPreference.SETTINGS_ID:
|
||||||
onManageUserClicked(userId, false);
|
onManageUserClicked(userId, false);
|
||||||
|
Reference in New Issue
Block a user