Merge "Update userUnlockedWithBiometric on unlock changes" into tm-qpr-dev

This commit is contained in:
Beverly Tai
2023-02-15 13:35:28 +00:00
committed by Android (Google) Code Review
2 changed files with 39 additions and 14 deletions

View File

@@ -466,6 +466,17 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
} }
} }
/**
* @return whether the userUnlockedWithBiometric state changed
*/
private boolean updateUserUnlockedWithBiometric() {
final boolean wasUserUnlockedWithBiometric = mUserUnlockedWithBiometric;
mUserUnlockedWithBiometric =
mKeyguardUpdateMonitor.getUserUnlockedWithBiometric(
KeyguardUpdateMonitor.getCurrentUser());
return wasUserUnlockedWithBiometric != mUserUnlockedWithBiometric;
}
private StatusBarStateController.StateListener mStatusBarStateListener = private StatusBarStateController.StateListener mStatusBarStateListener =
new StatusBarStateController.StateListener() { new StatusBarStateController.StateListener() {
@Override @Override
@@ -503,11 +514,7 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
@Override @Override
public void onBiometricsCleared() { public void onBiometricsCleared() {
final boolean wasUserUnlockedWithBiometric = mUserUnlockedWithBiometric; if (updateUserUnlockedWithBiometric()) {
mUserUnlockedWithBiometric =
mKeyguardUpdateMonitor.getUserUnlockedWithBiometric(
KeyguardUpdateMonitor.getCurrentUser());
if (wasUserUnlockedWithBiometric != mUserUnlockedWithBiometric) {
updateVisibility(); updateVisibility();
} }
} }
@@ -516,10 +523,8 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
public void onBiometricRunningStateChanged(boolean running, public void onBiometricRunningStateChanged(boolean running,
BiometricSourceType biometricSourceType) { BiometricSourceType biometricSourceType) {
final boolean wasRunningFps = mRunningFPS; final boolean wasRunningFps = mRunningFPS;
final boolean wasUserUnlockedWithBiometric = mUserUnlockedWithBiometric; final boolean userUnlockedWithBiometricChanged =
mUserUnlockedWithBiometric = updateUserUnlockedWithBiometric();
mKeyguardUpdateMonitor.getUserUnlockedWithBiometric(
KeyguardUpdateMonitor.getCurrentUser());
if (biometricSourceType == FINGERPRINT) { if (biometricSourceType == FINGERPRINT) {
mRunningFPS = running; mRunningFPS = running;
@@ -537,8 +542,7 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
} }
} }
if (wasUserUnlockedWithBiometric != mUserUnlockedWithBiometric if (userUnlockedWithBiometricChanged || wasRunningFps != mRunningFPS) {
|| wasRunningFps != mRunningFPS) {
updateVisibility(); updateVisibility();
} }
} }
@@ -549,6 +553,7 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
@Override @Override
public void onUnlockedChanged() { public void onUnlockedChanged() {
mCanDismissLockScreen = mKeyguardStateController.canDismissLockScreen(); mCanDismissLockScreen = mKeyguardStateController.canDismissLockScreen();
updateUserUnlockedWithBiometric();
updateKeyguardShowing(); updateKeyguardShowing();
updateVisibility(); updateVisibility();
} }
@@ -566,9 +571,7 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
updateKeyguardShowing(); updateKeyguardShowing();
if (mIsKeyguardShowing) { if (mIsKeyguardShowing) {
mUserUnlockedWithBiometric = updateUserUnlockedWithBiometric();
mKeyguardUpdateMonitor.getUserUnlockedWithBiometric(
KeyguardUpdateMonitor.getCurrentUser());
} }
updateVisibility(); updateVisibility();
} }

View File

@@ -284,4 +284,26 @@ public class LockIconViewControllerTest extends LockIconViewControllerBaseTest {
// THEN the lock icon is shown // THEN the lock icon is shown
verify(mLockIconView).setContentDescription(LOCKED_LABEL); verify(mLockIconView).setContentDescription(LOCKED_LABEL);
} }
@Test
public void lockIconShows_afterUnlockStateChanges() {
// GIVEN lock icon controller is initialized and view is attached
init(/* useMigrationFlag= */false);
captureKeyguardStateCallback();
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 the unlocked state changes
when(mKeyguardUpdateMonitor.getUserUnlockedWithBiometric(anyInt())).thenReturn(false);
mKeyguardStateCallback.onUnlockedChanged();
// THEN the lock icon is shown
verify(mLockIconView).setContentDescription(LOCKED_LABEL);
}
} }