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

Commit 388945c0 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Changed to allow removal of remaining static stack ids from CTS.

Test: Existing tests pass.
Bug: 64146578
Change-Id: Ia9e7c62427f270fe6cbfd60e068f7c2c95133c53
parent 6b2fa023
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -3866,7 +3866,9 @@ package android.app {
    method public void removeOnUidImportanceListener(android.app.ActivityManager.OnUidImportanceListener);
    method public void removeStacksInWindowingModes(int[]) throws java.lang.SecurityException;
    method public void removeStacksWithActivityTypes(int[]) throws java.lang.SecurityException;
    method public void resizeStack(int, android.graphics.Rect) throws java.lang.SecurityException;
    method public deprecated void restartPackage(java.lang.String);
    method public void setTaskWindowingMode(int, int, boolean) throws java.lang.SecurityException;
    method public static void setVrThread(int);
    method public void setWatchHeapLimit(long);
    method public static boolean supportsMultiWindow(android.content.Context);
@@ -4019,11 +4021,7 @@ package android.app {
  }
  public static class ActivityManager.StackId {
    field public static final int DOCKED_STACK_ID = 3; // 0x3
    field public static final int FREEFORM_WORKSPACE_STACK_ID = 2; // 0x2
    field public static final int FULLSCREEN_WORKSPACE_STACK_ID = 1; // 0x1
    field public static final int INVALID_STACK_ID = -1; // 0xffffffff
    field public static final int PINNED_STACK_ID = 4; // 0x4
  }
  public static class ActivityManager.TaskDescription implements android.os.Parcelable {
+46 −4
Original line number Diff line number Diff line
@@ -674,16 +674,20 @@ public class ActivityManager {
         * @hide */
        private  static final int FIRST_STATIC_STACK_ID = 0;

        /** ID of stack where fullscreen activities are normally launched into. */
        /** ID of stack where fullscreen activities are normally launched into.
         * @hide */
        public static final int FULLSCREEN_WORKSPACE_STACK_ID = 1;

        /** ID of stack where freeform/resized activities are normally launched into. */
        /** ID of stack where freeform/resized activities are normally launched into.
         * @hide */
        public static final int FREEFORM_WORKSPACE_STACK_ID = FULLSCREEN_WORKSPACE_STACK_ID + 1;

        /** ID of stack that occupies a dedicated region of the screen. */
        /** ID of stack that occupies a dedicated region of the screen.
         * @hide */
        public static final int DOCKED_STACK_ID = FREEFORM_WORKSPACE_STACK_ID + 1;

        /** ID of stack that always on top (always visible) when it exist. */
        /** ID of stack that always on top (always visible) when it exist.
         * @hide */
        public static final int PINNED_STACK_ID = DOCKED_STACK_ID + 1;

        /** Last static stack stack ID.
@@ -2024,6 +2028,42 @@ public class ActivityManager {
        }
    }

    /**
     * Sets the windowing mode for a specific task. Only works on tasks of type
     * {@link WindowConfiguration#ACTIVITY_TYPE_STANDARD}
     * @param taskId The id of the task to set the windowing mode for.
     * @param windowingMode The windowing mode to set for the task.
     * @param toTop If the task should be moved to the top once the windowing mode changes.
     * @hide
     */
    @TestApi
    @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
    public void setTaskWindowingMode(int taskId, int windowingMode, boolean toTop)
            throws SecurityException {
        try {
            getService().setTaskWindowingMode(taskId, windowingMode, toTop);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Resizes the input stack id to the given bounds.
     * @param stackId Id of the stack to resize.
     * @param bounds Bounds to resize the stack to or {@code null} for fullscreen.
     * @hide
     */
    @TestApi
    @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
    public void resizeStack(int stackId, Rect bounds) throws SecurityException {
        try {
            getService().resizeStack(stackId, bounds, false /* allowResizeInDockedMode */,
                    false /* preserveWindows */, false /* animate */, -1 /* animationDuration */);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Removes stacks in the windowing modes from the system if they are of activity type
     * ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED
@@ -2031,6 +2071,7 @@ public class ActivityManager {
     * @hide
     */
    @TestApi
    @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
    public void removeStacksInWindowingModes(int[] windowingModes) throws SecurityException {
        try {
            getService().removeStacksInWindowingModes(windowingModes);
@@ -2045,6 +2086,7 @@ public class ActivityManager {
     * @hide
     */
    @TestApi
    @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
    public void removeStacksWithActivityTypes(int[] activityTypes) throws SecurityException {
        try {
            getService().removeStacksWithActivityTypes(activityTypes);
+9 −0
Original line number Diff line number Diff line
@@ -361,6 +361,15 @@ interface IActivityManager {
    void killUid(int appId, int userId, in String reason);
    void setUserIsMonkey(boolean monkey);
    void hang(in IBinder who, boolean allowRestart);

    /**
     * Sets the windowing mode for a specific task. Only works on tasks of type
     * {@link WindowConfiguration#ACTIVITY_TYPE_STANDARD}
     * @param taskId The id of the task to set the windowing mode for.
     * @param windowingMode The windowing mode to set for the task.
     * @param toTop If the task should be moved to the top once the windowing mode changes.
     */
    void setTaskWindowingMode(int taskId, int windowingMode, boolean toTop);
    void moveTaskToStack(int taskId, int stackId, boolean toTop);
    /**
     * Resizes the input stack id to the given bounds.
+39 −1
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import static android.app.ActivityManager.StackId.isStaticStack;
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_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
import static android.content.pm.PackageManager.FEATURE_ACTIVITIES_ON_SECONDARY_DISPLAYS;
@@ -3239,7 +3240,8 @@ public class ActivityManagerService extends IActivityManager.Stub
        if (r.requestedVrComponent != null && r.getStackId() >= FIRST_DYNAMIC_STACK_ID) {
            Slog.i(TAG, "Moving " + r.shortComponentName + " from stack " + r.getStackId()
                    + " to main stack for VR");
            moveTaskToStack(r.getTask().taskId, FULLSCREEN_WORKSPACE_STACK_ID, true /* toTop */);
            setTaskWindowingMode(r.getTask().taskId,
                    WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY, true /* toTop */);
        }
        mHandler.sendMessage(
                mHandler.obtainMessage(VR_MODE_CHANGE_MSG, 0, 0, r));
@@ -10607,6 +10609,42 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
    }
    @Override
    public void setTaskWindowingMode(int taskId, int windowingMode, boolean toTop) {
        enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "setTaskWindowingMode()");
        synchronized (this) {
            final long ident = Binder.clearCallingIdentity();
            try {
                final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId);
                if (task == null) {
                    Slog.w(TAG, "setTaskWindowingMode: No task for id=" + taskId);
                    return;
                }
                if (DEBUG_STACK) Slog.d(TAG_STACK, "setTaskWindowingMode: moving task=" + taskId
                        + " to windowingMode=" + windowingMode + " toTop=" + toTop);
                if (windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) {
                    mWindowManager.setDockedStackCreateState(DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT,
                            null /* initialBounds */);
                }
                if (!task.isActivityTypeStandardOrUndefined()) {
                    throw new IllegalArgumentException("setTaskWindowingMode: Attempt to move task "
                            + taskId + " to non-standard windowin mode=" + windowingMode);
                }
                final ActivityDisplay display = task.getStack().getDisplay();
                final ActivityStack stack = display.getOrCreateStack(windowingMode,
                        task.getStack().getActivityType(), toTop);
                // TODO: We should just change the windowing mode for the task vs. creating and
                // moving it to a stack.
                task.reparent(stack, toTop, REPARENT_KEEP_STACK_AT_FRONT, ANIMATE, !DEFER_RESUME,
                        "moveTaskToStack");
            } finally {
                Binder.restoreCallingIdentity(ident);
            }
        }
    }
    @Override
    public void moveTaskToStack(int taskId, int stackId, boolean toTop) {
        enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "moveTaskToStack()");
+1 −1
Original line number Diff line number Diff line
@@ -5089,7 +5089,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
            if (isAttached()) {
                getDisplay().positionChildAtBottom(this);
            }
            if (!isHomeOrRecentsStack()) {
            if (!isActivityTypeHome()) {
                remove();
            }
        }
Loading