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

Commit 82a40c69 authored by Bartosz Chomiński's avatar Bartosz Chomiński Committed by Android (Google) Code Review
Browse files

Merge "Add fields related to self-movability to WindowContainer" into main

parents dae32f36 4c92aa6e
Loading
Loading
Loading
Loading
+41 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.app;
import static android.app.ActivityTaskManager.INVALID_TASK_ID;
import static android.window.DisplayAreaOrganizer.FEATURE_UNDEFINED;

import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.TestApi;
@@ -53,6 +54,46 @@ public class TaskInfo {
     */
    public static final int PROPERTY_VALUE_UNSET = -1;

    /**
     * Self-movable state is not set.
     *
     * @hide
     */
    public static final int SELF_MOVABLE_UNSET = -1;

    /**
     * Self-movable state is not defined. WM core uses freeform windowing mode to decide.
     *
     * @hide
     */
    public static final int SELF_MOVABLE_DEFAULT = 0;

    /**
     * Self-moving is allowed. Note that there are permission checks in addition to this flag for
     * apps calling {@link android.app.ActivityManager.AppTask#moveTaskToFront}.
     *
     * @hide
     */
    public static final int SELF_MOVABLE_ALLOWED = 1;

    /**
     * Self-moving is denied.
     *
     * @hide
     */
    public static final int SELF_MOVABLE_DENIED = 2;

    /** @hide */
    @IntDef(
            prefix = {"SELF_MOVABLE_"},
            value = {
                SELF_MOVABLE_UNSET,
                SELF_MOVABLE_DEFAULT,
                SELF_MOVABLE_ALLOWED,
                SELF_MOVABLE_DENIED,
            })
    public @interface SelfMovable {}

    /**
     * The id of the user the task was running as if this is a leaf task. The id of the current
     * running user of the system otherwise.
+77 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.window;

import static android.app.Instrumentation.DEBUG_START_ACTIVITY;
import static android.app.TaskInfo.SELF_MOVABLE_UNSET;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.window.TaskFragmentOperation.OP_TYPE_CLEAR_ADJACENT_TASK_FRAGMENTS;
import static android.window.TaskFragmentOperation.OP_TYPE_CREATE_TASK_FRAGMENT;
@@ -35,6 +36,7 @@ import android.annotation.SuppressLint;
import android.annotation.TestApi;
import android.app.Instrumentation;
import android.app.PendingIntent;
import android.app.TaskInfo.SelfMovable;
import android.app.WindowConfiguration;
import android.app.WindowConfiguration.WindowingMode;
import android.content.Intent;
@@ -518,6 +520,47 @@ public final class WindowContainerTransaction implements Parcelable {
        return this;
    }

    /**
     * Sets whether the given container can be repositioned by {@link
     * android.app.ActivityManager.AppTask#moveTaskTo}.
     * Note that there are additional permission checks for the caller of {@link
     * android.app.ActivityManager.AppTask#moveTaskTo}.
     *
     * @param container The window container of the task that the self-movable state is set on.
     * @param selfMovable {@link android.app.TaskInfo#SELF_MOVABLE_ALLOWED} or {@link
     *     android.app.TaskInfo#SELF_MOVABLE_DENIED} to set the task as self-movable or not, {@link
     *     android.app.TaskInfo#SELF_MOVABLE_DEFAULT} to let the WM Core decide.
     * @hide
     */
    @NonNull
    public WindowContainerTransaction setSelfMovable(
            @NonNull WindowContainerToken container, @SelfMovable int selfMovable) {
        final Change change = getOrCreateChange(container.asBinder());
        change.mSelfMovable = selfMovable;
        return this;
    }

    /**
     * Sets whether the given container is able to contain self-movable tasks. A display is
     * considered able to contain self-movable tasks as long as there is one child window container
     * that is able to contain self-movable tasks.
     *
     * <p>Initially after each boot-up no window containers can contain self-movable tasks.
     *
     * @param container The window container whose ability to contain self-movable tasks is set on.
     * @param isTaskMoveAllowed {@code true} to allow containing self-movable tasks, {@code
     *     false} otherwise.
     * @hide
     */
    @NonNull
    public WindowContainerTransaction setIsTaskMoveAllowed(
            @NonNull WindowContainerToken container, boolean isTaskMoveAllowed) {
        final Change change = getOrCreateChange(container.asBinder());
        change.mChangeMask |= Change.CHANGE_IS_TASK_MOVE_ALLOWED;
        change.mIsTaskMoveAllowed = isTaskMoveAllowed;
        return this;
    }

    /*
     * ===========================================================================================
     * Hierarchy updates (create/destroy/reorder/reparent containers)
@@ -1381,6 +1424,7 @@ public final class WindowContainerTransaction implements Parcelable {
        public static final int CHANGE_LAUNCH_NEXT_TO_BUBBLE = 1 << 10;
        public static final int CHANGE_DISABLE_PIP = 1 << 11;
        public static final int CHANGE_DISABLE_LAUNCH_ADJACENT = 1 << 12;
        public static final int CHANGE_IS_TASK_MOVE_ALLOWED = 1 << 13;

        @IntDef(flag = true, prefix = { "CHANGE_" }, value = {
                CHANGE_FOCUSABLE,
@@ -1396,6 +1440,7 @@ public final class WindowContainerTransaction implements Parcelable {
                CHANGE_LAUNCH_NEXT_TO_BUBBLE,
                CHANGE_DISABLE_PIP,
                CHANGE_DISABLE_LAUNCH_ADJACENT,
                CHANGE_IS_TASK_MOVE_ALLOWED,
        })
        @Retention(RetentionPolicy.SOURCE)
        public @interface ChangeMask {}
@@ -1409,6 +1454,7 @@ public final class WindowContainerTransaction implements Parcelable {
        private boolean mForceExcludedFromRecents = false;
        private boolean mDisablePip = false;
        private boolean mDisableLaunchAdjacent = false;
        private boolean mIsTaskMoveAllowed = false;

        private @ChangeMask int mChangeMask = 0;
        private @ActivityInfo.Config int mConfigSetMask = 0;
@@ -1421,6 +1467,7 @@ public final class WindowContainerTransaction implements Parcelable {

        private int mActivityWindowingMode = -1;
        private int mWindowingMode = -1;
        private @SelfMovable int mSelfMovable = SELF_MOVABLE_UNSET;

        private boolean mLaunchNextToBubble = false;

@@ -1437,6 +1484,7 @@ public final class WindowContainerTransaction implements Parcelable {
            mLaunchNextToBubble = in.readBoolean();
            mDisablePip = in.readBoolean();
            mDisableLaunchAdjacent = in.readBoolean();
            mIsTaskMoveAllowed = in.readBoolean();
            mChangeMask = in.readInt();
            mConfigSetMask = in.readInt();
            mWindowSetMask = in.readInt();
@@ -1452,6 +1500,7 @@ public final class WindowContainerTransaction implements Parcelable {

            mWindowingMode = in.readInt();
            mActivityWindowingMode = in.readInt();
            mSelfMovable = in.readInt();
        }

        /**
@@ -1494,6 +1543,9 @@ public final class WindowContainerTransaction implements Parcelable {
            if ((other.mChangeMask & CHANGE_DISABLE_LAUNCH_ADJACENT) != 0) {
                mDisableLaunchAdjacent = other.mDisableLaunchAdjacent;
            }
            if ((other.mChangeMask & CHANGE_IS_TASK_MOVE_ALLOWED) != 0) {
                mIsTaskMoveAllowed = other.mIsTaskMoveAllowed;
            }
            mChangeMask |= other.mChangeMask;
            if (other.mActivityWindowingMode >= WINDOWING_MODE_UNDEFINED) {
                mActivityWindowingMode = other.mActivityWindowingMode;
@@ -1501,6 +1553,9 @@ public final class WindowContainerTransaction implements Parcelable {
            if (other.mWindowingMode >= WINDOWING_MODE_UNDEFINED) {
                mWindowingMode = other.mWindowingMode;
            }
            if (other.mSelfMovable != SELF_MOVABLE_UNSET) {
                mSelfMovable = other.mSelfMovable;
            }
            if (other.mRelativeBounds != null) {
                mRelativeBounds = transfer
                        ? other.mRelativeBounds
@@ -1602,6 +1657,23 @@ public final class WindowContainerTransaction implements Parcelable {
            return mConfigAtTransitionEnd;
        }

        /**
         * Gets whether the given container can be repositioned by {@link
         * android.app.ActivityManager.AppTask#moveTaskTo}.
         */
        public @SelfMovable int getSelfMovable() {
            return mSelfMovable;
        }

        /**
         * Gets whether the given container is able to contain self-movable tasks. A display
         * is considered able to contain self-movable tasks as long as there is one child window
         * container that is able to contain self-movable tasks.
         */
        public boolean getIsTaskMoveAllowed() {
            return mIsTaskMoveAllowed;
        }

        @ChangeMask
        public int getChangeMask() {
            return mChangeMask;
@@ -1676,6 +1748,9 @@ public final class WindowContainerTransaction implements Parcelable {
            if ((mChangeMask & CHANGE_DISABLE_LAUNCH_ADJACENT) != 0) {
                sb.append("disableLaunchAdjacent:" + mDisableLaunchAdjacent + ",");
            }
            if ((mChangeMask & CHANGE_IS_TASK_MOVE_ALLOWED) != 0) {
                sb.append("isTaskMoveAllowed:" + mIsTaskMoveAllowed + ",");
            }
            if (mBoundsChangeTransaction != null) {
                sb.append("hasBoundsTransaction,");
            }
@@ -1707,6 +1782,7 @@ public final class WindowContainerTransaction implements Parcelable {
            dest.writeBoolean(mLaunchNextToBubble);
            dest.writeBoolean(mDisablePip);
            dest.writeBoolean(mDisableLaunchAdjacent);
            dest.writeBoolean(mIsTaskMoveAllowed);
            dest.writeInt(mChangeMask);
            dest.writeInt(mConfigSetMask);
            dest.writeInt(mWindowSetMask);
@@ -1721,6 +1797,7 @@ public final class WindowContainerTransaction implements Parcelable {

            dest.writeInt(mWindowingMode);
            dest.writeInt(mActivityWindowingMode);
            dest.writeInt(mSelfMovable);
        }

        @Override
+24 −0
Original line number Diff line number Diff line
@@ -128,6 +128,7 @@ import android.app.AppGlobals;
import android.app.IActivityController;
import android.app.PictureInPictureParams;
import android.app.TaskInfo;
import android.app.TaskInfo.SelfMovable;
import android.app.WindowConfiguration;
import android.content.ComponentName;
import android.content.Intent;
@@ -527,6 +528,12 @@ class Task extends TaskFragment {
     */
    private boolean mForceNonResizeOverride;

    /**
     * If the window is allowed to be repositioned by {@link
     * android.app.ActivityManager.AppTask#moveTaskTo}.
     */
    private @SelfMovable int mSelfMovable = TaskInfo.SELF_MOVABLE_DEFAULT;

    private static final int TRANSLUCENT_TIMEOUT_MSG = FIRST_ACTIVITY_TASK_MSG + 1;

    private final Handler mHandler;
@@ -3856,6 +3863,7 @@ class Task extends TaskFragment {
        if (mReparentLeafTaskIfRelaunch) {
            pw.println(prefix + "mReparentLeafTaskIfRelaunch=true");
        }
        pw.println(prefix + "mSelfMovable=" + mSelfMovable);
    }

    @Override
@@ -6405,6 +6413,22 @@ class Task extends TaskFragment {
                || (mRequiredDisplayCategory == null && info.requiredDisplayCategory == null);
    }

    /**
     * Sets whether the window is allowed to be repositioned by {@link
     * android.app.ActivityManager.AppTask#moveTaskTo}.
     */
    void setSelfMovable(@SelfMovable int selfMovable) {
        mSelfMovable = selfMovable;
    }

    /**
     * Gets whether the window is allowed to be repositioned by {@link
     * android.app.ActivityManager.AppTask#moveTaskTo}.
     */
    @SelfMovable int getSelfMovable() {
        return mSelfMovable;
    }

    @Override
    public void dumpDebug(ProtoOutputStream proto, long fieldId,
            @WindowTracingLogLevel int logLevel) {
+15 −0
Original line number Diff line number Diff line
@@ -288,6 +288,12 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
     */
    RemoteToken mRemoteToken = null;

    /**
     * This indicates whether this Container can hold tasks that can be repositioned on screen
     * using the {@link android.app.ActivityManager.AppTask#moveTaskTo} method.
     */
    private boolean mIsTaskMoveAllowed = false;

    /** This isn't participating in a sync. */
    public static final int SYNC_STATE_NONE = 0;

@@ -3248,6 +3254,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
        if (mSafeRegionBounds != null) {
            pw.println(prefix + "mSafeRegionBounds=" + mSafeRegionBounds);
        }
        pw.println(prefix + "mIsTaskMoveAllowed=" + mIsTaskMoveAllowed);
    }

    final void updateSurfacePositionNonOrganized() {
@@ -3901,4 +3908,12 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
    int getSyncTransactionCommitCallbackDepth() {
        return mSyncTransactionCommitCallbackDepth;
    }

    void setIsTaskMoveAllowed(boolean isTaskMoveAllowed) {
        mIsTaskMoveAllowed = isTaskMoveAllowed;
    }

    boolean getIsTaskMoveAllowed() {
        return mIsTaskMoveAllowed;
    }
}
+10 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.server.wm;

import static android.Manifest.permission.START_TASKS_FROM_RECENTS;
import static android.app.ActivityManager.isStartResultSuccessful;
import static android.app.TaskInfo.SELF_MOVABLE_UNSET;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
@@ -876,6 +877,11 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
            }
        }

        if ((change.getChangeMask()
                & WindowContainerTransaction.Change.CHANGE_IS_TASK_MOVE_ALLOWED) != 0) {
            container.setIsTaskMoveAllowed(change.getIsTaskMoveAllowed());
        }

        if (windowingMode > -1) {
            if (mService.isInLockTaskMode()
                    && WindowConfiguration.inMultiWindowMode(windowingMode)
@@ -998,6 +1004,10 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
            }
        }

        if (c.getSelfMovable() != SELF_MOVABLE_UNSET) {
            tr.setSelfMovable(c.getSelfMovable());
        }

        return effects;
    }

Loading