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:
Geoffrey Borggaard
2013-08-02 18:16:27 -04:00
parent d98d2abda6
commit fe21d9aaa8
8 changed files with 159 additions and 44 deletions

View File

@@ -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
@@ -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;
@@ -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);
@@ -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);
@@ -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();