diff options
6 files changed, 63 insertions, 9 deletions
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 90f76c1a349c..717038e04232 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -6463,4 +6463,7 @@ <!-- Whether the AOSP support for app cloning building blocks is to be enabled for the device. --> <bool name="config_enableAppCloningBuildingBlocks">true</bool> + + <!-- Whether unlocking and waking a device are sequenced --> + <bool name="config_orderUnlockAndWake">false</bool> </resources> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index ea215d115272..7be34b718b79 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -5138,4 +5138,7 @@ <java-symbol type="drawable" name="focus_event_pressed_key_background" /> <java-symbol type="string" name="lockscreen_too_many_failed_attempts_countdown" /> + + <!-- Whether we order unlocking and waking --> + <java-symbol type="bool" name="config_orderUnlockAndWake" /> </resources> diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index 00b300a0816f..3c21e4d6e05e 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -470,6 +470,11 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, private final int mDreamOpenAnimationDuration; /** + * Whether unlock and wake should be sequenced. + */ + private final boolean mOrderUnlockAndWake; + + /** * The animation used for hiding keyguard. This is used to fetch the animation timings if * WindowManager is not providing us with them. */ @@ -1434,6 +1439,9 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, mMainDispatcher = mainDispatcher; mDreamingToLockscreenTransitionViewModel = dreamingToLockscreenTransitionViewModel; + + mOrderUnlockAndWake = context.getResources().getBoolean( + com.android.internal.R.bool.config_orderUnlockAndWake); } public void userActivity() { @@ -2781,6 +2789,10 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, private void setUnlockAndWakeFromDream(boolean updatedValue, @WakeAndUnlockUpdateReason int reason) { + if (!mOrderUnlockAndWake) { + return; + } + if (updatedValue == mUnlockingAndWakingFromDream) { return; } @@ -2863,6 +2875,13 @@ 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 && !mOrderUnlockAndWake) { + 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 ed11711f66c6..a0b72fa208e0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java @@ -173,6 +173,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp private final VibratorHelper mVibratorHelper; private final BiometricUnlockLogger mLogger; private final SystemClock mSystemClock; + private final boolean mOrderUnlockAndWake; private long mLastFpFailureUptimeMillis; private int mNumConsecutiveFpFailures; @@ -308,6 +309,8 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp mVibratorHelper = vibrator; mLogger = biometricUnlockLogger; mSystemClock = systemClock; + mOrderUnlockAndWake = resources.getBoolean( + com.android.internal.R.bool.config_orderUnlockAndWake); dumpManager.registerDumpable(getClass().getName(), this); } @@ -462,10 +465,11 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp Trace.endSection(); }; - final boolean wakingFromDream = mMode == MODE_WAKE_AND_UNLOCK_FROM_DREAM - && mPowerManager.isInteractive(); + final boolean wakeInKeyguard = mMode == MODE_WAKE_AND_UNLOCK_FROM_DREAM + && mPowerManager.isInteractive() && mOrderUnlockAndWake + && mOrderUnlockAndWake; - if (mMode != MODE_NONE && !wakingFromDream) { + if (mMode != MODE_NONE && !wakeInKeyguard) { wakeUp.run(); } switch (mMode) { @@ -501,7 +505,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp // later to awaken. } mNotificationShadeWindowController.setNotificationShadeFocusable(false); - mKeyguardViewMediator.onWakeAndUnlocking(wakingFromDream); + mKeyguardViewMediator.onWakeAndUnlocking(wakeInKeyguard); Trace.endSection(); break; case MODE_ONLY_WAKE: 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 6b23fbadfa44..78654a37a75d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java @@ -614,6 +614,9 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { @Test public void testWakeAndUnlockingOverDream() { + // Ensure ordering unlock and wake is enabled. + createAndStartViewMediator(true); + // Send signal to wake mViewMediator.onWakeAndUnlocking(true); @@ -643,6 +646,9 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { @Test public void testWakeAndUnlockingOverDream_signalAuthenticateIfStillShowing() { + // Ensure ordering unlock and wake is enabled. + createAndStartViewMediator(true); + // Send signal to wake mViewMediator.onWakeAndUnlocking(true); @@ -797,6 +803,15 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { } private void createAndStartViewMediator() { + createAndStartViewMediator(false); + } + + private void createAndStartViewMediator(boolean orderUnlockAndWake) { + if (orderUnlockAndWake) { + mContext.getOrCreateTestableResources().addOverride( + com.android.internal.R.bool.config_orderUnlockAndWake, orderUnlockAndWake); + } + mViewMediator = new KeyguardViewMediator( mContext, mUiEventLogger, 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 7acf398955fb..2131f9d55ca8 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 @@ -124,7 +124,7 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase { @Before public void setUp() { MockitoAnnotations.initMocks(this); - TestableResources res = getContext().getOrCreateTestableResources(); + when(mKeyguardStateController.isShowing()).thenReturn(true); when(mUpdateMonitor.isDeviceInteractive()).thenReturn(true); when(mKeyguardStateController.isFaceAuthEnabled()).thenReturn(true); @@ -134,7 +134,15 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase { when(mAuthController.isUdfpsFingerDown()).thenReturn(false); when(mVibratorHelper.hasVibrator()).thenReturn(true); mDependency.injectTestDependency(NotificationMediaManager.class, mMediaManager); - mBiometricUnlockController = new BiometricUnlockController(mDozeScrimController, + mBiometricUnlockController = createController(false); + when(mUpdateMonitor.getStrongAuthTracker()).thenReturn(mStrongAuthTracker); + } + + BiometricUnlockController createController(boolean orderUnlockAndWake) { + TestableResources res = getContext().getOrCreateTestableResources(); + res.addOverride(com.android.internal.R.bool.config_orderUnlockAndWake, orderUnlockAndWake); + BiometricUnlockController biometricUnlockController = new BiometricUnlockController( + mDozeScrimController, mKeyguardViewMediator, mNotificationShadeWindowController, mKeyguardStateController, mHandler, mUpdateMonitor, res.getResources(), mKeyguardBypassController, @@ -144,9 +152,10 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase { mSessionTracker, mLatencyTracker, mScreenOffAnimationController, mVibratorHelper, mSystemClock ); - mBiometricUnlockController.setKeyguardViewController(mStatusBarKeyguardViewManager); - mBiometricUnlockController.addListener(mBiometricUnlockEventsListener); - when(mUpdateMonitor.getStrongAuthTracker()).thenReturn(mStrongAuthTracker); + biometricUnlockController.setKeyguardViewController(mStatusBarKeyguardViewManager); + biometricUnlockController.addListener(mBiometricUnlockEventsListener); + + return biometricUnlockController; } @Test @@ -549,6 +558,7 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase { } @Test public void onSideFingerprintSuccess_dreaming_unlockNoWake() { + mBiometricUnlockController = createController(true); when(mAuthController.isSfpsEnrolled(anyInt())).thenReturn(true); when(mWakefulnessLifecycle.getLastWakeReason()) .thenReturn(PowerManager.WAKE_REASON_POWER_BUTTON); |