diff options
3 files changed, 62 insertions, 7 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/widgets/CommunalTransitionAnimatorControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/widgets/CommunalTransitionAnimatorControllerTest.kt index ac50db483301..58459ae58129 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/widgets/CommunalTransitionAnimatorControllerTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/widgets/CommunalTransitionAnimatorControllerTest.kt @@ -14,13 +14,14 @@ * limitations under the License. */ +package com.android.systemui.communal.widgets + import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.animation.ActivityTransitionAnimator import com.android.systemui.communal.domain.interactor.communalSceneInteractor import com.android.systemui.communal.shared.model.CommunalScenes -import com.android.systemui.communal.widgets.CommunalTransitionAnimatorController import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.testScope import com.android.systemui.testKosmos diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/LegacyActivityStarterInternalImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/LegacyActivityStarterInternalImplTest.kt index d82b9dbfbae8..179799503ac0 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/LegacyActivityStarterInternalImplTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/LegacyActivityStarterInternalImplTest.kt @@ -147,6 +147,48 @@ class LegacyActivityStarterInternalImplTest : SysuiTestCase() { } @Test + fun startActivityDismissingKeyguard_dismissShadeWhenOccluded_runAfterKeyguardGone() { + val intent = mock(Intent::class.java) + `when`(keyguardStateController.isShowing).thenReturn(true) + `when`(keyguardStateController.isOccluded).thenReturn(true) + `when`(communalSceneInteractor.isCommunalVisible).thenReturn(MutableStateFlow(true)) + `when`(communalSettingsInteractor.isCommunalFlagEnabled()).thenReturn(false) + + underTest.startActivityDismissingKeyguard(intent, dismissShade = true) + mainExecutor.runAllReady() + + val actionCaptor = argumentCaptor<OnDismissAction>() + verify(statusBarKeyguardViewManager) + .dismissWithAction(actionCaptor.capture(), any(), anyBoolean(), eq(null)) + actionCaptor.firstValue.onDismiss() + mainExecutor.runAllReady() + + verify(statusBarKeyguardViewManager).addAfterKeyguardGoneRunnable(any()) + } + + @Test + fun startActivityDismissingKeyguard_dismissShadeWhenOccluded_runImmediately() { + val intent = mock(Intent::class.java) + `when`(keyguardStateController.isShowing).thenReturn(true) + `when`(keyguardStateController.isOccluded).thenReturn(true) + `when`(communalSceneInteractor.isCommunalVisible).thenReturn(MutableStateFlow(true)) + `when`(communalSettingsInteractor.isCommunalFlagEnabled()).thenReturn(true) + + underTest.startActivityDismissingKeyguard(intent, dismissShade = true) + mainExecutor.runAllReady() + + val actionCaptor = argumentCaptor<OnDismissAction>() + verify(statusBarKeyguardViewManager) + .dismissWithAction(actionCaptor.capture(), any(), anyBoolean(), eq(null)) + actionCaptor.firstValue.onDismiss() + mainExecutor.runAllReady() + + verify(statusBarKeyguardViewManager, never()).addAfterKeyguardGoneRunnable(any()) + verify(activityTransitionAnimator) + .startIntentWithAnimation(eq(null), eq(false), eq(null), eq(false), any()) + } + + @Test fun startPendingIntentDismissingKeyguard_keyguardShowing_dismissWithAction() { val pendingIntent = mock(PendingIntent::class.java) `when`(pendingIntent.isActivity).thenReturn(true) @@ -342,7 +384,6 @@ class LegacyActivityStarterInternalImplTest : SysuiTestCase() { ) } - @EnableFlags(Flags.FLAG_COMMUNAL_HUB) @Test fun startPendingIntentDismissingKeyguard_transitionAnimator_animateCommunal() { val parent = FrameLayout(context) @@ -389,7 +430,6 @@ class LegacyActivityStarterInternalImplTest : SysuiTestCase() { ) } - @DisableFlags(Flags.FLAG_COMMUNAL_HUB) @Test fun startPendingIntentDismissingKeyguard_transitionAnimator_doNotAnimateCommunal() { val parent = FrameLayout(context) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LegacyActivityStarterInternalImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LegacyActivityStarterInternalImpl.kt index e69a78fb14fd..eeffd7e0657b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LegacyActivityStarterInternalImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LegacyActivityStarterInternalImpl.kt @@ -208,10 +208,16 @@ constructor( val cancelRunnable = Runnable { callback?.onActivityStarted(ActivityManager.START_CANCELED) } - // Do not deferKeyguard when occluded because, when keyguard is occluded, - // we do not launch the activity until keyguard is done. + // Do not deferKeyguard when occluded because, when keyguard is occluded, we do not launch + // the activity until keyguard is done. The only exception is when we're on the Hub and want + // to dismiss the shade immediately, which means that another animation will take care of + // the transition. val occluded = (keyguardStateController.isShowing && keyguardStateController.isOccluded) - val deferred = !occluded + val dismissOnCommunal = + communalSettingsInteractor.isCommunalFlagEnabled() && + communalSceneInteractor.isCommunalVisible.value && + dismissShadeDirectly + val deferred = !occluded || dismissOnCommunal executeRunnableDismissingKeyguard( runnable, cancelRunnable, @@ -463,10 +469,18 @@ constructor( object : ActivityStarter.OnDismissAction { override fun onDismiss(): Boolean { if (runnable != null) { + // We don't wait for Keyguard to be gone if we're dismissing the shade + // immediately and we're on the Communal Hub. This is to make sure that the + // Hub -> Edit Mode transition is seamless. + val dismissOnCommunal = + communalSettingsInteractor.isCommunalFlagEnabled() && + communalSceneInteractor.isCommunalVisible.value && + dismissShade if ( keyguardStateController.isShowing && keyguardStateController.isOccluded && - !isCommunalWidgetLaunch() + !isCommunalWidgetLaunch() && + !dismissOnCommunal ) { statusBarKeyguardViewManagerLazy .get() |