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

Commit 839def9b authored by Andrii Kulian's avatar Andrii Kulian
Browse files

Add shell command to move activity stacks between displays

Also rename "stack movetask" command to be consistent with other
shell commands.

Test: New CTS tests coming soon.
Change-Id: I3d7e04e0ae8ea76c27c3e4c1e286d5cd4539870c
parent ab8220f3
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -752,6 +752,15 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            return true;
        }

        case MOVE_STACK_TO_DISPLAY_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            int stackId = data.readInt();
            int displayId = data.readInt();
            moveStackToDisplay(stackId, displayId);
            reply.writeNoException();
            return true;
        }

        case MOVE_TASK_TO_FRONT_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            int task = data.readInt();
@@ -3885,6 +3894,19 @@ class ActivityManagerProxy implements IActivityManager
        reply.recycle();
        return list;
    }
    public void moveStackToDisplay(int stackId, int displayId) throws RemoteException
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeInt(stackId);
        data.writeInt(displayId);
        mRemote.transact(MOVE_STACK_TO_DISPLAY_TRANSACTION, data, reply, 0);
        reply.readException();
        data.recycle();
        reply.recycle();
    }
    @Override
    public void moveTaskToFront(int task, int flags, Bundle options) throws RemoteException
    {
        Parcel data = Parcel.obtain();
+0 −7
Original line number Diff line number Diff line
@@ -448,13 +448,6 @@ public class ActivityView extends ViewGroup {
            mGuard.open("release");
        }

        void attachToDisplay(int displayId) {
            try {
                mIActivityContainer.attachToDisplay(displayId);
            } catch (RemoteException e) {
            }
        }

        void setSurface(Surface surface, int width, int height, int density)
                throws RemoteException {
            mIActivityContainer.setSurface(surface, width, height, density);
+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ import android.view.Surface;

/** @hide */
interface IActivityContainer {
    void attachToDisplay(int displayId);
    void addToDisplay(int displayId);
    void setSurface(in Surface surface, int width, int height, int density);
    int startActivity(in Intent intent);
    int startActivityIntentSender(in IIntentSender intentSender);
+2 −0
Original line number Diff line number Diff line
@@ -143,6 +143,7 @@ public interface IActivityManager extends IInterface {
    public List<RunningServiceInfo> getServices(int maxNum, int flags) throws RemoteException;
    public List<ActivityManager.ProcessErrorStateInfo> getProcessesInErrorState()
            throws RemoteException;
    public void moveStackToDisplay(int stackId, int displayId) throws RemoteException;
    public void moveTaskToFront(int task, int flags, Bundle options) throws RemoteException;
    public boolean moveActivityTaskToBack(IBinder token, boolean nonRoot) throws RemoteException;
    public void moveTaskBackwards(int task) throws RemoteException;
@@ -1100,4 +1101,5 @@ public interface IActivityManager extends IInterface {
    int REQUEST_ACTIVITY_RELAUNCH = IBinder.FIRST_CALL_TRANSACTION+400;
    int UPDATE_DISPLAY_OVERRIDE_CONFIGURATION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 401;
    int UNREGISTER_TASK_STACK_LISTENER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+402;
    int MOVE_STACK_TO_DISPLAY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 403;
}
+16 −0
Original line number Diff line number Diff line
@@ -9512,6 +9512,22 @@ public class ActivityManagerService extends ActivityManagerNative
        }
    }
    @Override
    public void moveStackToDisplay(int stackId, int displayId) {
        enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "moveStackToDisplay()");
        synchronized (this) {
            final long ident = Binder.clearCallingIdentity();
            try {
                if (DEBUG_STACK) Slog.d(TAG_STACK, "moveStackToDisplay: moving stackId=" + stackId
                        + " to displayId=" + displayId);
                mStackSupervisor.moveStackToDisplayLocked(stackId, displayId);
            } finally {
                Binder.restoreCallingIdentity(ident);
            }
        }
    }
    @Override
    public boolean removeTask(int taskId) {
        enforceCallingPermission(android.Manifest.permission.REMOVE_TASKS, "removeTask()");
Loading