Fix 2594148: confirm PIN/Password before resetting device
This fixes a bug where user was allowed to factory reset the device
without entering their PIN/Password.
It also fixes the same issue with MediaFormat (Settings->SD Card->Format).
Change-Id: I0677a50aa771ad8663513fd7ec398a70953dcde2
diff --git a/src/com/android/settings/MasterClear.java b/src/com/android/settings/MasterClear.java
index 7e408d1..4de0e44 100644
--- a/src/com/android/settings/MasterClear.java
+++ b/src/com/android/settings/MasterClear.java
@@ -69,19 +69,16 @@
};
/**
- * Keyguard validation is run using the standard {@link ConfirmLockPattern}
+ * Keyguard validation is run using the standard {@link ConfirmLockPattern}
* component as a subactivity
+ * @param request the request code to be returned once confirmation finishes
+ * @return true if confirmation launched
*/
- private void runKeyguardConfirmation() {
- final Intent intent = new Intent();
- intent.setClassName("com.android.settings",
- "com.android.settings.ConfirmLockPattern");
- // supply header and footer text in the intent
- intent.putExtra(ConfirmLockPattern.HEADER_TEXT,
- getText(R.string.master_clear_gesture_prompt));
- intent.putExtra(ConfirmLockPattern.FOOTER_TEXT,
- getText(R.string.master_clear_gesture_explanation));
- startActivityForResult(intent, KEYGUARD_REQUEST);
+ private boolean runKeyguardConfirmation(int request) {
+ return new ChooseLockSettingsHelper(this)
+ .launchConfirmationActivity(request,
+ getText(R.string.master_clear_gesture_prompt),
+ getText(R.string.master_clear_gesture_explanation));
}
@Override
@@ -96,6 +93,8 @@
// confirmation prompt; otherwise, go back to the initial state.
if (resultCode == Activity.RESULT_OK) {
establishFinalConfirmationState();
+ } else if (resultCode == Activity.RESULT_CANCELED) {
+ finish();
} else {
establishInitialState();
}
@@ -108,9 +107,7 @@
*/
private Button.OnClickListener mInitiateListener = new Button.OnClickListener() {
public void onClick(View v) {
- if (mLockUtils.isLockPatternEnabled()) {
- runKeyguardConfirmation();
- } else {
+ if (!runKeyguardConfirmation(KEYGUARD_REQUEST)) {
establishFinalConfirmationState();
}
}