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

Commit bf29986c authored by Jeff Chang's avatar Jeff Chang
Browse files

Signal a rerouted callback if display was set to SingleTaskInstance

singleTaskInstance displays will only contain one task and any attempt
to launch new task will re-route to the default display. Signal a callback
for listeners to handle the case.

Bug: 123642392
Test: atest ActivityManagerMultiDisplayTests#testSingleTaskInstanceDisplay
Change-Id: I16b98d47a798f920a551942d761f07b1df1defc0
parent 9a9e8d0d
Loading
Loading
Loading
Loading
+10 −0
Original line number Original line Diff line number Diff line
@@ -80,6 +80,16 @@ oneway interface ITaskStackListener {
    void onActivityLaunchOnSecondaryDisplayFailed(in ActivityManager.RunningTaskInfo taskInfo,
    void onActivityLaunchOnSecondaryDisplayFailed(in ActivityManager.RunningTaskInfo taskInfo,
            int requestedDisplayId);
            int requestedDisplayId);


    /**
     * Called when an activity was requested to be launched on a secondary display but was rerouted
     * to default display.
     *
     * @param taskInfo info about the Activity's task
     * @param requestedDisplayId the id of the requested launch display
     */
    void onActivityLaunchOnSecondaryDisplayRerouted(in ActivityManager.RunningTaskInfo taskInfo,
                int requestedDisplayId);

    /**
    /**
     * Called when a task is added.
     * Called when a task is added.
     *
     *
+6 −0
Original line number Original line Diff line number Diff line
@@ -84,6 +84,12 @@ public abstract class TaskStackListener extends ITaskStackListener.Stub {
    public void onActivityLaunchOnSecondaryDisplayFailed() throws RemoteException {
    public void onActivityLaunchOnSecondaryDisplayFailed() throws RemoteException {
    }
    }


    @Override
    @UnsupportedAppUsage
    public void onActivityLaunchOnSecondaryDisplayRerouted(ActivityManager.RunningTaskInfo taskInfo,
            int requestedDisplayId) throws RemoteException {
    }

    @Override
    @Override
    public void onTaskCreated(int taskId, ComponentName componentName) throws RemoteException {
    public void onTaskCreated(int taskId, ComponentName componentName) throws RemoteException {
    }
    }
+15 −0
Original line number Original line Diff line number Diff line
@@ -48,6 +48,21 @@ public abstract class TaskStackChangeListener {
        onActivityLaunchOnSecondaryDisplayFailed();
        onActivityLaunchOnSecondaryDisplayFailed();
    }
    }


    /**
     * @see #onActivityLaunchOnSecondaryDisplayRerouted(RunningTaskInfo taskInfo)
     */
    public void onActivityLaunchOnSecondaryDisplayRerouted() { }

    /**
     * Called when an activity was requested to be launched on a secondary display but was rerouted
     * to default display.
     *
     * @param taskInfo info about the Activity's task
     */
    public void onActivityLaunchOnSecondaryDisplayRerouted(RunningTaskInfo taskInfo) {
        onActivityLaunchOnSecondaryDisplayRerouted();
    }

    public void onTaskProfileLocked(int taskId, int userId) { }
    public void onTaskProfileLocked(int taskId, int userId) { }
    public void onTaskCreated(int taskId, ComponentName componentName) { }
    public void onTaskCreated(int taskId, ComponentName componentName) { }
    public void onTaskRemoved(int taskId) { }
    public void onTaskRemoved(int taskId) { }
+16 −0
Original line number Original line Diff line number Diff line
@@ -140,6 +140,13 @@ public class TaskStackChangeListeners extends TaskStackListener {
                taskInfo).sendToTarget();
                taskInfo).sendToTarget();
    }
    }


    @Override
    public void onActivityLaunchOnSecondaryDisplayRerouted(RunningTaskInfo taskInfo,
            int requestedDisplayId) throws RemoteException {
        mHandler.obtainMessage(H.ON_ACTIVITY_LAUNCH_ON_SECONDARY_DISPLAY_REROUTED,
                 requestedDisplayId, 0 /* unused */, taskInfo).sendToTarget();
    }

    @Override
    @Override
    public void onTaskProfileLocked(int taskId, int userId) throws RemoteException {
    public void onTaskProfileLocked(int taskId, int userId) throws RemoteException {
        mHandler.obtainMessage(H.ON_TASK_PROFILE_LOCKED, taskId, userId).sendToTarget();
        mHandler.obtainMessage(H.ON_TASK_PROFILE_LOCKED, taskId, userId).sendToTarget();
@@ -189,6 +196,7 @@ public class TaskStackChangeListeners extends TaskStackListener {
        private static final int ON_TASK_REMOVED = 13;
        private static final int ON_TASK_REMOVED = 13;
        private static final int ON_TASK_MOVED_TO_FRONT = 14;
        private static final int ON_TASK_MOVED_TO_FRONT = 14;
        private static final int ON_ACTIVITY_REQUESTED_ORIENTATION_CHANGE = 15;
        private static final int ON_ACTIVITY_REQUESTED_ORIENTATION_CHANGE = 15;
        private static final int ON_ACTIVITY_LAUNCH_ON_SECONDARY_DISPLAY_REROUTED = 16;




        public H(Looper looper) {
        public H(Looper looper) {
@@ -270,6 +278,14 @@ public class TaskStackChangeListeners extends TaskStackListener {
                        }
                        }
                        break;
                        break;
                    }
                    }
                    case ON_ACTIVITY_LAUNCH_ON_SECONDARY_DISPLAY_REROUTED: {
                        final RunningTaskInfo info = (RunningTaskInfo) msg.obj;
                        for (int i = mTaskStackListeners.size() - 1; i >= 0; i--) {
                            mTaskStackListeners.get(i)
                                .onActivityLaunchOnSecondaryDisplayRerouted(info);
                        }
                        break;
                    }
                    case ON_TASK_PROFILE_LOCKED: {
                    case ON_TASK_PROFILE_LOCKED: {
                        for (int i = mTaskStackListeners.size() - 1; i >= 0; i--) {
                        for (int i = mTaskStackListeners.size() - 1; i >= 0; i--) {
                            mTaskStackListeners.get(i).onTaskProfileLocked(msg.arg1, msg.arg2);
                            mTaskStackListeners.get(i).onTaskProfileLocked(msg.arg1, msg.arg2);
+3 −0
Original line number Original line Diff line number Diff line
@@ -2351,6 +2351,9 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
                // Suppress the warning toast if the preferredDisplay was set to singleTask.
                // Suppress the warning toast if the preferredDisplay was set to singleTask.
                // The singleTaskInstance displays will only contain one task and any attempt to
                // The singleTaskInstance displays will only contain one task and any attempt to
                // launch new task will re-route to the default display.
                // launch new task will re-route to the default display.
                mService.getTaskChangeNotificationController()
                        .notifyActivityLaunchOnSecondaryDisplayRerouted(task.getTaskInfo(),
                                preferredDisplayId);
                return;
                return;
            }
            }


Loading