Fix creating new activity instance when launching alias activity
New activity instance was being started on existing task while
starting alias activity because we used to correct the activity
intent for aliasing. Since the task record intent can now also
save alias activity component, they were evaluated as not using
the same intent filter.
Making sure they are evaluated as the same component as long as
they are having the same real activity.
Bug: 122550967
Test: atest TaskRecordTests
Change-Id: I4fd1f7310cf18645495532ffcf900f8113b69dd1
diff --git a/services/core/java/com/android/server/wm/TaskRecord.java b/services/core/java/com/android/server/wm/TaskRecord.java
index e343322..fec93c4 100644
--- a/services/core/java/com/android/server/wm/TaskRecord.java
+++ b/services/core/java/com/android/server/wm/TaskRecord.java
@@ -971,10 +971,11 @@
*/
boolean isSameIntentFilter(ActivityRecord r) {
final Intent intent = new Intent(r.intent);
- // Correct the activity intent for aliasing. The task record intent will always be based on
- // the real activity that will be launched not the alias, so we need to use an intent with
- // the component name pointing to the real activity not the alias in the activity record.
- intent.setComponent(r.mActivityComponent);
+ // Make sure the component are the same if the input activity has the same real activity
+ // as the one in the task because either one of them could be the alias activity.
+ if (Objects.equals(realActivity, r.mActivityComponent) && this.intent != null) {
+ intent.setComponent(this.intent.getComponent());
+ }
return intent.filterEquals(this.intent);
}