From fb310c25ee1d9acab1e6d97eb973fa4bac40412a Mon Sep 17 00:00:00 2001 From: Beverly Date: Thu, 5 Jan 2023 16:34:11 +0000 Subject: [PATCH] Update lock icon view when biometrics cleared To ensure when face auth is the only biometric enrolled, that the unlocked icon immediately becomes the locked icon on screen off (when biometrics authentication states are cleared). Also add the unlocked => locked icon transition so there isn't a jump-cut animation when AoD is enabled and the unlocked icon transitions to the locked icon. Fixes: 264217642 Test: manual 1. enroll face auth only without bypass enabled 2. unlock the lock screen (see unlocked icon) 3. let the screen timeout 4. tap screen to wakeup Observe: lock icon (not unlocked icon) Test: atest LockIconViewControllerTest Change-Id: I317725fee4519ad0af39a1a7ade0361263643902 --- .../res-keyguard/drawable/super_lock_icon.xml | 5 + .../drawable/unlocked_to_locked.xml | 145 ++++++++++++++++++ .../keyguard/LockIconViewController.java | 11 ++ .../LockIconViewControllerBaseTest.java | 2 + .../keyguard/LockIconViewControllerTest.java | 20 +++ 5 files changed, 183 insertions(+) create mode 100644 packages/SystemUI/res-keyguard/drawable/unlocked_to_locked.xml diff --git a/packages/SystemUI/res-keyguard/drawable/super_lock_icon.xml b/packages/SystemUI/res-keyguard/drawable/super_lock_icon.xml index b3987f1aeeda0..951d6fed0a17c 100644 --- a/packages/SystemUI/res-keyguard/drawable/super_lock_icon.xml +++ b/packages/SystemUI/res-keyguard/drawable/super_lock_icon.xml @@ -99,4 +99,9 @@ android:fromId="@id/unlocked" android:toId="@id/locked_aod" android:drawable="@drawable/unlocked_to_aod_lock" /> + + diff --git a/packages/SystemUI/res-keyguard/drawable/unlocked_to_locked.xml b/packages/SystemUI/res-keyguard/drawable/unlocked_to_locked.xml new file mode 100644 index 0000000000000..b55abd1fdddc4 --- /dev/null +++ b/packages/SystemUI/res-keyguard/drawable/unlocked_to_locked.xml @@ -0,0 +1,145 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java b/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java index dd6a1bd457b8d..1322f16a5a59e 100644 --- a/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java @@ -500,6 +500,17 @@ public class LockIconViewController extends ViewController impleme updateVisibility(); } + @Override + public void onBiometricsCleared() { + final boolean wasUserUnlockedWithBiometric = mUserUnlockedWithBiometric; + mUserUnlockedWithBiometric = + mKeyguardUpdateMonitor.getUserUnlockedWithBiometric( + KeyguardUpdateMonitor.getCurrentUser()); + if (wasUserUnlockedWithBiometric != mUserUnlockedWithBiometric) { + updateVisibility(); + } + } + @Override public void onBiometricRunningStateChanged(boolean running, BiometricSourceType biometricSourceType) { diff --git a/packages/SystemUI/tests/src/com/android/keyguard/LockIconViewControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/keyguard/LockIconViewControllerBaseTest.java index ae8f419d4e648..e4c41a7ed804d 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/LockIconViewControllerBaseTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/LockIconViewControllerBaseTest.java @@ -68,6 +68,7 @@ import org.mockito.quality.Strictness; public class LockIconViewControllerBaseTest extends SysuiTestCase { protected static final String UNLOCKED_LABEL = "unlocked"; + protected static final String LOCKED_LABEL = "locked"; protected static final int PADDING = 10; protected MockitoSession mStaticMockSession; @@ -130,6 +131,7 @@ public class LockIconViewControllerBaseTest extends SysuiTestCase { Rect windowBounds = new Rect(0, 0, 800, 1200); when(mWindowManager.getCurrentWindowMetrics().getBounds()).thenReturn(windowBounds); when(mResources.getString(R.string.accessibility_unlock_button)).thenReturn(UNLOCKED_LABEL); + when(mResources.getString(R.string.accessibility_lock_icon)).thenReturn(LOCKED_LABEL); when(mResources.getDrawable(anyInt(), any())).thenReturn(mIconDrawable); when(mResources.getDimensionPixelSize(R.dimen.lock_icon_padding)).thenReturn(PADDING); when(mAuthController.getScaleFactor()).thenReturn(1f); diff --git a/packages/SystemUI/tests/src/com/android/keyguard/LockIconViewControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/LockIconViewControllerTest.java index da40595a4f122..b69491ed10964 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/LockIconViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/LockIconViewControllerTest.java @@ -262,6 +262,26 @@ public class LockIconViewControllerTest extends LockIconViewControllerBaseTest { // THEN the view is updated to NO translation (no burn-in offsets anymore) verify(mLockIconView).setTranslationY(0); verify(mLockIconView).setTranslationX(0); + } + @Test + public void lockIconShows_afterBiometricsCleared() { + // GIVEN lock icon controller is initialized and view is attached + init(/* useMigrationFlag= */false); + captureKeyguardUpdateMonitorCallback(); + + // GIVEN user has unlocked with a biometric auth (ie: face auth) + // and biometric running state changes + when(mKeyguardUpdateMonitor.getUserUnlockedWithBiometric(anyInt())).thenReturn(true); + mKeyguardUpdateMonitorCallback.onBiometricRunningStateChanged(false, + BiometricSourceType.FACE); + reset(mLockIconView); + + // WHEN biometrics are cleared + when(mKeyguardUpdateMonitor.getUserUnlockedWithBiometric(anyInt())).thenReturn(false); + mKeyguardUpdateMonitorCallback.onBiometricsCleared(); + + // THEN the lock icon is shown + verify(mLockIconView).setContentDescription(LOCKED_LABEL); } }