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

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

Merge "Added support for static vs. dynamic stacks"

parents 9f2cddbb ddc1cb2c
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -139,6 +139,7 @@ public class Am extends BaseCommand {
                "       am stack movetask <TASK_ID> <STACK_ID> [true|false]\n" +
                "       am stack resize <STACK_ID> <LEFT,TOP,RIGHT,BOTTOM>\n" +
                "       am stack split <STACK_ID> <v|h> [INTENT]\n" +
                "       am stack positiontask <TASK_ID> <STACK_ID> <POSITION>\n" +
                "       am stack list\n" +
                "       am stack info <STACK_ID>\n" +
                "       am task lock <TASK_ID>\n" +
@@ -280,6 +281,8 @@ public class Am extends BaseCommand {
                "   of the current task will be moved to the new stack. Command will also force\n" +
                "   all current tasks in both stacks to be resizeable.\n" +
                "\n" +
                "am stack positiontask: place <TASK_ID> in <STACK_ID> at <POSITION>" +
                "\n" +
                "am stack list: list all of the activity stacks and their sizes.\n" +
                "\n" +
                "am stack info: display the information about activity stack <STACK_ID>.\n" +
@@ -1921,6 +1924,8 @@ public class Am extends BaseCommand {
            runStackMoveTask();
        } else if (op.equals("resize")) {
            runStackResize();
        } else if (op.equals("positiontask")) {
            runStackPositionTask();
        } else if (op.equals("list")) {
            runStackList();
        } else if (op.equals("info")) {
@@ -1984,6 +1989,20 @@ public class Am extends BaseCommand {
        }
    }

    private void runStackPositionTask() throws Exception {
        String taskIdStr = nextArgRequired();
        int taskId = Integer.valueOf(taskIdStr);
        String stackIdStr = nextArgRequired();
        int stackId = Integer.valueOf(stackIdStr);
        String positionStr = nextArgRequired();
        int position = Integer.valueOf(positionStr);

        try {
            mAm.positionTaskInStack(taskId, stackId, position);
        } catch (RemoteException e) {
        }
    }

    private void runStackList() throws Exception {
        try {
            List<StackInfo> stacks = mAm.getAllStackInfos();
+36 −0
Original line number Diff line number Diff line
@@ -404,6 +404,42 @@ public class ActivityManager {
     */
    public static final int COMPAT_MODE_TOGGLE = 2;

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

    /**
     * Home activity stack ID.
     * @hide
     */
    public static final int HOME_STACK_ID = FIRST_STATIC_STACK_ID;

    /**
     * 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.
     * @hide
     */
    public static final int FREEFORM_WORKSPACE_STACK_ID = FULLSCREEN_WORKSPACE_STACK_ID + 1;

    /**
     * Last static stack stack ID.
     * @hide
     */
    public static final int LAST_STATIC_STACK_ID = FREEFORM_WORKSPACE_STACK_ID;

    /**
     * Start of ID range used by stacks that are created dynamically.
     * @hide
     */
    public static final int FIRST_DYNAMIC_STACK_ID = LAST_STATIC_STACK_ID + 1;

    /** @hide */
    public int getFrontActivityScreenCompatMode() {
        try {
+24 −0
Original line number Diff line number Diff line
@@ -752,6 +752,16 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            return true;
        }

        case POSITION_TASK_IN_STACK_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            int taskId = data.readInt();
            int stackId = data.readInt();
            int position = data.readInt();
            positionTaskInStack(taskId, stackId, position);
            reply.writeNoException();
            return true;
        }

        case GET_ALL_STACK_INFOS_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            List<StackInfo> list = getAllStackInfos();
@@ -3469,6 +3479,20 @@ class ActivityManagerProxy implements IActivityManager
        reply.recycle();
    }
    @Override
    public void positionTaskInStack(int taskId, int stackId, int position) throws RemoteException
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeInt(taskId);
        data.writeInt(stackId);
        data.writeInt(position);
        mRemote.transact(POSITION_TASK_IN_STACK_TRANSACTION, data, reply, 0);
        reply.readException();
        data.recycle();
        reply.recycle();
    }
    @Override
    public List<StackInfo> getAllStackInfos() throws RemoteException
    {
        Parcel data = Parcel.obtain();
+2 −0
Original line number Diff line number Diff line
@@ -139,6 +139,7 @@ public interface IActivityManager extends IInterface {
    public void moveTaskBackwards(int task) throws RemoteException;
    public void moveTaskToStack(int taskId, int stackId, boolean toTop) throws RemoteException;
    public void resizeStack(int stackId, Rect bounds) throws RemoteException;
    public void positionTaskInStack(int taskId, int stackId, int position) throws RemoteException;
    public List<StackInfo> getAllStackInfos() throws RemoteException;
    public StackInfo getStackInfo(int stackId) throws RemoteException;
    public boolean isInHomeStack(int taskId) throws RemoteException;
@@ -874,4 +875,5 @@ public interface IActivityManager extends IInterface {
    // Start of N transactions
    int START_BINDER_TRACKING_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 340;
    int STOP_BINDER_TRACKING_AND_DUMP_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 341;
    int POSITION_TASK_IN_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 342;
}
+25 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.server.am;
import static android.Manifest.permission.INTERACT_ACROSS_USERS;
import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
import static android.Manifest.permission.START_TASKS_FROM_RECENTS;
import static android.app.ActivityManager.HOME_STACK_ID;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static com.android.internal.util.XmlUtils.readBooleanAttribute;
import static com.android.internal.util.XmlUtils.readIntAttribute;
@@ -28,7 +29,6 @@ import static com.android.internal.util.XmlUtils.writeIntAttribute;
import static com.android.internal.util.XmlUtils.writeLongAttribute;
import static com.android.server.Watchdog.NATIVE_STACKS_OF_INTEREST;
import static com.android.server.am.ActivityManagerDebugConfig.*;
import static com.android.server.am.ActivityStackSupervisor.HOME_STACK_ID;
import static com.android.server.am.TaskRecord.INVALID_TASK_ID;
import static com.android.server.am.TaskRecord.LOCK_TASK_AUTH_DONT_LOCK;
import static com.android.server.am.TaskRecord.LOCK_TASK_AUTH_LAUNCHABLE_PRIV;
@@ -8898,7 +8898,8 @@ public final class ActivityManagerService extends ActivityManagerNative
                "createStackOnDisplay()");
        synchronized (this) {
            final int stackId = mStackSupervisor.getNextStackId();
            final ActivityStack stack = mStackSupervisor.createStackOnDisplay(stackId, displayId);
            final ActivityStack stack =
                    mStackSupervisor.createStackOnDisplay(stackId, displayId, true /*onTop*/);
            if (stack == null) {
                return null;
            }
@@ -8951,6 +8952,28 @@ public final class ActivityManagerService extends ActivityManagerNative
        }
    }
    @Override
    public void positionTaskInStack(int taskId, int stackId, int position) {
        enforceCallingPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS,
                "positionTaskInStack()");
        if (stackId == HOME_STACK_ID) {
            Slog.e(TAG, "positionTaskInStack: Attempt to change the position of task "
                    + taskId + " in/to home stack",
                    new RuntimeException("here").fillInStackTrace());
        }
        synchronized (this) {
            long ident = Binder.clearCallingIdentity();
            try {
                if (DEBUG_STACK) Slog.d(TAG_STACK,
                        "positionTaskInStack: positioning task=" + taskId
                        + " in stackId=" + stackId + " at position=" + position);
                mStackSupervisor.positionTaskInStackLocked(taskId, stackId, position);
            } finally {
                Binder.restoreCallingIdentity(ident);
            }
        }
    }
    @Override
    public List<StackInfo> getAllStackInfos() {
        enforceCallingPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS,
Loading