Have doze update the scrim controller rather than the scrim state.

Right now, when Doze wants to update the front alpha in AOD, it updates
the scrim state's front alpha value. Unfortunately, this is only looked
at when transitioning into the state, but entirely ignored once we're in
it. With this, we instead tell the scrim controller which tells the
scrim state but also updates the current front scrim alpha if we're
currently in the AOD state.

Bug: 78124574
Bug: 70939994
Test: atest ScrimControllerTest\#transitionToAod_withFrontAlphaUpdates
Change-Id: I09b33208bd3e3fd6d3829b33776364aa7b61a4f6
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 0416232..58c6bc7 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
@@ -156,6 +156,38 @@
     }
 
     @Test
+    public void transitionToAod_withFrontAlphaUpdates() {
+        // Assert that setting the AOD front scrim alpha doesn't take effect in a non-AOD state.
+        mScrimController.transitionTo(ScrimState.KEYGUARD);
+        mScrimController.setAodFrontScrimAlpha(0.5f);
+        mScrimController.finishAnimationsImmediately();
+        // Front scrim should be transparent
+        // Back scrim should be visible without tint
+        assertScrimVisibility(VISIBILITY_FULLY_TRANSPARENT, VISIBILITY_SEMI_TRANSPARENT);
+
+        // ... but that it does take effect once we enter the AOD state.
+        mScrimController.transitionTo(ScrimState.AOD);
+        mScrimController.finishAnimationsImmediately();
+        // Front scrim should be semi-transparent
+        // Back scrim should be visible
+        assertScrimVisibility(VISIBILITY_SEMI_TRANSPARENT, VISIBILITY_FULLY_OPAQUE);
+
+        // ... and that if we set it while we're in AOD, it does take immediate effect.
+        mScrimController.setAodFrontScrimAlpha(1f);
+        assertScrimVisibility(VISIBILITY_FULLY_OPAQUE, VISIBILITY_FULLY_OPAQUE);
+
+        // ... and make sure we recall the previous front scrim alpha even if we transition away
+        // for a bit.
+        mScrimController.transitionTo(ScrimState.UNLOCKED);
+        mScrimController.transitionTo(ScrimState.AOD);
+        mScrimController.finishAnimationsImmediately();
+        assertScrimVisibility(VISIBILITY_FULLY_OPAQUE, VISIBILITY_FULLY_OPAQUE);
+
+        // Reset value since enums are static.
+        mScrimController.setAodFrontScrimAlpha(0f);
+    }
+
+    @Test
     public void transitionToPulsing() {
         // Pre-condition
         // Need to go to AoD first because PULSING doesn't change