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

Commit 9101d266 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Allow AMS.moveTasksToFullscreenStack moving tasks onTop

Bug: 26573473
Change-Id: I4517ac2b3e803637971c329be2511ba66412d815
parent b68d2d5b
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -2798,7 +2798,8 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
        case MOVE_TASKS_TO_FULLSCREEN_STACK_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            final int stackId = data.readInt();
            moveTasksToFullscreenStack(stackId);
            final boolean onTop = data.readInt() == 1;
            moveTasksToFullscreenStack(stackId, onTop);
            reply.writeNoException();
            return true;
        }
@@ -6573,11 +6574,12 @@ class ActivityManagerProxy implements IActivityManager
    }

    @Override
    public void moveTasksToFullscreenStack(int fromStackId) throws RemoteException {
    public void moveTasksToFullscreenStack(int fromStackId, boolean onTop) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeInt(fromStackId);
        data.writeInt(onTop ? 1 : 0);
        mRemote.transact(MOVE_TASKS_TO_FULLSCREEN_STACK_TRANSACTION, data, reply, 0);
        reply.readException();
        data.recycle();
+1 −1
Original line number Diff line number Diff line
@@ -577,7 +577,7 @@ public interface IActivityManager extends IInterface {

    public void suppressResizeConfigChanges(boolean suppress) throws RemoteException;

    public void moveTasksToFullscreenStack(int fromStackId) throws RemoteException;
    public void moveTasksToFullscreenStack(int fromStackId, boolean onTop) throws RemoteException;

    public int getAppStartMode(int uid, String packageName) throws RemoteException;

+2 −1
Original line number Diff line number Diff line
@@ -85,7 +85,8 @@ public class WindowManagerProxy {
        @Override
        public void run() {
            try {
                ActivityManagerNative.getDefault().moveTasksToFullscreenStack(DOCKED_STACK_ID);
                ActivityManagerNative.getDefault().moveTasksToFullscreenStack(
                        DOCKED_STACK_ID, false /* onTop */);
            } catch (RemoteException e) {
                Log.w(TAG, "Failed to remove stack: " + e);
            }
+13 −4
Original line number Diff line number Diff line
@@ -18155,7 +18155,7 @@ public final class ActivityManagerService extends ActivityManagerNative
    }
    @Override
    public void moveTasksToFullscreenStack(int fromStackId) {
    public void moveTasksToFullscreenStack(int fromStackId, boolean onTop) {
        enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "moveTasksToFullscreenStack()");
        if (fromStackId == HOME_STACK_ID) {
            throw new IllegalArgumentException("You can't move tasks from the home stack.");
@@ -18165,11 +18165,20 @@ public final class ActivityManagerService extends ActivityManagerNative
            final ActivityStack stack = mStackSupervisor.getStack(fromStackId);
            if (stack != null) {
                final ArrayList<TaskRecord> tasks = stack.getAllTasks();
                for (int i = tasks.size() - 1; i >= 0; i--) {
                final int size = tasks.size();
                if (onTop) {
                    for (int i = 0; i < size; i++) {
                        mStackSupervisor.moveTaskToStackLocked(tasks.get(i).taskId,
                                FULLSCREEN_WORKSPACE_STACK_ID, ON_TOP, !FORCE_FOCUS,
                                "moveTasksToFullscreenStack", ANIMATE);
                    }
                } else {
                    for (int i = size - 1; i >= 0; i--) {
                        mStackSupervisor.positionTaskInStackLocked(tasks.get(i).taskId,
                                FULLSCREEN_WORKSPACE_STACK_ID, 0);
                    }
                }
            }
            Binder.restoreCallingIdentity(origId);
        }
    }