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

Commit c9c09123 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fade away wallpapers when long pulse"

parents 871a873d a71c8929
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -84,6 +84,14 @@ public class DozeScrimController implements StateListener {
        public void onCancelled() {
            pulseFinished();
        }

        /**
         * Whether to fade out wallpaper.
         */
        @Override
        public  boolean isFadeOutWallpaper() {
            return mPulseReason == DozeLog.PULSE_REASON_DOCKING;
        }
    };

    public DozeScrimController(DozeParameters dozeParameters) {
+12 −5
Original line number Diff line number Diff line
@@ -275,9 +275,12 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
            holdWakeLock();
        }

        // AOD wallpapers should fade away after a while
        if (mWallpaperSupportsAmbientMode && mDozeParameters.getAlwaysOn()
                && mState == ScrimState.AOD) {
        // AOD wallpapers should fade away after a while.
        // Docking pulses may take a long time, wallpapers should also fade away after a while.
        if (mWallpaperSupportsAmbientMode && (
                mDozeParameters.getAlwaysOn() && mState == ScrimState.AOD
                        || mState == ScrimState.PULSING && mCallback != null
                        && mCallback.isFadeOutWallpaper())) {
            if (!mWallpaperVisibilityTimedOut) {
                mTimeTicker.schedule(mDozeParameters.getWallpaperAodDuration(),
                        AlarmTimeout.MODE_IGNORE_IF_SCHEDULED);
@@ -329,7 +332,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo

    @VisibleForTesting
    protected void onHideWallpaperTimeout() {
        if (mState != ScrimState.AOD) {
        if (mState != ScrimState.AOD && mState != ScrimState.PULSING) {
            return;
        }

@@ -504,7 +507,8 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo

        // We want to override the back scrim opacity for the AOD state
        // when it's time to fade the wallpaper away.
        boolean aodWallpaperTimeout = mState == ScrimState.AOD && mWallpaperVisibilityTimedOut;
        boolean aodWallpaperTimeout = (mState == ScrimState.AOD || mState == ScrimState.PULSING)
                && mWallpaperVisibilityTimedOut;
        // We also want to hide FLAG_SHOW_WHEN_LOCKED activities under the scrim.
        boolean occludedKeyguard = (mState == ScrimState.PULSING || mState == ScrimState.AOD)
                && mKeyguardOccluded;
@@ -917,6 +921,9 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
        }
        default void onCancelled() {
        }
        default boolean isFadeOutWallpaper() {
            return false;
        }
    }

    /**
+49 −1
Original line number Diff line number Diff line
@@ -94,6 +94,7 @@ public class ScrimControllerTest extends SysuiTestCase {
                },
                visible -> mScrimVisibility = visible, mDozeParamenters, mAlarmManager);
        mScrimController.setHasBackdrop(false);
        mScrimController.setWallpaperSupportsAmbientMode(false);
    }

    @Test
@@ -473,6 +474,26 @@ public class ScrimControllerTest extends SysuiTestCase {
        verify(mWakeLock).release();
    }

    @Test
    public void testHoldsPulsingWallpaperAnimationLock() {
        // Pre-conditions
        mScrimController.transitionTo(ScrimState.PULSING, new ScrimController.Callback() {
            @Override
            public boolean isFadeOutWallpaper() {
                return true;
            }
        });
        mScrimController.finishAnimationsImmediately();
        reset(mWakeLock);

        mScrimController.onHideWallpaperTimeout();
        verify(mWakeLock).acquire();
        verify(mWakeLock, never()).release();
        mScrimController.finishAnimationsImmediately();
        verify(mWakeLock).release();
        assertScrimVisibility(VISIBILITY_FULLY_TRANSPARENT, VISIBILITY_FULLY_OPAQUE);
    }

    @Test
    public void testWillHideAodWallpaper() {
        mScrimController.setWallpaperSupportsAmbientMode(true);
@@ -482,6 +503,34 @@ public class ScrimControllerTest extends SysuiTestCase {
        verify(mAlarmManager).cancel(any(AlarmManager.OnAlarmListener.class));
    }

    @Test
    public void testWillHidePulsingWallpaper_withRequestFadeOut() {
        mScrimController.setWallpaperSupportsAmbientMode(true);
        mScrimController.transitionTo(ScrimState.PULSING, new ScrimController.Callback() {
            @Override
            public boolean isFadeOutWallpaper() {
                return true;
            }
        });
        verify(mAlarmManager).setExact(anyInt(), anyLong(), any(), any(), any());
        mScrimController.transitionTo(ScrimState.KEYGUARD);
        verify(mAlarmManager).cancel(any(AlarmManager.OnAlarmListener.class));
    }

    @Test
    public void testDoesNotHidePulsingWallpaper_withoutRequestFadeOut() {
        mScrimController.setWallpaperSupportsAmbientMode(true);
        mScrimController.transitionTo(ScrimState.PULSING, new ScrimController.Callback() {});
        verify(mAlarmManager, never()).setExact(anyInt(), anyLong(), any(), any(), any());
    }

    @Test
    public void testDoesNotHidePulsingWallpaper_withoutCallback() {
        mScrimController.setWallpaperSupportsAmbientMode(true);
        mScrimController.transitionTo(ScrimState.PULSING);
        verify(mAlarmManager, never()).setExact(anyInt(), anyLong(), any(), any(), any());
    }

    @Test
    public void testConservesExpansionOpacityAfterTransition() {
        mScrimController.transitionTo(ScrimState.UNLOCKED);
@@ -738,5 +787,4 @@ public class ScrimControllerTest extends SysuiTestCase {
            callback.run();
        }
    }

}