Merge changes I09f58bdc,Iaf6cee33 into pi-dev am: b5438ce105
am: 7ee7406915
Change-Id: Id697f434d8b70c929e0390a48e360a5d10dc3e9e
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
index ae55ae8..739d8d5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
@@ -158,6 +158,7 @@
private final WakeLock mWakeLock;
private boolean mWakeLockHeld;
+ private boolean mKeyguardOccluded;
public ScrimController(LightBarController lightBarController, ScrimView scrimBehind,
ScrimView scrimInFront, View headsUpScrim, Consumer<Integer> scrimVisibleListener,
@@ -268,12 +269,13 @@
// AOD wallpapers should fade away after a while
if (mWallpaperSupportsAmbientMode && mDozeParameters.getAlwaysOn()
- && (mState == ScrimState.AOD || mState == ScrimState.PULSING)) {
+ && mState == ScrimState.AOD) {
if (!mWallpaperVisibilityTimedOut) {
mTimeTicker.schedule(mDozeParameters.getWallpaperAodDuration(),
AlarmTimeout.MODE_IGNORE_IF_SCHEDULED);
}
- } else {
+ // Do not re-schedule timeout when pulsing, let's save some extra battery.
+ } else if (mState != ScrimState.PULSING) {
mTimeTicker.cancel();
mWallpaperVisibilityTimedOut = false;
}
@@ -317,7 +319,7 @@
@VisibleForTesting
protected void onHideWallpaperTimeout() {
- if (mState != ScrimState.AOD && mState != ScrimState.PULSING) {
+ if (mState != ScrimState.AOD) {
return;
}
@@ -478,11 +480,13 @@
mLightBarController.setScrimColor(mScrimInFront.getColors());
}
- // We want to override the back scrim opacity for AOD and PULSING
+ // We want to override the back scrim opacity for the AOD state
// when it's time to fade the wallpaper away.
- boolean overrideBackScrimAlpha = (mState == ScrimState.PULSING || mState == ScrimState.AOD)
- && mWallpaperVisibilityTimedOut;
- if (overrideBackScrimAlpha) {
+ boolean aodWallpaperTimeout = mState == ScrimState.AOD && mWallpaperVisibilityTimedOut;
+ // We also want to hide FLAG_SHOW_WHEN_LOCKED activities under the scrim.
+ boolean occludedKeyguard = (mState == ScrimState.PULSING || mState == ScrimState.AOD)
+ && mKeyguardOccluded;
+ if (aodWallpaperTimeout || occludedKeyguard) {
mCurrentBehindAlpha = 1;
}
@@ -926,6 +930,10 @@
mExpansionAffectsAlpha = expansionAffectsAlpha;
}
+ public void setKeyguardOccluded(boolean keyguardOccluded) {
+ mKeyguardOccluded = keyguardOccluded;
+ }
+
public interface Callback {
default void onStart() {
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index c92f300..7422a43 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -2040,6 +2040,7 @@
public void setOccluded(boolean occluded) {
mIsOccluded = occluded;
+ mScrimController.setKeyguardOccluded(occluded);
updateHideIconsForBouncer(false /* animate */);
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java
index f088c0b..d32c9a8 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java
@@ -475,6 +475,19 @@
Assert.assertTrue("Should be focusable on keyguard", mScrimInFront.isFocusable());
}
+ @Test
+ public void testHidesShowWhenLockedActivity() {
+ mScrimController.setWallpaperSupportsAmbientMode(true);
+ mScrimController.setKeyguardOccluded(true);
+ mScrimController.transitionTo(ScrimState.AOD);
+ mScrimController.finishAnimationsImmediately();
+ assertScrimVisibility(VISIBILITY_FULLY_TRANSPARENT, VISIBILITY_FULLY_OPAQUE);
+
+ mScrimController.transitionTo(ScrimState.PULSING);
+ mScrimController.finishAnimationsImmediately();
+ assertScrimVisibility(VISIBILITY_FULLY_TRANSPARENT, VISIBILITY_FULLY_OPAQUE);
+ }
+
/**
* Conserves old notification density after leaving state and coming back.
*
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java
index 14baaeb..f13fa4e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java
@@ -30,6 +30,7 @@
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -547,6 +548,16 @@
verify(mScrimController).transitionTo(eq(ScrimState.UNLOCKED), any());
}
+ @Test
+ public void testSetOccluded_propagatesToScrimController() {
+ mStatusBar.setOccluded(true);
+ verify(mScrimController).setKeyguardOccluded(eq(true));
+
+ reset(mScrimController);
+ mStatusBar.setOccluded(false);
+ verify(mScrimController).setKeyguardOccluded(eq(false));
+ }
+
static class TestableStatusBar extends StatusBar {
public TestableStatusBar(StatusBarKeyguardViewManager man,
UnlockMethodCache unlock, KeyguardIndicationController key,