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

Commit 4cd0c13f authored by Craig Mautner's avatar Craig Mautner
Browse files

Incremental repairs to side by side stacks.

- Add taskId parameter to createStack() so stacks are pre-populated
with a task.
- Keep track of stack access order in DisplayContent so getTasks
returns in MRU order.
- Set touchableRegion in InputMonitor so modal touching does not
extend beyond stack boundary.
- Fix stack merging so that deleting a stack results in a new
stack the size of the two children.

Change-Id: I62a6ba0a34f34dd7ec866b440bf04595379e19e8
parent 967212cb
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@ 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 create <TASK_ID> <RELATIVE_STACK_ID> <POSITION> <WEIGHT>\n" +
                "       am stack movetask <STACK_ID> <TASK_ID> [true|false]\n" +
                "       am stack dump\n" +
                "\n" +
@@ -186,6 +186,7 @@ public class Am extends BaseCommand {
                "  code until a later explicit switch to it.\n" +
                "\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" +
                "   <WEIGHT>: float between 0.2 and 0.8 inclusive.\n" +
@@ -1454,6 +1455,8 @@ public class Am extends BaseCommand {
    }

    private void runStackCreate() throws Exception {
        String taskIdStr = nextArgRequired();
        int taskId = Integer.valueOf(taskIdStr);
        String relativeToStr = nextArgRequired();
        int relativeTo = Integer.valueOf(relativeToStr);
        String positionStr = nextArgRequired();
@@ -1462,8 +1465,8 @@ public class Am extends BaseCommand {
        float weight = Float.valueOf(weightStr);

        try {
            int stackId = mAm.createStack(relativeTo, position, weight);
            System.out.println("createStack returned " + stackId + "\n\n");
            int stackId = mAm.createStack(taskId, relativeTo, position, weight);
            System.out.println("createStack returned new stackId=" + stackId + "\n\n");
        } catch (RemoteException e) {
        }
    }
+24 −22
Original line number Diff line number Diff line
@@ -108,6 +108,7 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
        attachInterface(this, descriptor);
    }

    @Override
    public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
            throws RemoteException {
        switch (code) {
@@ -478,14 +479,13 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            IThumbnailReceiver receiver = receiverBinder != null
                ? IThumbnailReceiver.Stub.asInterface(receiverBinder)
                : null;
            List list = getTasks(maxNum, fl, receiver);
            List<ActivityManager.RunningTaskInfo> list = getTasks(maxNum, fl, receiver);
            reply.writeNoException();
            int N = list != null ? list.size() : -1;
            reply.writeInt(N);
            int i;
            for (i=0; i<N; i++) {
                ActivityManager.RunningTaskInfo info =
                        (ActivityManager.RunningTaskInfo)list.get(i);
                ActivityManager.RunningTaskInfo info = list.get(i);
                info.writeToParcel(reply, 0);
            }
            return true;
@@ -535,14 +535,13 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            data.enforceInterface(IActivityManager.descriptor);
            int maxNum = data.readInt();
            int fl = data.readInt();
            List list = getServices(maxNum, fl);
            List<ActivityManager.RunningServiceInfo> list = getServices(maxNum, fl);
            reply.writeNoException();
            int N = list != null ? list.size() : -1;
            reply.writeInt(N);
            int i;
            for (i=0; i<N; i++) {
                ActivityManager.RunningServiceInfo info =
                        (ActivityManager.RunningServiceInfo)list.get(i);
                ActivityManager.RunningServiceInfo info = list.get(i);
                info.writeToParcel(reply, 0);
            }
            return true;
@@ -611,10 +610,11 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM

        case CREATE_STACK_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            int position = data.readInt();
            int taskId = data.readInt();
            int relativeStackId = data.readInt();
            int position = data.readInt();
            float weight = data.readFloat();
            int res = createStack(position, relativeStackId, weight);
            int res = createStack(taskId, relativeStackId, position, weight);
            reply.writeNoException();
            reply.writeInt(res);
            return true;
@@ -2595,13 +2595,15 @@ class ActivityManagerProxy implements IActivityManager
        reply.recycle();
    }
    @Override
    public int createStack(int position, int relativeStackId, float weight) throws RemoteException
    public int createStack(int taskId, int relativeStackId, int position, float weight)
            throws RemoteException
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeInt(position);
        data.writeInt(taskId);
        data.writeInt(relativeStackId);
        data.writeInt(position);
        data.writeFloat(weight);
        mRemote.transact(CREATE_STACK_TRANSACTION, data, reply, 0);
        reply.readException();
+2 −1
Original line number Diff line number Diff line
@@ -115,7 +115,8 @@ 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 relativeStackId, int position, float weight) throws RemoteException;
    public int createStack(int taskId, 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;
+4 −1
Original line number Diff line number Diff line
@@ -6261,13 +6261,16 @@ public final class ActivityManagerService extends ActivityManagerNative
    }
    @Override
    public int createStack(int relativeStackId, int position, float weight) {
    public int createStack(int taskId, int relativeStackId, int position, float weight) {
        synchronized (this) {
            if (mStackSupervisor.getStack(relativeStackId) == null) {
                return -1;
            }
            int stackId = mStackSupervisor.createStack();
            mWindowManager.createStack(stackId, relativeStackId, position, weight);
            if (taskId > 0) {
                moveTaskToStack(taskId, stackId, true);
            }
            return stackId;
        }
    }
+6 −9
Original line number Diff line number Diff line
@@ -236,13 +236,10 @@ public class ActivityStackSupervisor {
        final ActivityStack stack = task.stack;
        if (stack.removeTask(task) && !stack.isHomeStack()) {
            mStacks.remove(stack);
            final int oldStackId = stack.mStackId;
            final int newMainStackId = mService.mWindowManager.removeStack(oldStackId);
            if (newMainStackId == HOME_STACK_ID) {
                return;
            }
            if (mMainStack.mStackId == oldStackId) {
                mMainStack = getStack(newMainStackId);
            final int stackId = stack.mStackId;
            final int nextStackId = mService.mWindowManager.removeStack(stackId);
            if (mMainStack.mStackId == stackId) {
                mMainStack = nextStackId == HOME_STACK_ID ? null : getStack(nextStackId);
            }
        }
    }
@@ -1044,8 +1041,8 @@ public class ActivityStackSupervisor {
        if (!r.isHomeActivity) {
            if (mStacks.size() == 1) {
                // Time to create the first app stack.
                int stackId =
                        mService.createStack(HOME_STACK_ID, StackBox.TASK_STACK_GOES_OVER, 1.0f);
                int stackId = mService.createStack(-1, HOME_STACK_ID,
                        StackBox.TASK_STACK_GOES_OVER, 1.0f);
                mMainStack = getStack(stackId);
            }
            return mMainStack;
Loading