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

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

Merge "Implement stack splitting and task movement."

parents e76dd37b 967212cb
Loading
Loading
Loading
Loading
+86 −8
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ public class Am extends BaseCommand {
        (new Am()).run(args);
    }

    @Override
    public void onShowUsage(PrintStream out) {
        out.println(
                "usage: am [subcommand] [options]\n" +
@@ -99,6 +100,9 @@ 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 <RELATIVE_STACK_ID> <POSITION> <WEIGHT>\n" +
                "       am stack movetask <STACK_ID> <TASK_ID> [true|false]\n" +
                "       am stack dump\n" +
                "\n" +
                "am start: start an Activity.  Options are:\n" +
                "    -D: enable debugging\n" +
@@ -181,6 +185,16 @@ public class Am extends BaseCommand {
                "am stop-user: stop execution of USER_ID, not allowing it to run any\n" +
                "  code until a later explicit switch to it.\n" +
                "\n" +
                "am stack create: create a new stack relative to an existing one.\n" +
                "   <RELATIVE_STACK_ID>: existing stack's id.\n" +
                "   <POSITION>: 0: to left of, 1: to right of, 2: above, 3: below\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" +
                "   bottom (false) of <STACK_ID>.\n" +
                "\n" +
                "am stack dump: list the hierarchy of stacks.\n" +
                "\n" +
                "<INTENT> specifications include these flags and arguments:\n" +
                "    [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]\n" +
                "    [-c <CATEGORY> [-c <CATEGORY>] ...]\n" +
@@ -213,6 +227,7 @@ public class Am extends BaseCommand {
                );
    }

    @Override
    public void onRun() throws Exception {

        mAm = ActivityManagerNative.getDefault();
@@ -259,6 +274,8 @@ public class Am extends BaseCommand {
            runSwitchUser();
        } else if (op.equals("stop-user")) {
            runStopUser();
        } else if (op.equals("stack")) {
            runStack();
        } else {
            showError("Error: unknown command '" + op + "'");
        }
@@ -1029,7 +1046,7 @@ public class Am extends BaseCommand {
        }

        @Override
        public boolean activityResuming(String pkg) throws RemoteException {
        public boolean activityResuming(String pkg) {
            synchronized (this) {
                System.out.println("** Activity resuming: " + pkg);
            }
@@ -1037,7 +1054,7 @@ public class Am extends BaseCommand {
        }

        @Override
        public boolean activityStarting(Intent intent, String pkg) throws RemoteException {
        public boolean activityStarting(Intent intent, String pkg) {
            synchronized (this) {
                System.out.println("** Activity starting: " + pkg);
            }
@@ -1046,7 +1063,7 @@ public class Am extends BaseCommand {

        @Override
        public boolean appCrashed(String processName, int pid, String shortMsg, String longMsg,
                long timeMillis, String stackTrace) throws RemoteException {
                long timeMillis, String stackTrace) {
            synchronized (this) {
                System.out.println("** ERROR: PROCESS CRASHED");
                System.out.println("processName: " + processName);
@@ -1063,8 +1080,7 @@ public class Am extends BaseCommand {
        }

        @Override
        public int appEarlyNotResponding(String processName, int pid, String annotation)
                throws RemoteException {
        public int appEarlyNotResponding(String processName, int pid, String annotation) {
            synchronized (this) {
                System.out.println("** ERROR: EARLY PROCESS NOT RESPONDING");
                System.out.println("processName: " + processName);
@@ -1077,8 +1093,7 @@ public class Am extends BaseCommand {
        }

        @Override
        public int appNotResponding(String processName, int pid, String processStats)
                throws RemoteException {
        public int appNotResponding(String processName, int pid, String processStats) {
            synchronized (this) {
                System.out.println("** ERROR: PROCESS NOT RESPONDING");
                System.out.println("processName: " + processName);
@@ -1326,7 +1341,7 @@ public class Am extends BaseCommand {

        @Override
        public void performReceive(Intent intent, int resultCode, String data, Bundle extras,
                boolean ordered, boolean sticky, int sendingUser) throws RemoteException {
                boolean ordered, boolean sticky, int sendingUser) {
            String line = "Broadcast completed: result=" + resultCode;
            if (data != null) line = line + ", data=\"" + data + "\"";
            if (extras != null) line = line + ", extras: " + extras;
@@ -1359,6 +1374,7 @@ public class Am extends BaseCommand {
            mRawMode = rawMode;
        }

        @Override
        public void instrumentationStatus(ComponentName name, int resultCode, Bundle results) {
            synchronized (this) {
                // pretty printer mode?
@@ -1381,6 +1397,7 @@ public class Am extends BaseCommand {
            }
        }

        @Override
        public void instrumentationFinished(ComponentName name, int resultCode,
                Bundle results) {
            synchronized (this) {
@@ -1421,4 +1438,65 @@ public class Am extends BaseCommand {
            return true;
        }
    }

    private void runStack() throws Exception {
        String op = nextArgRequired();
        if (op.equals("create")) {
            runStackCreate();
        } else if (op.equals("movetask")) {
            runStackMoveTask();
        } else if (op.equals("dump")) {
            runStackDump();
        } else {
            showError("Error: unknown command '" + op + "'");
            return;
        }
    }

    private void runStackCreate() throws Exception {
        String relativeToStr = nextArgRequired();
        int relativeTo = Integer.valueOf(relativeToStr);
        String positionStr = nextArgRequired();
        int position = Integer.valueOf(positionStr);
        String weightStr = nextArgRequired();
        float weight = Float.valueOf(weightStr);

        try {
            int stackId = mAm.createStack(relativeTo, position, weight);
            System.out.println("createStack returned " + stackId + "\n\n");
        } catch (RemoteException e) {
        }
    }

    private void runStackMoveTask() throws Exception {
        String taskIdStr = nextArgRequired();
        int taskId = Integer.valueOf(taskIdStr);
        String stackIdStr = nextArgRequired();
        int stackId = Integer.valueOf(stackIdStr);
        String toTopStr = nextArgRequired();
        final boolean toTop;
        if ("true".equals(toTopStr)) {
            toTop = true;
        } else if ("false".equals(toTopStr)) {
            toTop = false;
        } else {
            System.err.println("Error: bad toTop arg: " + toTopStr);
            return;
        }

        try {
            mAm.moveTaskToStack(taskId, stackId, toTop);
        } catch (RemoteException e) {
        }
    }

    private void runStackDump() throws Exception {
        try {
            List<ActivityManager.StackInfo> stacks = mAm.getStacks();
            for (ActivityManager.StackInfo stack : stacks) {
                System.out.println(stack);
            }
        } catch (RemoteException e) {
        }
    }
}
+69 −3
Original line number Diff line number Diff line
@@ -31,9 +31,8 @@ import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.hardware.display.DisplayManager;
import android.graphics.Rect;
import android.hardware.display.DisplayManagerGlobal;
import android.os.Binder;
import android.os.Bundle;
import android.os.Debug;
import android.os.Handler;
@@ -1230,6 +1229,73 @@ public class ActivityManager {
        }
    }


    /**
     * Information you can retrieve about an ActivityStack in the system.
     * @hide
     */
    public static class StackInfo implements Parcelable {
        public int stackId;
        public Rect bounds;
        public int[] taskIds;
        public String[] taskNames;

        public StackInfo() {
        }

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeInt(stackId);
            dest.writeInt(bounds.left);
            dest.writeInt(bounds.top);
            dest.writeInt(bounds.right);
            dest.writeInt(bounds.bottom);
            dest.writeIntArray(taskIds);
            dest.writeStringArray(taskNames);
        }

        public void readFromParcel(Parcel source) {
            stackId = source.readInt();
            bounds = new Rect(
                    source.readInt(), source.readInt(), source.readInt(), source.readInt());
            taskIds = source.createIntArray();
            taskNames = source.createStringArray();
        }

        public static final Creator<StackInfo> CREATOR = new Creator<StackInfo>() {
            @Override
            public StackInfo createFromParcel(Parcel source) {
                return new StackInfo(source);
            }
            @Override
            public StackInfo[] newArray(int size) {
                return new StackInfo[size];
            }
        };

        private StackInfo(Parcel source) {
            readFromParcel(source);
        }

        @Override
        public String toString() {
            StringBuilder sb = new StringBuilder(256);
            sb.append("Stack id="); sb.append(stackId);
                    sb.append(" bounds="); sb.append(bounds.toShortString()); sb.append("\n");
            final String prefix = "  ";
            for (int i = 0; i < taskIds.length; ++i) {
                sb.append(prefix); sb.append("taskId="); sb.append(taskIds[i]);
                        sb.append(": "); sb.append(taskNames[i]); sb.append("\n");
            }
            return sb.toString();
        }
    }

    /**
     * @hide
     */
+25 −0
Original line number Diff line number Diff line
@@ -639,6 +639,14 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            return true;
        }

        case GET_STACKS_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            List<ActivityManager.StackInfo> list = getStacks();
            reply.writeNoException();
            reply.writeTypedList(list);
            return true;
        }

        case GET_TASK_FOR_ACTIVITY_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            IBinder token = data.readStrongBinder();
@@ -2591,6 +2599,7 @@ class ActivityManagerProxy implements IActivityManager
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeInt(position);
        data.writeInt(relativeStackId);
        data.writeFloat(weight);
@@ -2606,6 +2615,7 @@ class ActivityManagerProxy implements IActivityManager
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeInt(taskId);
        data.writeInt(stackId);
        data.writeInt(toTop ? 1 : 0);
@@ -2619,6 +2629,7 @@ class ActivityManagerProxy implements IActivityManager
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeInt(stackId);
        data.writeFloat(weight);
        mRemote.transact(RESIZE_STACK_TRANSACTION, data, reply, 0);
@@ -2626,6 +2637,20 @@ class ActivityManagerProxy implements IActivityManager
        data.recycle();
        reply.recycle();
    }
    @Override
    public List<ActivityManager.StackInfo> getStacks() throws RemoteException
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        mRemote.transact(GET_STACKS_TRANSACTION, data, reply, 0);
        reply.readException();
        ArrayList<ActivityManager.StackInfo> list
                = reply.createTypedArrayList(ActivityManager.StackInfo.CREATOR);
        data.recycle();
        reply.recycle();
        return list;
    }
    public int getTaskForActivity(IBinder token, boolean onlyRoot) throws RemoteException
    {
        Parcel data = Parcel.obtain();
+4 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.app;

import android.app.ActivityManager.RunningTaskInfo;
import android.app.ActivityManager.RunningServiceInfo;
import android.app.ActivityManager.StackInfo;
import android.content.ComponentName;
import android.content.ContentProviderNative;
import android.content.IContentProvider;
@@ -114,9 +115,10 @@ public interface IActivityManager extends IInterface {
    public void moveTaskToBack(int task) throws RemoteException;
    public boolean moveActivityTaskToBack(IBinder token, boolean nonRoot) throws RemoteException;
    public void moveTaskBackwards(int task) throws RemoteException;
    public int createStack(int position, int relativeStackId, float weight) throws RemoteException;
    public int createStack(int relativeStackId, int position, float weight) throws RemoteException;
    public void moveTaskToStack(int taskId, int stackId, boolean toTop) throws RemoteException;
    public void resizeStack(int stackId, float weight) throws RemoteException;
    public List<StackInfo> getStacks() throws RemoteException;
    public int getTaskForActivity(IBinder token, boolean onlyRoot) throws RemoteException;
    /* oneway */
    public void reportThumbnail(IBinder token,
@@ -646,4 +648,5 @@ public interface IActivityManager extends IInterface {
    int MOVE_TASK_TO_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+166;
    int RESIZE_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+167;
    int SET_USER_IS_MONKEY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+168;
    int GET_STACKS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+169;
}
+8 −0
Original line number Diff line number Diff line
@@ -815,6 +815,14 @@ public interface WindowManagerPolicy {
     */
    public int getSystemDecorRectLw(Rect systemRect);

    /**
     * Return the rectangle of the screen that is available for applications to run in.
     * This will be called immediately after {@link #beginLayoutLw}.
     *
     * @param r The rectangle to be filled with the boundaries available to applications.
     */
    public void getContentRectLw(Rect r);

    /**
     * Called for each window attached to the window manager as layout is
     * proceeding.  The implementation of this function must take care of
Loading