diff options
author | Bryce Lee <brycelee@google.com> | 2023-08-18 18:55:07 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-09-15 21:17:52 +0000 |
commit | c84f7f90605db5d6466889cfba848c5855ede0cd (patch) | |
tree | af441202e456c48acc2b4685222e97ece6c1a4b3 | |
parent | 4770073be337349eb81f28b17f59eab0ddfed6dc (diff) | |
download | base-c84f7f90605db5d6466889cfba848c5855ede0cd.tar.gz |
Limit ordering unlock and wake by configuration.
This change limits sequencing unlock and wake to only devices where
the configuration has been enabled.
Test: atest KeyguardViewMediatorTest
Test: atest BiometricsUnlockControllerTest
Bug: 289861878
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:45c5e0412c4e9e5c2947f24582e905af1f6b3235)
Merged-In: I2bdf8bb16dba693c4afb824e861ab4b87783d61b
Change-Id: I2bdf8bb16dba693c4afb824e861ab4b87783d61b
6 files changed, 63 insertions, 9 deletions
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index bd0fe40e758d..70013911904e 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -6459,4 +6459,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 2d040bb66d83..2425d367e1db 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -5132,4 +5132,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 1a06b0184bc5..18474e0af5b8 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 34ea91b94414..1c8241433172 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java @@ -602,6 +602,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); @@ -631,6 +634,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); @@ -787,6 +793,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); |