diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index 26b2f071e3f5f..0e0b2dc3df8a3 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -11051,25 +11051,13 @@ public class Intent implements Parcelable, Cloneable { if (!Objects.equals(this.mData, other.mData)) return false; if (!Objects.equals(this.mType, other.mType)) return false; if (!Objects.equals(this.mIdentifier, other.mIdentifier)) return false; - if (!(this.hasPackageEquivalentComponent() && other.hasPackageEquivalentComponent()) - && !Objects.equals(this.mPackage, other.mPackage)) { - return false; - } + if (!Objects.equals(this.mPackage, other.mPackage)) return false; if (!Objects.equals(this.mComponent, other.mComponent)) return false; if (!Objects.equals(this.mCategories, other.mCategories)) return false; return true; } - /** - * Return {@code true} if the component name is not null and is in the same package that this - * intent limited to. otherwise return {@code false}. - */ - private boolean hasPackageEquivalentComponent() { - return mComponent != null - && (mPackage == null || mPackage.equals(mComponent.getPackageName())); - } - /** * Generate hash code that matches semantics of filterEquals(). * diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 74e1fe4d288b0..8de556ac46670 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -1109,6 +1109,9 @@ class Task extends TaskFragment { // 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()); + // Make sure the package name the same to prevent one of the intent is set while the + // other one is not. + intent.setPackage(this.intent.getPackage()); } return intent.filterEquals(this.intent); } diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java index f4323db2ceeca..6a7e388dc0b83 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java @@ -846,6 +846,7 @@ public class TaskTests extends WindowTestsBase { new ComponentName(DEFAULT_COMPONENT_PACKAGE_NAME, targetClassName); final Intent intent = new Intent(); + intent.setPackage(DEFAULT_COMPONENT_PACKAGE_NAME); intent.setComponent(aliasComponent); final ActivityInfo info = new ActivityInfo(); info.applicationInfo = new ApplicationInfo();