diff options
3 files changed, 52 insertions, 111 deletions
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 d43fed0cbf59..2cd8eafcdb54 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java @@ -31,7 +31,6 @@ import android.animation.ValueAnimator; import android.annotation.IntDef; import android.graphics.Color; import android.os.Handler; -import android.os.Trace; import android.util.Log; import android.util.MathUtils; import android.util.Pair; @@ -53,6 +52,7 @@ import com.android.keyguard.BouncerPanelExpansionCalculator; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; import com.android.systemui.Dumpable; +import com.android.systemui.Flags; import com.android.systemui.animation.ShadeInterpolation; import com.android.systemui.bouncer.shared.constants.KeyguardBouncerConstants; import com.android.systemui.dagger.SysUISingleton; @@ -82,6 +82,9 @@ import com.android.systemui.util.kotlin.JavaAdapter; import com.android.systemui.util.wakelock.DelayedWakeLock; import com.android.systemui.util.wakelock.WakeLock; +import kotlinx.coroutines.CoroutineDispatcher; +import kotlinx.coroutines.ExperimentalCoroutinesApi; + import java.io.PrintWriter; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -90,9 +93,6 @@ import java.util.function.Consumer; import javax.inject.Inject; -import kotlinx.coroutines.CoroutineDispatcher; -import kotlinx.coroutines.ExperimentalCoroutinesApi; - /** * Controls both the scrim behind the notifications and in front of the notifications (when a * security method gets shown). @@ -226,6 +226,8 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump private float mAdditionalScrimBehindAlphaKeyguard = 0f; // Combined scrim behind keyguard alpha of default scrim + additional scrim private float mScrimBehindAlphaKeyguard = KEYGUARD_SCRIM_ALPHA; + + static final float TRANSPARENT_BOUNCER_SCRIM_ALPHA = 0.54f; private final float mDefaultScrimAlpha; private float mRawPanelExpansionFraction; @@ -340,7 +342,10 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump LargeScreenShadeInterpolator largeScreenShadeInterpolator) { mScrimStateListener = lightBarController::setScrimState; mLargeScreenShadeInterpolator = largeScreenShadeInterpolator; - mDefaultScrimAlpha = BUSY_SCRIM_ALPHA; + // All scrims default alpha need to match bouncer background alpha to make sure the + // transitions involving the bouncer are smooth and don't overshoot the bouncer alpha. + mDefaultScrimAlpha = + Flags.bouncerUiRevamp() ? TRANSPARENT_BOUNCER_SCRIM_ALPHA : BUSY_SCRIM_ALPHA; mKeyguardStateController = keyguardStateController; mDarkenWhileDragging = !mKeyguardStateController.canDismissLockScreen(); @@ -974,8 +979,6 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump mBehindTint, interpolatedFraction); } - } else if (mState == ScrimState.AUTH_SCRIMMED_SHADE) { - mNotificationsAlpha = (float) Math.pow(getInterpolatedFraction(), 0.8f); } else if (mState == ScrimState.KEYGUARD || mState == ScrimState.SHADE_LOCKED || mState == ScrimState.PULSING || mState == ScrimState.GLANCEABLE_HUB) { Pair<Integer, Float> result = calculateBackStateForState(mState); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java index 8dcb66312558..14937295051d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java @@ -16,17 +16,24 @@ package com.android.systemui.statusbar.phone; +import static com.android.systemui.statusbar.phone.ScrimController.BUSY_SCRIM_ALPHA; +import static com.android.systemui.statusbar.phone.ScrimController.TRANSPARENT_BOUNCER_SCRIM_ALPHA; + import android.graphics.Color; import com.android.app.tracing.coroutines.TrackTracer; +import com.android.systemui.Flags; import com.android.systemui.dock.DockManager; import com.android.systemui.res.R; import com.android.systemui.scrim.ScrimView; import com.android.systemui.statusbar.notification.stack.StackStateAnimator; +import kotlinx.coroutines.ExperimentalCoroutinesApi; + /** * Possible states of the ScrimController state machine. */ +@ExperimentalCoroutinesApi public enum ScrimState { /** @@ -92,40 +99,19 @@ public enum ScrimState { } }, - AUTH_SCRIMMED_SHADE { - @Override - public void prepare(ScrimState previousState) { - // notif scrim alpha values are determined by ScrimController#applyState - // based on the shade expansion - - mFrontTint = mBackgroundColor; - mFrontAlpha = .66f; - - mBehindTint = mBackgroundColor; - mBehindAlpha = 1f; - } - }, - - AUTH_SCRIMMED { - @Override - public void prepare(ScrimState previousState) { - mNotifTint = previousState.mNotifTint; - mNotifAlpha = previousState.mNotifAlpha; - - mBehindTint = previousState.mBehindTint; - mBehindAlpha = previousState.mBehindAlpha; - - mFrontTint = mBackgroundColor; - mFrontAlpha = .66f; - } - }, - /** * Showing password challenge on the keyguard. */ BOUNCER { @Override public void prepare(ScrimState previousState) { + if (Flags.bouncerUiRevamp()) { + mBehindAlpha = mClipQsScrim ? 0.0f : TRANSPARENT_BOUNCER_SCRIM_ALPHA; + mNotifAlpha = mClipQsScrim ? TRANSPARENT_BOUNCER_SCRIM_ALPHA : 0; + mBehindTint = mNotifTint = mSurfaceColor; + mFrontAlpha = 0f; + return; + } mBehindAlpha = mClipQsScrim ? 1 : mDefaultScrimAlpha; mBehindTint = mClipQsScrim ? mBackgroundColor : mSurfaceColor; mNotifAlpha = mClipQsScrim ? mDefaultScrimAlpha : 0; @@ -136,6 +122,10 @@ public enum ScrimState { @Override public void setSurfaceColor(int surfaceColor) { super.setSurfaceColor(surfaceColor); + if (Flags.bouncerUiRevamp()) { + mBehindTint = mNotifTint = mSurfaceColor; + return; + } if (!mClipQsScrim) { mBehindTint = mSurfaceColor; } @@ -146,15 +136,38 @@ public enum ScrimState { * Showing password challenge on top of a FLAG_SHOW_WHEN_LOCKED activity. */ BOUNCER_SCRIMMED { + @ExperimentalCoroutinesApi @Override public void prepare(ScrimState previousState) { + if (Flags.bouncerUiRevamp()) { + mBehindAlpha = 0f; + mFrontAlpha = TRANSPARENT_BOUNCER_SCRIM_ALPHA; + mFrontTint = mSurfaceColor; + return; + } mBehindAlpha = 0; mFrontAlpha = mDefaultScrimAlpha; } + + @Override + public boolean shouldBlendWithMainColor() { + return !Flags.bouncerUiRevamp(); + } }, SHADE_LOCKED { @Override + public void setDefaultScrimAlpha(float defaultScrimAlpha) { + super.setDefaultScrimAlpha(defaultScrimAlpha); + if (!Flags.notificationShadeBlur()) { + // Temporary change that prevents the shade from being semi-transparent when + // bouncer blur is enabled but notification shade blur is not enabled. This is + // required to perf test these two flags independently. + mDefaultScrimAlpha = BUSY_SCRIM_ALPHA; + } + } + + @Override public void prepare(ScrimState previousState) { mBehindAlpha = mClipQsScrim ? 1 : mDefaultScrimAlpha; mNotifAlpha = 1f; 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 38ddb3e426fa..a02d333d1507 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 @@ -30,7 +30,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyFloat; -import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; @@ -1425,8 +1424,7 @@ public class ScrimControllerTest extends SysuiTestCase { HashSet<ScrimState> regularStates = new HashSet<>(Arrays.asList( ScrimState.UNINITIALIZED, ScrimState.KEYGUARD, BOUNCER, ScrimState.DREAMING, ScrimState.BOUNCER_SCRIMMED, ScrimState.BRIGHTNESS_MIRROR, - ScrimState.UNLOCKED, SHADE_LOCKED, ScrimState.AUTH_SCRIMMED, - ScrimState.AUTH_SCRIMMED_SHADE, ScrimState.GLANCEABLE_HUB, + ScrimState.UNLOCKED, SHADE_LOCKED, ScrimState.GLANCEABLE_HUB, ScrimState.GLANCEABLE_HUB_OVER_DREAM)); for (ScrimState state : ScrimState.values()) { @@ -1451,79 +1449,6 @@ public class ScrimControllerTest extends SysuiTestCase { } @Test - public void testAuthScrim_setClipQSScrimTrue_notifScrimOpaque_whenShadeFullyExpanded() { - // GIVEN device has an activity showing ('UNLOCKED' state can occur on the lock screen - // with the camera app occluding the keyguard) - mScrimController.legacyTransitionTo(ScrimState.UNLOCKED); - mScrimController.setClipsQsScrim(true); - mScrimController.setRawPanelExpansionFraction(1); - // notifications scrim alpha change require calling setQsPosition - mScrimController.setQsPosition(0, 300); - finishAnimationsImmediately(); - - // WHEN the user triggers the auth bouncer - mScrimController.legacyTransitionTo(ScrimState.AUTH_SCRIMMED_SHADE); - finishAnimationsImmediately(); - - assertEquals("Behind scrim should be opaque", - mScrimBehind.getViewAlpha(), 1, 0.0); - assertEquals("Notifications scrim should be opaque", - mNotificationsScrim.getViewAlpha(), 1, 0.0); - - assertScrimTinted(Map.of( - mScrimInFront, true, - mScrimBehind, true, - mNotificationsScrim, false - )); - } - - - @Test - public void testAuthScrim_setClipQSScrimFalse_notifScrimOpaque_whenShadeFullyExpanded() { - // GIVEN device has an activity showing ('UNLOCKED' state can occur on the lock screen - // with the camera app occluding the keyguard) - mScrimController.legacyTransitionTo(ScrimState.UNLOCKED); - mScrimController.setClipsQsScrim(false); - mScrimController.setRawPanelExpansionFraction(1); - // notifications scrim alpha change require calling setQsPosition - mScrimController.setQsPosition(0, 300); - finishAnimationsImmediately(); - - // WHEN the user triggers the auth bouncer - mScrimController.legacyTransitionTo(ScrimState.AUTH_SCRIMMED_SHADE); - finishAnimationsImmediately(); - - assertEquals("Behind scrim should be opaque", - mScrimBehind.getViewAlpha(), 1, 0.0); - assertEquals("Notifications scrim should be opaque", - mNotificationsScrim.getViewAlpha(), 1, 0.0); - - assertScrimTinted(Map.of( - mScrimInFront, true, - mScrimBehind, true, - mNotificationsScrim, false - )); - } - - @Test - public void testAuthScrimKeyguard() { - // GIVEN device is on the keyguard - mScrimController.legacyTransitionTo(ScrimState.KEYGUARD); - finishAnimationsImmediately(); - - // WHEN the user triggers the auth bouncer - mScrimController.legacyTransitionTo(ScrimState.AUTH_SCRIMMED); - finishAnimationsImmediately(); - - // THEN the front scrim is updated and the KEYGUARD scrims are the same as the - // KEYGUARD scrim state - assertScrimAlpha(Map.of( - mScrimInFront, SEMI_TRANSPARENT, - mScrimBehind, SEMI_TRANSPARENT, - mNotificationsScrim, TRANSPARENT)); - } - - @Test public void testScrimsVisible_whenShadeVisible() { mScrimController.setClipsQsScrim(true); mScrimController.legacyTransitionTo(ScrimState.UNLOCKED); |