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

Commit 3b0f74a1 authored by Matt Pietal's avatar Matt Pietal
Browse files

Delay low power state when entering KeyguardState AOD

This handles all cases, including when starting from GONE with
shade expanded, to ensure animations play smoothly.

Fixes: 342287233
Test: atest DozeParametersTest
Flag: EXEMPT bugfix
Change-Id: Iacea61b782d619ff1982c393b5b92cea9126a9f6
parent d8e5981d
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -44,6 +44,8 @@ import com.android.systemui.doze.AlwaysOnDisplayPolicy;
import com.android.systemui.doze.DozeScreenState;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.keyguard.domain.interactor.DozeInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor;
import com.android.systemui.keyguard.shared.model.KeyguardState;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.settings.UserTracker;
import com.android.systemui.statusbar.policy.BatteryController;
@@ -59,6 +61,7 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
@@ -88,6 +91,8 @@ public class DozeParametersTest extends SysuiTestCase {
    @Mock private ConfigurationController mConfigurationController;
    @Mock private UserTracker mUserTracker;
    @Mock private DozeInteractor mDozeInteractor;
    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
    private KeyguardTransitionInteractor mKeyguardTransitionInteractor;
    @Captor private ArgumentCaptor<BatteryStateChangeCallback> mBatteryStateChangeCallback;

    /**
@@ -134,6 +139,7 @@ public class DozeParametersTest extends SysuiTestCase {
            mStatusBarStateController,
            mUserTracker,
            mDozeInteractor,
            mKeyguardTransitionInteractor,
            secureSettings
        );

@@ -286,6 +292,18 @@ public class DozeParametersTest extends SysuiTestCase {
        assertTrue(mDozeParameters.shouldControlScreenOff());
    }

    @Test
    public void shouldDelayDisplayDozeTransition_True_WhenTransitioningToAod() {
        setShouldControlUnlockedScreenOffForTest(false);
        when(mScreenOffAnimationController.shouldDelayDisplayDozeTransition()).thenReturn(false);
        when(mKeyguardTransitionInteractor.getTransitionState().getValue().getTo())
                .thenReturn(KeyguardState.LOCKSCREEN);
        assertFalse(mDozeParameters.shouldDelayDisplayDozeTransition());

        when(mKeyguardTransitionInteractor.getTransitionState().getValue().getTo())
                .thenReturn(KeyguardState.AOD);
        assertTrue(mDozeParameters.shouldDelayDisplayDozeTransition());
    }

    @Test
    public void keyguardVisibility_changesControlScreenOffAnimation() {
+8 −0
Original line number Diff line number Diff line
@@ -45,6 +45,8 @@ import com.android.systemui.doze.AlwaysOnDisplayPolicy;
import com.android.systemui.doze.DozeScreenState;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.keyguard.domain.interactor.DozeInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor;
import com.android.systemui.keyguard.shared.model.KeyguardState;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.res.R;
import com.android.systemui.settings.UserTracker;
@@ -85,6 +87,7 @@ public class DozeParameters implements
    private final BatteryController mBatteryController;
    private final ScreenOffAnimationController mScreenOffAnimationController;
    private final DozeInteractor mDozeInteractor;
    private final KeyguardTransitionInteractor mTransitionInteractor;
    private final FoldAodAnimationController mFoldAodAnimationController;
    private final UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController;
    private final UserTracker mUserTracker;
@@ -134,6 +137,7 @@ public class DozeParameters implements
            StatusBarStateController statusBarStateController,
            UserTracker userTracker,
            DozeInteractor dozeInteractor,
            KeyguardTransitionInteractor transitionInteractor,
            SecureSettings secureSettings) {
        mResources = resources;
        mAmbientDisplayConfiguration = ambientDisplayConfiguration;
@@ -148,6 +152,7 @@ public class DozeParameters implements
        mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController;
        mUserTracker = userTracker;
        mDozeInteractor = dozeInteractor;
        mTransitionInteractor = transitionInteractor;
        mSecureSettings = secureSettings;

        keyguardUpdateMonitor.registerCallback(mKeyguardVisibilityCallback);
@@ -353,6 +358,9 @@ public class DozeParameters implements
     * delayed for a few seconds. This might be useful to play animations without reducing FPS.
     */
    public boolean shouldDelayDisplayDozeTransition() {
        if (mTransitionInteractor.getTransitionState().getValue().getTo() == KeyguardState.AOD) {
            return true;
        }
        return willAnimateFromLockScreenToAod()
                || mScreenOffAnimationController.shouldDelayDisplayDozeTransition();
    }