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

Commit 3b7e6b95 authored by Craig Mautner's avatar Craig Mautner Committed by Android (Google) Code Review
Browse files

Merge "Add new API getStackBoxInfo"

parents 94c747db fd1ce8d5
Loading
Loading
Loading
Loading
+22 −3
Original line number Diff line number Diff line
@@ -103,10 +103,11 @@ public class Am extends BaseCommand {
                "       am to-intent-uri [INTENT]\n" +
                "       am switch-user <USER_ID>\n" +
                "       am stop-user <USER_ID>\n" +
                "       am stack create <TASK_ID> <RELATIVE_STACK_ID> <POSITION> <WEIGHT>\n" +
                "       am stack create <TASK_ID> <RELATIVE_STACK_BOX_ID> <POSITION> <WEIGHT>\n" +
                "       am stack movetask <STACK_ID> <TASK_ID> [true|false]\n" +
                "       am stack resize <STACK_ID> <WEIGHT>\n" +
                "       am stack boxes\n" +
                "       am stack box <STACK_BOX_ID>\n" +
                "\n" +
                "am start: start an Activity.  Options are:\n" +
                "    -D: enable debugging\n" +
@@ -194,8 +195,12 @@ public class Am extends BaseCommand {
                "\n" +
                "am stack create: create a new stack relative to an existing one.\n" +
                "   <TASK_ID>: the task to populate the new stack with. Must exist.\n" +
                "   <RELATIVE_STACK_ID>: existing stack's id.\n" +
                "   <POSITION>: 0: to left of, 1: to right of, 2: above, 3: below\n" +
                "   <RELATIVE_STACK_BOX_ID>: existing stack box's id.\n" +
                "   <POSITION>: 0: before <RELATIVE_STACK_BOX_ID>, per RTL/LTR configuration,\n" +
                "               1: after <RELATIVE_STACK_BOX_ID>, per RTL/LTR configuration,\n" +
                "               2: to left of <RELATIVE_STACK_BOX_ID>,\n" +
                "               3: to right of <RELATIVE_STACK_BOX_ID>," +
                "               4: above <RELATIVE_STACK_BOX_ID>, 5: below <RELATIVE_STACK_BOX_ID>\n" +
                "   <WEIGHT>: float between 0.2 and 0.8 inclusive.\n" +
                "\n" +
                "am stack movetask: move <TASK_ID> from its current stack to the top (true) or" +
@@ -205,6 +210,8 @@ public class Am extends BaseCommand {
                "\n" +
                "am stack boxes: list the hierarchy of stack boxes and their contents.\n" +
                "\n" +
                "am stack box: list the hierarchy of stack boxes rooted at <STACK_BOX_ID>.\n" +
                "\n" +
                "<INTENT> specifications include these flags and arguments:\n" +
                "    [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]\n" +
                "    [-c <CATEGORY> [-c <CATEGORY>] ...]\n" +
@@ -1488,6 +1495,8 @@ public class Am extends BaseCommand {
            runStackBoxResize();
        } else if (op.equals("boxes")) {
            runStackBoxes();
        } else if (op.equals("box")) {
            runStackBoxInfo();
        } else {
            showError("Error: unknown command '" + op + "'");
            return;
@@ -1554,4 +1563,14 @@ public class Am extends BaseCommand {
        } catch (RemoteException e) {
        }
    }

    private void runStackBoxInfo() throws Exception {
        try {
            String stackBoxIdStr = nextArgRequired();
            int stackBoxId = Integer.valueOf(stackBoxIdStr);
            StackBoxInfo stackBoxInfo = mAm.getStackBoxInfo(stackBoxId); 
            System.out.println(stackBoxInfo);
        } catch (RemoteException e) {
        }
    }
}
+32 −0
Original line number Diff line number Diff line
@@ -648,6 +648,20 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            return true;
        }

        case GET_STACK_BOX_INFO_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            int stackBoxId = data.readInt();
            StackBoxInfo info = getStackBoxInfo(stackBoxId);
            reply.writeNoException();
            if (info != null) {
                reply.writeInt(1);
                info.writeToParcel(reply, 0);
            } else {
                reply.writeInt(0);
            }
            return true;
        }

        case SET_FOCUSED_STACK_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            int stackId = data.readInt();
@@ -2672,6 +2686,24 @@ class ActivityManagerProxy implements IActivityManager
        return list;
    }
    @Override
    public StackBoxInfo getStackBoxInfo(int stackBoxId) throws RemoteException
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeInt(stackBoxId);
        mRemote.transact(GET_STACK_BOX_INFO_TRANSACTION, data, reply, 0);
        reply.readException();
        int res = reply.readInt();
        StackBoxInfo info = null;
        if (res != 0) {
            info = StackBoxInfo.CREATOR.createFromParcel(reply);
        }
        data.recycle();
        reply.recycle();
        return info;
    }
    @Override
    public void setFocusedStack(int stackId) throws RemoteException
    {
        Parcel data = Parcel.obtain();
+2 −0
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ public interface IActivityManager extends IInterface {
    public void moveTaskToStack(int taskId, int stackId, boolean toTop) throws RemoteException;
    public void resizeStackBox(int stackBoxId, float weight) throws RemoteException;
    public List<StackBoxInfo> getStackBoxes() throws RemoteException;
    public StackBoxInfo getStackBoxInfo(int stackBoxId) throws RemoteException;
    public void setFocusedStack(int stackId) throws RemoteException;
    public int getTaskForActivity(IBinder token, boolean onlyRoot) throws RemoteException;
    /* oneway */
@@ -664,4 +665,5 @@ public interface IActivityManager extends IInterface {
    int RESIZE_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+169;
    int GET_STACK_BOXES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+170;
    int SET_FOCUSED_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+171;
    int GET_STACK_BOX_INFO_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+172;
}
+16 −0
Original line number Diff line number Diff line
@@ -6449,6 +6449,22 @@ public final class ActivityManagerService extends ActivityManagerNative
        return stackBoxInfos;
    }
    @Override
    public StackBoxInfo getStackBoxInfo(int stackBoxId) {
        List<StackBoxInfo> stackBoxInfos = mWindowManager.getStackBoxInfos();
        StackBoxInfo info = null;
        synchronized (this) {
            List<StackInfo> stackInfos = getStacks();
            for (StackBoxInfo stackBoxInfo : stackBoxInfos) {
                addStackInfoToStackBoxInfo(stackBoxInfo, stackInfos);
                if (stackBoxInfo.stackBoxId == stackBoxId) {
                    info = stackBoxInfo;
                }
            }
        }
        return info;
    }
    @Override
    public int getTaskForActivity(IBinder token, boolean onlyRoot) {
        synchronized(this) {