Loading packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt +51 −23 Original line number Diff line number Diff line Loading @@ -464,29 +464,6 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() { verify(view).resetScale() } @Test fun showNextSecurityScreenOrFinish_setsSecurityScreenToPinAfterSimPinUnlock() { // GIVEN the current security method is SimPin whenever(keyguardUpdateMonitor.getUserHasTrust(anyInt())).thenReturn(false) whenever(keyguardUpdateMonitor.getUserUnlockedWithBiometric(TARGET_USER_ID)) .thenReturn(false) underTest.showSecurityScreen(SecurityMode.SimPin) // WHEN a request is made from the SimPin screens to show the next security method whenever(keyguardSecurityModel.getSecurityMode(TARGET_USER_ID)).thenReturn(SecurityMode.PIN) underTest.showNextSecurityScreenOrFinish( /* authenticated= */ true, TARGET_USER_ID, /* bypassSecondaryLockScreen= */ true, SecurityMode.SimPin ) // THEN the next security method of PIN is set, and the keyguard is not marked as done verify(viewMediatorCallback, never()).keyguardDonePending(anyInt()) verify(viewMediatorCallback, never()).keyguardDone(anyInt()) Truth.assertThat(underTest.currentSecurityMode).isEqualTo(SecurityMode.PIN) } @Test fun showNextSecurityScreenOrFinish_DeviceNotSecure() { // GIVEN the current security method is SimPin Loading Loading @@ -577,6 +554,57 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() { verify(viewMediatorCallback).keyguardDone(anyInt()) } @Test fun showNextSecurityScreenOrFinish_SimPin_Password() { // GIVEN the current security method is SimPin whenever(keyguardUpdateMonitor.getUserHasTrust(anyInt())).thenReturn(false) whenever(keyguardUpdateMonitor.getUserUnlockedWithBiometric(TARGET_USER_ID)) .thenReturn(false) underTest.showSecurityScreen(SecurityMode.SimPin) // WHEN a request is made from the SimPin screens to show the next security method whenever(keyguardSecurityModel.getSecurityMode(TARGET_USER_ID)) .thenReturn(SecurityMode.Password) // WHEN security method is SWIPE whenever(lockPatternUtils.isLockScreenDisabled(anyInt())).thenReturn(false) whenever(deviceProvisionedController.isUserSetup(anyInt())).thenReturn(false) underTest.showNextSecurityScreenOrFinish( /* authenticated= */ true, TARGET_USER_ID, /* bypassSecondaryLockScreen= */ true, SecurityMode.SimPin ) // THEN we will not show the password screen. verify(viewFlipperController, never()) .getSecurityView(eq(SecurityMode.Password), any(), any()) } @Test fun showNextSecurityScreenOrFinish_SimPin_SimPin() { // GIVEN the current security method is SimPin whenever(keyguardUpdateMonitor.getUserHasTrust(anyInt())).thenReturn(false) whenever(keyguardUpdateMonitor.getUserUnlockedWithBiometric(TARGET_USER_ID)) .thenReturn(false) underTest.showSecurityScreen(SecurityMode.SimPin) // WHEN a request is made from the SimPin screens to show the next security method whenever(keyguardSecurityModel.getSecurityMode(TARGET_USER_ID)) .thenReturn(SecurityMode.SimPin) // WHEN security method is SWIPE whenever(lockPatternUtils.isLockScreenDisabled(anyInt())).thenReturn(false) whenever(deviceProvisionedController.isUserSetup(anyInt())).thenReturn(false) underTest.showNextSecurityScreenOrFinish( /* authenticated= */ true, TARGET_USER_ID, /* bypassSecondaryLockScreen= */ true, SecurityMode.SimPin ) // THEN we will not show the password screen. verify(viewFlipperController).getSecurityView(eq(SecurityMode.SimPin), any(), any()) } @Test fun onSwipeUp_forwardsItToFaceAuthInteractor() { val registeredSwipeListener = registeredSwipeListener Loading packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSimPinViewControllerTest.kt +27 −0 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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() { Loading Loading @@ -95,6 +100,9 @@ class KeyguardSimPinViewControllerTest : SysuiTestCase() { mSelectedUserInteractor ) underTest.init() underTest.onResume(0) verify(keyguardUpdateMonitor) .registerCallback(updateMonitorCallbackArgumentCaptor.capture()) } @Test Loading @@ -111,6 +119,7 @@ class KeyguardSimPinViewControllerTest : SysuiTestCase() { @Test fun onResume() { reset(keyguardUpdateMonitor) underTest.onResume(KeyguardSecurityView.VIEW_REVEALED) verify(keyguardUpdateMonitor) .registerCallback(any(KeyguardUpdateMonitorCallback::class.java)) Loading @@ -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() } } packages/SystemUI/src/com/android/keyguard/KeyguardSecurityCallback.java +10 −0 Original line number Diff line number Diff line Loading @@ -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() { } } packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java +14 −5 Original line number Diff line number Diff line Loading @@ -27,6 +27,8 @@ import static com.android.keyguard.KeyguardSecurityContainer.BOUNCER_DISMISS_SIM import static com.android.keyguard.KeyguardSecurityContainer.USER_TYPE_PRIMARY; import static com.android.keyguard.KeyguardSecurityContainer.USER_TYPE_SECONDARY_USER; import static com.android.keyguard.KeyguardSecurityContainer.USER_TYPE_WORK_PROFILE; import static com.android.keyguard.KeyguardSecurityModel.SecurityMode.SimPin; import static com.android.keyguard.KeyguardSecurityModel.SecurityMode.SimPuk; import static com.android.systemui.DejankUtils.whitelistIpcs; import static com.android.systemui.flags.Flags.LOCKSCREEN_ENABLE_LANDSCAPE; import static com.android.systemui.flags.Flags.REVAMPED_BOUNCER_MESSAGES; Loading Loading @@ -99,6 +101,7 @@ import com.android.systemui.util.settings.GlobalSettings; import dagger.Lazy; import java.io.File; import java.util.Arrays; import java.util.Optional; import javax.inject.Inject; Loading Loading @@ -164,8 +167,8 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard } mCurrentUser = mSelectedUserInteractor.getSelectedUserId(); showPrimarySecurityScreen(false); if (mCurrentSecurityMode != SecurityMode.SimPin && mCurrentSecurityMode != SecurityMode.SimPuk) { if (mCurrentSecurityMode != SimPin && mCurrentSecurityMode != SimPuk) { reinflateViewFlipper((l) -> { }); } Loading Loading @@ -334,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() { Loading Loading @@ -888,7 +896,8 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard finish = true; eventSubtype = BOUNCER_DISMISS_SIM; uiEvent = BouncerUiEvent.BOUNCER_DISMISS_SIM; } else { } else if (Arrays.asList(SimPin, SimPuk).contains(securityMode)) { // There are additional screens to the sim pin/puk flow. showSecurityScreen(securityMode); } break; Loading Loading @@ -1095,8 +1104,8 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard } private void configureMode() { boolean useSimSecurity = mCurrentSecurityMode == SecurityMode.SimPin || mCurrentSecurityMode == SecurityMode.SimPuk; boolean useSimSecurity = mCurrentSecurityMode == SimPin || mCurrentSecurityMode == SimPuk; int mode = KeyguardSecurityContainer.MODE_DEFAULT; if (canDisplayUserSwitcher() && !useSimSecurity) { mode = KeyguardSecurityContainer.MODE_USER_SWITCHER; Loading packages/SystemUI/src/com/android/keyguard/KeyguardSimPinViewController.java +9 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading @@ -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(); Loading Loading
packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.kt +51 −23 Original line number Diff line number Diff line Loading @@ -464,29 +464,6 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() { verify(view).resetScale() } @Test fun showNextSecurityScreenOrFinish_setsSecurityScreenToPinAfterSimPinUnlock() { // GIVEN the current security method is SimPin whenever(keyguardUpdateMonitor.getUserHasTrust(anyInt())).thenReturn(false) whenever(keyguardUpdateMonitor.getUserUnlockedWithBiometric(TARGET_USER_ID)) .thenReturn(false) underTest.showSecurityScreen(SecurityMode.SimPin) // WHEN a request is made from the SimPin screens to show the next security method whenever(keyguardSecurityModel.getSecurityMode(TARGET_USER_ID)).thenReturn(SecurityMode.PIN) underTest.showNextSecurityScreenOrFinish( /* authenticated= */ true, TARGET_USER_ID, /* bypassSecondaryLockScreen= */ true, SecurityMode.SimPin ) // THEN the next security method of PIN is set, and the keyguard is not marked as done verify(viewMediatorCallback, never()).keyguardDonePending(anyInt()) verify(viewMediatorCallback, never()).keyguardDone(anyInt()) Truth.assertThat(underTest.currentSecurityMode).isEqualTo(SecurityMode.PIN) } @Test fun showNextSecurityScreenOrFinish_DeviceNotSecure() { // GIVEN the current security method is SimPin Loading Loading @@ -577,6 +554,57 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() { verify(viewMediatorCallback).keyguardDone(anyInt()) } @Test fun showNextSecurityScreenOrFinish_SimPin_Password() { // GIVEN the current security method is SimPin whenever(keyguardUpdateMonitor.getUserHasTrust(anyInt())).thenReturn(false) whenever(keyguardUpdateMonitor.getUserUnlockedWithBiometric(TARGET_USER_ID)) .thenReturn(false) underTest.showSecurityScreen(SecurityMode.SimPin) // WHEN a request is made from the SimPin screens to show the next security method whenever(keyguardSecurityModel.getSecurityMode(TARGET_USER_ID)) .thenReturn(SecurityMode.Password) // WHEN security method is SWIPE whenever(lockPatternUtils.isLockScreenDisabled(anyInt())).thenReturn(false) whenever(deviceProvisionedController.isUserSetup(anyInt())).thenReturn(false) underTest.showNextSecurityScreenOrFinish( /* authenticated= */ true, TARGET_USER_ID, /* bypassSecondaryLockScreen= */ true, SecurityMode.SimPin ) // THEN we will not show the password screen. verify(viewFlipperController, never()) .getSecurityView(eq(SecurityMode.Password), any(), any()) } @Test fun showNextSecurityScreenOrFinish_SimPin_SimPin() { // GIVEN the current security method is SimPin whenever(keyguardUpdateMonitor.getUserHasTrust(anyInt())).thenReturn(false) whenever(keyguardUpdateMonitor.getUserUnlockedWithBiometric(TARGET_USER_ID)) .thenReturn(false) underTest.showSecurityScreen(SecurityMode.SimPin) // WHEN a request is made from the SimPin screens to show the next security method whenever(keyguardSecurityModel.getSecurityMode(TARGET_USER_ID)) .thenReturn(SecurityMode.SimPin) // WHEN security method is SWIPE whenever(lockPatternUtils.isLockScreenDisabled(anyInt())).thenReturn(false) whenever(deviceProvisionedController.isUserSetup(anyInt())).thenReturn(false) underTest.showNextSecurityScreenOrFinish( /* authenticated= */ true, TARGET_USER_ID, /* bypassSecondaryLockScreen= */ true, SecurityMode.SimPin ) // THEN we will not show the password screen. verify(viewFlipperController).getSecurityView(eq(SecurityMode.SimPin), any(), any()) } @Test fun onSwipeUp_forwardsItToFaceAuthInteractor() { val registeredSwipeListener = registeredSwipeListener Loading
packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSimPinViewControllerTest.kt +27 −0 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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() { Loading Loading @@ -95,6 +100,9 @@ class KeyguardSimPinViewControllerTest : SysuiTestCase() { mSelectedUserInteractor ) underTest.init() underTest.onResume(0) verify(keyguardUpdateMonitor) .registerCallback(updateMonitorCallbackArgumentCaptor.capture()) } @Test Loading @@ -111,6 +119,7 @@ class KeyguardSimPinViewControllerTest : SysuiTestCase() { @Test fun onResume() { reset(keyguardUpdateMonitor) underTest.onResume(KeyguardSecurityView.VIEW_REVEALED) verify(keyguardUpdateMonitor) .registerCallback(any(KeyguardUpdateMonitorCallback::class.java)) Loading @@ -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() } }
packages/SystemUI/src/com/android/keyguard/KeyguardSecurityCallback.java +10 −0 Original line number Diff line number Diff line Loading @@ -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() { } }
packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java +14 −5 Original line number Diff line number Diff line Loading @@ -27,6 +27,8 @@ import static com.android.keyguard.KeyguardSecurityContainer.BOUNCER_DISMISS_SIM import static com.android.keyguard.KeyguardSecurityContainer.USER_TYPE_PRIMARY; import static com.android.keyguard.KeyguardSecurityContainer.USER_TYPE_SECONDARY_USER; import static com.android.keyguard.KeyguardSecurityContainer.USER_TYPE_WORK_PROFILE; import static com.android.keyguard.KeyguardSecurityModel.SecurityMode.SimPin; import static com.android.keyguard.KeyguardSecurityModel.SecurityMode.SimPuk; import static com.android.systemui.DejankUtils.whitelistIpcs; import static com.android.systemui.flags.Flags.LOCKSCREEN_ENABLE_LANDSCAPE; import static com.android.systemui.flags.Flags.REVAMPED_BOUNCER_MESSAGES; Loading Loading @@ -99,6 +101,7 @@ import com.android.systemui.util.settings.GlobalSettings; import dagger.Lazy; import java.io.File; import java.util.Arrays; import java.util.Optional; import javax.inject.Inject; Loading Loading @@ -164,8 +167,8 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard } mCurrentUser = mSelectedUserInteractor.getSelectedUserId(); showPrimarySecurityScreen(false); if (mCurrentSecurityMode != SecurityMode.SimPin && mCurrentSecurityMode != SecurityMode.SimPuk) { if (mCurrentSecurityMode != SimPin && mCurrentSecurityMode != SimPuk) { reinflateViewFlipper((l) -> { }); } Loading Loading @@ -334,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() { Loading Loading @@ -888,7 +896,8 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard finish = true; eventSubtype = BOUNCER_DISMISS_SIM; uiEvent = BouncerUiEvent.BOUNCER_DISMISS_SIM; } else { } else if (Arrays.asList(SimPin, SimPuk).contains(securityMode)) { // There are additional screens to the sim pin/puk flow. showSecurityScreen(securityMode); } break; Loading Loading @@ -1095,8 +1104,8 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard } private void configureMode() { boolean useSimSecurity = mCurrentSecurityMode == SecurityMode.SimPin || mCurrentSecurityMode == SecurityMode.SimPuk; boolean useSimSecurity = mCurrentSecurityMode == SimPin || mCurrentSecurityMode == SimPuk; int mode = KeyguardSecurityContainer.MODE_DEFAULT; if (canDisplayUserSwitcher() && !useSimSecurity) { mode = KeyguardSecurityContainer.MODE_USER_SWITCHER; Loading
packages/SystemUI/src/com/android/keyguard/KeyguardSimPinViewController.java +9 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading @@ -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(); Loading