summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Matt Pietal <mpietal@google.com> 2024-05-15 15:01:23 +0000
committer Matt Pietal <mpietal@google.com> 2024-05-16 12:18:44 +0000
commit5afbd0f461b2dbf753e5a1f5bb10f6bf8496756c (patch)
treec651b815e563c1335f95903a0f486f892470984b
parent619d1e182a944fdd4004f07e65bdbd1317da3cea (diff)
Fix scrim transition when leaving DREAMING
This can mean delaying alternate auth transitions, in order to wait for a potential end to the dream. Fixes: 339817220 Test: manual, check Scrims after existing dream to alternate bouncer Flag: None Change-Id: I13b47198ba73fd33e3ff265fe5886e5d7bc1ee79
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt15
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java12
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java43
3 files changed, 63 insertions, 7 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt
index 8065c0f4bc41..7a86f7a1f8e4 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt
@@ -55,6 +55,7 @@ import javax.inject.Provider
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.channels.awaitClose
+import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
@@ -225,7 +226,19 @@ constructor(
@JvmField val primaryBouncerShowing: Flow<Boolean> = bouncerRepository.primaryBouncerShow
/** Whether the alternate bouncer is showing or not. */
- val alternateBouncerShowing: Flow<Boolean> = bouncerRepository.alternateBouncerVisible
+ val alternateBouncerShowing: Flow<Boolean> =
+ bouncerRepository.alternateBouncerVisible.sample(isAbleToDream) {
+ alternateBouncerVisible,
+ isAbleToDream ->
+ if (isAbleToDream) {
+ // If the alternate bouncer will show over a dream, it is likely that the dream has
+ // requested a dismissal, which will stop the dream. By delaying this slightly, the
+ // DREAMING->LOCKSCREEN transition will now happen first, followed by
+ // LOCKSCREEN->ALTERNATE_BOUNCER.
+ delay(600L)
+ }
+ alternateBouncerVisible
+ }
/** Observable for the [StatusBarState] */
val statusBarState: Flow<StatusBarState> = repository.statusBarState
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
index aa55f375b2eb..50fad783a4a0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
@@ -2805,7 +2805,16 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
mScrimController.setExpansionAffectsAlpha(!unlocking);
if (mAlternateBouncerInteractor.isVisibleState()) {
- if (!DeviceEntryUdfpsRefactor.isEnabled()) {
+ if (DeviceEntryUdfpsRefactor.isEnabled()) {
+ if ((!mKeyguardStateController.isOccluded() || mShadeSurface.isPanelExpanded())
+ && (mState == StatusBarState.SHADE || mState == StatusBarState.SHADE_LOCKED
+ || mTransitionToFullShadeProgress > 0f)) {
+ // Assume scrim state for shade is already correct and do nothing
+ } else {
+ // Safeguard which prevents the scrim from being stuck in the wrong state
+ mScrimController.transitionTo(ScrimState.KEYGUARD);
+ }
+ } else {
if ((!mKeyguardStateController.isOccluded() || mShadeSurface.isPanelExpanded())
&& (mState == StatusBarState.SHADE || mState == StatusBarState.SHADE_LOCKED
|| mTransitionToFullShadeProgress > 0f)) {
@@ -2814,7 +2823,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
mScrimController.transitionTo(ScrimState.AUTH_SCRIMMED);
}
}
-
// This will cancel the keyguardFadingAway animation if it is running. We need to do
// this as otherwise it can remain pending and leave keyguard in a weird state.
mUnlockScrimCallback.onCancelled();
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java
index b9312d3ce2be..320b6ffff433 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java
@@ -21,6 +21,7 @@ import static android.app.StatusBarManager.WINDOW_STATE_SHOWING;
import static android.provider.Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED;
import static android.provider.Settings.Global.HEADS_UP_ON;
+import static com.android.systemui.Flags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR;
import static com.android.systemui.Flags.FLAG_KEYBOARD_SHORTCUT_HELPER_REWRITE;
import static com.android.systemui.Flags.FLAG_LIGHT_REVEAL_MIGRATION;
import static com.android.systemui.flags.Flags.SHORTCUT_LIST_SEARCH_LAYOUT;
@@ -70,6 +71,8 @@ import android.os.IThermalService;
import android.os.Looper;
import android.os.PowerManager;
import android.os.UserHandle;
+import android.platform.test.annotations.DisableFlags;
+import android.platform.test.annotations.EnableFlags;
import android.service.dreams.IDreamManager;
import android.support.test.metricshelper.MetricsAsserts;
import android.testing.AndroidTestingRunner;
@@ -366,9 +369,6 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
// Turn AOD on and toggle feature flag for jank fixes
mFeatureFlags.set(Flags.ZJ_285570694_LOCKSCREEN_TRANSITION_FROM_AOD, true);
when(mDozeParameters.getAlwaysOn()).thenReturn(true);
- if (!SceneContainerFlag.isEnabled()) {
- mSetFlagsRule.disableFlags(com.android.systemui.Flags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR);
- }
IThermalService thermalService = mock(IThermalService.class);
mPowerManager = new PowerManager(mContext, mPowerManagerService, thermalService,
@@ -837,6 +837,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
}
@Test
+ @DisableFlags(FLAG_DEVICE_ENTRY_UDFPS_REFACTOR)
public void testSetDozingNotUnlocking_transitionToAuthScrimmed_cancelKeyguardFadingAway() {
when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true);
when(mKeyguardStateController.isKeyguardFadingAway()).thenReturn(true);
@@ -848,7 +849,8 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
}
@Test
- public void testOccludingQSNotExpanded_transitionToAuthScrimmed() {
+ @DisableFlags(FLAG_DEVICE_ENTRY_UDFPS_REFACTOR)
+ public void testOccludingQSNotExpanded_flagOff_transitionToAuthScrimmed() {
when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true);
// GIVEN device occluded and panel is NOT expanded
@@ -862,6 +864,39 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
}
@Test
+ @EnableFlags(FLAG_DEVICE_ENTRY_UDFPS_REFACTOR)
+ public void testNotOccluding_QSNotExpanded_flagOn_doesNotTransitionScrimState() {
+ when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true);
+
+ // GIVEN device occluded and panel is NOT expanded
+ mCentralSurfaces.setBarStateForTest(SHADE);
+ when(mKeyguardStateController.isOccluded()).thenReturn(false);
+ when(mNotificationPanelViewController.isPanelExpanded()).thenReturn(false);
+
+ mCentralSurfaces.updateScrimController();
+
+ // Tests the safeguard to reset the scrimstate
+ verify(mScrimController, never()).transitionTo(any());
+ }
+
+ @Test
+ @EnableFlags(FLAG_DEVICE_ENTRY_UDFPS_REFACTOR)
+ public void testNotOccluding_QSExpanded_flagOn_doesTransitionScrimStateToKeyguard() {
+ when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true);
+
+ // GIVEN device occluded and panel is NOT expanded
+ mCentralSurfaces.setBarStateForTest(SHADE);
+ when(mKeyguardStateController.isOccluded()).thenReturn(false);
+ when(mNotificationPanelViewController.isPanelExpanded()).thenReturn(true);
+
+ mCentralSurfaces.updateScrimController();
+
+ // Tests the safeguard to reset the scrimstate
+ verify(mScrimController, never()).transitionTo(eq(ScrimState.KEYGUARD));
+ }
+
+ @Test
+ @DisableFlags(FLAG_DEVICE_ENTRY_UDFPS_REFACTOR)
public void testOccludingQSExpanded_transitionToAuthScrimmedShade() {
when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true);