Use the real activity component to find reusable task
The resolved target component was not save in task intent when an alias
activity was started. When starting alias activity again, the target
component was different from the alias component name which stored in
the task. So, we were unable to find a reusable task if the task was on
other display.
Bug: 135738129
Test: atest ActivityStackTests
Change-Id: I87249b6909eab9cd381f9de01b9c0edb32f2ae70
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityStackTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityStackTests.java
index 757267e5..bde0ef6 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityStackTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityStackTests.java
@@ -262,6 +262,35 @@
}
@Test
+ public void testFindTaskAlias() {
+ final String targetActivity = "target.activity";
+ final String aliasActivity = "alias.activity";
+ final ComponentName target = new ComponentName(DEFAULT_COMPONENT_PACKAGE_NAME,
+ targetActivity);
+ final ComponentName alias = new ComponentName(DEFAULT_COMPONENT_PACKAGE_NAME,
+ aliasActivity);
+ final TaskRecord task = new TaskBuilder(mService.mStackSupervisor).setStack(mStack).build();
+ task.origActivity = alias;
+ task.realActivity = target;
+ new ActivityBuilder(mService).setComponent(target).setTask(task).setTargetActivity(
+ targetActivity).build();
+
+ // Using target activity to find task.
+ final ActivityRecord r1 = new ActivityBuilder(mService).setComponent(
+ target).setTargetActivity(targetActivity).build();
+ RootActivityContainer.FindTaskResult result = new RootActivityContainer.FindTaskResult();
+ mStack.findTaskLocked(r1, result);
+ assertThat(result.mRecord).isNotNull();
+
+ // Using alias activity to find task.
+ final ActivityRecord r2 = new ActivityBuilder(mService).setComponent(
+ alias).setTargetActivity(targetActivity).build();
+ result = new RootActivityContainer.FindTaskResult();
+ mStack.findTaskLocked(r2, result);
+ assertThat(result.mRecord).isNotNull();
+ }
+
+ @Test
public void testMoveStackToBackIncludingParent() {
final ActivityDisplay display = addNewActivityDisplayAt(ActivityDisplay.POSITION_TOP);
final ActivityStack stack1 = createStackForShouldBeVisibleTest(display,