Merge "Fade away wallpapers when long pulse" into qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
14e6d18ec9
@@ -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) {
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user