Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5afbd0f4 authored by Matt Pietal's avatar Matt Pietal
Browse files

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
parent 619d1e18
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -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
+10 −2
Original line number Diff line number Diff line
@@ -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();
+39 −4
Original line number Diff line number Diff line
@@ -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);