OSDN Git Service

Apply front scrim to doze pulsing
authorChris.CC Lee <chriscclee@google.com>
Mon, 16 Sep 2019 04:17:19 +0000 (12:17 +0800)
committerChris.CC Lee <chriscclee@google.com>
Wed, 18 Sep 2019 06:38:25 +0000 (14:38 +0800)
When ambient goes dark, apply the same front scrim opacity during doze
pulsing. The would then be a common behavior to all pulsing reaons.

Bug: 139445074
Test: Manual tests
Test: atest ScrimControllerTest
Change-Id: I3f1f7ca00b9d200ce4a7120b5328527ab9d9fb13

packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java

index 5733d4b..45f3b32 100644 (file)
@@ -473,11 +473,11 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
             if (mDarkenWhileDragging) {
                 mBehindAlpha = MathUtils.lerp(GRADIENT_SCRIM_ALPHA_BUSY, alphaBehind,
                         interpolatedFract);
-                mInFrontAlpha = 0;
+                mInFrontAlpha = mState.getFrontAlpha();
             } else {
                 mBehindAlpha = MathUtils.lerp(0 /* start */, alphaBehind,
                         interpolatedFract);
-                mInFrontAlpha = 0;
+                mInFrontAlpha = mState.getFrontAlpha();
             }
             mBehindTint = ColorUtils.blendARGB(ScrimState.BOUNCER.getBehindTint(),
                     mState.getBehindTint(), interpolatedFract);
@@ -503,13 +503,14 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
      * device is dozing when the light sensor is on.
      */
     public void setAodFrontScrimAlpha(float alpha) {
-        if (mState == ScrimState.AOD && mDozeParameters.getAlwaysOn()
-                && mInFrontAlpha != alpha) {
+        if (((mState == ScrimState.AOD && mDozeParameters.getAlwaysOn())
+                || mState == ScrimState.PULSING) && mInFrontAlpha != alpha) {
             mInFrontAlpha = alpha;
             updateScrims();
         }
 
         mState.AOD.setAodFrontScrimAlpha(alpha);
+        mState.PULSING.setAodFrontScrimAlpha(alpha);
     }
 
     /**
index c9acbad..7463c7c 100644 (file)
@@ -139,7 +139,7 @@ public enum ScrimState {
     PULSING(5) {
         @Override
         public void prepare(ScrimState previousState) {
-            mFrontAlpha = 0f;
+            mFrontAlpha = mAodFrontScrimAlpha;
             mBubbleAlpha = 0f;
             mBehindTint = Color.BLACK;
             mFrontTint = Color.BLACK;
index c5d4019..e05ad09 100644 (file)
@@ -241,7 +241,7 @@ public class ScrimControllerTest extends SysuiTestCase {
     }
 
     @Test
-    public void transitionToPulsing() {
+    public void transitionToPulsing_withFrontAlphaUpdates() {
         // Pre-condition
         // Need to go to AoD first because PULSING doesn't change
         // the back scrim opacity - otherwise it would hide AoD wallpapers.
@@ -265,11 +265,22 @@ public class ScrimControllerTest extends SysuiTestCase {
                 true /* behind */,
                 false /* bubble */);
 
+        // ... and when ambient goes dark, front scrim should be semi-transparent
+        mScrimController.setAodFrontScrimAlpha(0.5f);
+        mScrimController.finishAnimationsImmediately();
+        // Front scrim should be semi-transparent
+        assertScrimAlpha(SEMI_TRANSPARENT /* front */,
+                OPAQUE /* back */,
+                TRANSPARENT /* bubble */);
+
         mScrimController.setWakeLockScreenSensorActive(true);
         mScrimController.finishAnimationsImmediately();
-        assertScrimAlpha(TRANSPARENT /* front */,
+        assertScrimAlpha(SEMI_TRANSPARENT /* front */,
                 SEMI_TRANSPARENT /* back */,
                 TRANSPARENT /* bubble */);
+
+        // Reset value since enums are static.
+        mScrimController.setAodFrontScrimAlpha(0f);
     }
 
     @Test