}
// If the activity is associated with the recents stack, then try and get that first
+ final int userId = mService.getCurrentUserId();
mTargetActivityType = intent.getComponent() != null
&& recentsComponent.equals(intent.getComponent())
? ACTIVITY_TYPE_RECENTS
: ACTIVITY_TYPE_HOME;
ActivityStack targetStack = mDefaultDisplay.getStack(WINDOWING_MODE_UNDEFINED,
mTargetActivityType);
- ActivityRecord targetActivity = getTargetActivity(targetStack, intent.getComponent());
+ ActivityRecord targetActivity = getTargetActivity(targetStack, intent.getComponent(),
+ userId);
final boolean hasExistingActivity = targetActivity != null;
if (hasExistingActivity) {
final ActivityDisplay display = targetActivity.getDisplay();
.setCallingUid(recentsUid)
.setCallingPackage(recentsComponent.getPackageName())
.setActivityOptions(SafeActivityOptions.fromBundle(options.toBundle()))
- .setMayWait(mService.getCurrentUserId())
+ .setMayWait(userId)
.execute();
// Move the recents activity into place for the animation
- targetActivity = mDefaultDisplay.getStack(WINDOWING_MODE_UNDEFINED,
- mTargetActivityType).getTopActivity();
- targetStack = targetActivity.getActivityStack();
+ targetStack = mDefaultDisplay.getStack(WINDOWING_MODE_UNDEFINED,
+ mTargetActivityType);
+ targetActivity = getTargetActivity(targetStack, intent.getComponent(), userId);
mDefaultDisplay.moveStackBehindBottomMostVisibleStack(targetStack);
if (DEBUG) {
Slog.d(TAG, "Moved stack=" + targetStack + " behind stack="
mWindowManager.prepareAppTransition(TRANSIT_NONE, false);
mWindowManager.executeAppTransition();
-
// TODO: Maybe wait for app to draw in this particular case?
if (DEBUG) Slog.d(TAG, "Started intent=" + intent);
* @return the top activity in the {@param targetStack} matching the {@param component}, or just
* the top activity of the top task if no task matches the component.
*/
- private ActivityRecord getTargetActivity(ActivityStack targetStack, ComponentName component) {
+ private ActivityRecord getTargetActivity(ActivityStack targetStack, ComponentName component,
+ int userId) {
if (targetStack == null) {
return null;
}
for (int i = targetStack.getChildCount() - 1; i >= 0; i--) {
final TaskRecord task = targetStack.getChildAt(i);
- if (task.getBaseIntent().getComponent().equals(component)) {
+ if (task.userId == userId && task.getBaseIntent().getComponent().equals(component)) {
return task.getTopActivity();
}
}
- return targetStack.getTopActivity();
+ return null;
}
}
package com.android.server.wm;
+import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
+import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doAnswer;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doCallRealMethod;
@Presubmit
public class RecentsAnimationTest extends ActivityTestsBase {
+ private static final int TEST_USER_ID = 100;
+
private final ComponentName mRecentsComponent =
new ComponentName(mContext.getPackageName(), "RecentsActivity");
private RecentsAnimationController mRecentsAnimationController;
verify(mRecentsAnimationController, times(0)).cancelOnNextTransitionStart();
}
+ @Test
+ public void testMultipleUserHomeActivity_findUserHomeTask() {
+ ActivityDisplay display = mService.mRootActivityContainer.getDefaultDisplay();
+ ActivityStack homeStack = display.getStack(WINDOWING_MODE_UNDEFINED, ACTIVITY_TYPE_HOME);
+ ActivityRecord otherUserHomeActivity = new ActivityBuilder(mService)
+ .setStack(homeStack)
+ .setCreateTask(true)
+ .setComponent(new ComponentName(mContext.getPackageName(), "Home2"))
+ .build();
+ otherUserHomeActivity.getTaskRecord().userId = TEST_USER_ID;
+
+ ActivityStack fullscreenStack = display.createStack(WINDOWING_MODE_FULLSCREEN,
+ ACTIVITY_TYPE_STANDARD, true /* onTop */);
+ new ActivityBuilder(mService)
+ .setComponent(new ComponentName(mContext.getPackageName(), "App1"))
+ .setCreateTask(true)
+ .setStack(fullscreenStack)
+ .build();
+
+ doReturn(TEST_USER_ID).when(mService).getCurrentUserId();
+ doCallRealMethod().when(mRootActivityContainer).ensureActivitiesVisible(
+ any() /* starting */, anyInt() /* configChanges */,
+ anyBoolean() /* preserveWindows */);
+
+ startRecentsActivity(otherUserHomeActivity.getTaskRecord().getBaseIntent().getComponent(),
+ true);
+
+ // Ensure we find the task for the right user and it is made visible
+ assertTrue(otherUserHomeActivity.visible);
+ }
+
private void startRecentsActivity() {
startRecentsActivity(mRecentsComponent, false /* getRecentsAnimation */);
}