Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 47acea55 authored by Aaron Liu's avatar Aaron Liu
Browse files

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
parent def54492
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -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()
    }
}
+10 −0
Original line number Diff line number Diff line
@@ -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() {

    }
}
+5 −0
Original line number Diff line number Diff line
@@ -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() {
+9 −1
Original line number Diff line number Diff line
@@ -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();