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

am: 14e6d18ec9

Change-Id: Ia529dee9e06c48035846d2c112bf2993ac2a7bbc
This commit is contained in:
Jerry Chang
2019-06-22 17:16:14 -07:00
committed by android-build-merger
3 changed files with 73 additions and 7 deletions

View File

@@ -84,6 +84,14 @@ public class DozeScrimController implements StateListener {
public void onCancelled() { public void onCancelled() {
pulseFinished(); pulseFinished();
} }
/**
* Whether to timeout wallpaper or not.
*/
@Override
public boolean shouldTimeoutWallpaper() {
return mPulseReason == DozeLog.PULSE_REASON_DOCKING;
}
}; };
public DozeScrimController(DozeParameters dozeParameters) { 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. // AOD wallpapers should fade away after a while.
// Docking pulses may take a long time, wallpapers should also fade away after a while. // Docking pulses may take a long time, wallpapers should also fade away after a while.
if (mWallpaperSupportsAmbientMode && mDozeParameters.getAlwaysOn() mWallpaperVisibilityTimedOut = false;
&& mState == ScrimState.AOD) { if (shouldFadeAwayWallpaper()) {
if (!mWallpaperVisibilityTimedOut) { mTimeTicker.schedule(mDozeParameters.getWallpaperAodDuration(),
mTimeTicker.schedule(mDozeParameters.getWallpaperAodDuration(), AlarmTimeout.MODE_IGNORE_IF_SCHEDULED);
AlarmTimeout.MODE_IGNORE_IF_SCHEDULED);
}
} else { } else {
mTimeTicker.cancel(); mTimeTicker.cancel();
mWallpaperVisibilityTimedOut = false;
} }
if (mKeyguardUpdateMonitor.needsSlowUnlockTransition() && mState == ScrimState.UNLOCKED) { if (mKeyguardUpdateMonitor.needsSlowUnlockTransition() && mState == ScrimState.UNLOCKED) {
@@ -313,6 +310,23 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
dispatchScrimState(mScrimBehind.getViewAlpha()); 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() { public ScrimState getState() {
return mState; return mState;
} }
@@ -387,6 +401,14 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
setOrAdaptCurrentAnimation(mScrimInFront); setOrAdaptCurrentAnimation(mScrimInFront);
dispatchScrimState(mScrimBehind.getViewAlpha()); 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() { 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)); 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 @Test
public void testConservesExpansionOpacityAfterTransition() { public void testConservesExpansionOpacityAfterTransition() {
mScrimController.transitionTo(ScrimState.UNLOCKED); mScrimController.transitionTo(ScrimState.UNLOCKED);