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

Commit 46c7d4c3 authored by Evan Rosky's avatar Evan Rosky Committed by Android (Google) Code Review
Browse files

Merge "Add Transition filter support for animation-option presence" into main

parents 34df8bb9 ed104f28
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.view.WindowManager;

import com.android.window.flags.Flags;

/**
 * A parcelable filter that can be used for rerouting transitions to a remote. This is a local
 * representation so that the transition system doesn't need to make blocking queries over
@@ -183,6 +185,9 @@ public final class TransitionFilter implements Parcelable {
        public ComponentName mTopActivity;
        public IBinder mLaunchCookie;

        /** If non-null, requires the change to specifically have or not-have a custom animation. */
        public Boolean mCustomAnimation = null;

        public Requirement() {
        }

@@ -196,6 +201,9 @@ public final class TransitionFilter implements Parcelable {
            mOrder = in.readInt();
            mTopActivity = in.readTypedObject(ComponentName.CREATOR);
            mLaunchCookie = in.readStrongBinder();
            // 0: null, 1: false, 2: true
            final int customAnimRaw = in.readInt();
            mCustomAnimation = customAnimRaw == 0 ? null : Boolean.valueOf(customAnimRaw == 2);
        }

        /** Go through changes and find if at-least one change matches this filter */
@@ -237,6 +245,23 @@ public final class TransitionFilter implements Parcelable {
                if (!matchesCookie(change.getTaskInfo())) {
                    continue;
                }
                if (mCustomAnimation != null
                        // only applies to activity/task
                        && (change.getTaskInfo() != null
                                || change.getActivityComponent() != null)) {
                    final TransitionInfo.AnimationOptions opts =
                            Flags.moveAnimationOptionsToChange() ? change.getAnimationOptions()
                                    : info.getAnimationOptions();
                    if (opts != null) {
                        boolean canActuallyOverride = change.getTaskInfo() == null
                                || opts.getOverrideTaskTransition();
                        if (mCustomAnimation != canActuallyOverride) {
                            continue;
                        }
                    } else if (mCustomAnimation) {
                        continue;
                    }
                }
                return true;
            }
            return false;
@@ -286,6 +311,8 @@ public final class TransitionFilter implements Parcelable {
            dest.writeInt(mOrder);
            dest.writeTypedObject(mTopActivity, flags);
            dest.writeStrongBinder(mLaunchCookie);
            int customAnimRaw = mCustomAnimation == null ? 0 : (mCustomAnimation ? 2 : 1);
            dest.writeInt(customAnimRaw);
        }

        @NonNull
@@ -327,6 +354,9 @@ public final class TransitionFilter implements Parcelable {
            out.append(" order=" + containerOrderToString(mOrder));
            out.append(" topActivity=").append(mTopActivity);
            out.append(" launchCookie=").append(mLaunchCookie);
            if (mCustomAnimation != null) {
                out.append(" customAnim=").append(mCustomAnimation.booleanValue());
            }
            out.append("}");
            return out.toString();
        }
+21 −0
Original line number Diff line number Diff line
@@ -441,6 +441,27 @@ public class ShellTransitionTests extends ShellTestCase {
        assertTrue(filter.matches(openAct));
    }

    @Test
    public void testTransitionFilterAnimOverride() {
        TransitionFilter filter = new TransitionFilter();
        filter.mRequirements =
                new TransitionFilter.Requirement[]{new TransitionFilter.Requirement()};
        filter.mRequirements[0].mCustomAnimation = true;
        filter.mRequirements[0].mModes = new int[]{TRANSIT_OPEN, TRANSIT_TO_FRONT};

        final RunningTaskInfo taskInf = createTaskInfo(1);
        final TransitionInfo openTask = new TransitionInfoBuilder(TRANSIT_OPEN)
                .addChange(TRANSIT_OPEN, taskInf).build();
        assertFalse(filter.matches(openTask));

        final TransitionInfo.AnimationOptions overOpts =
                TransitionInfo.AnimationOptions.makeCustomAnimOptions("pakname", 0, 0, 0, true);
        final TransitionInfo openTaskOpts = new TransitionInfoBuilder(TRANSIT_OPEN)
                .addChange(TRANSIT_OPEN, taskInf).build();
        openTaskOpts.getChanges().get(0).setAnimationOptions(overOpts);
        assertTrue(filter.matches(openTaskOpts));
    }

    @Test
    public void testRegisteredRemoteTransition() {
        Transitions transitions = createTestTransitions();