Merge "Feedback on: Fade out display when prox or pres..."
This commit is contained in:
@@ -68,6 +68,12 @@ public interface DozeHost {
|
||||
*/
|
||||
void prepareForGentleSleep(Runnable onDisplayOffCallback);
|
||||
|
||||
/**
|
||||
* Cancel pending {@code onDisplayOffCallback} callback.
|
||||
* @see #prepareForGentleSleep(Runnable)
|
||||
*/
|
||||
void cancelGentleSleep();
|
||||
|
||||
void onIgnoreTouchWhilePulsing(boolean ignore);
|
||||
|
||||
/**
|
||||
|
||||
@@ -71,7 +71,7 @@ public class DozeScreenState implements DozeMachine.Part {
|
||||
@Override
|
||||
public void transitionTo(DozeMachine.State oldState, DozeMachine.State newState) {
|
||||
int screenState = newState.screenState(mParameters);
|
||||
mDozeHost.prepareForGentleSleep(null);
|
||||
mDozeHost.cancelGentleSleep();
|
||||
|
||||
if (newState == DozeMachine.State.FINISH) {
|
||||
// Make sure not to apply the screen state after DozeService was destroyed.
|
||||
|
||||
@@ -39,15 +39,20 @@ public enum ScrimState {
|
||||
@Override
|
||||
public void prepare(ScrimState previousState) {
|
||||
mFrontTint = Color.BLACK;
|
||||
mBehindTint = previousState.mBehindTint;
|
||||
mBehindTint = Color.BLACK;
|
||||
mBubbleTint = previousState.mBubbleTint;
|
||||
|
||||
mFrontAlpha = 1f;
|
||||
mBehindAlpha = previousState.mBehindAlpha;
|
||||
mBehindAlpha = 1f;
|
||||
mBubbleAlpha = previousState.mBubbleAlpha;
|
||||
|
||||
mAnimationDuration = ScrimController.ANIMATION_DURATION_LONG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLowPowerState() {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -4323,13 +4323,21 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
|
||||
@Override
|
||||
public void prepareForGentleSleep(Runnable onDisplayOffCallback) {
|
||||
if (onDisplayOffCallback != null) {
|
||||
if (mPendingScreenOffCallback != null) {
|
||||
Log.w(TAG, "Overlapping onDisplayOffCallback. Ignoring previous one.");
|
||||
}
|
||||
mPendingScreenOffCallback = onDisplayOffCallback;
|
||||
updateScrimController();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelGentleSleep() {
|
||||
mPendingScreenOffCallback = null;
|
||||
if (mScrimController.getState() == ScrimState.OFF) {
|
||||
updateScrimController();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When the dozing host is waiting for scrims to fade out to change the display state.
|
||||
*/
|
||||
|
||||
@@ -64,6 +64,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
|
||||
@@ -249,7 +250,7 @@ public class ScrimControllerTest extends SysuiTestCase {
|
||||
finishAnimationsImmediately();
|
||||
|
||||
assertScrimAlpha(OPAQUE /* front */,
|
||||
SEMI_TRANSPARENT /* back */,
|
||||
OPAQUE /* back */,
|
||||
TRANSPARENT /* bubble */);
|
||||
|
||||
assertScrimTint(true /* front */,
|
||||
@@ -858,6 +859,22 @@ public class ScrimControllerTest extends SysuiTestCase {
|
||||
mScrimForBubble.getDefaultFocusHighlightEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsLowPowerMode() {
|
||||
HashSet<ScrimState> lowPowerModeStates = new HashSet<>(Arrays.asList(
|
||||
ScrimState.OFF, ScrimState.AOD, ScrimState.PULSING));
|
||||
HashSet<ScrimState> regularStates = new HashSet<>(Arrays.asList(
|
||||
ScrimState.UNINITIALIZED, ScrimState.KEYGUARD, ScrimState.BOUNCER,
|
||||
ScrimState.BOUNCER_SCRIMMED, ScrimState.BRIGHTNESS_MIRROR, ScrimState.UNLOCKED,
|
||||
ScrimState.BUBBLE_EXPANDED));
|
||||
|
||||
for (ScrimState state : ScrimState.values()) {
|
||||
if (!lowPowerModeStates.contains(state) && !regularStates.contains(state)) {
|
||||
Assert.fail("Scrim state not whitelisted nor blacklisted as low power mode");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void assertScrimTint(boolean front, boolean behind, boolean bubble) {
|
||||
Assert.assertEquals("Tint test failed at state " + mScrimController.getState()
|
||||
+ " with scrim: " + getScrimName(mScrimInFront) + " and tint: "
|
||||
|
||||
Reference in New Issue
Block a user