Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +9 −3 Original line number Diff line number Diff line Loading @@ -2790,6 +2790,9 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { || mKeyguardStateController.isKeyguardGoingAway() || mKeyguardViewMediator.requestedShowSurfaceBehindKeyguard() || mKeyguardViewMediator.isAnimatingBetweenKeyguardAndSurfaceBehind()); boolean dreaming = mKeyguardStateController.isShowing() && mKeyguardUpdateMonitor.isDreaming() && !unlocking; mScrimController.setExpansionAffectsAlpha(!unlocking); Loading Loading @@ -2834,13 +2837,16 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { // this as otherwise it can remain pending and leave keyguard in a weird state. mUnlockScrimCallback.onCancelled(); } else if (mIsIdleOnCommunal) { if (dreaming) { mScrimController.transitionTo(ScrimState.GLANCEABLE_HUB_OVER_DREAM); } else { mScrimController.transitionTo(ScrimState.GLANCEABLE_HUB); } } else if (mKeyguardStateController.isShowing() && !mKeyguardStateController.isOccluded() && !unlocking) { mScrimController.transitionTo(ScrimState.KEYGUARD); } else if (mKeyguardStateController.isShowing() && mKeyguardUpdateMonitor.isDreaming() && !unlocking) { } else if (dreaming) { mScrimController.transitionTo(ScrimState.DREAMING); } else { mScrimController.transitionTo(ScrimState.UNLOCKED, mUnlockScrimCallback); Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java +17 −3 Original line number Diff line number Diff line Loading @@ -536,6 +536,16 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump mAnimateChange = state.getAnimateChange(); mAnimationDuration = state.getAnimationDuration(); if (mState == ScrimState.GLANCEABLE_HUB_OVER_DREAM) { // When the device is docked while on GLANCEABLE_HUB, the dream starts underneath the // hub and the ScrimState transitions to GLANCEABLE_HUB_OVER_DREAM. To prevent the // scrims from flickering in during this transition, we set the panel expansion // fraction, which is 1 when idle on GLANCEABLE_HUB, to 0. This only occurs when the hub // is open because the hub lives in the same window as the shade, which is not visible // when transitioning from KEYGUARD to DREAMING. mPanelExpansionFraction = 0f; } applyState(); mScrimInFront.setBlendWithMainColor(state.shouldBlendWithMainColor()); Loading Loading @@ -738,6 +748,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump boolean relevantState = (mState == ScrimState.UNLOCKED || mState == ScrimState.KEYGUARD || mState == ScrimState.DREAMING || mState == ScrimState.GLANCEABLE_HUB_OVER_DREAM || mState == ScrimState.SHADE_LOCKED || mState == ScrimState.PULSING); if (!(relevantState && mExpansionAffectsAlpha) || mAnimatingPanelExpansionOnUnlock) { Loading Loading @@ -844,7 +855,8 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump return; } mBouncerHiddenFraction = bouncerHiddenAmount; if (mState == ScrimState.DREAMING || mState == ScrimState.GLANCEABLE_HUB) { if (mState == ScrimState.DREAMING || mState == ScrimState.GLANCEABLE_HUB || mState == ScrimState.GLANCEABLE_HUB_OVER_DREAM) { // The dreaming and glanceable hub states requires this for the scrim calculation, so we // should only trigger an update in those states. applyAndDispatchState(); Loading Loading @@ -926,7 +938,8 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump return; } if (mState == ScrimState.UNLOCKED || mState == ScrimState.DREAMING) { if (mState == ScrimState.UNLOCKED || mState == ScrimState.DREAMING || mState == ScrimState.GLANCEABLE_HUB_OVER_DREAM) { final boolean occluding = mOccludeAnimationPlaying || mState.mLaunchingAffordanceWithPreview; // Darken scrim as it's pulled down while unlocked. If we're unlocked but playing the Loading Loading @@ -954,8 +967,9 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump mInFrontAlpha = 0; } if (mState == ScrimState.DREAMING if ((mState == ScrimState.DREAMING || mState == ScrimState.GLANCEABLE_HUB_OVER_DREAM) && mBouncerHiddenFraction != KeyguardBouncerConstants.EXPANSION_HIDDEN) { // Bouncer is opening over dream or glanceable hub over dream. final float interpolatedFraction = BouncerPanelExpansionCalculator.aboutToShowBouncerProgress( mBouncerHiddenFraction); Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java +22 −3 Original line number Diff line number Diff line Loading @@ -299,9 +299,9 @@ public enum ScrimState { }, /** * Device is locked or on dream and user has swiped from the right edge to enter the glanceable * hub UI. From this state, the user can swipe from the left edge to go back to the lock screen * or dream, as well as swipe down for the notifications and up for the bouncer. * Device is on the lockscreen and user has swiped from the right edge to enter the glanceable * hub UI. From this state, the user can swipe from the left edge to go back to the lock screen, * as well as swipe down for the notifications and up for the bouncer. */ GLANCEABLE_HUB { @Override Loading @@ -310,6 +310,25 @@ public enum ScrimState { mBehindAlpha = 0; mNotifAlpha = 0; mFrontAlpha = 0; mFrontTint = Color.TRANSPARENT; mBehindTint = mBackgroundColor; mNotifTint = mClipQsScrim ? mBackgroundColor : Color.TRANSPARENT; } }, /** * Device is dreaming and user has swiped from the right edge to enter the glanceable hub UI. * From this state, the user can swipe from the left edge to go back to the dream, as well as * swipe down for the notifications and up for the bouncer. * * This is a separate state from {@link #GLANCEABLE_HUB} because the scrims behave differently * when the dream is running. */ GLANCEABLE_HUB_OVER_DREAM { @Override public void prepare(ScrimState previousState) { GLANCEABLE_HUB.prepare(previousState); } }; Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java +23 −0 Original line number Diff line number Diff line Loading @@ -858,6 +858,29 @@ public class CentralSurfacesImplTest extends SysuiTestCase { verify(mScrimController).transitionTo(eq(ScrimState.UNLOCKED), any()); } @Test public void testEnteringGlanceableHub_whenDreaming_updatesScrim() { when(mKeyguardStateController.isShowing()).thenReturn(true); when(mKeyguardStateController.isOccluded()).thenReturn(true); when(mKeyguardUpdateMonitor.isDreaming()).thenReturn(true); // Transition to the glanceable hub. mCommunalRepository.setTransitionState(flowOf(new ObservableTransitionState.Idle( CommunalScenes.Communal))); mTestScope.getTestScheduler().runCurrent(); // ScrimState also transitions. verify(mScrimController).transitionTo(ScrimState.GLANCEABLE_HUB_OVER_DREAM); // Transition away from the glanceable hub. mCommunalRepository.setTransitionState(flowOf(new ObservableTransitionState.Idle( CommunalScenes.Blank))); mTestScope.getTestScheduler().runCurrent(); // ScrimState goes back to UNLOCKED. verify(mScrimController).transitionTo(eq(ScrimState.DREAMING)); } @Test public void testShowKeyguardImplementation_setsState() { when(mLockscreenUserManager.getCurrentProfiles()).thenReturn(new SparseArray<>()); Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java +69 −1 Original line number Diff line number Diff line Loading @@ -793,6 +793,73 @@ public class ScrimControllerTest extends SysuiTestCase { mScrimBehind, TRANSPARENT)); } @Test public void transitionToHubOverDream() { mScrimController.setRawPanelExpansionFraction(0f); mScrimController.setBouncerHiddenFraction(KeyguardBouncerConstants.EXPANSION_HIDDEN); mScrimController.transitionTo(ScrimState.GLANCEABLE_HUB_OVER_DREAM); finishAnimationsImmediately(); // All scrims transparent on the hub. assertScrimAlpha(Map.of( mScrimInFront, TRANSPARENT, mNotificationsScrim, TRANSPARENT, mScrimBehind, TRANSPARENT)); } @Test public void openBouncerOnHubOverDream() { mScrimController.transitionTo(ScrimState.GLANCEABLE_HUB_OVER_DREAM); // Open the bouncer. mScrimController.setRawPanelExpansionFraction(0f); mScrimController.setBouncerHiddenFraction(KeyguardBouncerConstants.EXPANSION_VISIBLE); finishAnimationsImmediately(); // Only behind widget is visible. assertScrimAlpha(Map.of( mScrimInFront, TRANSPARENT, mNotificationsScrim, TRANSPARENT, mScrimBehind, OPAQUE)); // Bouncer is closed. mScrimController.setBouncerHiddenFraction(KeyguardBouncerConstants.EXPANSION_HIDDEN); mScrimController.transitionTo(ScrimState.GLANCEABLE_HUB_OVER_DREAM); finishAnimationsImmediately(); // All scrims are transparent. assertScrimAlpha(Map.of( mScrimInFront, TRANSPARENT, mNotificationsScrim, TRANSPARENT, mScrimBehind, TRANSPARENT)); } @Test public void openShadeOnHubOverDream() { mScrimController.transitionTo(ScrimState.GLANCEABLE_HUB_OVER_DREAM); // Open the shade. mScrimController.transitionTo(SHADE_LOCKED); mScrimController.setQsPosition(1f, 0); mScrimController.setRawPanelExpansionFraction(1f); finishAnimationsImmediately(); // Shade scrims are visible. assertScrimAlpha(Map.of( mNotificationsScrim, OPAQUE, mScrimInFront, TRANSPARENT, mScrimBehind, OPAQUE)); mScrimController.transitionTo(ScrimState.GLANCEABLE_HUB_OVER_DREAM); finishAnimationsImmediately(); // All scrims are transparent. assertScrimAlpha(Map.of( mScrimInFront, TRANSPARENT, mNotificationsScrim, TRANSPARENT, mScrimBehind, TRANSPARENT)); } @Test public void onThemeChange_bouncerBehindTint_isUpdatedToSurfaceColor() { assertEquals(BOUNCER.getBehindTint(), 0x112233); Loading Loading @@ -1432,7 +1499,8 @@ public class ScrimControllerTest extends SysuiTestCase { 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.AUTH_SCRIMMED_SHADE, ScrimState.GLANCEABLE_HUB, ScrimState.GLANCEABLE_HUB_OVER_DREAM)); for (ScrimState state : ScrimState.values()) { if (!lowPowerModeStates.contains(state) && !regularStates.contains(state)) { Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +9 −3 Original line number Diff line number Diff line Loading @@ -2790,6 +2790,9 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { || mKeyguardStateController.isKeyguardGoingAway() || mKeyguardViewMediator.requestedShowSurfaceBehindKeyguard() || mKeyguardViewMediator.isAnimatingBetweenKeyguardAndSurfaceBehind()); boolean dreaming = mKeyguardStateController.isShowing() && mKeyguardUpdateMonitor.isDreaming() && !unlocking; mScrimController.setExpansionAffectsAlpha(!unlocking); Loading Loading @@ -2834,13 +2837,16 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { // this as otherwise it can remain pending and leave keyguard in a weird state. mUnlockScrimCallback.onCancelled(); } else if (mIsIdleOnCommunal) { if (dreaming) { mScrimController.transitionTo(ScrimState.GLANCEABLE_HUB_OVER_DREAM); } else { mScrimController.transitionTo(ScrimState.GLANCEABLE_HUB); } } else if (mKeyguardStateController.isShowing() && !mKeyguardStateController.isOccluded() && !unlocking) { mScrimController.transitionTo(ScrimState.KEYGUARD); } else if (mKeyguardStateController.isShowing() && mKeyguardUpdateMonitor.isDreaming() && !unlocking) { } else if (dreaming) { mScrimController.transitionTo(ScrimState.DREAMING); } else { mScrimController.transitionTo(ScrimState.UNLOCKED, mUnlockScrimCallback); Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java +17 −3 Original line number Diff line number Diff line Loading @@ -536,6 +536,16 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump mAnimateChange = state.getAnimateChange(); mAnimationDuration = state.getAnimationDuration(); if (mState == ScrimState.GLANCEABLE_HUB_OVER_DREAM) { // When the device is docked while on GLANCEABLE_HUB, the dream starts underneath the // hub and the ScrimState transitions to GLANCEABLE_HUB_OVER_DREAM. To prevent the // scrims from flickering in during this transition, we set the panel expansion // fraction, which is 1 when idle on GLANCEABLE_HUB, to 0. This only occurs when the hub // is open because the hub lives in the same window as the shade, which is not visible // when transitioning from KEYGUARD to DREAMING. mPanelExpansionFraction = 0f; } applyState(); mScrimInFront.setBlendWithMainColor(state.shouldBlendWithMainColor()); Loading Loading @@ -738,6 +748,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump boolean relevantState = (mState == ScrimState.UNLOCKED || mState == ScrimState.KEYGUARD || mState == ScrimState.DREAMING || mState == ScrimState.GLANCEABLE_HUB_OVER_DREAM || mState == ScrimState.SHADE_LOCKED || mState == ScrimState.PULSING); if (!(relevantState && mExpansionAffectsAlpha) || mAnimatingPanelExpansionOnUnlock) { Loading Loading @@ -844,7 +855,8 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump return; } mBouncerHiddenFraction = bouncerHiddenAmount; if (mState == ScrimState.DREAMING || mState == ScrimState.GLANCEABLE_HUB) { if (mState == ScrimState.DREAMING || mState == ScrimState.GLANCEABLE_HUB || mState == ScrimState.GLANCEABLE_HUB_OVER_DREAM) { // The dreaming and glanceable hub states requires this for the scrim calculation, so we // should only trigger an update in those states. applyAndDispatchState(); Loading Loading @@ -926,7 +938,8 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump return; } if (mState == ScrimState.UNLOCKED || mState == ScrimState.DREAMING) { if (mState == ScrimState.UNLOCKED || mState == ScrimState.DREAMING || mState == ScrimState.GLANCEABLE_HUB_OVER_DREAM) { final boolean occluding = mOccludeAnimationPlaying || mState.mLaunchingAffordanceWithPreview; // Darken scrim as it's pulled down while unlocked. If we're unlocked but playing the Loading Loading @@ -954,8 +967,9 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump mInFrontAlpha = 0; } if (mState == ScrimState.DREAMING if ((mState == ScrimState.DREAMING || mState == ScrimState.GLANCEABLE_HUB_OVER_DREAM) && mBouncerHiddenFraction != KeyguardBouncerConstants.EXPANSION_HIDDEN) { // Bouncer is opening over dream or glanceable hub over dream. final float interpolatedFraction = BouncerPanelExpansionCalculator.aboutToShowBouncerProgress( mBouncerHiddenFraction); Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java +22 −3 Original line number Diff line number Diff line Loading @@ -299,9 +299,9 @@ public enum ScrimState { }, /** * Device is locked or on dream and user has swiped from the right edge to enter the glanceable * hub UI. From this state, the user can swipe from the left edge to go back to the lock screen * or dream, as well as swipe down for the notifications and up for the bouncer. * Device is on the lockscreen and user has swiped from the right edge to enter the glanceable * hub UI. From this state, the user can swipe from the left edge to go back to the lock screen, * as well as swipe down for the notifications and up for the bouncer. */ GLANCEABLE_HUB { @Override Loading @@ -310,6 +310,25 @@ public enum ScrimState { mBehindAlpha = 0; mNotifAlpha = 0; mFrontAlpha = 0; mFrontTint = Color.TRANSPARENT; mBehindTint = mBackgroundColor; mNotifTint = mClipQsScrim ? mBackgroundColor : Color.TRANSPARENT; } }, /** * Device is dreaming and user has swiped from the right edge to enter the glanceable hub UI. * From this state, the user can swipe from the left edge to go back to the dream, as well as * swipe down for the notifications and up for the bouncer. * * This is a separate state from {@link #GLANCEABLE_HUB} because the scrims behave differently * when the dream is running. */ GLANCEABLE_HUB_OVER_DREAM { @Override public void prepare(ScrimState previousState) { GLANCEABLE_HUB.prepare(previousState); } }; Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java +23 −0 Original line number Diff line number Diff line Loading @@ -858,6 +858,29 @@ public class CentralSurfacesImplTest extends SysuiTestCase { verify(mScrimController).transitionTo(eq(ScrimState.UNLOCKED), any()); } @Test public void testEnteringGlanceableHub_whenDreaming_updatesScrim() { when(mKeyguardStateController.isShowing()).thenReturn(true); when(mKeyguardStateController.isOccluded()).thenReturn(true); when(mKeyguardUpdateMonitor.isDreaming()).thenReturn(true); // Transition to the glanceable hub. mCommunalRepository.setTransitionState(flowOf(new ObservableTransitionState.Idle( CommunalScenes.Communal))); mTestScope.getTestScheduler().runCurrent(); // ScrimState also transitions. verify(mScrimController).transitionTo(ScrimState.GLANCEABLE_HUB_OVER_DREAM); // Transition away from the glanceable hub. mCommunalRepository.setTransitionState(flowOf(new ObservableTransitionState.Idle( CommunalScenes.Blank))); mTestScope.getTestScheduler().runCurrent(); // ScrimState goes back to UNLOCKED. verify(mScrimController).transitionTo(eq(ScrimState.DREAMING)); } @Test public void testShowKeyguardImplementation_setsState() { when(mLockscreenUserManager.getCurrentProfiles()).thenReturn(new SparseArray<>()); Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java +69 −1 Original line number Diff line number Diff line Loading @@ -793,6 +793,73 @@ public class ScrimControllerTest extends SysuiTestCase { mScrimBehind, TRANSPARENT)); } @Test public void transitionToHubOverDream() { mScrimController.setRawPanelExpansionFraction(0f); mScrimController.setBouncerHiddenFraction(KeyguardBouncerConstants.EXPANSION_HIDDEN); mScrimController.transitionTo(ScrimState.GLANCEABLE_HUB_OVER_DREAM); finishAnimationsImmediately(); // All scrims transparent on the hub. assertScrimAlpha(Map.of( mScrimInFront, TRANSPARENT, mNotificationsScrim, TRANSPARENT, mScrimBehind, TRANSPARENT)); } @Test public void openBouncerOnHubOverDream() { mScrimController.transitionTo(ScrimState.GLANCEABLE_HUB_OVER_DREAM); // Open the bouncer. mScrimController.setRawPanelExpansionFraction(0f); mScrimController.setBouncerHiddenFraction(KeyguardBouncerConstants.EXPANSION_VISIBLE); finishAnimationsImmediately(); // Only behind widget is visible. assertScrimAlpha(Map.of( mScrimInFront, TRANSPARENT, mNotificationsScrim, TRANSPARENT, mScrimBehind, OPAQUE)); // Bouncer is closed. mScrimController.setBouncerHiddenFraction(KeyguardBouncerConstants.EXPANSION_HIDDEN); mScrimController.transitionTo(ScrimState.GLANCEABLE_HUB_OVER_DREAM); finishAnimationsImmediately(); // All scrims are transparent. assertScrimAlpha(Map.of( mScrimInFront, TRANSPARENT, mNotificationsScrim, TRANSPARENT, mScrimBehind, TRANSPARENT)); } @Test public void openShadeOnHubOverDream() { mScrimController.transitionTo(ScrimState.GLANCEABLE_HUB_OVER_DREAM); // Open the shade. mScrimController.transitionTo(SHADE_LOCKED); mScrimController.setQsPosition(1f, 0); mScrimController.setRawPanelExpansionFraction(1f); finishAnimationsImmediately(); // Shade scrims are visible. assertScrimAlpha(Map.of( mNotificationsScrim, OPAQUE, mScrimInFront, TRANSPARENT, mScrimBehind, OPAQUE)); mScrimController.transitionTo(ScrimState.GLANCEABLE_HUB_OVER_DREAM); finishAnimationsImmediately(); // All scrims are transparent. assertScrimAlpha(Map.of( mScrimInFront, TRANSPARENT, mNotificationsScrim, TRANSPARENT, mScrimBehind, TRANSPARENT)); } @Test public void onThemeChange_bouncerBehindTint_isUpdatedToSurfaceColor() { assertEquals(BOUNCER.getBehindTint(), 0x112233); Loading Loading @@ -1432,7 +1499,8 @@ public class ScrimControllerTest extends SysuiTestCase { 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.AUTH_SCRIMMED_SHADE, ScrimState.GLANCEABLE_HUB, ScrimState.GLANCEABLE_HUB_OVER_DREAM)); for (ScrimState state : ScrimState.values()) { if (!lowPowerModeStates.contains(state) && !regularStates.contains(state)) { Loading