diff options
| author | 2023-12-07 12:52:22 -0800 | |
|---|---|---|
| committer | 2023-12-07 19:56:47 -0800 | |
| commit | 47acea557408eefb56c792b3af9461915b15ce62 (patch) | |
| tree | 3e84b9be3d18ba60e6bdf2e6ee5305ea6bb36c31 | |
| parent | def5449265cfa4fad887edbc591b5a2716f1b8d9 (diff) | |
Call showNextSecurityScreen when simstate changes.
Going from sim pin to sim puk is currently broken. This is because we
prevented boucer#show when keyguard resets to prevent flickering when
the falsing manager sends a signal for falsing.
If the sim state changes to puk required than we can guarantee that we
will go the puk screen with this addition.
Fixes: 315359989
Test: fail 3 times on sim pin and transition to sim puk.
Flag: NONE
Change-Id: I8982b986e0c720ea121ee4ca24d82daac295cc96
4 files changed, 51 insertions, 1 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSimPinViewControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSimPinViewControllerTest.kt index 94c3bde29597..84d735430edd 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSimPinViewControllerTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSimPinViewControllerTest.kt @@ -34,11 +34,14 @@ import com.android.systemui.util.mockito.any import org.junit.Before import org.junit.Test import org.junit.runner.RunWith +import org.mockito.ArgumentCaptor import org.mockito.ArgumentMatchers.anyString import org.mockito.Mock import org.mockito.Mockito import org.mockito.Mockito.anyInt import org.mockito.Mockito.mock +import org.mockito.Mockito.never +import org.mockito.Mockito.reset import org.mockito.Mockito.verify import org.mockito.Mockito.`when` import org.mockito.MockitoAnnotations @@ -63,6 +66,8 @@ class KeyguardSimPinViewControllerTest : SysuiTestCase() { @Mock private lateinit var keyguardMessageAreaController: KeyguardMessageAreaController<BouncerKeyguardMessageArea> + private val updateMonitorCallbackArgumentCaptor = + ArgumentCaptor.forClass(KeyguardUpdateMonitorCallback::class.java) @Before fun setup() { @@ -95,6 +100,9 @@ class KeyguardSimPinViewControllerTest : SysuiTestCase() { mSelectedUserInteractor ) underTest.init() + underTest.onResume(0) + verify(keyguardUpdateMonitor) + .registerCallback(updateMonitorCallbackArgumentCaptor.capture()) } @Test @@ -111,6 +119,7 @@ class KeyguardSimPinViewControllerTest : SysuiTestCase() { @Test fun onResume() { + reset(keyguardUpdateMonitor) underTest.onResume(KeyguardSecurityView.VIEW_REVEALED) verify(keyguardUpdateMonitor) .registerCallback(any(KeyguardUpdateMonitorCallback::class.java)) @@ -137,4 +146,22 @@ class KeyguardSimPinViewControllerTest : SysuiTestCase() { underTest.resetState() verify(keyguardMessageAreaController).setMessage("") } + + @Test + fun onSimStateChangedFromPinToPuk_showsCurrentSecurityScreen() { + updateMonitorCallbackArgumentCaptor.value.onSimStateChanged( + /* subId= */ 0, + /* slotId= */ 0, + TelephonyManager.SIM_STATE_PIN_REQUIRED + ) + verify(keyguardSecurityCallback, never()).showCurrentSecurityScreen() + + updateMonitorCallbackArgumentCaptor.value.onSimStateChanged( + /* subId= */ 0, + /* slotId= */ 0, + TelephonyManager.SIM_STATE_PUK_REQUIRED + ) + + verify(keyguardSecurityCallback).showCurrentSecurityScreen() + } } diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityCallback.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityCallback.java index 38a8cd39a078..c4aa7a26be18 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityCallback.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityCallback.java @@ -104,4 +104,14 @@ public interface KeyguardSecurityCallback { */ default void onSecurityModeChanged(SecurityMode securityMode, boolean needsInput) { } + + /** + * Shows the security screen that should be shown. + * + * This can be considered as a "refresh" of the bouncer view. Based on certain parameters, + * we might switch to a different bouncer screen. e.g. SimPin to SimPuk. + */ + default void showCurrentSecurityScreen() { + + } } diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java index 49c3f418aa88..0a4378e07b45 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java @@ -337,6 +337,11 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard public void onSecurityModeChanged(SecurityMode securityMode, boolean needsInput) { mViewMediatorCallback.setNeedsInput(needsInput); } + + @Override + public void showCurrentSecurityScreen() { + showPrimarySecurityScreen(false); + } }; private final SwipeListener mSwipeListener = new SwipeListener() { diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinViewController.java index 6e242084d68c..c5e70703cd2b 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinViewController.java @@ -16,6 +16,8 @@ package com.android.keyguard; +import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID; + import static com.android.systemui.util.PluralMessageFormaterKt.icuMessageFormat; import android.annotation.NonNull; @@ -60,7 +62,7 @@ public class KeyguardSimPinViewController // When this is true and when SIM card is PIN locked state, on PIN lock screen, message would // be displayed to inform user about the number of remaining PIN attempts left. private boolean mShowDefaultMessage; - private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; + private int mSubId = INVALID_SUBSCRIPTION_ID; private AlertDialog mRemainingAttemptsDialog; private ImageView mSimImageView; @@ -68,6 +70,12 @@ public class KeyguardSimPinViewController @Override public void onSimStateChanged(int subId, int slotId, int simState) { if (DEBUG) Log.v(TAG, "onSimStateChanged(subId=" + subId + ",state=" + simState + ")"); + // If subId has gone to PUK required then we need to go to the PUK screen. + if (subId == mSubId && simState == TelephonyManager.SIM_STATE_PUK_REQUIRED) { + getKeyguardSecurityCallback().showCurrentSecurityScreen(); + return; + } + if (simState == TelephonyManager.SIM_STATE_READY) { mRemainingAttempts = -1; resetState(); |