Respect the expanded amount with AUTH_SCRIMMED_SHADE

ScrimState.UNLOCKED is used when the device is locked
and an activity is occluding the keyguard (ie: camera activty
on top of the lock screen, then pull down the shade). Therefore,
the AUTH_SCRIMMED_SHADE (tap notification with udfps enrolled) needs to
also respect the expanded state of the shade to correctly
determine the behind and notification scrim alpha values.

Test: atest ScrimControllerTest
Fixes: 198789984
Change-Id: I36f064c84821389367a06edff736bed8a75cdc19
This commit is contained in:
Beverly
2021-10-18 15:16:41 -04:00
parent 2956f1d302
commit e764ba30d7
4 changed files with 61 additions and 2 deletions

View File

@@ -675,6 +675,12 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
}
mInFrontAlpha = 0;
}
} else if (mState == ScrimState.AUTH_SCRIMMED_SHADE) {
float behindFraction = getInterpolatedFraction();
behindFraction = (float) Math.pow(behindFraction, 0.8f);
mBehindAlpha = behindFraction * mDefaultScrimAlpha;
mNotificationsAlpha = mBehindAlpha;
} else if (mState == ScrimState.KEYGUARD || mState == ScrimState.SHADE_LOCKED
|| mState == ScrimState.PULSING) {
Pair<Integer, Float> result = calculateBackStateForState(mState);

View File

@@ -87,6 +87,17 @@ public enum ScrimState {
}
},
AUTH_SCRIMMED_SHADE {
@Override
public void prepare(ScrimState previousState) {
// notif & behind scrim alpha values are determined by ScrimController#applyState
// based on the shade expansion
mFrontTint = Color.BLACK;
mFrontAlpha = .66f;
}
},
AUTH_SCRIMMED {
@Override
public void prepare(ScrimState previousState) {

View File

@@ -3837,7 +3837,11 @@ public class StatusBar extends SystemUI implements
mScrimController.setLaunchingAffordanceWithPreview(launchingAffordanceWithPreview);
if (mStatusBarKeyguardViewManager.isShowingAlternateAuth()) {
mScrimController.transitionTo(ScrimState.AUTH_SCRIMMED);
if (mState == StatusBarState.SHADE || mState == StatusBarState.SHADE_LOCKED) {
mScrimController.transitionTo(ScrimState.AUTH_SCRIMMED_SHADE);
} else {
mScrimController.transitionTo(ScrimState.AUTH_SCRIMMED);
}
} else if (mBouncerShowing) {
// Bouncer needs the front scrim when it's on top of an activity,
// tapping on a notification, editing QS or being dismissed by

View File

@@ -1063,7 +1063,7 @@ public class ScrimControllerTest extends SysuiTestCase {
HashSet<ScrimState> regularStates = new HashSet<>(Arrays.asList(
ScrimState.UNINITIALIZED, ScrimState.KEYGUARD, ScrimState.BOUNCER,
ScrimState.BOUNCER_SCRIMMED, ScrimState.BRIGHTNESS_MIRROR, ScrimState.UNLOCKED,
ScrimState.SHADE_LOCKED, ScrimState.AUTH_SCRIMMED));
ScrimState.SHADE_LOCKED, ScrimState.AUTH_SCRIMMED, ScrimState.AUTH_SCRIMMED_SHADE));
for (ScrimState state : ScrimState.values()) {
if (!lowPowerModeStates.contains(state) && !regularStates.contains(state)) {
@@ -1086,6 +1086,44 @@ public class ScrimControllerTest extends SysuiTestCase {
mNotificationsScrim.getViewAlpha(), 1, 0.0);
}
@Test
public void testAuthScrim_notifScrimOpaque_whenShadeFullyExpanded() {
// GIVEN device has an activity showing ('UNLOCKED' state can occur on the lock screen
// with the camera app occluding the keyguard)
mScrimController.transitionTo(ScrimState.UNLOCKED);
mScrimController.setRawPanelExpansionFraction(1);
// notifications scrim alpha change require calling setQsPosition
mScrimController.setQsPosition(0, 300);
finishAnimationsImmediately();
// WHEN the user triggers the auth bouncer
mScrimController.transitionTo(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);
}
@Test
public void testAuthScrimKeyguard() {
// GIVEN device is on the keyguard
mScrimController.transitionTo(ScrimState.KEYGUARD);
finishAnimationsImmediately();
// WHEN the user triggers the auth bouncer
mScrimController.transitionTo(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.transitionTo(ScrimState.UNLOCKED);