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

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

Merge "Fade away wallpapers when long pulse" into qt-dev

parents 23b6339e bde4c0cc
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 timeout wallpaper or not.
         */
        @Override
        public boolean shouldTimeoutWallpaper() {
            return mPulseReason == DozeLog.PULSE_REASON_DOCKING;
        }
    };

    public DozeScrimController(DozeParameters dozeParameters) {
+33 −7
Original line number Diff line number Diff line
@@ -284,15 +284,12 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo

        // 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) {
            if (!mWallpaperVisibilityTimedOut) {
        mWallpaperVisibilityTimedOut = false;
        if (shouldFadeAwayWallpaper()) {
            mTimeTicker.schedule(mDozeParameters.getWallpaperAodDuration(),
                    AlarmTimeout.MODE_IGNORE_IF_SCHEDULED);
            }
        } else {
            mTimeTicker.cancel();
            mWallpaperVisibilityTimedOut = false;
        }

        if (mKeyguardUpdateMonitor.needsSlowUnlockTransition() && mState == ScrimState.UNLOCKED) {
@@ -313,6 +310,23 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
        dispatchScrimState(mScrimBehind.getViewAlpha());
    }

    private boolean shouldFadeAwayWallpaper() {
        if (!mWallpaperSupportsAmbientMode) {
            return false;
        }

        if (mState == ScrimState.AOD && mDozeParameters.getAlwaysOn()) {
            return true;
        }

        if (mState == ScrimState.PULSING
                && mCallback != null && mCallback.shouldTimeoutWallpaper()) {
            return true;
        }

        return false;
    }

    public ScrimState getState() {
        return mState;
    }
@@ -387,6 +401,14 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
            setOrAdaptCurrentAnimation(mScrimInFront);

            dispatchScrimState(mScrimBehind.getViewAlpha());

            // Reset wallpaper timeout if it's already timeout like expanding panel while PULSING
            // and docking.
            if (mWallpaperVisibilityTimedOut) {
                mWallpaperVisibilityTimedOut = false;
                mTimeTicker.schedule(mDozeParameters.getWallpaperAodDuration(),
                        AlarmTimeout.MODE_IGNORE_IF_SCHEDULED);
            }
        }
    }

@@ -925,6 +947,10 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
        }
        default void onCancelled() {
        }
        /** Returns whether to timeout wallpaper or not. */
        default boolean shouldTimeoutWallpaper() {
            return false;
        }
    }

    /**
+32 −0
Original line number Diff line number Diff line
@@ -507,6 +507,38 @@ public class ScrimControllerTest extends SysuiTestCase {
        verify(mAlarmManager).cancel(any(AlarmManager.OnAlarmListener.class));
    }

    @Test
    public void transitionToPulsing_withTimeoutWallpaperCallback_willHideWallpaper() {
        mScrimController.setWallpaperSupportsAmbientMode(true);

        mScrimController.transitionTo(ScrimState.PULSING, new ScrimController.Callback() {
            @Override
            public boolean shouldTimeoutWallpaper() {
                return true;
            }
        });

        verify(mAlarmManager).setExact(anyInt(), anyLong(), any(), any(), any());
    }

    @Test
    public void transitionToPulsing_withDefaultCallback_wontHideWallpaper() {
        mScrimController.setWallpaperSupportsAmbientMode(true);

        mScrimController.transitionTo(ScrimState.PULSING, new ScrimController.Callback() {});

        verify(mAlarmManager, never()).setExact(anyInt(), anyLong(), any(), any(), any());
    }

    @Test
    public void transitionToPulsing_withoutCallback_wontHideWallpaper() {
        mScrimController.setWallpaperSupportsAmbientMode(true);

        mScrimController.transitionTo(ScrimState.PULSING);

        verify(mAlarmManager, never()).setExact(anyInt(), anyLong(), any(), any(), any());
    }

    @Test
    public void testConservesExpansionOpacityAfterTransition() {
        mScrimController.transitionTo(ScrimState.UNLOCKED);