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

Commit d562d535 authored by Wale Ogunwale's avatar Wale Ogunwale Committed by Android (Google) Code Review
Browse files

Merge changes from topic "stack-gone"

* changes:
  HOME_STACK_ID, ASSISTANT_STACK_ID, and RECENTS_STACK_ID be gone!
  Ability to getOrCreateStack by windowingMode/activityType in AM.
parents f7873f4d 68278568
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -3864,6 +3864,8 @@ package android.app {
    method public void moveTaskToFront(int, int);
    method public void moveTaskToFront(int, int, android.os.Bundle);
    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 deprecated void restartPackage(java.lang.String);
    method public static void setVrThread(int);
    method public void setWatchHeapLimit(long);
@@ -4017,14 +4019,11 @@ package android.app {
  }
  public static class ActivityManager.StackId {
    field public static final int ASSISTANT_STACK_ID = 6; // 0x6
    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 HOME_STACK_ID = 0; // 0x0
    field public static final int INVALID_STACK_ID = -1; // 0xffffffff
    field public static final int PINNED_STACK_ID = 4; // 0x4
    field public static final int RECENTS_STACK_ID = 5; // 0x5
  }
  public static class ActivityManager.TaskDescription implements android.os.Parcelable {
+60 −130
Original line number Diff line number Diff line
@@ -16,10 +16,6 @@

package android.app;

import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT;
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_SPLIT_SCREEN_PRIMARY;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
@@ -46,6 +42,7 @@ import android.content.pm.IPackageDataObserver;
import android.content.pm.PackageManager;
import android.content.pm.ParceledListSlice;
import android.content.pm.UserInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@@ -675,10 +672,7 @@ public class ActivityManager {

        /** First static stack ID.
         * @hide */
        public static final int FIRST_STATIC_STACK_ID = 0;

        /** Home activity stack ID. */
        public static final int HOME_STACK_ID = FIRST_STATIC_STACK_ID;
        private  static final int FIRST_STATIC_STACK_ID = 0;

        /** ID of stack where fullscreen activities are normally launched into. */
        public static final int FULLSCREEN_WORKSPACE_STACK_ID = 1;
@@ -692,15 +686,9 @@ public class ActivityManager {
        /** ID of stack that always on top (always visible) when it exist. */
        public static final int PINNED_STACK_ID = DOCKED_STACK_ID + 1;

        /** ID of stack that contains the Recents activity. */
        public static final int RECENTS_STACK_ID = PINNED_STACK_ID + 1;

        /** ID of stack that contains activities launched by the assistant. */
        public static final int ASSISTANT_STACK_ID = RECENTS_STACK_ID + 1;

        /** Last static stack stack ID.
         * @hide */
        public static final int LAST_STATIC_STACK_ID = ASSISTANT_STACK_ID;
        private static final int LAST_STATIC_STACK_ID = PINNED_STACK_ID;

        /** Start of ID range used by stacks that are created dynamically.
         * @hide */
@@ -719,15 +707,6 @@ public class ActivityManager {
            return stackId >= FIRST_DYNAMIC_STACK_ID;
        }

        /**
         * Returns true if dynamic stacks are allowed to be visible behind the input stack.
         * @hide
         */
        // TODO: Figure-out a way to remove.
        public static boolean isDynamicStacksVisibleBehindAllowed(int stackId) {
            return stackId == PINNED_STACK_ID || stackId == ASSISTANT_STACK_ID;
        }

        /**
         * Returns true if we try to maintain focus in the current stack when the top activity
         * finishes.
@@ -739,15 +718,6 @@ public class ActivityManager {
                    || stackId == DOCKED_STACK_ID || stackId == PINNED_STACK_ID;
        }

        /**
         * Returns true if the input stack is affected by drag resizing.
         * @hide
         */
        public static boolean isStackAffectedByDragResizing(int stackId) {
            return isStaticStack(stackId) && stackId != PINNED_STACK_ID
                    && stackId != ASSISTANT_STACK_ID;
        }

        /**
         * Returns true if the windows of tasks being moved to the target stack from the source
         * stack should be replaced, meaning that window manager will keep the old window around
@@ -759,26 +729,6 @@ public class ActivityManager {
                    || targetStackId == FREEFORM_WORKSPACE_STACK_ID;
        }

        /**
         * Return whether a stackId is a stack that be a backdrop to a translucent activity.  These
         * are generally fullscreen stacks.
         * @hide
         */
        public static boolean isBackdropToTranslucentActivity(int stackId) {
            return stackId == FULLSCREEN_WORKSPACE_STACK_ID
                    || stackId == ASSISTANT_STACK_ID;
        }

        /**
         * Returns true if activities from stasks in the given {@param stackId} are allowed to
         * enter picture-in-picture.
         * @hide
         */
        public static boolean isAllowedToEnterPictureInPicture(int stackId) {
            return stackId != HOME_STACK_ID && stackId != ASSISTANT_STACK_ID &&
                    stackId != RECENTS_STACK_ID;
        }

        /**
         * Returns true if the top task in the task is allowed to return home when finished and
         * there are other tasks in the stack.
@@ -810,34 +760,18 @@ public class ActivityManager {
                    && stackId != DOCKED_STACK_ID;
        }

        /**
         * Returns true if the input stack id should only be present on a device that supports
         * multi-window mode.
         * @see android.app.ActivityManager#supportsMultiWindow
         * @hide
         */
        // TODO: What about the other side of docked stack if we move this to WindowConfiguration?
        public static boolean isMultiWindowStack(int stackId) {
            return stackId == PINNED_STACK_ID || stackId == FREEFORM_WORKSPACE_STACK_ID
                    || stackId == DOCKED_STACK_ID;
        }

        /**
         * Returns true if the input {@param stackId} is HOME_STACK_ID or RECENTS_STACK_ID
         * @hide
         */
        public static boolean isHomeOrRecentsStack(int stackId) {
            return stackId == HOME_STACK_ID || stackId == RECENTS_STACK_ID;
        }

        /** Returns true if the input stack and its content can affect the device orientation.
        /** Returns the stack id for the input windowing mode.
         * @hide */
        public static boolean canSpecifyOrientation(int stackId) {
            return stackId == HOME_STACK_ID
                    || stackId == RECENTS_STACK_ID
                    || stackId == FULLSCREEN_WORKSPACE_STACK_ID
                    || stackId == ASSISTANT_STACK_ID
                    || isDynamicStack(stackId);
        // TODO: To be removed once we are not using stack id for stuff...
        public static int getStackIdForWindowingMode(int windowingMode) {
            switch (windowingMode) {
                case WINDOWING_MODE_PINNED: return PINNED_STACK_ID;
                case WINDOWING_MODE_FREEFORM: return FREEFORM_WORKSPACE_STACK_ID;
                case WINDOWING_MODE_SPLIT_SCREEN_PRIMARY: return DOCKED_STACK_ID;
                case WINDOWING_MODE_SPLIT_SCREEN_SECONDARY: return FULLSCREEN_WORKSPACE_STACK_ID;
                case WINDOWING_MODE_FULLSCREEN: return FULLSCREEN_WORKSPACE_STACK_ID;
                default: return INVALID_STACK_ID;
            }
        }

        /** Returns the windowing mode that should be used for this input stack id.
@@ -847,14 +781,9 @@ public class ActivityManager {
            final int windowingMode;
            switch (stackId) {
                case FULLSCREEN_WORKSPACE_STACK_ID:
                case HOME_STACK_ID:
                case RECENTS_STACK_ID:
                    windowingMode = inSplitScreenMode
                            ? WINDOWING_MODE_SPLIT_SCREEN_SECONDARY : WINDOWING_MODE_FULLSCREEN;
                    break;
                case ASSISTANT_STACK_ID:
                    windowingMode = WINDOWING_MODE_FULLSCREEN;
                    break;
                case PINNED_STACK_ID:
                    windowingMode = WINDOWING_MODE_PINNED;
                    break;
@@ -869,51 +798,6 @@ public class ActivityManager {
            }
            return windowingMode;
        }

        /** Returns the stack id for the input windowing mode.
         * @hide */
        // TODO: To be removed once we are not using stack id for stuff...
        public static int getStackIdForWindowingMode(int windowingMode) {
            switch (windowingMode) {
                case WINDOWING_MODE_PINNED: return PINNED_STACK_ID;
                case WINDOWING_MODE_FREEFORM: return FREEFORM_WORKSPACE_STACK_ID;
                case WINDOWING_MODE_SPLIT_SCREEN_PRIMARY: return DOCKED_STACK_ID;
                default: return INVALID_STACK_ID;
            }
        }

        /** Returns the activity type that should be used for this input stack id.
         * @hide */
        // TODO: To be removed once we are not using stack id for stuff...
        public static int getActivityTypeForStackId(int stackId) {
            final int activityType;
            switch (stackId) {
                case HOME_STACK_ID:
                    activityType = ACTIVITY_TYPE_HOME;
                    break;
                case RECENTS_STACK_ID:
                    activityType = ACTIVITY_TYPE_RECENTS;
                    break;
                case ASSISTANT_STACK_ID:
                    activityType = ACTIVITY_TYPE_ASSISTANT;
                    break;
                default :
                    activityType = ACTIVITY_TYPE_STANDARD;
            }
            return activityType;
        }

        /** Returns the stack id for the input activity type.
         * @hide */
        // TODO: To be removed once we are not using stack id for stuff...
        public static int getStackIdForActivityType(int activityType) {
            switch (activityType) {
                case ACTIVITY_TYPE_HOME: return HOME_STACK_ID;
                case ACTIVITY_TYPE_RECENTS: return RECENTS_STACK_ID;
                case ACTIVITY_TYPE_ASSISTANT: return ASSISTANT_STACK_ID;
                default: return INVALID_STACK_ID;
            }
        }
    }

    /**
@@ -1910,6 +1794,12 @@ public class ActivityManager {
         */
        public int resizeMode;

        /**
         * The full configuration the task is currently running in.
         * @hide
         */
        public Configuration configuration = new Configuration();

        public RunningTaskInfo() {
        }

@@ -1934,6 +1824,7 @@ public class ActivityManager {
            dest.writeInt(numRunning);
            dest.writeInt(supportsSplitScreenMultiWindow ? 1 : 0);
            dest.writeInt(resizeMode);
            configuration.writeToParcel(dest, flags);
        }

        public void readFromParcel(Parcel source) {
@@ -1951,6 +1842,7 @@ public class ActivityManager {
            numRunning = source.readInt();
            supportsSplitScreenMultiWindow = source.readInt() != 0;
            resizeMode = source.readInt();
            configuration.readFromParcel(source);
        }

        public static final Creator<RunningTaskInfo> CREATOR = new Creator<RunningTaskInfo>() {
@@ -2132,6 +2024,35 @@ public class ActivityManager {
        }
    }

    /**
     * Removes stacks in the windowing modes from the system if they are of activity type
     * ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED
     *
     * @hide
     */
    @TestApi
    public void removeStacksInWindowingModes(int[] windowingModes) throws SecurityException {
        try {
            getService().removeStacksInWindowingModes(windowingModes);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Removes stack of the activity types from the system.
     *
     * @hide
     */
    @TestApi
    public void removeStacksWithActivityTypes(int[] activityTypes) throws SecurityException {
        try {
            getService().removeStacksWithActivityTypes(activityTypes);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Represents a task snapshot.
     * @hide
@@ -2610,6 +2531,11 @@ public class ActivityManager {
        public boolean visible;
        // Index of the stack in the display's stack list, can be used for comparison of stack order
        public int position;
        /**
         * The full configuration the stack is currently running in.
         * @hide
         */
        public Configuration configuration = new Configuration();

        @Override
        public int describeContents() {
@@ -2644,6 +2570,7 @@ public class ActivityManager {
            } else {
                dest.writeInt(0);
            }
            configuration.writeToParcel(dest, flags);
        }

        public void readFromParcel(Parcel source) {
@@ -2671,6 +2598,7 @@ public class ActivityManager {
            if (source.readInt() > 0) {
                topActivity = ComponentName.readFromParcel(source);
            }
            configuration.readFromParcel(source);
        }

        public static final Creator<StackInfo> CREATOR = new Creator<StackInfo>() {
@@ -2698,6 +2626,8 @@ public class ActivityManager {
                    sb.append(" displayId="); sb.append(displayId);
                    sb.append(" userId="); sb.append(userId);
                    sb.append("\n");
                    sb.append(" configuration="); sb.append(configuration);
                    sb.append("\n");
            prefix = prefix + "  ";
            for (int i = 0; i < taskIds.length; ++i) {
                sb.append(prefix); sb.append("taskId="); sb.append(taskIds[i]);
+9 −2
Original line number Diff line number Diff line
@@ -380,7 +380,8 @@ interface IActivityManager {
            boolean preserveWindows, boolean animate, int animationDuration);
    List<ActivityManager.StackInfo> getAllStackInfos();
    void setFocusedStack(int stackId);
    ActivityManager.StackInfo getStackInfo(int stackId);
    ActivityManager.StackInfo getFocusedStackInfo();
    ActivityManager.StackInfo getStackInfo(int windowingMode, int activityType);
    boolean convertFromTranslucent(in IBinder token);
    boolean convertToTranslucent(in IBinder token, in Bundle options);
    void notifyActivityDrawn(in IBinder token);
@@ -440,7 +441,6 @@ interface IActivityManager {
    // Start of M transactions
    void notifyCleartextNetwork(int uid, in byte[] firstPacket);
    int createStackOnDisplay(int displayId);
    int getFocusedStackId();
    void setTaskResizeable(int taskId, int resizeableMode);
    boolean requestAssistContextExtras(int requestType, in IResultReceiver receiver,
            in Bundle receiverExtras, in IBinder activityToken,
@@ -540,6 +540,13 @@ interface IActivityManager {
    void notifyPinnedStackAnimationStarted();
    void notifyPinnedStackAnimationEnded();
    void removeStack(int stackId);
    /**
     * Removes stacks in the input windowing modes from the system if they are of activity type
     * ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED
     */
    void removeStacksInWindowingModes(in int[] windowingModes);
    /** Removes stack of the activity types from the system. */
    void removeStacksWithActivityTypes(in int[] activityTypes);
    void makePackageIdle(String packageName, int userId);
    int getMemoryTrimLevel();
    /**
+7 −2
Original line number Diff line number Diff line
@@ -500,10 +500,15 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu
     * @hide
     */
    public boolean supportSplitScreenWindowingMode() {
        if (mActivityType == ACTIVITY_TYPE_ASSISTANT) {
        return supportSplitScreenWindowingMode(mWindowingMode, mActivityType);
    }

    /** @hide */
    public static boolean supportSplitScreenWindowingMode(int windowingMode, int activityType) {
        if (activityType == ACTIVITY_TYPE_ASSISTANT) {
            return false;
        }
        return mWindowingMode != WINDOWING_MODE_FREEFORM && mWindowingMode != WINDOWING_MODE_PINNED;
        return windowingMode != WINDOWING_MODE_FREEFORM && windowingMode != WINDOWING_MODE_PINNED;
    }

    private static String windowingModeToString(@WindowingMode int windowingMode) {
+2 −2
Original line number Diff line number Diff line
@@ -358,10 +358,10 @@ interface IWindowManager
     * Updates the dim layer used while resizing.
     *
     * @param visible Whether the dim layer should be visible.
     * @param targetStackId The id of the task stack the dim layer should be placed on.
     * @param targetWindowingMode The windowing mode of the stack the dim layer should be placed on.
     * @param alpha The translucency of the dim layer, between 0 and 1.
     */
    void setResizeDimLayer(boolean visible, int targetStackId, float alpha);
    void setResizeDimLayer(boolean visible, int targetWindowingMode, float alpha);

    /**
     * Requests Keyboard Shortcuts from the displayed window.
Loading