Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 44d69cbf authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix transition from Communal Hub to Edit mode." into main

parents 0be63b70 fef19173
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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
+42 −2
Original line number Diff line number Diff line
@@ -146,6 +146,48 @@ class LegacyActivityStarterInternalImplTest : SysuiTestCase() {
        `when`(communalSceneInteractor.isLaunchingWidget).thenReturn(MutableStateFlow(false))
    }

    @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)
@@ -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)
+18 −4
Original line number Diff line number Diff line
@@ -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()