From 4cd3bdcfa39500a85e09de889986b155dec9daa0 Mon Sep 17 00:00:00 2001 From: Brad Ebinger Date: Mon, 21 Aug 2017 14:58:52 -0700 Subject: [PATCH] Remove PIN/PUK keyguard when SIM is removed/ready 1) If the PIN/PUK keyguard comes up for a locked SIM, it can not be removed by removing the affected SIM. It can only be removed by rebooting the device or entering a bogus PIN. This change automatically clears the keyguard when when the locked SIM is removed. It will be shown again if the locked SIM is re-entered. 2) If the device is PUK locked and the code **05*PUK*new pin* new Pin# is entered in the emergency dialer, it will unlock the SIM. By listening to the READY state, we can remove the keyguard when the SIM is unlocked by other means. Bug: 64469515 Bug: 64044132 Test: Manual Merged-In: I7b576ee7e38f141075cae094e3d1f74b7145d53f Change-Id: I9507f80edcd4c04dfa0cc3b48a25e619aafa9eb3 --- .../android/keyguard/KeyguardSimPinView.java | 16 ++++++++++++--- .../android/keyguard/KeyguardSimPukView.java | 20 ++++++++++++++++--- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java index 0cf890037f557..fe03fba5bfda9 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java @@ -58,9 +58,19 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView { KeyguardUpdateMonitorCallback mUpdateMonitorCallback = new KeyguardUpdateMonitorCallback() { @Override public void onSimStateChanged(int subId, int slotId, State simState) { - if (DEBUG) Log.v(TAG, "onSimStateChanged(subId=" + subId + ",state=" + simState + ")"); - resetState(); - }; + if (DEBUG) Log.v(TAG, "onSimStateChanged(subId=" + subId + ",state=" + simState + ")"); + switch(simState) { + // If the SIM is removed, then we must remove the keyguard. It will be put up + // again when the PUK locked SIM is re-entered. + case ABSENT: { + KeyguardUpdateMonitor.getInstance(getContext()).reportSimUnlocked(mSubId); + mCallback.dismiss(true, KeyguardUpdateMonitor.getCurrentUser()); + break; + } + default: + resetState(); + } + } }; public KeyguardSimPinView(Context context) { diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java index fb3cee74ab687..826a03d1b6587 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java @@ -60,9 +60,23 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView { KeyguardUpdateMonitorCallback mUpdateMonitorCallback = new KeyguardUpdateMonitorCallback() { @Override public void onSimStateChanged(int subId, int slotId, State simState) { - if (DEBUG) Log.v(TAG, "onSimStateChanged(subId=" + subId + ",state=" + simState + ")"); - resetState(); - }; + if (DEBUG) Log.v(TAG, "onSimStateChanged(subId=" + subId + ",state=" + simState + ")"); + switch(simState) { + // If the SIM is removed, then we must remove the keyguard. It will be put up + // again when the PUK locked SIM is re-entered. + case ABSENT: + // intentional fall-through + // If the SIM is unlocked via a key sequence through the emergency dialer, it will + // move into the READY state and the PUK lock keyguard should be removed. + case READY: { + KeyguardUpdateMonitor.getInstance(getContext()).reportSimUnlocked(mSubId); + mCallback.dismiss(true, KeyguardUpdateMonitor.getCurrentUser()); + break; + } + default: + resetState(); + } + } }; public KeyguardSimPukView(Context context) {