Improves PIN/PUK handling events in keyguard
1) Remove old bypass code for ABSENT in KeyguardPin/Puk class
and move it into KeyguardViewMediator where it belongs.
2) Fix issue where pulling out sim and then putting it back in
doesnt trigger PIN/PUK screen until turn off->on screen by clearing
SimData state for the slot that became ABSENT.
Bug: 119560495
Test: Move across eSIM and pSIM as well as manually remove PIN/PUK'ed SIMs
Merged-In: Iebf2cb046b1a1d7e0689a2329a9f78e1cbb6aca4
Change-Id: Iebf2cb046b1a1d7e0689a2329a9f78e1cbb6aca4
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java
index 42c7a56..df9fb35 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java
@@ -67,17 +67,6 @@
public void onSimStateChanged(int subId, int slotId, State simState) {
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);
- // onSimStateChanged callback can fire when the SIM PIN lock is not currently
- // active and mCallback is null.
- if (mCallback != null) {
- mCallback.dismiss(true, KeyguardUpdateMonitor.getCurrentUser());
- }
- break;
- }
case READY: {
mRemainingAttempts = -1;
resetState();
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java
index 1b61568..5da764d 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java
@@ -70,14 +70,11 @@
public void onSimStateChanged(int subId, int slotId, State simState) {
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);
+ mRemainingAttempts = -1;
+ mShowDefaultMessage = true;
// mCallback can be null if onSimStateChanged callback is called when keyguard
// isn't active.
if (mCallback != null) {
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
index 241184e6..8b48130 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -1582,6 +1582,13 @@
// Even though the subscription is not valid anymore, we need to notify that the
// SIM card was removed so we can update the UI.
becameAbsent = true;
+ for (SimData data : mSimDatas.values()) {
+ // Set the SIM state of all SimData associated with that slot to ABSENT se we
+ // do not move back into PIN/PUK locked and not detect the change below.
+ if (data.slotId == slotId) {
+ data.simState = State.ABSENT;
+ }
+ }
} else {
return;
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index 5409db7..2bb9423 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -461,8 +461,7 @@
boolean simWasLocked;
synchronized (KeyguardViewMediator.this) {
IccCardConstants.State lastState = mLastSimStates.get(slotId);
- simWasLocked = (lastState == PIN_REQUIRED || lastState == PUK_REQUIRED)
- && simState == READY;
+ simWasLocked = (lastState == PIN_REQUIRED || lastState == PUK_REQUIRED);
mLastSimStates.append(slotId, simState);
}
@@ -487,6 +486,8 @@
// so we should only lock when they are ABSENT.
onSimAbsentLocked();
if (simWasLocked) {
+ if (DEBUG_SIM_STATES) Log.d(TAG, "SIM moved to ABSENT when the "
+ + "previous state was locked. Reset the state.");
resetStateLocked();
}
}
@@ -523,6 +524,8 @@
synchronized (KeyguardViewMediator.this) {
if (DEBUG_SIM_STATES) Log.d(TAG, "READY, reset state? " + mShowing);
if (mShowing && simWasLocked) {
+ if (DEBUG_SIM_STATES) Log.d(TAG, "SIM moved to READY when the "
+ + "previous state was locked. Reset the state.");
resetStateLocked();
}
mLockWhenSimRemoved = true;