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

Commit b3da834a authored by Filip Gruszczynski's avatar Filip Gruszczynski
Browse files

Move tasks to fullscreen stack when dismissing docked stack.

When we dismissing a docked stack we don't want to get rid of it,
but instead make it available in the full screen stack. We need to
make sure that it goes into the bottom of the stack and prevent it
from taking focus or running any animation, so the operation is
invisible to the user.

Bug: 25840497
Bug: 25823213
Change-Id: Ibd08d7b723a2847d98c435f79541d5eb43587064
parent f0fc0c83
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -2718,10 +2718,10 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            reply.writeNoException();
            return true;
        }
        case REMOVE_STACK_TRANSACTION: {
        case MOVE_TASKS_TO_FULLSCREEN_STACK_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            final int stackId = data.readInt();
            removeStack(stackId);
            moveTasksToFullscreenStack(stackId);
            reply.writeNoException();
            return true;
        }
@@ -6358,12 +6358,12 @@ class ActivityManagerProxy implements IActivityManager
    }

    @Override
    public void removeStack(int stackId) throws RemoteException {
    public void moveTasksToFullscreenStack(int fromStackId) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeInt(stackId);
        mRemote.transact(REMOVE_STACK_TRANSACTION, data, reply, 0);
        data.writeInt(fromStackId);
        mRemote.transact(MOVE_TASKS_TO_FULLSCREEN_STACK_TRANSACTION, data, reply, 0);
        reply.readException();
        data.recycle();
        reply.recycle();
+2 −2
Original line number Diff line number Diff line
@@ -541,7 +541,7 @@ public interface IActivityManager extends IInterface {

    public void suppressResizeConfigChanges(boolean suppress) throws RemoteException;

    public void removeStack(int stackId) throws RemoteException;
    public void moveTasksToFullscreenStack(int fromStackId) throws RemoteException;

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

@@ -906,7 +906,7 @@ public interface IActivityManager extends IInterface {
    int REPORT_SIZE_CONFIGURATIONS = IBinder.FIRST_CALL_TRANSACTION + 345;
    int MOVE_TASK_TO_DOCKED_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 346;
    int SUPPRESS_RESIZE_CONFIG_CHANGES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 347;
    int REMOVE_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 348;
    int MOVE_TASKS_TO_FULLSCREEN_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 348;
    int MOVE_TOP_ACTIVITY_TO_PINNED_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 349;
    int GET_APP_START_MODE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 350;
    int UNLOCK_USER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 351;
+1 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ public class WindowManagerProxy {
        @Override
        public void run() {
            try {
                ActivityManagerNative.getDefault().removeStack(DOCKED_STACK_ID);
                ActivityManagerNative.getDefault().moveTasksToFullscreenStack(DOCKED_STACK_ID);
            } catch (RemoteException e) {
                Log.w(TAG, "Failed to remove stack: " + e);
            }
+14 −12
Original line number Diff line number Diff line
@@ -490,6 +490,8 @@ public final class ActivityManagerService extends ActivityManagerNative
    // Used to indicate that a task is removed it should also be removed from recents.
    private static final boolean REMOVE_FROM_RECENTS = true;
    // Used to indicate that an app transition should be animated.
    private static final boolean ANIMATE = true;
    private static native int nativeMigrateToBoost();
    private static native int nativeMigrateFromBoost();
@@ -4333,7 +4335,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                if (task.stack.mStackId != launchStackId) {
                    mStackSupervisor.moveTaskToStackLocked(
                            taskId, launchStackId, ON_TOP, FORCE_FOCUS, "startActivityFromRecents",
                            true /* animate */);
                            ANIMATE);
                }
            }
@@ -9314,7 +9316,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                if (DEBUG_STACK) Slog.d(TAG_STACK, "moveActivityToStack: moving r=" + r
                        + " to stackId=" + stackId);
                mStackSupervisor.moveTaskToStackLocked(r.task.taskId, stackId, ON_TOP, !FORCE_FOCUS,
                        "moveActivityToStack", true /* animate */);
                        "moveActivityToStack", ANIMATE);
            } finally {
                Binder.restoreCallingIdentity(ident);
            }
@@ -9335,7 +9337,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                if (DEBUG_STACK) Slog.d(TAG_STACK, "moveTaskToStack: moving task=" + taskId
                        + " to stackId=" + stackId + " toTop=" + toTop);
                mStackSupervisor.moveTaskToStackLocked(taskId, stackId, toTop, !FORCE_FOCUS,
                        "moveTaskToStack", true /* animate */);
                        "moveTaskToStack", ANIMATE);
            } finally {
                Binder.restoreCallingIdentity(ident);
            }
@@ -17779,20 +17781,20 @@ public final class ActivityManagerService extends ActivityManagerNative
    }
    @Override
    public void removeStack(int stackId) {
    public void moveTasksToFullscreenStack(int fromStackId) {
        enforceCallingPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS,
                "detahStack()");
        if (stackId == HOME_STACK_ID) {
            throw new IllegalArgumentException("Removing home stack is not allowed.");
                "moveTasksToFullscreenStack()");
        if (fromStackId == HOME_STACK_ID) {
            throw new IllegalArgumentException("You can't move tasks from the home stack.");
        }
        synchronized (this) {
            long origId = Binder.clearCallingIdentity();
            ActivityStack stack = mStackSupervisor.getStack(stackId);
            final long origId = Binder.clearCallingIdentity();
            final ActivityStack stack = mStackSupervisor.getStack(fromStackId);
            if (stack != null) {
                ArrayList<TaskRecord> tasks = stack.getAllTasks();
                final ArrayList<TaskRecord> tasks = stack.getAllTasks();
                for (int i = tasks.size() - 1; i >= 0; i--) {
                    removeTaskByIdLocked(tasks.get(i).taskId, false /* killProcess */,
                            !REMOVE_FROM_RECENTS);
                    mStackSupervisor.positionTaskInStackLocked(tasks.get(i).taskId,
                            FULLSCREEN_WORKSPACE_STACK_ID, 0);
                }
            }
            Binder.restoreCallingIdentity(origId);