Restriction pin changes.

Fixed bug in WirelessSettings where it was asking users for a PIN when
they weren't restricted.  Did this by refactoring the preference level
pin checking into the superclass, where it checks for the restricted mode first.
Also pin protected changes to certificates for restricted users.

Change-Id: I8310fd39f0862159668318fc1360ec6859cc00d5
This commit is contained in:
Geoffrey Borggaard
2013-08-07 14:57:43 -04:00
parent 8a181dd0d1
commit 6e1102d9fa
7 changed files with 98 additions and 40 deletions

View File

@@ -45,7 +45,6 @@ import android.util.Log;
import com.android.internal.widget.LockPatternUtils;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
/**
@@ -75,6 +74,7 @@ public class SecuritySettings extends RestrictedSettingsFragment
private static final String KEY_SHOW_PASSWORD = "show_password";
private static final String KEY_CREDENTIAL_STORAGE_TYPE = "credential_storage_type";
private static final String KEY_RESET_CREDENTIALS = "reset_credentials";
private static final String KEY_CREDENTIALS_INSTALL = "credentials_install";
private static final String KEY_TOGGLE_INSTALL_APPLICATIONS = "toggle_install_applications";
private static final String KEY_TOGGLE_VERIFY_APPLICATIONS = "toggle_verify_applications";
private static final String KEY_POWER_INSTANTLY_LOCKS = "power_button_instantly_locks";
@@ -82,8 +82,6 @@ public class SecuritySettings extends RestrictedSettingsFragment
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;
@@ -245,6 +243,7 @@ public class SecuritySettings extends RestrictedSettingsFragment
// Show password
mShowPassword = (CheckBoxPreference) root.findPreference(KEY_SHOW_PASSWORD);
mResetCredentials = root.findPreference(KEY_RESET_CREDENTIALS);
// Credential storage
final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
@@ -257,7 +256,6 @@ public class SecuritySettings extends RestrictedSettingsFragment
: R.string.credential_storage_type_software;
credentialStorageType.setSummary(storageSummaryRes);
mResetCredentials = root.findPreference(KEY_RESET_CREDENTIALS);
} else {
removePreference(KEY_CREDENTIALS_MANAGER);
}
@@ -312,16 +310,12 @@ public class SecuritySettings extends RestrictedSettingsFragment
if (shouldBePinProtected(RESTRICTIONS_PIN_SET)) {
protectByRestrictions(mToggleAppInstallation);
protectByRestrictions(mToggleVerifyApps);
protectByRestrictions(mResetCredentials);
protectByRestrictions(root.findPreference(KEY_CREDENTIALS_INSTALL));
}
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);
@@ -487,11 +481,9 @@ public class SecuritySettings extends RestrictedSettingsFragment
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
if (mProtectedByRestictionsPrefs.contains(preference)
&& !restrictionsPinCheck(RESTRICTIONS_PIN_SET)) {
return false;
if (ensurePinRestrictedPreference(preference)) {
return true;
}
final String key = preference.getKey();
final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();