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

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

Merge "Add WindowingMode check to TransitionFilter." into main

parents 58786083 0e2aecb6
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