From fb1db79cf48be8f8e43d32201a0cd2a0ea68f2d7 Mon Sep 17 00:00:00 2001 From: Aaron Liu Date: Mon, 5 Jun 2023 12:30:44 -0700 Subject: Handle UNKNOWN sim state in KGVM. In keyguard view mediator, we do not handle the UNKNOWN sim state correctly. In CentralSurfaces, we are preventing dismiss amounts to be considered because the sim state is considered secure. When the esim is disabled, it is confirmed that we expect an UNKNOWN sim state. This state does not propagate to the view mediator from the update monitor. When the sim is disabled, the subscription id is -1 and state is UNKNOWN(0). We want to ensure that this state change is propgated to view mediator to ensure that the sim state is no longer considered secure. Additionally, a SIM_PIN_REQUIRED signal is sent as it transitions from SIM_PIN_REQUIRED to UNKNOWN. This is setting mPendingPinLock to true. This makes keyguard show after it is dismissed the first time. Fixes: 280010618 Test: disable sim and swipe to unlock LS with none security method Test: unlock sim and swipe to unlock LS with none security method Test: disable sim and unlock with pin Test: unlock sim and unlock with pin Test: disable sim puk and swipe to unlock LS with none security method Test: unlock sim puk and swipe to unlock LS with none security method Change-Id: I5bf6ce457a2d87d8f27ca907684a3e1571f9252b --- .../src/com/android/keyguard/KeyguardUpdateMonitor.java | 5 +++-- .../com/android/systemui/keyguard/KeyguardViewMediator.java | 3 +++ .../src/com/android/keyguard/KeyguardUpdateMonitorTest.java | 10 ++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java index 83c317fe3061..2bf8fb36469c 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -3668,7 +3668,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab mLogger.logSimState(subId, slotId, state); boolean becameAbsent = false; - if (!SubscriptionManager.isValidSubscriptionId(subId)) { + if (!SubscriptionManager.isValidSubscriptionId(subId) + && state != TelephonyManager.SIM_STATE_UNKNOWN) { mLogger.w("invalid subId in handleSimStateChange()"); /* Only handle No SIM(ABSENT) and Card Error(CARD_IO_ERROR) due to * handleServiceStateChange() handle other case */ @@ -3703,7 +3704,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab data.subId = subId; data.slotId = slotId; } - if ((changed || becameAbsent) && state != TelephonyManager.SIM_STATE_UNKNOWN) { + if ((changed || becameAbsent) || state == TelephonyManager.SIM_STATE_UNKNOWN) { for (int i = 0; i < mCallbacks.size(); i++) { KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get(); if (cb != null) { diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index 6948c8d4e563..0e0cf74ba463 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -697,6 +697,9 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, } } break; + case TelephonyManager.SIM_STATE_UNKNOWN: + mPendingPinLock = false; + break; default: if (DEBUG_SIM_STATES) Log.v(TAG, "Unspecific state: " + simState); break; diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java index 419d045885a8..de306d669476 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java @@ -2800,6 +2800,16 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { ); } + @Test + public void testOnSimStateChanged_Unknown() { + KeyguardUpdateMonitorCallback keyguardUpdateMonitorCallback = spy( + KeyguardUpdateMonitorCallback.class); + mKeyguardUpdateMonitor.registerCallback(keyguardUpdateMonitorCallback); + mKeyguardUpdateMonitor.handleSimStateChange(-1, 0, TelephonyManager.SIM_STATE_UNKNOWN); + verify(keyguardUpdateMonitorCallback).onSimStateChanged(-1, 0, + TelephonyManager.SIM_STATE_UNKNOWN); + } + private void verifyFingerprintAuthenticateNeverCalled() { verify(mFingerprintManager, never()).authenticate(any(), any(), any(), any(), any()); verify(mFingerprintManager, never()).authenticate(any(), any(), any(), any(), anyInt(), -- cgit v1.2.3-59-g8ed1b