From 92e1eeb5f0a047430c0d6f14384fd5612fec8e69 Mon Sep 17 00:00:00 2001 From: Jeremy Sim Date: Thu, 11 May 2023 22:10:51 -0700 Subject: [PATCH] Allows splitscreen with work & personal version of the same app This patch makes changes in various splitscreen controllers to pass userId to the new shell API, to allow same-app splitting with different users. Fixes: 274973415 Test: Manual Change-Id: I810b5353aad738c7c275856586b9c521f1554022 --- .../taskbar/TaskbarPopupController.java | 1 + ...kbarShortcutMenuAccessibilityDelegate.java | 3 +- .../com/android/quickstep/SystemUiProxy.java | 42 ++++++++-------- .../quickstep/util/SplitSelectDataHolder.kt | 4 ++ .../util/SplitSelectStateController.java | 50 +++++++++++-------- 5 files changed, 57 insertions(+), 43 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java index a442849e02..5e59726afb 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java @@ -328,6 +328,7 @@ public class TaskbarPopupController implements TaskbarControllers.LoggableTaskba mItemInfo.getIntent().getComponent(), null, mItemInfo.user), + mItemInfo.user.getIdentifier(), new Intent(), getPosition().stagePosition, null, diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarShortcutMenuAccessibilityDelegate.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarShortcutMenuAccessibilityDelegate.java index 054689b04a..e8c8fc49fc 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarShortcutMenuAccessibilityDelegate.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarShortcutMenuAccessibilityDelegate.java @@ -111,7 +111,8 @@ public class TaskbarShortcutMenuAccessibilityDelegate item.getIntent().getComponent(), /* startActivityOptions= */null, item.user), - new Intent(), side, null, instanceIds.first); + item.user.getIdentifier(), new Intent(), side, null, + instanceIds.first); } return true; } else if (action == DEEP_SHORTCUTS || action == SHORTCUTS_AND_NOTIFICATIONS) { diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java index 0549d9f8ce..29aed2532b 100644 --- a/quickstep/src/com/android/quickstep/SystemUiProxy.java +++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java @@ -683,12 +683,12 @@ public class SystemUiProxy implements ISystemUiProxy { } } - public void startIntentAndTask(PendingIntent pendingIntent, Bundle options1, int taskId, - Bundle options2, @SplitConfigurationOptions.StagePosition int splitPosition, + public void startIntentAndTask(PendingIntent pendingIntent, int userId1, Bundle options1, + int taskId, Bundle options2, @SplitConfigurationOptions.StagePosition int splitPosition, float splitRatio, RemoteTransition remoteTransition, InstanceId instanceId) { if (mSystemUiProxy != null) { try { - mSplitScreen.startIntentAndTask(pendingIntent, options1, taskId, options2, + mSplitScreen.startIntentAndTask(pendingIntent, userId1, options1, taskId, options2, splitPosition, splitRatio, remoteTransition, instanceId); } catch (RemoteException e) { Log.w(TAG, "Failed call startIntentAndTask"); @@ -696,15 +696,16 @@ public class SystemUiProxy implements ISystemUiProxy { } } - public void startIntents(PendingIntent pendingIntent1, @Nullable ShortcutInfo shortcutInfo1, - Bundle options1, PendingIntent pendingIntent2, @Nullable ShortcutInfo shortcutInfo2, - Bundle options2, @SplitConfigurationOptions.StagePosition int splitPosition, - float splitRatio, RemoteTransition remoteTransition, InstanceId instanceId) { + public void startIntents(PendingIntent pendingIntent1, int userId1, + @Nullable ShortcutInfo shortcutInfo1, Bundle options1, PendingIntent pendingIntent2, + int userId2, @Nullable ShortcutInfo shortcutInfo2, Bundle options2, + @SplitConfigurationOptions.StagePosition int splitPosition, float splitRatio, + RemoteTransition remoteTransition, InstanceId instanceId) { if (mSystemUiProxy != null) { try { - mSplitScreen.startIntents(pendingIntent1, shortcutInfo1, options1, pendingIntent2, - shortcutInfo2, options2, splitPosition, splitRatio, remoteTransition, - instanceId); + mSplitScreen.startIntents(pendingIntent1, userId1, shortcutInfo1, options1, + pendingIntent2, userId2, shortcutInfo2, options2, splitPosition, splitRatio, + remoteTransition, instanceId); } catch (RemoteException e) { Log.w(TAG, "Failed call startIntents"); } @@ -740,14 +741,14 @@ public class SystemUiProxy implements ISystemUiProxy { } } - public void startIntentAndTaskWithLegacyTransition(PendingIntent pendingIntent, + public void startIntentAndTaskWithLegacyTransition(PendingIntent pendingIntent, int userId1, Bundle options1, int taskId, Bundle options2, @SplitConfigurationOptions.StagePosition int splitPosition, float splitRatio, RemoteAnimationAdapter adapter, InstanceId instanceId) { if (mSystemUiProxy != null) { try { - mSplitScreen.startIntentAndTaskWithLegacyTransition(pendingIntent, options1, taskId, - options2, splitPosition, splitRatio, adapter, instanceId); + mSplitScreen.startIntentAndTaskWithLegacyTransition(pendingIntent, userId1, + options1, taskId, options2, splitPosition, splitRatio, adapter, instanceId); } catch (RemoteException e) { Log.w(TAG, "Failed call startIntentAndTaskWithLegacyTransition"); } @@ -771,16 +772,16 @@ public class SystemUiProxy implements ISystemUiProxy { * Starts a pair of intents or shortcuts in split-screen using legacy transition. Passing a * non-null shortcut info means to start the app as a shortcut. */ - 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, @SplitConfigurationOptions.StagePosition int sidePosition, float splitRatio, RemoteAnimationAdapter adapter, InstanceId instanceId) { if (mSystemUiProxy != null) { try { - mSplitScreen.startIntentsWithLegacyTransition(pendingIntent1, shortcutInfo1, - options1, pendingIntent2, shortcutInfo2, options2, sidePosition, splitRatio, - adapter, instanceId); + mSplitScreen.startIntentsWithLegacyTransition(pendingIntent1, userId1, + shortcutInfo1, options1, pendingIntent2, userId2, shortcutInfo2, options2, + sidePosition, splitRatio, adapter, instanceId); } catch (RemoteException e) { Log.w(TAG, "Failed call startIntentsWithLegacyTransition"); } @@ -799,11 +800,12 @@ public class SystemUiProxy implements ISystemUiProxy { } } - public void startIntent(PendingIntent intent, Intent fillInIntent, int position, + public void startIntent(PendingIntent intent, int userId, Intent fillInIntent, int position, Bundle options, InstanceId instanceId) { if (mSplitScreen != null) { try { - mSplitScreen.startIntent(intent, fillInIntent, position, options, instanceId); + mSplitScreen.startIntent(intent, userId, fillInIntent, position, options, + instanceId); } catch (RemoteException e) { Log.w(TAG, "Failed call startIntent"); } diff --git a/quickstep/src/com/android/quickstep/util/SplitSelectDataHolder.kt b/quickstep/src/com/android/quickstep/util/SplitSelectDataHolder.kt index ebea58cee2..614dfe82d6 100644 --- a/quickstep/src/com/android/quickstep/util/SplitSelectDataHolder.kt +++ b/quickstep/src/com/android/quickstep/util/SplitSelectDataHolder.kt @@ -207,6 +207,8 @@ class SplitSelectDataHolder( secondTaskId, initialPendingIntent, secondPendingIntent, + initialUser?.identifier ?: -1, + secondUser?.identifier ?: -1, initialShortcut, secondShortcut, itemInfo, @@ -291,6 +293,8 @@ class SplitSelectDataHolder( var secondTaskId: Int = INVALID_TASK_ID, var initialPendingIntent: PendingIntent? = null, var secondPendingIntent: PendingIntent? = null, + var initialUserId: Int = -1, + var secondUserId: Int = -1, var initialShortcut: ShortcutInfo? = null, var secondShortcut: ShortcutInfo? = null, var itemInfo: ItemInfo? = null, diff --git a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java index acc3ba1681..da81410c7a 100644 --- a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java +++ b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java @@ -372,12 +372,13 @@ public class SplitSelectStateController { shellInstanceId); } else { mSystemUiProxy.startIntents(getPendingIntent(intent1, mInitialUser), - getShortcutInfo(intent1, mInitialUser), options1.toBundle(), - hasSecondaryPendingIntent + mInitialUser.getIdentifier(), getShortcutInfo(intent1, mInitialUser), + options1.toBundle(), hasSecondaryPendingIntent ? mSecondPendingIntent : getPendingIntent(intent2, mSecondUser), - getShortcutInfo(intent2, mSecondUser), null /* options2 */, - stagePosition, splitRatio, remoteTransition, shellInstanceId); + mSecondUser.getIdentifier(), getShortcutInfo(intent2, mSecondUser), + null /* options2 */, stagePosition, splitRatio, remoteTransition, + shellInstanceId); } } else { final RemoteSplitLaunchAnimationRunner animationRunner = @@ -399,13 +400,13 @@ public class SplitSelectStateController { shellInstanceId); } else { mSystemUiProxy.startIntentsWithLegacyTransition( - getPendingIntent(intent1, mInitialUser), + getPendingIntent(intent1, mInitialUser), mInitialUser.getIdentifier(), getShortcutInfo(intent1, mInitialUser), options1.toBundle(), hasSecondaryPendingIntent ? mSecondPendingIntent : getPendingIntent(intent2, mSecondUser), - getShortcutInfo(intent2, mSecondUser), null /* options2 */, stagePosition, - splitRatio, adapter, shellInstanceId); + mSecondUser.getIdentifier(), getShortcutInfo(intent2, mSecondUser), + null /* options2 */, stagePosition, splitRatio, adapter, shellInstanceId); } } } @@ -425,6 +426,8 @@ public class SplitSelectStateController { ShortcutInfo secondShortcut = launchData.getSecondShortcut(); PendingIntent firstPI = launchData.getInitialPendingIntent(); PendingIntent secondPI = launchData.getSecondPendingIntent(); + int firstUserId = launchData.getInitialUserId(); + int secondUserId = launchData.getSecondUserId(); int initialStagePosition = launchData.getInitialStagePosition(); Bundle optionsBundle = options1.toBundle(); @@ -441,8 +444,8 @@ public class SplitSelectStateController { remoteTransition, shellInstanceId); case SPLIT_TASK_PENDINGINTENT -> - mSystemUiProxy.startIntentAndTask(secondPI, optionsBundle, firstTaskId, - null /*options2*/, initialStagePosition, splitRatio, + mSystemUiProxy.startIntentAndTask(secondPI, secondUserId, optionsBundle, + firstTaskId, null /*options2*/, initialStagePosition, splitRatio, remoteTransition, shellInstanceId); case SPLIT_TASK_SHORTCUT -> @@ -451,13 +454,14 @@ public class SplitSelectStateController { remoteTransition, shellInstanceId); case SPLIT_PENDINGINTENT_TASK -> - mSystemUiProxy.startIntentAndTask(firstPI, optionsBundle, secondTaskId, - null /*options2*/, initialStagePosition, splitRatio, + mSystemUiProxy.startIntentAndTask(firstPI, firstUserId, optionsBundle, + secondTaskId, null /*options2*/, initialStagePosition, splitRatio, remoteTransition, shellInstanceId); case SPLIT_PENDINGINTENT_PENDINGINTENT -> - mSystemUiProxy.startIntents(firstPI, firstShortcut, optionsBundle, secondPI, - secondShortcut, null /*options2*/, initialStagePosition, splitRatio, + mSystemUiProxy.startIntents(firstPI, firstUserId, firstShortcut, + optionsBundle, secondPI, secondUserId, secondShortcut, + null /*options2*/, initialStagePosition, splitRatio, remoteTransition, shellInstanceId); case SPLIT_SHORTCUT_TASK -> @@ -479,8 +483,8 @@ public class SplitSelectStateController { case SPLIT_TASK_PENDINGINTENT -> mSystemUiProxy.startIntentAndTaskWithLegacyTransition(secondPI, - optionsBundle, firstTaskId, null /*options2*/, initialStagePosition, - splitRatio, adapter, shellInstanceId); + secondUserId, optionsBundle, firstTaskId, null /*options2*/, + initialStagePosition, splitRatio, adapter, shellInstanceId); case SPLIT_TASK_SHORTCUT -> mSystemUiProxy.startShortcutAndTaskWithLegacyTransition(secondShortcut, @@ -488,14 +492,15 @@ public class SplitSelectStateController { splitRatio, adapter, shellInstanceId); case SPLIT_PENDINGINTENT_TASK -> - mSystemUiProxy.startIntentAndTaskWithLegacyTransition(firstPI, + mSystemUiProxy.startIntentAndTaskWithLegacyTransition(firstPI, firstUserId, optionsBundle, secondTaskId, null /*options2*/, initialStagePosition, splitRatio, adapter, shellInstanceId); case SPLIT_PENDINGINTENT_PENDINGINTENT -> - mSystemUiProxy.startIntentsWithLegacyTransition(firstPI, firstShortcut, - optionsBundle, secondPI, secondShortcut, null /*options2*/, - initialStagePosition, splitRatio, adapter, shellInstanceId); + mSystemUiProxy.startIntentsWithLegacyTransition(firstPI, firstUserId, + firstShortcut, optionsBundle, secondPI, secondUserId, + secondShortcut, null /*options2*/, initialStagePosition, splitRatio, + adapter, shellInstanceId); case SPLIT_SHORTCUT_TASK -> mSystemUiProxy.startShortcutAndTaskWithLegacyTransition(firstShortcut, @@ -514,7 +519,7 @@ public class SplitSelectStateController { options1.toBundle(), taskId, null /* options2 */, stagePosition, splitRatio, remoteTransition, shellInstanceId); } else { - mSystemUiProxy.startIntentAndTask(getPendingIntent(intent, user), + mSystemUiProxy.startIntentAndTask(getPendingIntent(intent, user), user.getIdentifier(), options1.toBundle(), taskId, null /* options2 */, stagePosition, splitRatio, remoteTransition, shellInstanceId); } @@ -531,8 +536,9 @@ public class SplitSelectStateController { splitRatio, adapter, shellInstanceId); } else { mSystemUiProxy.startIntentAndTaskWithLegacyTransition( - getPendingIntent(intent, user), options1.toBundle(), taskId, - null /* options2 */, stagePosition, splitRatio, adapter, shellInstanceId); + getPendingIntent(intent, user), user.getIdentifier(), options1.toBundle(), + taskId, null /* options2 */, stagePosition, splitRatio, adapter, + shellInstanceId); } }