summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Bryce Lee <brycelee@google.com> 2023-07-22 07:34:09 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2023-07-22 07:34:09 +0000
commit373d17101065ee49c372ee8543aa4e7ce2ce8a53 (patch)
treea98e5c30a058e2ef9a580c15df98ba9843764917
parent301629a4bb37307fd03f487460d2d0b562b40672 (diff)
parent7db635ba432632c2fef69bca32242ad97acaee5a (diff)
Merge "Handle waking from unlock in KeyguardViewMediator." into udc-dev am: 83270333ff am: 7db635ba43
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/24157194 Change-Id: I00d4ee1036b44df9188637213d4520a4c20f7c01 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java36
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java27
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java64
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java87
4 files changed, 115 insertions, 99 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index ddcb31ff8c76..505be0867fe4 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -433,6 +433,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
private final LockPatternUtils mLockPatternUtils;
private final BroadcastDispatcher mBroadcastDispatcher;
private boolean mKeyguardDonePending = false;
+ private boolean mUnlockingAndWakingFromDream = false;
private boolean mHideAnimationRun = false;
private boolean mHideAnimationRunning = false;
@@ -806,6 +807,25 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
mKeyguardViewControllerLazy.get().setKeyguardGoingAwayState(false);
mKeyguardDisplayManager.hide();
mUpdateMonitor.startBiometricWatchdog();
+
+ // It's possible that the device was unlocked (via BOUNCER or Fingerprint) while
+ // dreaming. It's time to wake up.
+ if (mUnlockingAndWakingFromDream) {
+ Log.d(TAG, "waking from dream after unlock");
+ mUnlockingAndWakingFromDream = false;
+
+ if (mKeyguardStateController.isShowing()) {
+ Log.d(TAG, "keyguard showing after keyguardGone, dismiss");
+ mKeyguardViewControllerLazy.get()
+ .notifyKeyguardAuthenticated(!mWakeAndUnlocking);
+ } else {
+ Log.d(TAG, "keyguard gone, waking up from dream");
+ mPM.wakeUp(SystemClock.uptimeMillis(),
+ mWakeAndUnlocking ? PowerManager.WAKE_REASON_BIOMETRIC
+ : PowerManager.WAKE_REASON_GESTURE,
+ "com.android.systemui:UNLOCK_DREAMING");
+ }
+ }
Trace.endSection();
}
@@ -2634,6 +2654,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
mKeyguardExitAnimationRunner = null;
mWakeAndUnlocking = false;
+ mUnlockingAndWakingFromDream = false;
setPendingLock(false);
// Force if we we're showing in the middle of hiding, to ensure we end up in the correct
@@ -2758,7 +2779,13 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
mHiding = true;
- if (mShowing && !mOccluded) {
+ mUnlockingAndWakingFromDream = mStatusBarStateController.isDreaming()
+ && !mStatusBarStateController.isDozing();
+
+ if ((mShowing && !mOccluded) || mUnlockingAndWakingFromDream) {
+ if (mUnlockingAndWakingFromDream) {
+ Log.d(TAG, "hiding keyguard before waking from dream");
+ }
mKeyguardGoingAwayRunnable.run();
} else {
// TODO(bc-unlock): Fill parameters
@@ -2769,13 +2796,6 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
null /* nonApps */, null /* finishedCallback */);
});
}
-
- // It's possible that the device was unlocked (via BOUNCER or Fingerprint) while
- // dreaming. It's time to wake up.
- if (mDreamOverlayShowing) {
- mPM.wakeUp(SystemClock.uptimeMillis(), PowerManager.WAKE_REASON_GESTURE,
- "com.android.systemui:UNLOCK_DREAMING");
- }
}
Trace.endSection();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java
index 1f9c9f2b8c14..ccb51898a333 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java
@@ -160,7 +160,6 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
private KeyguardViewController mKeyguardViewController;
private DozeScrimController mDozeScrimController;
private KeyguardViewMediator mKeyguardViewMediator;
- private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
private PendingAuthenticated mPendingAuthenticated = null;
private boolean mHasScreenTurnedOnSinceAuthenticating;
private boolean mFadedAwayAfterWakeAndUnlock;
@@ -281,8 +280,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
LatencyTracker latencyTracker,
ScreenOffAnimationController screenOffAnimationController,
VibratorHelper vibrator,
- SystemClock systemClock,
- StatusBarKeyguardViewManager statusBarKeyguardViewManager
+ SystemClock systemClock
) {
mPowerManager = powerManager;
mUpdateMonitor = keyguardUpdateMonitor;
@@ -310,7 +308,6 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
mVibratorHelper = vibrator;
mLogger = biometricUnlockLogger;
mSystemClock = systemClock;
- mStatusBarKeyguardViewManager = statusBarKeyguardViewManager;
dumpManager.registerDumpable(getClass().getName(), this);
}
@@ -452,19 +449,8 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
// During wake and unlock, we need to draw black before waking up to avoid abrupt
// brightness changes due to display state transitions.
Runnable wakeUp = ()-> {
- // Check to see if we are still locked when we are waking and unlocking from dream.
- // This runnable should be executed after unlock. If that's true, we could be not
- // dreaming, but still locked. In this case, we should attempt to authenticate instead
- // of waking up.
- if (mode == MODE_WAKE_AND_UNLOCK_FROM_DREAM
- && !mKeyguardStateController.isUnlocked()
- && !mUpdateMonitor.isDreaming()) {
- // Post wakeUp runnable is called from a callback in keyguard.
- mHandler.post(() -> mKeyguardViewController.notifyKeyguardAuthenticated(
- false /* primaryAuth */));
- } else if (!wasDeviceInteractive || mUpdateMonitor.isDreaming()) {
+ if (!wasDeviceInteractive || mUpdateMonitor.isDreaming()) {
mLogger.i("bio wakelock: Authenticated, waking up...");
-
mPowerManager.wakeUp(
mSystemClock.uptimeMillis(),
PowerManager.WAKE_REASON_BIOMETRIC,
@@ -476,7 +462,10 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
Trace.endSection();
};
- if (mMode != MODE_NONE && mMode != MODE_WAKE_AND_UNLOCK_FROM_DREAM) {
+ final boolean wakingFromDream = mMode == MODE_WAKE_AND_UNLOCK_FROM_DREAM
+ && !mStatusBarStateController.isDozing();
+
+ if (mMode != MODE_NONE && !wakingFromDream) {
wakeUp.run();
}
switch (mMode) {
@@ -498,10 +487,6 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
Trace.endSection();
break;
case MODE_WAKE_AND_UNLOCK_FROM_DREAM:
- // In the case of waking and unlocking from dream, waking up is delayed until after
- // unlock is complete to avoid conflicts during each sequence's transitions.
- mStatusBarKeyguardViewManager.addAfterKeyguardGoneRunnable(wakeUp);
- // Execution falls through here to proceed unlocking.
case MODE_WAKE_AND_UNLOCK_PULSING:
case MODE_WAKE_AND_UNLOCK:
if (mMode == MODE_WAKE_AND_UNLOCK_PULSING) {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java
index 7a501a85714e..2fc3cf6af6b1 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java
@@ -31,7 +31,10 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.atLeast;
+import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -598,6 +601,67 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
}
@Test
+ public void testWakeAndUnlockingOverDream() {
+ // Send signal to wake
+ mViewMediator.onWakeAndUnlocking();
+
+ // Ensure not woken up yet
+ verify(mPowerManager, never()).wakeUp(anyLong(), anyInt(), anyString());
+
+ // Verify keyguard told of authentication
+ verify(mStatusBarKeyguardViewManager).notifyKeyguardAuthenticated(anyBoolean());
+ mViewMediator.mViewMediatorCallback.keyguardDonePending(true,
+ mUpdateMonitor.getCurrentUser());
+ mViewMediator.mViewMediatorCallback.readyForKeyguardDone();
+ final ArgumentCaptor<Runnable> animationRunnableCaptor =
+ ArgumentCaptor.forClass(Runnable.class);
+ verify(mStatusBarKeyguardViewManager).startPreHideAnimation(
+ animationRunnableCaptor.capture());
+
+ when(mStatusBarStateController.isDreaming()).thenReturn(true);
+ when(mStatusBarStateController.isDozing()).thenReturn(false);
+ animationRunnableCaptor.getValue().run();
+
+ when(mKeyguardStateController.isShowing()).thenReturn(false);
+ mViewMediator.mViewMediatorCallback.keyguardGone();
+
+ // Verify woken up now.
+ verify(mPowerManager).wakeUp(anyLong(), anyInt(), anyString());
+ }
+
+ @Test
+ public void testWakeAndUnlockingOverDream_signalAuthenticateIfStillShowing() {
+ // Send signal to wake
+ mViewMediator.onWakeAndUnlocking();
+
+ // Ensure not woken up yet
+ verify(mPowerManager, never()).wakeUp(anyLong(), anyInt(), anyString());
+
+ // Verify keyguard told of authentication
+ verify(mStatusBarKeyguardViewManager).notifyKeyguardAuthenticated(anyBoolean());
+ clearInvocations(mStatusBarKeyguardViewManager);
+ mViewMediator.mViewMediatorCallback.keyguardDonePending(true,
+ mUpdateMonitor.getCurrentUser());
+ mViewMediator.mViewMediatorCallback.readyForKeyguardDone();
+ final ArgumentCaptor<Runnable> animationRunnableCaptor =
+ ArgumentCaptor.forClass(Runnable.class);
+ verify(mStatusBarKeyguardViewManager).startPreHideAnimation(
+ animationRunnableCaptor.capture());
+
+ when(mStatusBarStateController.isDreaming()).thenReturn(true);
+ when(mStatusBarStateController.isDozing()).thenReturn(false);
+ animationRunnableCaptor.getValue().run();
+
+ when(mKeyguardStateController.isShowing()).thenReturn(true);
+
+ mViewMediator.mViewMediatorCallback.keyguardGone();
+
+
+ // Verify keyguard view controller informed of authentication again
+ verify(mStatusBarKeyguardViewManager).notifyKeyguardAuthenticated(anyBoolean());
+ }
+
+ @Test
@TestableLooper.RunWithLooper(setAsMainLooper = true)
public void testDoKeyguardWhileInteractive_resets() {
mViewMediator.setShowingLocked(true);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java
index 479803e1dfac..4f8de3eacf7a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java
@@ -142,8 +142,7 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
mNotificationMediaManager, mWakefulnessLifecycle, mScreenLifecycle,
mAuthController, mStatusBarStateController,
mSessionTracker, mLatencyTracker, mScreenOffAnimationController, mVibratorHelper,
- mSystemClock,
- mStatusBarKeyguardViewManager
+ mSystemClock
);
mBiometricUnlockController.setKeyguardViewController(mStatusBarKeyguardViewManager);
mBiometricUnlockController.addListener(mBiometricUnlockEventsListener);
@@ -465,69 +464,6 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
}
@Test
- public void onSideFingerprintSuccess_dreaming_unlockThenWake() {
- when(mAuthController.isSfpsEnrolled(anyInt())).thenReturn(true);
- when(mWakefulnessLifecycle.getLastWakeReason())
- .thenReturn(PowerManager.WAKE_REASON_POWER_BUTTON);
- final ArgumentCaptor<Runnable> afterKeyguardGoneRunnableCaptor =
- ArgumentCaptor.forClass(Runnable.class);
- givenDreamingLocked();
- mBiometricUnlockController.startWakeAndUnlock(BiometricSourceType.FINGERPRINT, true);
-
- // Make sure the BiometricUnlockController has registered a callback for when the keyguard
- // is gone
- verify(mStatusBarKeyguardViewManager).addAfterKeyguardGoneRunnable(
- afterKeyguardGoneRunnableCaptor.capture());
- // Ensure that the power hasn't been told to wake up yet.
- verify(mPowerManager, never()).wakeUp(anyLong(), anyInt(), anyString());
- // Check that the keyguard has been told to unlock.
- verify(mKeyguardViewMediator).onWakeAndUnlocking();
-
- // Simulate the keyguard disappearing.
- afterKeyguardGoneRunnableCaptor.getValue().run();
- // Verify that the power manager has been told to wake up now.
- verify(mPowerManager).wakeUp(anyLong(), anyInt(), anyString());
- }
-
- @Test
- public void onSideFingerprintSuccess_dreaming_unlockIfStillLockedNotDreaming() {
- when(mAuthController.isSfpsEnrolled(anyInt())).thenReturn(true);
- when(mWakefulnessLifecycle.getLastWakeReason())
- .thenReturn(PowerManager.WAKE_REASON_POWER_BUTTON);
- final ArgumentCaptor<Runnable> afterKeyguardGoneRunnableCaptor =
- ArgumentCaptor.forClass(Runnable.class);
- givenDreamingLocked();
- mBiometricUnlockController.startWakeAndUnlock(BiometricSourceType.FINGERPRINT, true);
-
- // Make sure the BiometricUnlockController has registered a callback for when the keyguard
- // is gone
- verify(mStatusBarKeyguardViewManager).addAfterKeyguardGoneRunnable(
- afterKeyguardGoneRunnableCaptor.capture());
- // Ensure that the power hasn't been told to wake up yet.
- verify(mPowerManager, never()).wakeUp(anyLong(), anyInt(), anyString());
- // Check that the keyguard has been told to unlock.
- verify(mKeyguardViewMediator).onWakeAndUnlocking();
-
- when(mUpdateMonitor.isDreaming()).thenReturn(false);
- when(mKeyguardStateController.isUnlocked()).thenReturn(false);
-
- // Simulate the keyguard disappearing.
- afterKeyguardGoneRunnableCaptor.getValue().run();
-
- final ArgumentCaptor<Runnable> dismissKeyguardRunnableCaptor =
- ArgumentCaptor.forClass(Runnable.class);
- verify(mHandler).post(dismissKeyguardRunnableCaptor.capture());
-
- // Verify that the power manager was not told to wake up.
- verify(mPowerManager, never()).wakeUp(anyLong(), anyInt(), anyString());
-
- dismissKeyguardRunnableCaptor.getValue().run();
- // Verify that the keyguard controller is told to unlock.
- verify(mStatusBarKeyguardViewManager).notifyKeyguardAuthenticated(eq(false));
- }
-
-
- @Test
public void onSideFingerprintSuccess_oldPowerButtonPress_playHaptic() {
// GIVEN side fingerprint enrolled, last wake reason was power button
when(mAuthController.isSfpsEnrolled(anyInt())).thenReturn(true);
@@ -601,14 +537,25 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
verify(mStatusBarKeyguardViewManager).showPrimaryBouncer(anyBoolean());
}
- private void givenDreamingLocked() {
- when(mUpdateMonitor.isDreaming()).thenReturn(true);
- when(mUpdateMonitor.isUnlockingWithBiometricAllowed(anyBoolean())).thenReturn(true);
- }
-
private void givenFingerprintModeUnlockCollapsing() {
when(mUpdateMonitor.isUnlockingWithBiometricAllowed(anyBoolean())).thenReturn(true);
when(mUpdateMonitor.isDeviceInteractive()).thenReturn(true);
when(mKeyguardStateController.isShowing()).thenReturn(true);
}
+
+ private void givenDreamingLocked() {
+ when(mUpdateMonitor.isDreaming()).thenReturn(true);
+ when(mUpdateMonitor.isUnlockingWithBiometricAllowed(anyBoolean())).thenReturn(true);
+ }
+ @Test
+ public void onSideFingerprintSuccess_dreaming_unlockNoWake() {
+ when(mAuthController.isSfpsEnrolled(anyInt())).thenReturn(true);
+ when(mWakefulnessLifecycle.getLastWakeReason())
+ .thenReturn(PowerManager.WAKE_REASON_POWER_BUTTON);
+ givenDreamingLocked();
+ mBiometricUnlockController.startWakeAndUnlock(BiometricSourceType.FINGERPRINT, true);
+ verify(mKeyguardViewMediator).onWakeAndUnlocking();
+ // Ensure that the power hasn't been told to wake up yet.
+ verify(mPowerManager, never()).wakeUp(anyLong(), anyInt(), anyString());
+ }
}