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

Commit d0e56778 authored by Zhi Dou's avatar Zhi Dou
Browse files

Revert "Fix shouldControlUnlockedScreenOff."

This reverts commit 8a0497ca.

Reason for revert: DroidMonitor: Potential culprit for Bug 222015750 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.

Change-Id: Ie2add444135faf605d11cf770f085b4fc52a01e2
parent 8a0497ca
Loading
Loading
Loading
Loading
+17 −15
Original line number Original line Diff line number Diff line
@@ -292,20 +292,11 @@ public class DozeParameters implements
    }
    }


    public void updateControlScreenOff() {
    public void updateControlScreenOff() {
        final boolean controlScreenOff = shouldControlUnlockedScreenOff()
        if (!getDisplayNeedsBlanking()) {
                || (!getDisplayNeedsBlanking() && getAlwaysOn() && mKeyguardShowing);
            final boolean controlScreenOff =
                    getAlwaysOn() && (mKeyguardShowing || shouldControlUnlockedScreenOff());
            setControlScreenOffAnimation(controlScreenOff);
            setControlScreenOffAnimation(controlScreenOff);
        }
        }

    /**
     * Whether we're capable of controlling the screen off animation if we want to. This isn't
     * possible if AOD isn't even enabled or if the flag is disabled, or if the display needs
     * blanking.
     */
    public boolean canControlUnlockedScreenOff() {
        return getAlwaysOn()
                && mFeatureFlags.isEnabled(Flags.LOCKSCREEN_ANIMATIONS)
                && !getDisplayNeedsBlanking();
    }
    }


    /**
    /**
@@ -318,7 +309,8 @@ public class DozeParameters implements
     * disabled for a11y.
     * disabled for a11y.
     */
     */
    public boolean shouldControlUnlockedScreenOff() {
    public boolean shouldControlUnlockedScreenOff() {
        return mUnlockedScreenOffAnimationController.shouldPlayUnlockedScreenOffAnimation();
        return canControlUnlockedScreenOff()
                && mUnlockedScreenOffAnimationController.shouldPlayUnlockedScreenOffAnimation();
    }
    }


    public boolean shouldDelayKeyguardShow() {
    public boolean shouldDelayKeyguardShow() {
@@ -350,6 +342,16 @@ public class DozeParameters implements
        return getAlwaysOn() && mKeyguardShowing;
        return getAlwaysOn() && mKeyguardShowing;
    }
    }


    /**
     * Whether we're capable of controlling the screen off animation if we want to. This isn't
     * possible if AOD isn't even enabled or if the flag is disabled.
     */
    public boolean canControlUnlockedScreenOff() {
        return getAlwaysOn()
                && mFeatureFlags.isEnabled(Flags.LOCKSCREEN_ANIMATIONS)
                && !getDisplayNeedsBlanking();
    }

    private boolean getBoolean(String propName, int resId) {
    private boolean getBoolean(String propName, int resId) {
        return SystemProperties.getBoolean(propName, mResources.getBoolean(resId));
        return SystemProperties.getBoolean(propName, mResources.getBoolean(resId));
    }
    }
