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

Commit e540f37e authored by Luca Zuccarini's avatar Luca Zuccarini Committed by Android (Google) Code Review
Browse files

Merge "Split the return animation framework flag into two." into main

parents 45e22250 cee82101
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

package com.android.wm.shell.transition;

import static com.android.systemui.shared.Flags.returnAnimationFrameworkLibrary;
import static com.android.systemui.shared.Flags.returnAnimationFrameworkLongLived;

import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -257,7 +257,7 @@ public class RemoteTransitionHandler implements Transitions.TransitionHandler {
    @Override
    public Transitions.TransitionHandler getHandlerForTakeover(
            @NonNull IBinder transition, @NonNull TransitionInfo info) {
        if (!returnAnimationFrameworkLibrary()) {
        if (!returnAnimationFrameworkLongLived()) {
            return null;
        }

+2 −2
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ import static android.window.TransitionInfo.FLAG_IS_WALLPAPER;
import static android.window.TransitionInfo.FLAG_NO_ANIMATION;
import static android.window.TransitionInfo.FLAG_STARTING_WINDOW_TRANSFER_RECIPIENT;

import static com.android.systemui.shared.Flags.returnAnimationFrameworkLibrary;
import static com.android.systemui.shared.Flags.returnAnimationFrameworkLongLived;
import static com.android.window.flags.Flags.ensureWallpaperInTransitions;
import static com.android.window.flags.Flags.migratePredictiveBackTransition;
import static com.android.wm.shell.shared.ShellSharedConstants.KEY_EXTRA_SHELL_SHELL_TRANSITIONS;
@@ -1252,7 +1252,7 @@ public class Transitions implements RemoteCallable<Transitions>,
    @Nullable
    public TransitionHandler getHandlerForTakeover(
            @NonNull IBinder transition, @NonNull TransitionInfo info) {
        if (!returnAnimationFrameworkLibrary()) {
        if (!returnAnimationFrameworkLongLived()) {
            ProtoLog.v(ShellProtoLogGroup.WM_SHELL_RECENTS_TRANSITION,
                    "Trying to get a handler for takeover but the flag is disabled");
            return null;
+2 −2
Original line number Diff line number Diff line
@@ -557,7 +557,7 @@ public class ShellTransitionTests extends ShellTestCase {
        mMainExecutor.flushAll();

        // Takeover shouldn't happen when the flag is disabled.
        setFlagsRule.disableFlags(Flags.FLAG_RETURN_ANIMATION_FRAMEWORK_LIBRARY);
        setFlagsRule.disableFlags(Flags.FLAG_RETURN_ANIMATION_FRAMEWORK_LONG_LIVED);
        IBinder transitToken = new Binder();
        transitions.requestStartTransition(transitToken,
                new TransitionRequestInfo(TRANSIT_OPEN, null /* trigger */, null /* remote */));
@@ -572,7 +572,7 @@ public class ShellTransitionTests extends ShellTestCase {
        verify(mOrganizer, times(1)).finishTransition(eq(transitToken), any());

        // Takeover should happen when the flag is enabled.
        setFlagsRule.enableFlags(Flags.FLAG_RETURN_ANIMATION_FRAMEWORK_LIBRARY);
        setFlagsRule.enableFlags(Flags.FLAG_RETURN_ANIMATION_FRAMEWORK_LONG_LIVED);
        transitions.requestStartTransition(transitToken,
                new TransitionRequestInfo(TRANSIT_OPEN, null /* trigger */, null /* remote */));
        info = new TransitionInfoBuilder(TRANSIT_OPEN)
+3 −2
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ import com.android.systemui.Flags.activityTransitionUseLargestWindow
import com.android.systemui.Flags.translucentOccludingActivityFix
import com.android.systemui.animation.TransitionAnimator.Companion.toTransitionState
import com.android.systemui.shared.Flags.returnAnimationFrameworkLibrary
import com.android.systemui.shared.Flags.returnAnimationFrameworkLongLived
import com.android.wm.shell.shared.IShellTransitions
import com.android.wm.shell.shared.ShellTransitions
import java.util.concurrent.Executor
@@ -607,8 +608,8 @@ constructor(
     * this registration.
     */
    fun register(controller: Controller) {
        check(returnAnimationFrameworkLibrary()) {
            "Long-lived registrations cannot be used when the returnAnimationFrameworkLibrary " +
        check(returnAnimationFrameworkLongLived()) {
            "Long-lived registrations cannot be used when the returnAnimationFrameworkLongLived " +
                "flag is disabled"
        }

+23 −16
Original line number Diff line number Diff line
@@ -8,7 +8,8 @@ import android.content.pm.ApplicationInfo
import android.graphics.Point
import android.graphics.Rect
import android.os.Looper
import android.platform.test.flag.junit.SetFlagsRule
import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
import android.testing.TestableLooper.RunWithLooper
import android.view.IRemoteAnimationFinishedCallback
import android.view.RemoteAnimationAdapter
@@ -63,7 +64,6 @@ class ActivityTransitionAnimatorTest : SysuiTestCase() {

    private lateinit var activityTransitionAnimator: ActivityTransitionAnimator
    @get:Rule val rule = MockitoJUnit.rule()
    @get:Rule val setFlagsRule = SetFlagsRule()

    @Before
    fun setup() {
@@ -90,7 +90,7 @@ class ActivityTransitionAnimatorTest : SysuiTestCase() {
        animator: ActivityTransitionAnimator = this.activityTransitionAnimator,
        controller: ActivityTransitionAnimator.Controller? = this.controller,
        animate: Boolean = true,
        intentStarter: (RemoteAnimationAdapter?) -> Int
        intentStarter: (RemoteAnimationAdapter?) -> Int,
    ) {
        // We start in a new thread so that we can ensure that the callbacks are called in the main
        // thread.
@@ -98,7 +98,7 @@ class ActivityTransitionAnimatorTest : SysuiTestCase() {
                animator.startIntentWithAnimation(
                    controller = controller,
                    animate = animate,
                    intentStarter = intentStarter
                    intentStarter = intentStarter,
                )
            }
            .join()
@@ -175,9 +175,9 @@ class ActivityTransitionAnimatorTest : SysuiTestCase() {
        assertFalse(willAnimateCaptor.value)
    }

    @EnableFlags(Flags.FLAG_RETURN_ANIMATION_FRAMEWORK_LIBRARY)
    @Test
    fun registersReturnIffCookieIsPresent() {
        setFlagsRule.enableFlags(Flags.FLAG_RETURN_ANIMATION_FRAMEWORK_LIBRARY)
        `when`(callback.isOnKeyguard()).thenReturn(false)

        startIntentWithAnimation(activityTransitionAnimator, controller) { _ ->
@@ -203,10 +203,12 @@ class ActivityTransitionAnimatorTest : SysuiTestCase() {
        assertTrue(testShellTransitions.remotesForTakeover.isEmpty())
    }

    @EnableFlags(
        Flags.FLAG_RETURN_ANIMATION_FRAMEWORK_LIBRARY,
        Flags.FLAG_RETURN_ANIMATION_FRAMEWORK_LONG_LIVED,
    )
    @Test
    fun registersLongLivedTransition() {
        setFlagsRule.enableFlags(Flags.FLAG_RETURN_ANIMATION_FRAMEWORK_LIBRARY)

        activityTransitionAnimator.register(
            object : DelegateTransitionAnimatorController(controller) {
                override val transitionCookie =
@@ -226,10 +228,12 @@ class ActivityTransitionAnimatorTest : SysuiTestCase() {
        assertEquals(4, testShellTransitions.remotes.size)
    }

    @EnableFlags(
        Flags.FLAG_RETURN_ANIMATION_FRAMEWORK_LIBRARY,
        Flags.FLAG_RETURN_ANIMATION_FRAMEWORK_LONG_LIVED,
    )
    @Test
    fun registersLongLivedTransitionOverridingPreviousRegistration() {
        setFlagsRule.enableFlags(Flags.FLAG_RETURN_ANIMATION_FRAMEWORK_LIBRARY)

        val cookie = ActivityTransitionAnimator.TransitionCookie("test_cookie")
        activityTransitionAnimator.register(
            object : DelegateTransitionAnimatorController(controller) {
@@ -251,9 +255,9 @@ class ActivityTransitionAnimatorTest : SysuiTestCase() {
        }
    }

    @DisableFlags(Flags.FLAG_RETURN_ANIMATION_FRAMEWORK_LONG_LIVED)
    @Test
    fun doesNotRegisterLongLivedTransitionIfFlagIsDisabled() {
        setFlagsRule.disableFlags(Flags.FLAG_RETURN_ANIMATION_FRAMEWORK_LIBRARY)

        val controller =
            object : DelegateTransitionAnimatorController(controller) {
@@ -266,9 +270,9 @@ class ActivityTransitionAnimatorTest : SysuiTestCase() {
        }
    }

    @EnableFlags(Flags.FLAG_RETURN_ANIMATION_FRAMEWORK_LONG_LIVED)
    @Test
    fun doesNotRegisterLongLivedTransitionIfMissingRequiredProperties() {
        setFlagsRule.enableFlags(Flags.FLAG_RETURN_ANIMATION_FRAMEWORK_LIBRARY)

        // No TransitionCookie
        val controllerWithoutCookie =
@@ -310,9 +314,12 @@ class ActivityTransitionAnimatorTest : SysuiTestCase() {
        }
    }

    @EnableFlags(
        Flags.FLAG_RETURN_ANIMATION_FRAMEWORK_LIBRARY,
        Flags.FLAG_RETURN_ANIMATION_FRAMEWORK_LONG_LIVED,
    )
    @Test
    fun unregistersLongLivedTransition() {
        setFlagsRule.enableFlags(Flags.FLAG_RETURN_ANIMATION_FRAMEWORK_LIBRARY)

        val cookies = arrayOfNulls<ActivityTransitionAnimator.TransitionCookie>(3)

@@ -411,7 +418,7 @@ class ActivityTransitionAnimatorTest : SysuiTestCase() {
            SurfaceControl(),
            Rect(),
            taskInfo,
            false
            false,
        )
    }
}
@@ -430,7 +437,7 @@ private class FakeShellTransitions : ShellTransitions {

    override fun registerRemoteForTakeover(
        filter: TransitionFilter,
        remoteTransition: RemoteTransition
        remoteTransition: RemoteTransition,
    ) {
        remotesForTakeover[filter] = remoteTransition
    }
@@ -460,7 +467,7 @@ private class TestTransitionAnimatorController(override var transitionContainer:
            left = 300,
            right = 400,
            topCornerRadius = 10f,
            bottomCornerRadius = 20f
            bottomCornerRadius = 20f,
        )

    private fun assertOnMainThread() {
@@ -480,7 +487,7 @@ private class TestTransitionAnimatorController(override var transitionContainer:
    override fun onTransitionAnimationProgress(
        state: TransitionAnimator.State,
        progress: Float,
        linearProgress: Float
        linearProgress: Float,
    ) {
        assertOnMainThread()
    }