Closed
Description
Steps to reproduce the bug
AndroidComponentAddress one = AndroidComponentAddress.forBindIntent(new Intent()
.setComponent("package", "service")
);
AndroidComponentAddress two = AndroidComponentAddress.forBindIntent(new Intent()
.setComponent("package", "service")
.setPackage("package")
);
assert(!one.equals(two) || (one.hashCode() == two.hashCode()))
What did you expect to see?
No assertion error. The Object API contract says that if one.equals(two) then one.hashCode() == two.hashCode().
What did you see instead?
Assertion error because, since Android SDK 31, one.equals(two) but one.hashCode() != two.hashCode().
AndroidComponentAddress implements hashCode() and equals() by delegating to Intent.filterHashcode() and filterEquals(). But since https://googleplex-android-review.git.corp.google.com/c/platform/frameworks/base/+/9324284 filterHashcode() and filterEquals() are no longer consistent the way Object requires when a (redundant) setPackage() filter is present.