Apply restrictions right away instead of on exit
Use usermanager to clear restrictions, as it needs to do a bunch of
book keeping.
Apply PIN restriction to master clear button.
Changing existing PIN now includes verifying the PIN, so it doesn't
need to be cleared here in Settings.
Removed automatic persisting of restrictions on receiving them unless
it is a restricted profile.
Make apps that are signed with platform certs immutable and ON.
Change-Id: Iffd1bf2eb0d18202fb66ddcf80668baa8e6b84ed
diff --git a/src/com/android/settings/MasterClear.java b/src/com/android/settings/MasterClear.java
index 495f3fd..3777a8e 100644
--- a/src/com/android/settings/MasterClear.java
+++ b/src/com/android/settings/MasterClear.java
@@ -29,6 +29,7 @@
import android.os.Bundle;
import android.os.Environment;
import android.os.SystemProperties;
+import android.os.UserManager;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.util.Log;
@@ -54,6 +55,7 @@
private static final String TAG = "MasterClear";
private static final int KEYGUARD_REQUEST = 55;
+ private static final int PIN_REQUEST = 56;
static final String ERASE_EXTERNAL_EXTRA = "erase_sd";
@@ -61,6 +63,7 @@
private Button mInitiateButton;
private View mExternalStorageContainer;
private CheckBox mExternalStorage;
+ private boolean mPinConfirmed;
/**
* Keyguard validation is run using the standard {@link ConfirmLockPattern}
@@ -76,11 +79,25 @@
res.getText(R.string.master_clear_gesture_explanation));
}
+ private boolean runRestrictionsChallenge() {
+ if (UserManager.get(getActivity()).hasRestrictionsPin()) {
+ startActivityForResult(
+ new Intent(Intent.ACTION_RESTRICTIONS_PIN_CHALLENGE), PIN_REQUEST);
+ return true;
+ }
+ return false;
+ }
+
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
- if (requestCode != KEYGUARD_REQUEST) {
+ if (requestCode == PIN_REQUEST) {
+ if (resultCode == Activity.RESULT_OK) {
+ mPinConfirmed = true;
+ }
+ return;
+ } else if (requestCode != KEYGUARD_REQUEST) {
return;
}
@@ -109,6 +126,10 @@
private final Button.OnClickListener mInitiateListener = new Button.OnClickListener() {
public void onClick(View v) {
+ mPinConfirmed = false;
+ if (runRestrictionsChallenge()) {
+ return;
+ }
if (!runKeyguardConfirmation(KEYGUARD_REQUEST)) {
showFinalConfirmation();
}
@@ -239,4 +260,17 @@
establishInitialState();
return mContentView;
}
+
+ @Override
+ public void onResume() {
+ super.onResume();
+
+ // If this is the second step after restrictions pin challenge
+ if (mPinConfirmed) {
+ mPinConfirmed = false;
+ if (!runKeyguardConfirmation(KEYGUARD_REQUEST)) {
+ showFinalConfirmation();
+ }
+ }
+ }
}