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

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

Merge "Remove flicker from Communal widget launches." into main

parents 1628b043 2e145921
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.kosmos.testScope
import com.android.systemui.testKosmos
import com.google.common.truth.Truth
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.advanceTimeBy
import kotlinx.coroutines.test.runTest
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
@@ -35,6 +37,7 @@ import org.junit.runner.RunWith
import org.mockito.kotlin.mock
import org.mockito.kotlin.verify

@ExperimentalCoroutinesApi
@SmallTest
@RunWith(AndroidJUnit4::class)
class CommunalTransitionAnimatorControllerTest : SysuiTestCase() {
@@ -67,7 +70,7 @@ class CommunalTransitionAnimatorControllerTest : SysuiTestCase() {
    }

    @Test
    fun animationCancelled_launchingWidgetStateIsClearedAndSceneIsNotChanged() {
    fun animationCancelled_launchingWidgetStateIsCleared() {
        with(kosmos) {
            testScope.runTest {
                val launching by collectLastValue(communalSceneInteractor.isLaunchingWidget)
@@ -82,9 +85,12 @@ class CommunalTransitionAnimatorControllerTest : SysuiTestCase() {
                assertTrue(launching!!)
                verify(controller).onIntentStarted(willAnimate = true)

                underTest.onTransitionAnimationStart(isExpandingFullyAbove = true)
                assertTrue(launching!!)
                verify(controller).onTransitionAnimationStart(isExpandingFullyAbove = true)

                underTest.onTransitionAnimationCancelled(newKeyguardOccludedState = true)
                assertFalse(launching!!)
                Truth.assertThat(scene).isEqualTo(CommunalScenes.Communal)
                verify(controller).onTransitionAnimationCancelled(newKeyguardOccludedState = true)
            }
        }
@@ -106,6 +112,12 @@ class CommunalTransitionAnimatorControllerTest : SysuiTestCase() {
                assertTrue(launching!!)
                verify(controller).onIntentStarted(willAnimate = true)

                underTest.onTransitionAnimationStart(isExpandingFullyAbove = true)
                assertTrue(launching!!)
                verify(controller).onTransitionAnimationStart(isExpandingFullyAbove = true)

                testScope.advanceTimeBy(ActivityTransitionAnimator.TIMINGS.totalDuration)

                underTest.onTransitionAnimationEnd(isExpandingFullyAbove = true)
                assertFalse(launching!!)
                Truth.assertThat(scene).isEqualTo(CommunalScenes.Blank)
+9 −1
Original line number Diff line number Diff line
@@ -37,13 +37,21 @@ class CommunalTransitionAnimatorController(
        delegate.onIntentStarted(willAnimate)
    }

    override fun onTransitionAnimationStart(isExpandingFullyAbove: Boolean) {
        delegate.onTransitionAnimationStart(isExpandingFullyAbove)
        // TODO(b/330672236): move this to onTransitionAnimationEnd() without the delay.
        communalSceneInteractor.snapToScene(
            CommunalScenes.Blank,
            ActivityTransitionAnimator.TIMINGS.totalDuration
        )
    }

    override fun onTransitionAnimationCancelled(newKeyguardOccludedState: Boolean?) {
        communalSceneInteractor.setIsLaunchingWidget(false)
        delegate.onTransitionAnimationCancelled(newKeyguardOccludedState)
    }

    override fun onTransitionAnimationEnd(isExpandingFullyAbove: Boolean) {
        communalSceneInteractor.snapToScene(CommunalScenes.Blank)
        communalSceneInteractor.setIsLaunchingWidget(false)
        delegate.onTransitionAnimationEnd(isExpandingFullyAbove)
    }
+0 −7
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ import com.android.systemui.assist.AssistManager
import com.android.systemui.camera.CameraIntents
import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor
import com.android.systemui.communal.domain.interactor.CommunalSettingsInteractor
import com.android.systemui.communal.shared.model.CommunalScenes
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.DisplayId
import com.android.systemui.dagger.qualifiers.Main
@@ -576,12 +575,6 @@ constructor(

                override fun onTransitionAnimationStart(isExpandingFullyAbove: Boolean) {
                    super.onTransitionAnimationStart(isExpandingFullyAbove)
                    if (communalSettingsInteractor.isCommunalFlagEnabled()) {
                        communalSceneInteractor.snapToScene(
                            CommunalScenes.Blank,
                            ActivityTransitionAnimator.TIMINGS.totalDuration
                        )
                    }
                    // Double check that the keyguard is still showing and not going
                    // away, but if so set the keyguard occluded. Typically, WM will let
                    // KeyguardViewMediator know directly, but we're overriding that to