diff options
| author | 2023-08-05 00:55:07 +0000 | |
|---|---|---|
| committer | 2023-08-05 00:55:07 +0000 | |
| commit | 15455f2c67b32b0200878311a407398b43b2d301 (patch) | |
| tree | 0274df1ad59e429c680e17ffcf292246b71dc118 | |
| parent | d57c8563b9b0dc0db4e46702703c917a0641caca (diff) | |
| parent | daa23804e9b526d485792f106bcd51435defdde4 (diff) | |
Merge cherrypicks of ['googleplex-android-review.googlesource.com/24248316', 'googleplex-android-review.googlesource.com/24281855', 'googleplex-android-review.googlesource.com/24026547', 'googleplex-android-review.googlesource.com/24284551', 'googleplex-android-review.googlesource.com/24034687'] into sparse-10615697-L90400000962407107.
SPARSE_CHANGE: Iaffbb53b29578c0575a7737c8aacdc8ca547b426
SPARSE_CHANGE: Id2e796edee45dae281f867c2b1549a80984c8a8e
SPARSE_CHANGE: I35df87ef05cb75dcd551cc4899a0a9863fdcbcc7
SPARSE_CHANGE: I890d102d10a3efa230e26e4e9753f9c66b71afdb
SPARSE_CHANGE: I67149c6faa2766be6d2537f2315dd2734bdd0447
Change-Id: I4931755494c45d9122f70e20665069a8102ed55a
12 files changed, 235 insertions, 30 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java index 841b5b3a1e82..9ff338e8d5ab 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java @@ -786,8 +786,6 @@ public class KeyguardSecurityContainer extends ConstraintLayout { void reloadColors() { mViewMode.reloadColors(); - setBackgroundColor(Utils.getColorAttrDefaultColor(getContext(), - com.android.internal.R.attr.materialColorSurface)); } /** Handles density or font scale changes. */ diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index 505be0867fe4..1a06b0184bc5 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -99,6 +99,7 @@ import android.view.WindowManagerPolicyConstants; import android.view.animation.Animation; import android.view.animation.AnimationUtils; +import androidx.annotation.IntDef; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; @@ -167,6 +168,8 @@ import com.android.wm.shell.keyguard.KeyguardTransitions; import dagger.Lazy; import java.io.PrintWriter; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.Arrays; import java.util.Objects; @@ -251,6 +254,22 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, private static final int SYSTEM_READY = 18; private static final int CANCEL_KEYGUARD_EXIT_ANIM = 19; + /** Enum for reasons behind updating wakeAndUnlock state. */ + @Retention(RetentionPolicy.SOURCE) + @IntDef( + value = { + WakeAndUnlockUpdateReason.HIDE, + WakeAndUnlockUpdateReason.SHOW, + WakeAndUnlockUpdateReason.FULFILL, + WakeAndUnlockUpdateReason.WAKE_AND_UNLOCK, + }) + @interface WakeAndUnlockUpdateReason { + int HIDE = 0; + int SHOW = 1; + int FULFILL = 2; + int WAKE_AND_UNLOCK = 3; + } + /** * The default amount of time we stay awake (used for all key input) */ @@ -812,7 +831,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, // dreaming. It's time to wake up. if (mUnlockingAndWakingFromDream) { Log.d(TAG, "waking from dream after unlock"); - mUnlockingAndWakingFromDream = false; + setUnlockAndWakeFromDream(false, WakeAndUnlockUpdateReason.FULFILL); if (mKeyguardStateController.isShowing()) { Log.d(TAG, "keyguard showing after keyguardGone, dismiss"); @@ -2654,7 +2673,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, mKeyguardExitAnimationRunner = null; mWakeAndUnlocking = false; - mUnlockingAndWakingFromDream = false; + setUnlockAndWakeFromDream(false, WakeAndUnlockUpdateReason.SHOW); setPendingLock(false); // Force if we we're showing in the middle of hiding, to ensure we end up in the correct @@ -2760,6 +2779,51 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, tryKeyguardDone(); }; + private void setUnlockAndWakeFromDream(boolean updatedValue, + @WakeAndUnlockUpdateReason int reason) { + if (updatedValue == mUnlockingAndWakingFromDream) { + return; + } + + final String reasonDescription; + + switch(reason) { + case WakeAndUnlockUpdateReason.FULFILL: + reasonDescription = "fulfilling existing request"; + break; + case WakeAndUnlockUpdateReason.HIDE: + reasonDescription = "hiding keyguard"; + break; + case WakeAndUnlockUpdateReason.SHOW: + reasonDescription = "showing keyguard"; + break; + case WakeAndUnlockUpdateReason.WAKE_AND_UNLOCK: + reasonDescription = "waking to unlock"; + break; + default: + throw new IllegalStateException("Unexpected value: " + reason); + } + + final boolean unsetUnfulfilled = !updatedValue + && reason != WakeAndUnlockUpdateReason.FULFILL; + + mUnlockingAndWakingFromDream = updatedValue; + + final String description; + + if (unsetUnfulfilled) { + description = "Interrupting request to wake and unlock"; + } else if (mUnlockingAndWakingFromDream) { + description = "Initiating request to wake and unlock"; + } else { + description = "Fulfilling request to wake and unlock"; + } + + Log.d(TAG, String.format( + "Updating waking and unlocking request to %b. description:[%s]. reason:[%s]", + mUnlockingAndWakingFromDream, description, reasonDescription)); + } + /** * Handle message sent by {@link #hideLocked()} * @see #HIDE @@ -2779,8 +2843,11 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, mHiding = true; - mUnlockingAndWakingFromDream = mStatusBarStateController.isDreaming() - && !mStatusBarStateController.isDozing(); + // If waking and unlocking, waking from dream has been set properly. + if (!mWakeAndUnlocking) { + setUnlockAndWakeFromDream(mStatusBarStateController.isDreaming() + && mPM.isInteractive(), WakeAndUnlockUpdateReason.HIDE); + } if ((mShowing && !mOccluded) || mUnlockingAndWakingFromDream) { if (mUnlockingAndWakingFromDream) { @@ -3282,9 +3349,14 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, } } - public void onWakeAndUnlocking() { + /** + * Informs the keyguard view mediator that the device is waking and unlocking. + * @param fromDream Whether waking and unlocking is happening over an interactive dream. + */ + public void onWakeAndUnlocking(boolean fromDream) { Trace.beginSection("KeyguardViewMediator#onWakeAndUnlocking"); mWakeAndUnlocking = true; + setUnlockAndWakeFromDream(fromDream, WakeAndUnlockUpdateReason.WAKE_AND_UNLOCK); mKeyguardViewControllerLazy.get().notifyKeyguardAuthenticated(/* primaryAuth */ false); userActivity(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java index ccb51898a333..ed11711f66c6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java @@ -463,7 +463,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp }; final boolean wakingFromDream = mMode == MODE_WAKE_AND_UNLOCK_FROM_DREAM - && !mStatusBarStateController.isDozing(); + && mPowerManager.isInteractive(); if (mMode != MODE_NONE && !wakingFromDream) { wakeUp.run(); @@ -501,7 +501,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp // later to awaken. } mNotificationShadeWindowController.setNotificationShadeFocusable(false); - mKeyguardViewMediator.onWakeAndUnlocking(); + mKeyguardViewMediator.onWakeAndUnlocking(wakingFromDream); Trace.endSection(); break; case MODE_ONLY_WAKE: 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 25ecf1a424e0..c42a6dc5b6f2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java @@ -1509,6 +1509,13 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump mColors.setSupportsDarkText( ColorUtils.calculateContrast(mColors.getMainColor(), Color.WHITE) > 4.5); } + + int surface = Utils.getColorAttr(mScrimBehind.getContext(), + com.android.internal.R.attr.materialColorSurface).getDefaultColor(); + for (ScrimState state : ScrimState.values()) { + state.setSurfaceColor(surface); + } + mNeedsDrawableColorUpdate = true; } 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 7b2028310a84..e3b65ab27f48 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java @@ -122,11 +122,19 @@ public enum ScrimState { @Override public void prepare(ScrimState previousState) { mBehindAlpha = mClipQsScrim ? 1 : mDefaultScrimAlpha; - mBehindTint = mClipQsScrim ? Color.BLACK : Color.TRANSPARENT; + mBehindTint = mClipQsScrim ? Color.BLACK : mSurfaceColor; mNotifAlpha = mClipQsScrim ? mDefaultScrimAlpha : 0; mNotifTint = Color.TRANSPARENT; mFrontAlpha = 0f; } + + @Override + public void setSurfaceColor(int surfaceColor) { + super.setSurfaceColor(surfaceColor); + if (!mClipQsScrim) { + mBehindTint = mSurfaceColor; + } + } }, /** @@ -295,6 +303,7 @@ public enum ScrimState { int mFrontTint = Color.TRANSPARENT; int mBehindTint = Color.TRANSPARENT; int mNotifTint = Color.TRANSPARENT; + int mSurfaceColor = Color.TRANSPARENT; boolean mAnimateChange = true; float mAodFrontScrimAlpha; @@ -409,6 +418,10 @@ public enum ScrimState { mDefaultScrimAlpha = defaultScrimAlpha; } + public void setSurfaceColor(int surfaceColor) { + mSurfaceColor = surfaceColor; + } + public void setWallpaperSupportsAmbientMode(boolean wallpaperSupportsAmbientMode) { mWallpaperSupportsAmbientMode = wallpaperSupportsAmbientMode; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowController.java b/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowController.java index bcf3b0cbfc86..24987abd7a85 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowController.java @@ -240,8 +240,10 @@ public class StatusBarWindowController { Insets.of(0, safeTouchRegionHeight, 0, 0)); } lp.providedInsets = new InsetsFrameProvider[] { - new InsetsFrameProvider(mInsetsSourceOwner, 0, statusBars()), - new InsetsFrameProvider(mInsetsSourceOwner, 0, tappableElement()), + new InsetsFrameProvider(mInsetsSourceOwner, 0, statusBars()) + .setInsetsSize(getInsets(height)), + new InsetsFrameProvider(mInsetsSourceOwner, 0, tappableElement()) + .setInsetsSize(getInsets(height)), gestureInsetsProvider }; return lp; @@ -306,12 +308,37 @@ public class StatusBarWindowController { mLpChanged.height = state.mIsLaunchAnimationRunning ? ViewGroup.LayoutParams.MATCH_PARENT : mBarHeight; for (int rot = Surface.ROTATION_0; rot <= Surface.ROTATION_270; rot++) { + int height = SystemBarUtils.getStatusBarHeightForRotation(mContext, rot); mLpChanged.paramsForRotation[rot].height = - state.mIsLaunchAnimationRunning ? ViewGroup.LayoutParams.MATCH_PARENT : - SystemBarUtils.getStatusBarHeightForRotation(mContext, rot); + state.mIsLaunchAnimationRunning ? ViewGroup.LayoutParams.MATCH_PARENT : height; + // The status bar height could change at runtime if one display has a cutout while + // another doesn't (like some foldables). It could also change when using debug cutouts. + // So, we need to re-fetch the height and re-apply it to the insets each time to avoid + // bugs like b/290300359. + InsetsFrameProvider[] providers = mLpChanged.paramsForRotation[rot].providedInsets; + if (providers != null) { + for (InsetsFrameProvider provider : providers) { + provider.setInsetsSize(getInsets(height)); + } + } } } + /** + * Get the insets that should be applied to the status bar window given the current status bar + * height. + * + * The status bar window height can sometimes be full-screen (see {@link #applyHeight(State)}. + * However, the status bar *insets* should *not* be full-screen, because this would prevent apps + * from drawing any content and can cause animations to be cancelled (see b/283958440). Instead, + * the status bar insets should always be equal to the space occupied by the actual status bar + * content -- setting the insets correctly will prevent window manager from unnecessarily + * re-drawing this window and other windows. This method provides the correct insets. + */ + private Insets getInsets(int height) { + return Insets.of(0, height, 0, 0); + } + private void apply(State state) { if (!mIsAttached) { return; diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java index 2fc3cf6af6b1..34ea91b94414 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java @@ -243,7 +243,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { TestableLooper.get(this).processAllMessages(); mViewMediator.onStartedGoingToSleep(OFF_BECAUSE_OF_USER); - mViewMediator.onWakeAndUnlocking(); + mViewMediator.onWakeAndUnlocking(false); mViewMediator.onStartedWakingUp(OFF_BECAUSE_OF_USER, false); TestableLooper.get(this).processAllMessages(); @@ -596,14 +596,14 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { @Test public void testWakeAndUnlocking() { - mViewMediator.onWakeAndUnlocking(); + mViewMediator.onWakeAndUnlocking(false); verify(mStatusBarKeyguardViewManager).notifyKeyguardAuthenticated(anyBoolean()); } @Test public void testWakeAndUnlockingOverDream() { // Send signal to wake - mViewMediator.onWakeAndUnlocking(); + mViewMediator.onWakeAndUnlocking(true); // Ensure not woken up yet verify(mPowerManager, never()).wakeUp(anyLong(), anyInt(), anyString()); @@ -632,7 +632,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { @Test public void testWakeAndUnlockingOverDream_signalAuthenticateIfStillShowing() { // Send signal to wake - mViewMediator.onWakeAndUnlocking(); + mViewMediator.onWakeAndUnlocking(true); // Ensure not woken up yet verify(mPowerManager, never()).wakeUp(anyLong(), anyInt(), anyString()); @@ -662,6 +662,35 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { } @Test + public void testWakeAndUnlockingOverNonInteractiveDream_noWakeByKeyguardViewMediator() { + // Send signal to wake + mViewMediator.onWakeAndUnlocking(false); + + // Ensure not woken up yet + verify(mPowerManager, never()).wakeUp(anyLong(), anyInt(), anyString()); + + // Verify keyguard told of authentication + verify(mStatusBarKeyguardViewManager).notifyKeyguardAuthenticated(anyBoolean()); + mViewMediator.mViewMediatorCallback.keyguardDonePending(true, + mUpdateMonitor.getCurrentUser()); + mViewMediator.mViewMediatorCallback.readyForKeyguardDone(); + final ArgumentCaptor<Runnable> animationRunnableCaptor = + ArgumentCaptor.forClass(Runnable.class); + verify(mStatusBarKeyguardViewManager).startPreHideAnimation( + animationRunnableCaptor.capture()); + + when(mStatusBarStateController.isDreaming()).thenReturn(true); + when(mStatusBarStateController.isDozing()).thenReturn(false); + animationRunnableCaptor.getValue().run(); + + when(mKeyguardStateController.isShowing()).thenReturn(false); + mViewMediator.mViewMediatorCallback.keyguardGone(); + + // Verify not woken up. + verify(mPowerManager, never()).wakeUp(anyLong(), anyInt(), anyString()); + } + + @Test @TestableLooper.RunWithLooper(setAsMainLooper = true) public void testDoKeyguardWhileInteractive_resets() { mViewMediator.setShowingLocked(true); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java index 4f8de3eacf7a..7acf398955fb 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java @@ -186,7 +186,7 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase { mBiometricUnlockController.onBiometricAuthenticated(UserHandle.USER_CURRENT, BiometricSourceType.FINGERPRINT, true /* isStrongBiometric */); - verify(mKeyguardViewMediator).onWakeAndUnlocking(); + verify(mKeyguardViewMediator).onWakeAndUnlocking(false); assertThat(mBiometricUnlockController.getMode()) .isEqualTo(BiometricUnlockController.MODE_WAKE_AND_UNLOCK_PULSING); } @@ -204,7 +204,7 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase { mBiometricUnlockController.onBiometricAuthenticated(UserHandle.USER_CURRENT, BiometricSourceType.FINGERPRINT, true /* isStrongBiometric */); - verify(mKeyguardViewMediator).onWakeAndUnlocking(); + verify(mKeyguardViewMediator).onWakeAndUnlocking(false); assertThat(mBiometricUnlockController.getMode()) .isEqualTo(MODE_WAKE_AND_UNLOCK); } @@ -553,8 +553,9 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase { when(mWakefulnessLifecycle.getLastWakeReason()) .thenReturn(PowerManager.WAKE_REASON_POWER_BUTTON); givenDreamingLocked(); + when(mPowerManager.isInteractive()).thenReturn(true); mBiometricUnlockController.startWakeAndUnlock(BiometricSourceType.FINGERPRINT, true); - verify(mKeyguardViewMediator).onWakeAndUnlocking(); + verify(mKeyguardViewMediator).onWakeAndUnlocking(true); // Ensure that the power hasn't been told to wake up yet. verify(mPowerManager, never()).wakeUp(anyLong(), anyInt(), anyString()); } 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 a9ed17531926..7fc02280354f 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 @@ -44,6 +44,9 @@ import static kotlinx.coroutines.flow.FlowKt.emptyFlow; import android.animation.Animator; import android.app.AlarmManager; +import android.content.Context; +import android.content.res.ColorStateList; +import android.content.res.TypedArray; import android.graphics.Color; import android.os.Handler; import android.testing.AndroidTestingRunner; @@ -121,6 +124,7 @@ public class ScrimControllerTest extends SysuiTestCase { private int mScrimVisibility; private boolean mAlwaysOnEnabled; private TestableLooper mLooper; + private Context mContext; @Mock private AlarmManager mAlarmManager; @Mock private DozeParameters mDozeParameters; @Mock private LightBarController mLightBarController; @@ -134,6 +138,7 @@ public class ScrimControllerTest extends SysuiTestCase { @Mock private PrimaryBouncerToGoneTransitionViewModel mPrimaryBouncerToGoneTransitionViewModel; @Mock private KeyguardTransitionInteractor mKeyguardTransitionInteractor; @Mock private CoroutineDispatcher mMainDispatcher; + @Mock private TypedArray mMockTypedArray; // TODO(b/204991468): Use a real PanelExpansionStateManager object once this bug is fixed. (The // event-dispatch-on-registration pattern caused some of these unit tests to fail.) @@ -182,10 +187,11 @@ public class ScrimControllerTest extends SysuiTestCase { mNumEnds = 0; mNumCancels = 0; } - }; + } private AnimatorListener mAnimatorListener = new AnimatorListener(); + private int mSurfaceColor = 0x112233; private void finishAnimationsImmediately() { // Execute code that will trigger animations. @@ -214,10 +220,17 @@ public class ScrimControllerTest extends SysuiTestCase { @Before public void setup() { MockitoAnnotations.initMocks(this); + mContext = spy(getContext()); + when(mContext.obtainStyledAttributes( + new int[]{com.android.internal.R.attr.materialColorSurface})) + .thenReturn(mMockTypedArray); + + when(mMockTypedArray.getColorStateList(anyInt())) + .thenAnswer((invocation) -> ColorStateList.valueOf(mSurfaceColor)); - mScrimBehind = spy(new ScrimView(getContext())); - mScrimInFront = new ScrimView(getContext()); - mNotificationsScrim = new ScrimView(getContext()); + mScrimBehind = spy(new ScrimView(mContext)); + mScrimInFront = new ScrimView(mContext); + mNotificationsScrim = new ScrimView(mContext); mAlwaysOnEnabled = true; mLooper = TestableLooper.get(this); DejankUtils.setImmediate(true); @@ -577,7 +590,7 @@ public class ScrimControllerTest extends SysuiTestCase { mScrimController.transitionTo(BOUNCER); finishAnimationsImmediately(); // Front scrim should be transparent - // Back scrim should be visible without tint + // Back scrim should be visible and tinted to the surface color assertScrimAlpha(Map.of( mScrimInFront, TRANSPARENT, mNotificationsScrim, TRANSPARENT, @@ -585,9 +598,31 @@ public class ScrimControllerTest extends SysuiTestCase { assertScrimTinted(Map.of( mScrimInFront, false, - mScrimBehind, false, + mScrimBehind, true, mNotificationsScrim, false )); + + assertScrimTint(mScrimBehind, mSurfaceColor); + } + + @Test + public void onThemeChange_bouncerBehindTint_isUpdatedToSurfaceColor() { + assertEquals(BOUNCER.getBehindTint(), 0x112233); + mSurfaceColor = 0x223344; + mConfigurationController.notifyThemeChanged(); + assertEquals(BOUNCER.getBehindTint(), 0x223344); + } + + @Test + public void onThemeChangeWhileClipQsScrim_bouncerBehindTint_remainsBlack() { + mScrimController.setClipsQsScrim(true); + mScrimController.transitionTo(BOUNCER); + finishAnimationsImmediately(); + + assertEquals(BOUNCER.getBehindTint(), Color.BLACK); + mSurfaceColor = 0x223344; + mConfigurationController.notifyThemeChanged(); + assertEquals(BOUNCER.getBehindTint(), Color.BLACK); } @Test @@ -619,16 +654,17 @@ public class ScrimControllerTest extends SysuiTestCase { finishAnimationsImmediately(); // Front scrim should be transparent - // Back scrim should be visible without tint + // Back scrim should be visible and has a tint of surfaceColor assertScrimAlpha(Map.of( mScrimInFront, TRANSPARENT, mNotificationsScrim, TRANSPARENT, mScrimBehind, OPAQUE)); assertScrimTinted(Map.of( mScrimInFront, false, - mScrimBehind, false, + mScrimBehind, true, mNotificationsScrim, false )); + assertScrimTint(mScrimBehind, mSurfaceColor); } @Test @@ -1809,6 +1845,13 @@ public class ScrimControllerTest extends SysuiTestCase { assertEquals(message, hasTint, scrim.getTint() != Color.TRANSPARENT); } + private void assertScrimTint(ScrimView scrim, int expectedTint) { + String message = "Tint test failed with expected scrim tint: " + + Integer.toHexString(expectedTint) + " and actual tint: " + + Integer.toHexString(scrim.getTint()) + " for scrim: " + getScrimName(scrim); + assertEquals(message, expectedTint, scrim.getTint(), 0.1); + } + private String getScrimName(ScrimView scrim) { if (scrim == mScrimInFront) { return "front"; diff --git a/services/core/java/com/android/server/biometrics/log/BiometricContextProvider.java b/services/core/java/com/android/server/biometrics/log/BiometricContextProvider.java index fc3d7c8114b0..745222873698 100644 --- a/services/core/java/com/android/server/biometrics/log/BiometricContextProvider.java +++ b/services/core/java/com/android/server/biometrics/log/BiometricContextProvider.java @@ -216,6 +216,10 @@ public final class BiometricContextProvider implements BiometricContext { public void subscribe(@NonNull OperationContextExt context, @NonNull Consumer<OperationContext> consumer) { mSubscribers.put(context, consumer); + // TODO(b/294161627) Combine the getContext/subscribe APIs to avoid race + if (context.getDisplayState() != getDisplayState()) { + consumer.accept(context.update(this, context.isCrypto()).toAidlContext()); + } } @Override diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index 95c953a5cf2d..a1a9a0877710 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -176,7 +176,7 @@ public class DisplayPolicy { // TODO(b/266197298): Remove this by a more general protocol from the insets providers. private static final boolean USE_CACHED_INSETS_FOR_DISPLAY_SWITCH = - SystemProperties.getBoolean("persist.wm.debug.cached_insets_switch", false); + SystemProperties.getBoolean("persist.wm.debug.cached_insets_switch", true); private final WindowManagerService mService; private final Context mContext; diff --git a/services/tests/servicestests/src/com/android/server/biometrics/log/BiometricContextProviderTest.java b/services/tests/servicestests/src/com/android/server/biometrics/log/BiometricContextProviderTest.java index a4423038a072..437510595ecb 100644 --- a/services/tests/servicestests/src/com/android/server/biometrics/log/BiometricContextProviderTest.java +++ b/services/tests/servicestests/src/com/android/server/biometrics/log/BiometricContextProviderTest.java @@ -252,6 +252,14 @@ public class BiometricContextProviderTest { } @Test + public void testSubscribesWithDifferentState() throws RemoteException { + final Consumer<OperationContext> nonEmptyConsumer = mock(Consumer.class); + mListener.onDisplayStateChanged(AuthenticateOptions.DISPLAY_STATE_AOD); + mProvider.subscribe(mOpContext, nonEmptyConsumer); + verify(nonEmptyConsumer).accept(same(mOpContext.toAidlContext())); + } + + @Test public void testUnsubscribes() throws RemoteException { final Consumer<OperationContext> emptyConsumer = mock(Consumer.class); mProvider.subscribe(mOpContext, emptyConsumer); @@ -259,6 +267,9 @@ public class BiometricContextProviderTest { mListener.onDisplayStateChanged(AuthenticateOptions.DISPLAY_STATE_AOD); + //reset to unknown to avoid trigger accept when subscribe + mListener.onDisplayStateChanged(AuthenticateOptions.DISPLAY_STATE_UNKNOWN); + final Consumer<OperationContext> nonEmptyConsumer = mock(Consumer.class); mProvider.subscribe(mOpContext, nonEmptyConsumer); mListener.onDisplayStateChanged(AuthenticateOptions.DISPLAY_STATE_LOCKSCREEN); |