Revert "Fix shouldControlUnlockedScreenOff."
This reverts commit 7755d00cc51c4250446f4521eea941a964a37d7a.
Reason for revert: Broke PlatformScenarioTests
Bug: 222015750
Change-Id: I38f9248ccce5bd73f45f4ee0cc0362f28388f92a
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java
index ebe91c7..8b25c2b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java
@@ -292,20 +292,11 @@
}
public void updateControlScreenOff() {
- final boolean controlScreenOff = shouldControlUnlockedScreenOff()
- || (!getDisplayNeedsBlanking() && getAlwaysOn() && mKeyguardShowing);
- setControlScreenOffAnimation(controlScreenOff);
- }
-
- /**
- * Whether we're capable of controlling the screen off animation if we want to. This isn't
- * possible if AOD isn't even enabled or if the flag is disabled, or if the display needs
- * blanking.
- */
- public boolean canControlUnlockedScreenOff() {
- return getAlwaysOn()
- && mFeatureFlags.isEnabled(Flags.LOCKSCREEN_ANIMATIONS)
- && !getDisplayNeedsBlanking();
+ if (!getDisplayNeedsBlanking()) {
+ final boolean controlScreenOff =
+ getAlwaysOn() && (mKeyguardShowing || shouldControlUnlockedScreenOff());
+ setControlScreenOffAnimation(controlScreenOff);
+ }
}
/**
@@ -318,7 +309,8 @@
* disabled for a11y.
*/
public boolean shouldControlUnlockedScreenOff() {
- return mUnlockedScreenOffAnimationController.shouldPlayUnlockedScreenOffAnimation();
+ return canControlUnlockedScreenOff()
+ && mUnlockedScreenOffAnimationController.shouldPlayUnlockedScreenOffAnimation();
}
public boolean shouldDelayKeyguardShow() {
@@ -350,6 +342,16 @@
return getAlwaysOn() && mKeyguardShowing;
}
+ /**
+ * Whether we're capable of controlling the screen off animation if we want to. This isn't
+ * possible if AOD isn't even enabled or if the flag is disabled.
+ */
+ public boolean canControlUnlockedScreenOff() {
+ return getAlwaysOn()
+ && mFeatureFlags.isEnabled(Flags.LOCKSCREEN_ANIMATIONS)
+ && !getDisplayNeedsBlanking();
+ }
+
private boolean getBoolean(String propName, int resId) {
return SystemProperties.getBoolean(propName, mResources.getBoolean(resId));
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt
index 8b0eaec..c11d450 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt
@@ -61,14 +61,6 @@
) : WakefulnessLifecycle.Observer, ScreenOffAnimation {
private lateinit var mCentralSurfaces: CentralSurfaces
-
- /**
- * Whether or not [initialize] has been called to provide us with the StatusBar,
- * NotificationPanelViewController, and LightRevealSrim so that we can run the unlocked screen
- * off animation.
- */
- private var initialized = false
-
private lateinit var lightRevealScrim: LightRevealScrim
private var animatorDurationScale = 1f
@@ -124,7 +116,6 @@
centralSurfaces: CentralSurfaces,
lightRevealScrim: LightRevealScrim
) {
- this.initialized = true
this.lightRevealScrim = lightRevealScrim
this.mCentralSurfaces = centralSurfaces
@@ -271,18 +262,6 @@
* on the current state of the device.
*/
fun shouldPlayUnlockedScreenOffAnimation(): Boolean {
- // If we haven't been initialized yet, we don't have a StatusBar/LightRevealScrim yet, so we
- // can't perform the animation.
- if (!initialized) {
- return false
- }
-
- // If the device isn't in a state where we can control unlocked screen off (no AOD enabled,
- // power save, etc.) then we shouldn't try to do so.
- if (!dozeParameters.get().canControlUnlockedScreenOff()) {
- return false
- }
-
// If we explicitly already decided not to play the screen off animation, then never change
// our mind.
if (decidedToAnimateGoingToSleep == false) {
@@ -325,7 +304,7 @@
}
override fun shouldDelayDisplayDozeTransition(): Boolean =
- shouldPlayUnlockedScreenOffAnimation()
+ dozeParameters.get().shouldControlUnlockedScreenOff()
/**
* Whether we're doing the light reveal animation or we're done with that and animating in the
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeParametersTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeParametersTest.java
index 077b41a..5f2bbd3 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeParametersTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeParametersTest.java
@@ -126,12 +126,6 @@
setAodEnabledForTest(true);
setShouldControlUnlockedScreenOffForTest(true);
setDisplayNeedsBlankingForTest(false);
-
- // Default to false here (with one test to make sure that when it returns true, we respect
- // that). We'll test the specific conditions for this to return true/false in the
- // UnlockedScreenOffAnimationController's tests.
- when(mUnlockedScreenOffAnimationController.shouldPlayUnlockedScreenOffAnimation())
- .thenReturn(false);
}
@Test
@@ -180,12 +174,9 @@
*/
@Test
public void testControlUnlockedScreenOffAnimation_dozeAfterScreenOff_false() {
- mDozeParameters.mKeyguardVisibilityCallback.onKeyguardVisibilityChanged(true);
-
// If AOD is disabled, we shouldn't want to control screen off. Also, let's double check
// that when that value is updated, we called through to PowerManager.
setAodEnabledForTest(false);
-
assertFalse(mDozeParameters.shouldControlScreenOff());
assertTrue(mPowerManagerDozeAfterScreenOff);
@@ -197,6 +188,7 @@
@Test
public void testControlUnlockedScreenOffAnimationDisabled_dozeAfterScreenOff() {
+ setShouldControlUnlockedScreenOffForTest(true);
when(mFeatureFlags.isEnabled(Flags.LOCKSCREEN_ANIMATIONS)).thenReturn(false);
assertFalse(mDozeParameters.shouldControlUnlockedScreenOff());
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationControllerTest.kt
index 0936b77..050563a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationControllerTest.kt
@@ -31,7 +31,6 @@
import com.android.systemui.statusbar.StatusBarStateControllerImpl
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.util.settings.GlobalSettings
-import junit.framework.Assert.assertFalse
import org.junit.After
import org.junit.Before
import org.junit.Test
@@ -134,7 +133,7 @@
*/
@Test
fun testAodUiShownIfNotInteractive() {
- `when`(dozeParameters.canControlUnlockedScreenOff()).thenReturn(true)
+ `when`(dozeParameters.shouldControlUnlockedScreenOff()).thenReturn(true)
`when`(powerManager.isInteractive).thenReturn(false)
val callbackCaptor = ArgumentCaptor.forClass(Runnable::class.java)
@@ -157,7 +156,7 @@
*/
@Test
fun testAodUiNotShownIfInteractive() {
- `when`(dozeParameters.canControlUnlockedScreenOff()).thenReturn(true)
+ `when`(dozeParameters.shouldControlUnlockedScreenOff()).thenReturn(true)
`when`(powerManager.isInteractive).thenReturn(true)
val callbackCaptor = ArgumentCaptor.forClass(Runnable::class.java)
@@ -168,13 +167,4 @@
verify(notificationPanelViewController, never()).showAodUi()
}
-
- @Test
- fun testNoAnimationPlaying_dozeParamsCanNotControlScreenOff() {
- `when`(dozeParameters.canControlUnlockedScreenOff()).thenReturn(false)
-
- assertFalse(controller.shouldPlayUnlockedScreenOffAnimation())
- controller.startAnimation()
- assertFalse(controller.isAnimationPlaying())
- }
}
\ No newline at end of file