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

This commit is contained in:
TreeHugger Robot
2019-06-22 11:59:49 +00:00
committed by Android (Google) Code Review
3 changed files with 73 additions and 7 deletions

View File

@@ -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) {

View File

@@ -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) {
mTimeTicker.schedule(mDozeParameters.getWallpaperAodDuration(),
AlarmTimeout.MODE_IGNORE_IF_SCHEDULED);
}
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;
}
}
/**

View File

@@ -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);