From 00f6fd9fd0bd59eb55573978c0271c1e44baddba Mon Sep 17 00:00:00 2001 From: Jeremy Sim Date: Thu, 11 May 2023 15:13:23 -0700 Subject: [PATCH] Allows splitscreen with work & personal version of the same app This patch makes it so that the user can use splitscreen with work & personal profile versions of the same app, even if the app does not support multi-instance. Previously, we checked package name to prevent the user from opening 2 versions of the same app if the app did not allow multi-instance. But multi-instance with different user profiles should actually be allowed, since they are essentially 2 independent apps in the system. Fixed by changing SplitScreenUtils#samePackage() to take in and check userIds as well. Fixes: 274973415 Test: Manual Change-Id: I13d80ddda10f08b87971f45a03d3ba2910befb8a --- .../shell/common/split/SplitScreenUtils.java | 13 +- .../shell/draganddrop/DragAndDropPolicy.java | 13 +- .../wm/shell/splitscreen/ISplitScreen.aidl | 24 ++-- .../splitscreen/SplitScreenController.java | 114 +++++++++++------- .../draganddrop/DragAndDropPolicyTest.java | 10 +- .../SplitScreenControllerTests.java | 15 ++- 6 files changed, 115 insertions(+), 74 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitScreenUtils.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitScreenUtils.java index 042721c97053b..0289da9169370 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitScreenUtils.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitScreenUtils.java @@ -78,8 +78,15 @@ public class SplitScreenUtils { return taskInfo != null ? getPackageName(taskInfo.baseIntent) : null; } - /** Returns true if they are the same package. */ - public static boolean samePackage(String packageName1, String packageName2) { - return packageName1 != null && packageName1.equals(packageName2); + /** Retrieve user id from a taskId */ + public static int getUserId(int taskId, ShellTaskOrganizer taskOrganizer) { + final ActivityManager.RunningTaskInfo taskInfo = taskOrganizer.getRunningTaskInfo(taskId); + return taskInfo != null ? taskInfo.userId : -1; + } + + /** Returns true if package names and user ids match. */ + public static boolean samePackage(String packageName1, String packageName2, + int userId1, int userId2) { + return (packageName1 != null && packageName1.equals(packageName2)) && (userId1 == userId2); } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragAndDropPolicy.java b/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragAndDropPolicy.java index df94b414c092b..fb08c878837a9 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragAndDropPolicy.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragAndDropPolicy.java @@ -266,6 +266,7 @@ public class DragAndDropPolicy { final boolean isShortcut = description.hasMimeType(MIMETYPE_APPLICATION_SHORTCUT); final Bundle opts = intent.hasExtra(EXTRA_ACTIVITY_OPTIONS) ? intent.getBundleExtra(EXTRA_ACTIVITY_OPTIONS) : new Bundle(); + final UserHandle user = intent.getParcelableExtra(EXTRA_USER); if (isTask) { final int taskId = intent.getIntExtra(EXTRA_TASK_ID, INVALID_TASK_ID); @@ -273,14 +274,14 @@ public class DragAndDropPolicy { } else if (isShortcut) { final String packageName = intent.getStringExtra(EXTRA_PACKAGE_NAME); final String id = intent.getStringExtra(EXTRA_SHORTCUT_ID); - final UserHandle user = intent.getParcelableExtra(EXTRA_USER); mStarter.startShortcut(packageName, id, position, opts, user); } else { final PendingIntent launchIntent = intent.getParcelableExtra(EXTRA_PENDING_INTENT); // Put BAL flags to avoid activity start aborted. opts.putBoolean(KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED, true); opts.putBoolean(KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED_BY_PERMISSION, true); - mStarter.startIntent(launchIntent, null /* fillIntent */, position, opts); + mStarter.startIntent(launchIntent, user.getIdentifier(), null /* fillIntent */, + position, opts); } } @@ -334,8 +335,8 @@ public class DragAndDropPolicy { void startTask(int taskId, @SplitPosition int position, @Nullable Bundle options); void startShortcut(String packageName, String shortcutId, @SplitPosition int position, @Nullable Bundle options, UserHandle user); - void startIntent(PendingIntent intent, Intent fillInIntent, @SplitPosition int position, - @Nullable Bundle options); + void startIntent(PendingIntent intent, int userId, Intent fillInIntent, + @SplitPosition int position, @Nullable Bundle options); void enterSplitScreen(int taskId, boolean leftOrTop); /** @@ -379,8 +380,8 @@ public class DragAndDropPolicy { } @Override - public void startIntent(PendingIntent intent, @Nullable Intent fillInIntent, int position, - @Nullable Bundle options) { + public void startIntent(PendingIntent intent, int userId, @Nullable Intent fillInIntent, + int position, @Nullable Bundle options) { try { intent.send(mContext, 0, fillInIntent, null, null, null, options); } catch (PendingIntent.CanceledException e) { diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/ISplitScreen.aidl b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/ISplitScreen.aidl index f819bee2d5e09..c414e708b28d1 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/ISplitScreen.aidl +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/ISplitScreen.aidl @@ -73,8 +73,8 @@ interface ISplitScreen { /** * Starts an activity in a stage. */ - oneway void startIntent(in PendingIntent intent, in Intent fillInIntent, int position, - in Bundle options, in InstanceId instanceId) = 9; + oneway void startIntent(in PendingIntent intent, int userId, in Intent fillInIntent, + int position, in Bundle options, in InstanceId instanceId) = 9; /** * Starts tasks simultaneously in one transition. @@ -86,8 +86,8 @@ interface ISplitScreen { /** * Starts a pair of intent and task in one transition. */ - oneway void startIntentAndTask(in PendingIntent pendingIntent, in Bundle options1, int taskId, - in Bundle options2, int sidePosition, float splitRatio, + oneway void startIntentAndTask(in PendingIntent pendingIntent, int userId1, in Bundle options1, + int taskId, in Bundle options2, int sidePosition, float splitRatio, in RemoteTransition remoteTransition, in InstanceId instanceId) = 16; /** @@ -107,7 +107,7 @@ interface ISplitScreen { /** * Starts a pair of intent and task using legacy transition system. */ - oneway void startIntentAndTaskWithLegacyTransition(in PendingIntent pendingIntent, + oneway void startIntentAndTaskWithLegacyTransition(in PendingIntent pendingIntent, int userId1, in Bundle options1, int taskId, in Bundle options2, int splitPosition, float splitRatio, in RemoteAnimationAdapter adapter, in InstanceId instanceId) = 12; @@ -121,18 +121,18 @@ interface ISplitScreen { /** * Start a pair of intents using legacy transition system. */ - oneway void startIntentsWithLegacyTransition(in PendingIntent pendingIntent1, + oneway void startIntentsWithLegacyTransition(in PendingIntent pendingIntent1, int userId1, in ShortcutInfo shortcutInfo1, in Bundle options1, in PendingIntent pendingIntent2, - in ShortcutInfo shortcutInfo2, in Bundle options2, int splitPosition, float splitRatio, - in RemoteAnimationAdapter adapter, in InstanceId instanceId) = 18; + int userId2, in ShortcutInfo shortcutInfo2, in Bundle options2, int splitPosition, + float splitRatio, in RemoteAnimationAdapter adapter, in InstanceId instanceId) = 18; /** * Start a pair of intents in one transition. */ - oneway void startIntents(in PendingIntent pendingIntent1, in ShortcutInfo shortcutInfo1, - in Bundle options1, in PendingIntent pendingIntent2, in ShortcutInfo shortcutInfo2, - in Bundle options2, int splitPosition, float splitRatio, - in RemoteTransition remoteTransition, in InstanceId instanceId) = 19; + oneway void startIntents(in PendingIntent pendingIntent1, int userId1, + in ShortcutInfo shortcutInfo1, in Bundle options1, in PendingIntent pendingIntent2, + int userId2, in ShortcutInfo shortcutInfo2, in Bundle options2, int splitPosition, + float splitRatio, in RemoteTransition remoteTransition, in InstanceId instanceId) = 19; /** * Blocking call that notifies and gets additional split-screen targets when entering diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenController.java index c654c1b0d431c..34701f1db7b7b 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenController.java @@ -502,7 +502,8 @@ public class SplitScreenController implements DragAndDropPolicy.Starter, if (options == null) options = new Bundle(); final ActivityOptions activityOptions = ActivityOptions.fromBundle(options); - if (samePackage(packageName, getPackageName(reverseSplitPosition(position)))) { + if (samePackage(packageName, getPackageName(reverseSplitPosition(position)), + user.getIdentifier(), getUserId(reverseSplitPosition(position)))) { if (supportMultiInstancesSplit(packageName)) { activityOptions.setApplyMultipleTaskFlagForShortcut(true); ProtoLog.v(ShellProtoLogGroup.WM_SHELL_SPLIT_SCREEN, "Adding MULTIPLE_TASK"); @@ -531,7 +532,9 @@ public class SplitScreenController implements DragAndDropPolicy.Starter, final String packageName1 = shortcutInfo.getPackage(); final String packageName2 = SplitScreenUtils.getPackageName(taskId, mTaskOrganizer); - if (samePackage(packageName1, packageName2)) { + final int userId1 = shortcutInfo.getUserId(); + final int userId2 = SplitScreenUtils.getUserId(taskId, mTaskOrganizer); + if (samePackage(packageName1, packageName2, userId1, userId2)) { if (supportMultiInstancesSplit(shortcutInfo.getPackage())) { activityOptions.setApplyMultipleTaskFlagForShortcut(true); ProtoLog.v(ShellProtoLogGroup.WM_SHELL_SPLIT_SCREEN, "Adding MULTIPLE_TASK"); @@ -558,7 +561,9 @@ public class SplitScreenController implements DragAndDropPolicy.Starter, // NOTE: This doesn't correctly pull out packageName2 if taskId is referring to a task in // recents that hasn't launched and is not being organized final String packageName2 = SplitScreenUtils.getPackageName(taskId, mTaskOrganizer); - if (samePackage(packageName1, packageName2)) { + final int userId1 = shortcutInfo.getUserId(); + final int userId2 = SplitScreenUtils.getUserId(taskId, mTaskOrganizer); + if (samePackage(packageName1, packageName2, userId1, userId2)) { if (supportMultiInstancesSplit(packageName1)) { activityOptions.setApplyMultipleTaskFlagForShortcut(true); ProtoLog.v(ShellProtoLogGroup.WM_SHELL_SPLIT_SCREEN, "Adding MULTIPLE_TASK"); @@ -578,23 +583,24 @@ public class SplitScreenController implements DragAndDropPolicy.Starter, } /** - * See {@link #startIntent(PendingIntent, Intent, int, Bundle)} + * See {@link #startIntent(PendingIntent, int, Intent, int, Bundle)} * @param instanceId to be used by {@link SplitscreenEventLogger} */ - public void startIntent(PendingIntent intent, @Nullable Intent fillInIntent, + public void startIntent(PendingIntent intent, int userId, @Nullable Intent fillInIntent, @SplitPosition int position, @Nullable Bundle options, @NonNull InstanceId instanceId) { mStageCoordinator.onRequestToSplit(instanceId, ENTER_REASON_LAUNCHER); - startIntent(intent, fillInIntent, position, options); + startIntent(intent, userId, fillInIntent, position, options); } - private void startIntentAndTaskWithLegacyTransition(PendingIntent pendingIntent, + private void startIntentAndTaskWithLegacyTransition(PendingIntent pendingIntent, int userId1, @Nullable Bundle options1, int taskId, @Nullable Bundle options2, @SplitPosition int splitPosition, float splitRatio, RemoteAnimationAdapter adapter, InstanceId instanceId) { Intent fillInIntent = null; final String packageName1 = SplitScreenUtils.getPackageName(pendingIntent); final String packageName2 = SplitScreenUtils.getPackageName(taskId, mTaskOrganizer); - if (samePackage(packageName1, packageName2)) { + final int userId2 = SplitScreenUtils.getUserId(taskId, mTaskOrganizer); + if (samePackage(packageName1, packageName2, userId1, userId2)) { if (supportMultiInstancesSplit(packageName1)) { fillInIntent = new Intent(); fillInIntent.addFlags(FLAG_ACTIVITY_MULTIPLE_TASK); @@ -611,15 +617,17 @@ public class SplitScreenController implements DragAndDropPolicy.Starter, options1, taskId, options2, splitPosition, splitRatio, adapter, instanceId); } - private void startIntentAndTask(PendingIntent pendingIntent, @Nullable Bundle options1, - int taskId, @Nullable Bundle options2, @SplitPosition int splitPosition, - float splitRatio, @Nullable RemoteTransition remoteTransition, InstanceId instanceId) { + private void startIntentAndTask(PendingIntent pendingIntent, int userId1, + @Nullable Bundle options1, int taskId, @Nullable Bundle options2, + @SplitPosition int splitPosition, float splitRatio, + @Nullable RemoteTransition remoteTransition, InstanceId instanceId) { Intent fillInIntent = null; final String packageName1 = SplitScreenUtils.getPackageName(pendingIntent); // NOTE: This doesn't correctly pull out packageName2 if taskId is referring to a task in // recents that hasn't launched and is not being organized final String packageName2 = SplitScreenUtils.getPackageName(taskId, mTaskOrganizer); - if (samePackage(packageName1, packageName2)) { + final int userId2 = SplitScreenUtils.getUserId(taskId, mTaskOrganizer); + if (samePackage(packageName1, packageName2, userId1, userId2)) { if (supportMultiInstancesSplit(packageName1)) { fillInIntent = new Intent(); fillInIntent.addFlags(FLAG_ACTIVITY_MULTIPLE_TASK); @@ -639,16 +647,16 @@ public class SplitScreenController implements DragAndDropPolicy.Starter, options2, splitPosition, splitRatio, remoteTransition, instanceId); } - private void startIntentsWithLegacyTransition(PendingIntent pendingIntent1, + private void startIntentsWithLegacyTransition(PendingIntent pendingIntent1, int userId1, @Nullable ShortcutInfo shortcutInfo1, @Nullable Bundle options1, - PendingIntent pendingIntent2, @Nullable ShortcutInfo shortcutInfo2, + PendingIntent pendingIntent2, int userId2, @Nullable ShortcutInfo shortcutInfo2, @Nullable Bundle options2, @SplitPosition int splitPosition, float splitRatio, RemoteAnimationAdapter adapter, InstanceId instanceId) { Intent fillInIntent1 = null; Intent fillInIntent2 = null; final String packageName1 = SplitScreenUtils.getPackageName(pendingIntent1); final String packageName2 = SplitScreenUtils.getPackageName(pendingIntent2); - if (samePackage(packageName1, packageName2)) { + if (samePackage(packageName1, packageName2, userId1, userId2)) { if (supportMultiInstancesSplit(packageName1)) { fillInIntent1 = new Intent(); fillInIntent1.addFlags(FLAG_ACTIVITY_MULTIPLE_TASK); @@ -668,16 +676,16 @@ public class SplitScreenController implements DragAndDropPolicy.Starter, splitPosition, splitRatio, adapter, instanceId); } - private void startIntents(PendingIntent pendingIntent1, + private void startIntents(PendingIntent pendingIntent1, int userId1, @Nullable ShortcutInfo shortcutInfo1, @Nullable Bundle options1, - PendingIntent pendingIntent2, @Nullable ShortcutInfo shortcutInfo2, + PendingIntent pendingIntent2, int userId2, @Nullable ShortcutInfo shortcutInfo2, @Nullable Bundle options2, @SplitPosition int splitPosition, float splitRatio, @Nullable RemoteTransition remoteTransition, InstanceId instanceId) { Intent fillInIntent1 = null; Intent fillInIntent2 = null; final String packageName1 = SplitScreenUtils.getPackageName(pendingIntent1); final String packageName2 = SplitScreenUtils.getPackageName(pendingIntent2); - if (samePackage(packageName1, packageName2)) { + if (samePackage(packageName1, packageName2, userId1, userId2)) { if (supportMultiInstancesSplit(packageName1)) { fillInIntent1 = new Intent(); fillInIntent1.addFlags(FLAG_ACTIVITY_MULTIPLE_TASK); @@ -698,7 +706,7 @@ public class SplitScreenController implements DragAndDropPolicy.Starter, } @Override - public void startIntent(PendingIntent intent, @Nullable Intent fillInIntent, + public void startIntent(PendingIntent intent, int userId1, @Nullable Intent fillInIntent, @SplitPosition int position, @Nullable Bundle options) { // Flag this as a no-user-action launch to prevent sending user leaving event to the current // top activity since it's going to be put into another side of the split. This prevents the @@ -708,7 +716,8 @@ public class SplitScreenController implements DragAndDropPolicy.Starter, final String packageName1 = SplitScreenUtils.getPackageName(intent); final String packageName2 = getPackageName(reverseSplitPosition(position)); - if (SplitScreenUtils.samePackage(packageName1, packageName2)) { + final int userId2 = getUserId(reverseSplitPosition(position)); + if (samePackage(packageName1, packageName2, userId1, userId2)) { if (supportMultiInstancesSplit(packageName1)) { // To prevent accumulating large number of instances in the background, reuse task // in the background with priority. @@ -761,6 +770,24 @@ public class SplitScreenController implements DragAndDropPolicy.Starter, return taskInfo != null ? SplitScreenUtils.getPackageName(taskInfo.baseIntent) : null; } + /** Retrieve user id of a specific split position if split screen is activated, otherwise + * returns the user id of the top running task. */ + private int getUserId(@SplitPosition int position) { + ActivityManager.RunningTaskInfo taskInfo; + if (isSplitScreenVisible()) { + taskInfo = getTaskInfo(position); + } else { + taskInfo = mRecentTasksOptional + .map(recentTasks -> recentTasks.getTopRunningTask()) + .orElse(null); + if (!isValidToSplit(taskInfo)) { + return -1; + } + } + + return taskInfo != null ? taskInfo.userId : -1; + } + @VisibleForTesting boolean supportMultiInstancesSplit(String packageName) { if (packageName != null) { @@ -1069,14 +1096,14 @@ public class SplitScreenController implements DragAndDropPolicy.Starter, } @Override - public void startIntentAndTaskWithLegacyTransition(PendingIntent pendingIntent, + public void startIntentAndTaskWithLegacyTransition(PendingIntent pendingIntent, int userId1, Bundle options1, int taskId, Bundle options2, int splitPosition, float splitRatio, RemoteAnimationAdapter adapter, InstanceId instanceId) { executeRemoteCallWithTaskPermission(mController, "startIntentAndTaskWithLegacyTransition", (controller) -> controller.startIntentAndTaskWithLegacyTransition(pendingIntent, - options1, taskId, options2, splitPosition, splitRatio, adapter, - instanceId)); + userId1, options1, taskId, options2, splitPosition, splitRatio, + adapter, instanceId)); } @Override @@ -1102,13 +1129,14 @@ public class SplitScreenController implements DragAndDropPolicy.Starter, } @Override - public void startIntentAndTask(PendingIntent pendingIntent, @Nullable Bundle options1, - int taskId, @Nullable Bundle options2, @SplitPosition int splitPosition, - float splitRatio, @Nullable RemoteTransition remoteTransition, - InstanceId instanceId) { + public void startIntentAndTask(PendingIntent pendingIntent, int userId1, + @Nullable Bundle options1, int taskId, @Nullable Bundle options2, + @SplitPosition int splitPosition, float splitRatio, + @Nullable RemoteTransition remoteTransition, InstanceId instanceId) { executeRemoteCallWithTaskPermission(mController, "startIntentAndTask", - (controller) -> controller.startIntentAndTask(pendingIntent, options1, taskId, - options2, splitPosition, splitRatio, remoteTransition, instanceId)); + (controller) -> controller.startIntentAndTask(pendingIntent, userId1, options1, + taskId, options2, splitPosition, splitRatio, remoteTransition, + instanceId)); } @Override @@ -1122,29 +1150,29 @@ public class SplitScreenController implements DragAndDropPolicy.Starter, } @Override - public void startIntentsWithLegacyTransition(PendingIntent pendingIntent1, + public void startIntentsWithLegacyTransition(PendingIntent pendingIntent1, int userId1, @Nullable ShortcutInfo shortcutInfo1, @Nullable Bundle options1, - PendingIntent pendingIntent2, @Nullable ShortcutInfo shortcutInfo2, + PendingIntent pendingIntent2, int userId2, @Nullable ShortcutInfo shortcutInfo2, @Nullable Bundle options2, @SplitPosition int splitPosition, float splitRatio, RemoteAnimationAdapter adapter, InstanceId instanceId) { executeRemoteCallWithTaskPermission(mController, "startIntentsWithLegacyTransition", (controller) -> - controller.startIntentsWithLegacyTransition(pendingIntent1, shortcutInfo1, - options1, pendingIntent2, shortcutInfo2, options2, splitPosition, - splitRatio, adapter, instanceId) + controller.startIntentsWithLegacyTransition(pendingIntent1, userId1, + shortcutInfo1, options1, pendingIntent2, userId2, shortcutInfo2, + options2, splitPosition, splitRatio, adapter, instanceId) ); } @Override - public void startIntents(PendingIntent pendingIntent1, @Nullable ShortcutInfo shortcutInfo1, - @Nullable Bundle options1, PendingIntent pendingIntent2, - @Nullable ShortcutInfo shortcutInfo2, @Nullable Bundle options2, - @SplitPosition int splitPosition, float splitRatio, + public void startIntents(PendingIntent pendingIntent1, int userId1, + @Nullable ShortcutInfo shortcutInfo1, @Nullable Bundle options1, + PendingIntent pendingIntent2, int userId2, @Nullable ShortcutInfo shortcutInfo2, + @Nullable Bundle options2, @SplitPosition int splitPosition, float splitRatio, @Nullable RemoteTransition remoteTransition, InstanceId instanceId) { executeRemoteCallWithTaskPermission(mController, "startIntents", (controller) -> - controller.startIntents(pendingIntent1, shortcutInfo1, - options1, pendingIntent2, shortcutInfo2, options2, + controller.startIntents(pendingIntent1, userId1, shortcutInfo1, + options1, pendingIntent2, userId2, shortcutInfo2, options2, splitPosition, splitRatio, remoteTransition, instanceId) ); } @@ -1158,11 +1186,11 @@ public class SplitScreenController implements DragAndDropPolicy.Starter, } @Override - public void startIntent(PendingIntent intent, Intent fillInIntent, int position, + public void startIntent(PendingIntent intent, int userId, Intent fillInIntent, int position, @Nullable Bundle options, InstanceId instanceId) { executeRemoteCallWithTaskPermission(mController, "startIntent", - (controller) -> controller.startIntent(intent, fillInIntent, position, options, - instanceId)); + (controller) -> controller.startIntent(intent, userId, fillInIntent, position, + options, instanceId)); } @Override diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/draganddrop/DragAndDropPolicyTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/draganddrop/DragAndDropPolicyTest.java index 9e988e8e8726b..7c1da35888b8e 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/draganddrop/DragAndDropPolicyTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/draganddrop/DragAndDropPolicyTest.java @@ -211,7 +211,7 @@ public class DragAndDropPolicyTest extends ShellTestCase { mPolicy.getTargets(mInsets), TYPE_FULLSCREEN); mPolicy.handleDrop(filterTargetByType(targets, TYPE_FULLSCREEN), mActivityClipData); - verify(mSplitScreenStarter).startIntent(any(), any(), + verify(mSplitScreenStarter).startIntent(any(), anyInt(), any(), eq(SPLIT_POSITION_UNDEFINED), any()); } @@ -223,12 +223,12 @@ public class DragAndDropPolicyTest extends ShellTestCase { mPolicy.getTargets(mInsets), TYPE_SPLIT_LEFT, TYPE_SPLIT_RIGHT); mPolicy.handleDrop(filterTargetByType(targets, TYPE_SPLIT_LEFT), mActivityClipData); - verify(mSplitScreenStarter).startIntent(any(), any(), + verify(mSplitScreenStarter).startIntent(any(), anyInt(), any(), eq(SPLIT_POSITION_TOP_OR_LEFT), any()); reset(mSplitScreenStarter); mPolicy.handleDrop(filterTargetByType(targets, TYPE_SPLIT_RIGHT), mActivityClipData); - verify(mSplitScreenStarter).startIntent(any(), any(), + verify(mSplitScreenStarter).startIntent(any(), anyInt(), any(), eq(SPLIT_POSITION_BOTTOM_OR_RIGHT), any()); } @@ -240,12 +240,12 @@ public class DragAndDropPolicyTest extends ShellTestCase { mPolicy.getTargets(mInsets), TYPE_SPLIT_TOP, TYPE_SPLIT_BOTTOM); mPolicy.handleDrop(filterTargetByType(targets, TYPE_SPLIT_TOP), mActivityClipData); - verify(mSplitScreenStarter).startIntent(any(), any(), + verify(mSplitScreenStarter).startIntent(any(), anyInt(), any(), eq(SPLIT_POSITION_TOP_OR_LEFT), any()); reset(mSplitScreenStarter); mPolicy.handleDrop(filterTargetByType(targets, TYPE_SPLIT_BOTTOM), mActivityClipData); - verify(mSplitScreenStarter).startIntent(any(), any(), + verify(mSplitScreenStarter).startIntent(any(), anyInt(), any(), eq(SPLIT_POSITION_BOTTOM_OR_RIGHT), any()); } diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SplitScreenControllerTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SplitScreenControllerTests.java index d0e26019f9bf1..c37a497c5d401 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SplitScreenControllerTests.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SplitScreenControllerTests.java @@ -181,7 +181,8 @@ public class SplitScreenControllerTests extends ShellTestCase { PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, startIntent, FLAG_IMMUTABLE); - mSplitScreenController.startIntent(pendingIntent, null, SPLIT_POSITION_TOP_OR_LEFT, null); + mSplitScreenController.startIntent(pendingIntent, mContext.getUserId(), null, + SPLIT_POSITION_TOP_OR_LEFT, null); verify(mStageCoordinator).startIntent(eq(pendingIntent), mIntentCaptor.capture(), eq(SPLIT_POSITION_TOP_OR_LEFT), isNull()); @@ -200,7 +201,8 @@ public class SplitScreenControllerTests extends ShellTestCase { createTaskInfo(WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, startIntent); doReturn(topRunningTask).when(mRecentTasks).getTopRunningTask(); - mSplitScreenController.startIntent(pendingIntent, null, SPLIT_POSITION_TOP_OR_LEFT, null); + mSplitScreenController.startIntent(pendingIntent, mContext.getUserId(), null, + SPLIT_POSITION_TOP_OR_LEFT, null); verify(mStageCoordinator).startIntent(eq(pendingIntent), mIntentCaptor.capture(), eq(SPLIT_POSITION_TOP_OR_LEFT), isNull()); @@ -223,7 +225,8 @@ public class SplitScreenControllerTests extends ShellTestCase { ActivityManager.RecentTaskInfo sameTaskInfo = new ActivityManager.RecentTaskInfo(); doReturn(sameTaskInfo).when(mRecentTasks).findTaskInBackground(any()); - mSplitScreenController.startIntent(pendingIntent, null, SPLIT_POSITION_TOP_OR_LEFT, null); + mSplitScreenController.startIntent(pendingIntent, mContext.getUserId(), null, + SPLIT_POSITION_TOP_OR_LEFT, null); verify(mSplitScreenController).startTask(anyInt(), eq(SPLIT_POSITION_TOP_OR_LEFT), isNull()); @@ -246,7 +249,8 @@ public class SplitScreenControllerTests extends ShellTestCase { doReturn(new ActivityManager.RecentTaskInfo()).when(mRecentTasks) .findTaskInBackground(any()); - mSplitScreenController.startIntent(pendingIntent, null, SPLIT_POSITION_TOP_OR_LEFT, null); + mSplitScreenController.startIntent(pendingIntent, mContext.getUserId(), null, + SPLIT_POSITION_TOP_OR_LEFT, null); verify(mSplitScreenController).startTask(anyInt(), eq(SPLIT_POSITION_TOP_OR_LEFT), isNull()); @@ -265,7 +269,8 @@ public class SplitScreenControllerTests extends ShellTestCase { doReturn(sameTaskInfo).when(mSplitScreenController).getTaskInfo( SPLIT_POSITION_BOTTOM_OR_RIGHT); - mSplitScreenController.startIntent(pendingIntent, null, SPLIT_POSITION_TOP_OR_LEFT, null); + mSplitScreenController.startIntent(pendingIntent, mContext.getUserId(), null, + SPLIT_POSITION_TOP_OR_LEFT, null); verify(mStageCoordinator).switchSplitPosition(anyString()); }