Avoid recycle task of different user
A task that belongs to work profile user was reused while starting an owner user activity. The task was recycled and had delivered new intent to the existing top activity (belongs to work profile user) instead of adding a new activity (of owner profile user) on top. Bug: 144915832 Test: atest ActivityStarterTests Test: repro steps on bug Change-Id: Ic210f8c436c086bca590facbdba5fe5fa556f4df
This commit is contained in:
@@ -149,7 +149,8 @@ class ActivityStarter {
|
||||
private final ActivityStartController mController;
|
||||
|
||||
// Share state variable among methods when starting an activity.
|
||||
private ActivityRecord mStartActivity;
|
||||
@VisibleForTesting
|
||||
ActivityRecord mStartActivity;
|
||||
private Intent mIntent;
|
||||
private int mCallingUid;
|
||||
private ActivityOptions mOptions;
|
||||
@@ -173,7 +174,8 @@ class ActivityStarter {
|
||||
private int mPreferredDisplayId;
|
||||
|
||||
private Task mInTask;
|
||||
private boolean mAddingToTask;
|
||||
@VisibleForTesting
|
||||
boolean mAddingToTask;
|
||||
private Task mReuseTask;
|
||||
|
||||
private ActivityInfo mNewTaskInfo;
|
||||
@@ -1665,7 +1667,16 @@ class ActivityStarter {
|
||||
* - Comply to the specified activity launch flags
|
||||
* - Determine whether need to add a new activity on top or just brought the task to front.
|
||||
*/
|
||||
private int recycleTask(Task targetTask, ActivityRecord targetTaskTop, Task reusedTask) {
|
||||
@VisibleForTesting
|
||||
int recycleTask(Task targetTask, ActivityRecord targetTaskTop, Task reusedTask) {
|
||||
// Should not recycle task which is from a different user, just adding the starting
|
||||
// activity to the task.
|
||||
if (targetTask.mUserId != mStartActivity.mUserId) {
|
||||
mTargetStack = targetTask.getStack();
|
||||
mAddingToTask = true;
|
||||
return START_SUCCESS;
|
||||
}
|
||||
|
||||
// True if we are clearing top and resetting of a standard (default) launch mode
|
||||
// ({@code LAUNCH_MULTIPLE}) activity. The existing activity will be finished.
|
||||
final boolean clearTopAndResetStandardLaunchMode =
|
||||
|
||||
@@ -962,4 +962,19 @@ public class ActivityStarterTests extends ActivityTestsBase {
|
||||
}
|
||||
assertThat(exceptionCaught).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRecycleTaskFromAnotherUser() {
|
||||
final ActivityStarter starter = prepareStarter(0 /* flags */);
|
||||
starter.mStartActivity = new ActivityBuilder(mService).build();
|
||||
final Task task = new TaskBuilder(mService.mStackSupervisor)
|
||||
.setStack(mService.mRootActivityContainer.getDefaultDisplay().createStack(
|
||||
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */))
|
||||
.setUserId(10)
|
||||
.build();
|
||||
|
||||
final int result = starter.recycleTask(task, null, null);
|
||||
assertThat(result == START_SUCCESS).isTrue();
|
||||
assertThat(starter.mAddingToTask).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user