Skip to content

Commit 2de5ee8

Browse files
author
Jim Miller
committed
Fix 6507787: fix MMI PUK unlock procedure
This fixes a bug where the user uses the MMI sequence (**05*PUK*PIN1*PIN1#) from the EmergencyDialer to unlock their phone instead of the provided interface. The code now recognizes when UnlockMode becomes invalid because it was previously locked because of SIM state. It then dismisses the PUK unlock screen and advances to the home screen. Change-Id: I8902350e6f640cd2fa0af3460c3ea1a39d926c8a
1 parent d2ee496 commit 2de5ee8

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ public class KeyguardUpdateMonitor {
105105
protected static final int MSG_DPM_STATE_CHANGED = 309;
106106
protected static final int MSG_USER_CHANGED = 310;
107107

108+
protected static final boolean DEBUG_SIM_STATES = DEBUG || false;
109+
108110
/**
109111
* When we receive a
110112
* {@link com.android.internal.telephony.TelephonyIntents#ACTION_SIM_STATE_CHANGED} broadcast,
@@ -292,6 +294,10 @@ public void onReceive(Context context, Intent intent) {
292294
MSG_BATTERY_UPDATE, new BatteryStatus(status, level, plugged, health));
293295
mHandler.sendMessage(msg);
294296
} else if (TelephonyIntents.ACTION_SIM_STATE_CHANGED.equals(action)) {
297+
if (DEBUG_SIM_STATES) {
298+
Log.v(TAG, "action " + action + " state" +
299+
intent.getStringExtra(IccCard.INTENT_KEY_ICC_STATE));
300+
}
295301
mHandler.sendMessage(mHandler.obtainMessage(
296302
MSG_SIM_STATE_CHANGE, SimArgs.fromIntent(intent)));
297303
} else if (AudioManager.RINGER_MODE_CHANGED_ACTION.equals(action)) {
@@ -407,6 +413,7 @@ private void handleSimStateChange(SimArgs simArgs) {
407413
}
408414

409415
if (state != IccCard.State.UNKNOWN && state != mSimState) {
416+
if (DEBUG_SIM_STATES) Log.v(TAG, "dispatching state: " + state);
410417
mSimState = state;
411418
for (int i = 0; i < mSimStateCallbacks.size(); i++) {
412419
mSimStateCallbacks.get(i).onSimStateChanged(state);

policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,21 @@ enum UnlockMode {
202202

203203
private Runnable mRecreateRunnable = new Runnable() {
204204
public void run() {
205-
updateScreen(mMode, true);
205+
Mode mode = mMode;
206+
// If we were previously in a locked state but now it's Unknown, it means the phone
207+
// was previously locked because of SIM state and has since been resolved. This
208+
// bit of code checks this condition and dismisses keyguard.
209+
boolean dismissAfterCreation = false;
210+
if (mode == Mode.UnlockScreen && getUnlockMode() == UnlockMode.Unknown) {
211+
if (DEBUG) Log.v(TAG, "Switch to Mode.LockScreen because SIM unlocked");
212+
mode = Mode.LockScreen;
213+
dismissAfterCreation = true;
214+
}
215+
updateScreen(mode, true);
206216
restoreWidgetState();
217+
if (dismissAfterCreation) {
218+
mKeyguardScreenCallback.keyguardDone(false);
219+
}
207220
}
208221
};
209222

@@ -307,6 +320,7 @@ public boolean isVerifyUnlockOnly() {
307320
}
308321

309322
public void recreateMe(Configuration config) {
323+
if (DEBUG) Log.v(TAG, "recreateMe()");
310324
removeCallbacks(mRecreateRunnable);
311325
post(mRecreateRunnable);
312326
}
@@ -524,6 +538,7 @@ protected void dispatchDraw(Canvas canvas) {
524538
public void reset() {
525539
mIsVerifyUnlockOnly = false;
526540
mForgotPattern = false;
541+
if (DEBUG) Log.v(TAG, "reset()");
527542
post(mRecreateRunnable);
528543
}
529544

@@ -673,6 +688,7 @@ protected void onConfigurationChanged(Configuration newConfig) {
673688
if (DEBUG_CONFIGURATION) Log.v(TAG, "**** re-creating lock screen since config changed");
674689
saveWidgetState();
675690
removeCallbacks(mRecreateRunnable);
691+
if (DEBUG) Log.v(TAG, "recreating lockscreen because config changed");
676692
post(mRecreateRunnable);
677693
}
678694

0 commit comments

Comments
 (0)