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

Commit 0e2aecb6 authored by Gustav Sennton's avatar Gustav Sennton
Browse files

Add WindowingMode check to TransitionFilter.

Test: manual + ShellTransitionTests
Bug: 369966416
Flag: com.android.window.flags.enable_desktop_app_launch_transitions
Change-Id: Ied23e0830b1a7fa88468b38aea82f538ee53c7e6
parent b00c0520
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.window;

import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.view.WindowManager.TransitionType;

import android.annotation.IntDef;
@@ -189,6 +190,8 @@ public final class TransitionFilter implements Parcelable {
        public Boolean mCustomAnimation = null;
        public IBinder mTaskFragmentToken = null;

        public int mWindowingMode = WINDOWING_MODE_UNDEFINED;

        public Requirement() {
        }

@@ -206,6 +209,7 @@ public final class TransitionFilter implements Parcelable {
            final int customAnimRaw = in.readInt();
            mCustomAnimation = customAnimRaw == 0 ? null : Boolean.valueOf(customAnimRaw == 2);
            mTaskFragmentToken = in.readStrongBinder();
            mWindowingMode = in.readInt();
        }

        /** Go through changes and find if at-least one change matches this filter */
@@ -270,6 +274,12 @@ public final class TransitionFilter implements Parcelable {
                        continue;
                    }
                }
                if (mWindowingMode != WINDOWING_MODE_UNDEFINED) {
                    if (change.getTaskInfo() == null
                            || change.getTaskInfo().getWindowingMode() != mWindowingMode) {
                        continue;
                    }
                }
                return true;
            }
            return false;
@@ -322,6 +332,7 @@ public final class TransitionFilter implements Parcelable {
            int customAnimRaw = mCustomAnimation == null ? 0 : (mCustomAnimation ? 2 : 1);
            dest.writeInt(customAnimRaw);
            dest.writeStrongBinder(mTaskFragmentToken);
            dest.writeInt(mWindowingMode);
        }

        @NonNull
@@ -369,6 +380,8 @@ public final class TransitionFilter implements Parcelable {
            if (mTaskFragmentToken != null) {
                out.append(" taskFragmentToken=").append(mTaskFragmentToken);
            }
            out.append(" windowingMode="
                    + WindowConfiguration.windowingModeToString(mWindowingMode));
            out.append("}");
            return out.toString();
        }
+20 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.wm.shell.transition;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
@@ -362,6 +363,25 @@ public class ShellTransitionTests extends ShellTestCase {
        assertFalse(filter.matches(infoNoTaskFragmentToken));
    }

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

        final TransitionInfo fullscreenStd = new TransitionInfoBuilder(TRANSIT_OPEN)
                .addChange(TRANSIT_OPEN, createTaskInfo(
                        1, WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD)).build();
        assertFalse(filter.matches(fullscreenStd));

        final TransitionInfo freeformStd = new TransitionInfoBuilder(TRANSIT_OPEN)
                .addChange(TRANSIT_OPEN, createTaskInfo(
                        1, WINDOWING_MODE_FREEFORM, ACTIVITY_TYPE_STANDARD)).build();
        assertTrue(filter.matches(freeformStd));
    }

    @Test
    public void testTransitionFilterMultiRequirement() {
        // filter that requires at-least one opening and one closing app