From 616ec5ec5d287d3a3280921191c1453c55c1d372 Mon Sep 17 00:00:00 2001 From: Beverly Date: Fri, 1 Jul 2022 17:53:10 +0000 Subject: [PATCH] Update face unlocked string when a11y is enabled If face unlocked the device and a11y is enabled, tell the user that face unlocked their device & they can swipe up to open (instead of telling them to press to open when UDFPS is supported). Test: atest KeyguardIndicationControllerTest Fixes: 195615155 Change-Id: Ic15c1efb17283d1e2843a200c3ff4a66eb8b6230 --- packages/SystemUI/res/values/strings.xml | 2 + .../KeyguardIndicationController.java | 38 +++- .../KeyguardIndicationControllerTest.java | 203 +++++++++++++----- 3 files changed, 186 insertions(+), 57 deletions(-) diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index ef672f3a62135..176e5818f5bd1 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -802,6 +802,8 @@ Press the unlock icon to open + + Unlocked by face. Swipe up to open. Unlocked by face. Press the unlock icon to open. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java index 9e029095ea6b7..ca147286a3018 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java @@ -900,16 +900,36 @@ public class KeyguardIndicationController { mStatusBarKeyguardViewManager.showBouncerMessage(message, mInitialTextColorState); } } else { - if (!mAccessibilityManager.isEnabled() - && !mAccessibilityManager.isTouchExplorationEnabled() - && mKeyguardUpdateMonitor.isUdfpsSupported() - && mKeyguardUpdateMonitor.getUserCanSkipBouncer( - KeyguardUpdateMonitor.getCurrentUser())) { - final int stringId = mKeyguardUpdateMonitor.getIsFaceAuthenticated() - ? R.string.keyguard_face_successful_unlock_press - : R.string.keyguard_unlock_press; - showBiometricMessage(mContext.getString(stringId)); + final boolean canSkipBouncer = mKeyguardUpdateMonitor.getUserCanSkipBouncer( + KeyguardUpdateMonitor.getCurrentUser()); + if (canSkipBouncer) { + final boolean faceAuthenticated = mKeyguardUpdateMonitor.getIsFaceAuthenticated(); + final boolean udfpsSupported = mKeyguardUpdateMonitor.isUdfpsSupported(); + final boolean a11yEnabled = mAccessibilityManager.isEnabled() + || mAccessibilityManager.isTouchExplorationEnabled(); + if (udfpsSupported && faceAuthenticated) { // co-ex + if (a11yEnabled) { + showBiometricMessage(mContext.getString( + R.string.keyguard_face_successful_unlock_swipe)); + } else { + showBiometricMessage(mContext.getString( + R.string.keyguard_face_successful_unlock_press)); + } + } else if (faceAuthenticated) { // face-only + showBiometricMessage(mContext.getString( + R.string.keyguard_face_successful_unlock_swipe)); + } else if (udfpsSupported) { // udfps-only + if (a11yEnabled) { + showBiometricMessage(mContext.getString(R.string.keyguard_unlock)); + } else { + showBiometricMessage(mContext.getString( + R.string.keyguard_unlock_press)); + } + } else { // no security or unlocked by a trust agent + showBiometricMessage(mContext.getString(R.string.keyguard_unlock)); + } } else { + // suggest swiping up for the primary authentication bouncer showBiometricMessage(mContext.getString(R.string.keyguard_unlock)); } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java index d67e26f138f27..9c25462b7c0d4 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java @@ -30,6 +30,7 @@ import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewCont import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_TRANSIENT; import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_TRUST; import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_USER_LOCKED; +import static com.android.systemui.keyguard.ScreenLifecycle.SCREEN_ON; import static com.google.common.truth.Truth.assertThat; @@ -212,7 +213,7 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase { R.string.do_financed_disclosure_with_name, ORGANIZATION_NAME); when(mKeyguardUpdateMonitor.isUnlockingWithBiometricAllowed(anyBoolean())).thenReturn(true); - when(mScreenLifecycle.getScreenState()).thenReturn(ScreenLifecycle.SCREEN_ON); + when(mScreenLifecycle.getScreenState()).thenReturn(SCREEN_ON); when(mKeyguardUpdateMonitor.isUserUnlocked(anyInt())).thenReturn(true); when(mIndicationArea.findViewById(R.id.keyguard_indication_text_bottom)) @@ -954,64 +955,170 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase { } @Test - public void nonBypassFaceSuccess_touchExplorationEnabled_showsSwipeToOpen() { - // GIVEN non bypass face auth and touch exploration is enabled - when(mKeyguardBypassController.canBypass()).thenReturn(false); - when(mAccessibilityManager.isTouchExplorationEnabled()).thenReturn(true); - when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); - createController(); - String swipeToOpen = mContext.getString(R.string.keyguard_unlock); - mController.setVisible(true); - - // WHEN face authenticated - mController.getKeyguardCallback().onBiometricAuthenticated(0, - BiometricSourceType.FACE, false); - - // THEN show 'swipe up to open' message - verifyIndicationMessage(INDICATION_TYPE_BIOMETRIC_MESSAGE, swipeToOpen); - } - - @Test - public void nonBypassFaceSuccess_a11yEnabled_showsSwipeToOpen() { - // GIVEN non bypass face auth and a11y is enabled - when(mKeyguardBypassController.canBypass()).thenReturn(false); - when(mAccessibilityManager.isEnabled()).thenReturn(true); - when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); - createController(); - String swipeToOpen = mContext.getString(R.string.keyguard_unlock); - mController.setVisible(true); - - // WHEN face auth is successful - mController.getKeyguardCallback().onBiometricAuthenticated(0, - BiometricSourceType.FACE, false); - - // THEN show 'swipe up to open' message - verifyIndicationMessage(INDICATION_TYPE_BIOMETRIC_MESSAGE, swipeToOpen); - } - - @Test - public void coEx_nonBypassFaceSuccess_showsPressLockIcon() { - // GIVEN udfps is supported, non-bypass face auth, and no a11y enabled - when(mKeyguardUpdateMonitor.isUdfpsSupported()).thenReturn(true); - when(mKeyguardBypassController.canBypass()).thenReturn(false); - when(mKeyguardUpdateMonitor.getIsFaceAuthenticated()).thenReturn(true); - when(mAccessibilityManager.isEnabled()).thenReturn(false); - when(mAccessibilityManager.isTouchExplorationEnabled()).thenReturn(false); + public void coEx_faceSuccess_showsPressToOpen() { + // GIVEN bouncer isn't showing, can skip bouncer, udfps is supported, no a11y enabled when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); when(mKeyguardUpdateMonitor.getUserCanSkipBouncer(KeyguardUpdateMonitor.getCurrentUser())) .thenReturn(true); + when(mKeyguardUpdateMonitor.isUdfpsSupported()).thenReturn(true); + when(mAccessibilityManager.isEnabled()).thenReturn(false); + when(mAccessibilityManager.isTouchExplorationEnabled()).thenReturn(false); createController(); mController.setVisible(true); // WHEN face auth succeeds + when(mKeyguardUpdateMonitor.getIsFaceAuthenticated()).thenReturn(true); mController.getKeyguardCallback().onBiometricAuthenticated(0, BiometricSourceType.FACE, false); - // THEN press unlock icon to open message shows - String pressLockIcon = mContext.getString(R.string.keyguard_face_successful_unlock_press); - verifyIndicationMessage(INDICATION_TYPE_BIOMETRIC_MESSAGE, pressLockIcon); + // THEN 'face unlocked. press unlock icon to open' message shows + String pressToOpen = mContext.getString(R.string.keyguard_face_successful_unlock_press); + verifyIndicationMessage(INDICATION_TYPE_BIOMETRIC_MESSAGE, pressToOpen); - assertThat(mTextView.getText()).isNotEqualTo(pressLockIcon); + assertThat(mTextView.getText()).isNotEqualTo(pressToOpen); + } + + + @Test + public void coEx_faceSuccess_touchExplorationEnabled_showsFaceUnlockedSwipeToOpen() { + // GIVEN bouncer isn't showing, can skip bouncer, udfps is supported, a11y enabled + when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); + when(mKeyguardUpdateMonitor.getUserCanSkipBouncer(KeyguardUpdateMonitor.getCurrentUser())) + .thenReturn(true); + when(mKeyguardUpdateMonitor.isUdfpsSupported()).thenReturn(true); + when(mAccessibilityManager.isEnabled()).thenReturn(true); + when(mAccessibilityManager.isTouchExplorationEnabled()).thenReturn(true); + createController(); + mController.setVisible(true); + + // WHEN face authenticated + when(mKeyguardUpdateMonitor.getIsFaceAuthenticated()).thenReturn(true); + mController.getKeyguardCallback().onBiometricAuthenticated(0, + BiometricSourceType.FACE, false); + + // THEN show 'face unlocked. swipe up to open' message + String faceUnlockedSwipeToOpen = + mContext.getString(R.string.keyguard_face_successful_unlock_swipe); + verifyIndicationMessage(INDICATION_TYPE_BIOMETRIC_MESSAGE, faceUnlockedSwipeToOpen); + } + + @Test + public void coEx_faceSuccess_a11yEnabled_showsFaceUnlockedSwipeToOpen() { + // GIVEN bouncer isn't showing, can skip bouncer, udfps is supported, a11y is enabled + when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); + when(mKeyguardUpdateMonitor.getUserCanSkipBouncer(KeyguardUpdateMonitor.getCurrentUser())) + .thenReturn(true); + when(mKeyguardUpdateMonitor.isUdfpsSupported()).thenReturn(true); + when(mAccessibilityManager.isEnabled()).thenReturn(true); + createController(); + mController.setVisible(true); + + // WHEN face auth is successful + when(mKeyguardUpdateMonitor.getIsFaceAuthenticated()).thenReturn(true); + mController.getKeyguardCallback().onBiometricAuthenticated(0, + BiometricSourceType.FACE, false); + + // THEN show 'swipe up to open' message + String faceUnlockedSwipeToOpen = + mContext.getString(R.string.keyguard_face_successful_unlock_swipe); + verifyIndicationMessage(INDICATION_TYPE_BIOMETRIC_MESSAGE, faceUnlockedSwipeToOpen); + } + + @Test + public void faceOnly_faceSuccess_showsFaceUnlockedSwipeToOpen() { + // GIVEN bouncer isn't showing, can skip bouncer, no udfps supported + when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); + when(mKeyguardUpdateMonitor.getUserCanSkipBouncer(KeyguardUpdateMonitor.getCurrentUser())) + .thenReturn(true); + when(mKeyguardUpdateMonitor.isUdfpsSupported()).thenReturn(false); + createController(); + mController.setVisible(true); + + // WHEN face auth is successful + when(mKeyguardUpdateMonitor.getIsFaceAuthenticated()).thenReturn(true); + mController.getKeyguardCallback().onBiometricAuthenticated(0, + BiometricSourceType.FACE, false); + + // THEN show 'swipe up to open' message + String faceUnlockedSwipeToOpen = + mContext.getString(R.string.keyguard_face_successful_unlock_swipe); + verifyIndicationMessage(INDICATION_TYPE_BIOMETRIC_MESSAGE, faceUnlockedSwipeToOpen); + } + + @Test + public void udfpsOnly_a11yEnabled_showsSwipeToOpen() { + // GIVEN bouncer isn't showing, can skip bouncer, udfps is supported, a11y is enabled + when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); + when(mKeyguardUpdateMonitor.getUserCanSkipBouncer(KeyguardUpdateMonitor.getCurrentUser())) + .thenReturn(true); + when(mKeyguardUpdateMonitor.isUdfpsSupported()).thenReturn(true); + when(mAccessibilityManager.isEnabled()).thenReturn(true); + when(mAccessibilityManager.isTouchExplorationEnabled()).thenReturn(true); + createController(); + mController.setVisible(true); + + // WHEN showActionToUnlock + mController.showActionToUnlock(); + + // THEN show 'swipe up to open' message + String swipeToOpen = mContext.getString(R.string.keyguard_unlock); + verifyIndicationMessage(INDICATION_TYPE_BIOMETRIC_MESSAGE, swipeToOpen); + } + + @Test + public void udfpsOnly_showsPressToOpen() { + // GIVEN bouncer isn't showing, udfps is supported, a11y is NOT enabled, can skip bouncer + when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); + when(mKeyguardUpdateMonitor.getUserCanSkipBouncer(KeyguardUpdateMonitor.getCurrentUser())) + .thenReturn(true); + when(mKeyguardUpdateMonitor.isUdfpsSupported()).thenReturn(true); + when(mAccessibilityManager.isEnabled()).thenReturn(false); + when(mAccessibilityManager.isTouchExplorationEnabled()).thenReturn(false); + createController(); + mController.setVisible(true); + + // WHEN showActionToUnlock + mController.showActionToUnlock(); + + // THEN show 'press unlock icon to open' message + String pressToOpen = mContext.getString(R.string.keyguard_unlock_press); + verifyIndicationMessage(INDICATION_TYPE_BIOMETRIC_MESSAGE, pressToOpen); + } + + @Test + public void canSkipBouncer_noSecurity_showSwipeToUnlockHint() { + // GIVEN bouncer isn't showing, can skip bouncer, no security (udfps isn't supported, + // face wasn't authenticated) + when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); + when(mKeyguardUpdateMonitor.getUserCanSkipBouncer(KeyguardUpdateMonitor.getCurrentUser())) + .thenReturn(true); + when(mKeyguardUpdateMonitor.isUdfpsSupported()).thenReturn(false); + createController(); + mController.setVisible(true); + + // WHEN showActionToUnlock + mController.showActionToUnlock(); + + // THEN show 'swipe up to open' message + String swipeToOpen = mContext.getString(R.string.keyguard_unlock); + verifyIndicationMessage(INDICATION_TYPE_BIOMETRIC_MESSAGE, swipeToOpen); + } + + @Test + public void cannotSkipBouncer_showSwipeToUnlockHint() { + // GIVEN bouncer isn't showing and cannot skip bouncer + when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false); + when(mKeyguardUpdateMonitor.getUserCanSkipBouncer(KeyguardUpdateMonitor.getCurrentUser())) + .thenReturn(false); + createController(); + mController.setVisible(true); + + // WHEN showActionToUnlock + mController.showActionToUnlock(); + + // THEN show 'swipe up to open' message + String swipeToOpen = mContext.getString(R.string.keyguard_unlock); + verifyIndicationMessage(INDICATION_TYPE_BIOMETRIC_MESSAGE, swipeToOpen); } private void sendUpdateDisclosureBroadcast() {