+2 −21
Original line number Original line Diff line number Diff line
@@ -59,14 +59,8 @@ class UnlockedScreenOffAnimationController @Inject constructor(
    private val powerManager: PowerManager,
    private val powerManager: PowerManager,
    private val handler: Handler = Handler()
    private val handler: Handler = Handler()
) : WakefulnessLifecycle.Observer, ScreenOffAnimation {
) : WakefulnessLifecycle.Observer, ScreenOffAnimation {
    private lateinit var mCentralSurfaces: CentralSurfaces
    /**
     * Whether or not [initialize] has been called to provide us with the StatusBar,
     * NotificationPanelViewController, and LightRevealSrim so that we can run the unlocked screen
     * off animation.
     */
    private var initialized = false


    private lateinit var mCentralSurfaces: CentralSurfaces
    private lateinit var lightRevealScrim: LightRevealScrim
    private lateinit var lightRevealScrim: LightRevealScrim


    private var animatorDurationScale = 1f
    private var animatorDurationScale = 1f
@@ -122,7 +116,6 @@ class UnlockedScreenOffAnimationController @Inject constructor(
        centralSurfaces: CentralSurfaces,
        centralSurfaces: CentralSurfaces,
        lightRevealScrim: LightRevealScrim
        lightRevealScrim: LightRevealScrim
    ) {
    ) {
        this.initialized = true
        this.lightRevealScrim = lightRevealScrim
        this.lightRevealScrim = lightRevealScrim
        this.mCentralSurfaces = centralSurfaces
        this.mCentralSurfaces = centralSurfaces


@@ -269,18 +262,6 @@ class UnlockedScreenOffAnimationController @Inject constructor(
     * on the current state of the device.
     * on the current state of the device.
     */
     */
    fun shouldPlayUnlockedScreenOffAnimation(): Boolean {
    fun shouldPlayUnlockedScreenOffAnimation(): Boolean {
        // If we haven't been initialized yet, we don't have a StatusBar/LightRevealScrim yet, so we
        // can't perform the animation.
        if (!initialized) {
            return false
        }

        // If the device isn't in a state where we can control unlocked screen off (no AOD enabled,
        // power save, etc.) then we shouldn't try to do so.
        if (!dozeParameters.get().canControlUnlockedScreenOff()) {
            return false
        }

        // If we explicitly already decided not to play the screen off animation, then never change
        // If we explicitly already decided not to play the screen off animation, then never change
        // our mind.
        // our mind.
        if (decidedToAnimateGoingToSleep == false) {
        if (decidedToAnimateGoingToSleep == false) {
@@ -323,7 +304,7 @@ class UnlockedScreenOffAnimationController @Inject constructor(
    }
    }


    override fun shouldDelayDisplayDozeTransition(): Boolean =
    override fun shouldDelayDisplayDozeTransition(): Boolean =
        shouldPlayUnlockedScreenOffAnimation()
        dozeParameters.get().shouldControlUnlockedScreenOff()


    /**
    /**
     * Whether we're doing the light reveal animation or we're done with that and animating in the
     * Whether we're doing the light reveal animation or we're done with that and animating in the
+1 −9
Original line number Original line Diff line number Diff line
@@ -126,12 +126,6 @@ public class DozeParametersTest extends SysuiTestCase {
        setAodEnabledForTest(true);
        setAodEnabledForTest(true);
        setShouldControlUnlockedScreenOffForTest(true);
        setShouldControlUnlockedScreenOffForTest(true);
        setDisplayNeedsBlankingForTest(false);
        setDisplayNeedsBlankingForTest(false);

        // Default to false here (with one test to make sure that when it returns true, we respect
        // that). We'll test the specific conditions for this to return true/false in the
        // UnlockedScreenOffAnimationController's tests.
        when(mUnlockedScreenOffAnimationController.shouldPlayUnlockedScreenOffAnimation())
                .thenReturn(false);
    }
    }


    @Test
    @Test
@@ -180,12 +174,9 @@ public class DozeParametersTest extends SysuiTestCase {
     */
     */
    @Test
    @Test
    public void testControlUnlockedScreenOffAnimation_dozeAfterScreenOff_false() {
    public void testControlUnlockedScreenOffAnimation_dozeAfterScreenOff_false() {
        mDozeParameters.mKeyguardVisibilityCallback.onKeyguardVisibilityChanged(true);

        // If AOD is disabled, we shouldn't want to control screen off. Also, let's double check
        // If AOD is disabled, we shouldn't want to control screen off. Also, let's double check
        // that when that value is updated, we called through to PowerManager.
        // that when that value is updated, we called through to PowerManager.
        setAodEnabledForTest(false);
        setAodEnabledForTest(false);

        assertFalse(mDozeParameters.shouldControlScreenOff());
        assertFalse(mDozeParameters.shouldControlScreenOff());
        assertTrue(mPowerManagerDozeAfterScreenOff);
        assertTrue(mPowerManagerDozeAfterScreenOff);


@@ -197,6 +188,7 @@ public class DozeParametersTest extends SysuiTestCase {


    @Test
    @Test
    public void testControlUnlockedScreenOffAnimationDisabled_dozeAfterScreenOff() {
    public void testControlUnlockedScreenOffAnimationDisabled_dozeAfterScreenOff() {
        setShouldControlUnlockedScreenOffForTest(true);
        when(mFeatureFlags.isEnabled(Flags.LOCKSCREEN_ANIMATIONS)).thenReturn(false);
        when(mFeatureFlags.isEnabled(Flags.LOCKSCREEN_ANIMATIONS)).thenReturn(false);


        assertFalse(mDozeParameters.shouldControlUnlockedScreenOff());
        assertFalse(mDozeParameters.shouldControlUnlockedScreenOff());
+2 −12
Original line number Original line Diff line number Diff line
@@ -31,7 +31,6 @@ import com.android.systemui.statusbar.LightRevealScrim
import com.android.systemui.statusbar.StatusBarStateControllerImpl
import com.android.systemui.statusbar.StatusBarStateControllerImpl
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.util.settings.GlobalSettings
import com.android.systemui.util.settings.GlobalSettings
import junit.framework.Assert.assertFalse
import org.junit.After
import org.junit.After
import org.junit.Before
import org.junit.Before
import org.junit.Test
import org.junit.Test
@@ -134,7 +133,7 @@ class UnlockedScreenOffAnimationControllerTest : SysuiTestCase() {
     */
     */
    @Test
    @Test
    fun testAodUiShownIfNotInteractive() {
    fun testAodUiShownIfNotInteractive() {
        `when`(dozeParameters.canControlUnlockedScreenOff()).thenReturn(true)
        `when`(dozeParameters.shouldControlUnlockedScreenOff()).thenReturn(true)
        `when`(powerManager.isInteractive).thenReturn(false)
        `when`(powerManager.isInteractive).thenReturn(false)


        val callbackCaptor = ArgumentCaptor.forClass(Runnable::class.java)
        val callbackCaptor = ArgumentCaptor.forClass(Runnable::class.java)
@@ -157,7 +156,7 @@ class UnlockedScreenOffAnimationControllerTest : SysuiTestCase() {
     */
     */
    @Test
    @Test
    fun testAodUiNotShownIfInteractive() {
    fun testAodUiNotShownIfInteractive() {
        `when`(dozeParameters.canControlUnlockedScreenOff()).thenReturn(true)
        `when`(dozeParameters.shouldControlUnlockedScreenOff()).thenReturn(true)
        `when`(powerManager.isInteractive).thenReturn(true)
        `when`(powerManager.isInteractive).thenReturn(true)


        val callbackCaptor = ArgumentCaptor.forClass(Runnable::class.java)
        val callbackCaptor = ArgumentCaptor.forClass(Runnable::class.java)
@@ -168,13 +167,4 @@ class UnlockedScreenOffAnimationControllerTest : SysuiTestCase() {


        verify(notificationPanelViewController, never()).showAodUi()
        verify(notificationPanelViewController, never()).showAodUi()
    }
    }

    @Test
    fun testNoAnimationPlaying_dozeParamsCanNotControlScreenOff() {
        `when`(dozeParameters.canControlUnlockedScreenOff()).thenReturn(false)

        assertFalse(controller.shouldPlayUnlockedScreenOffAnimation())
        controller.startAnimation()
        assertFalse(controller.isAnimationPlaying())
    }
}
}
 No newline at end of file