Non-functional simplification of ComponentName.equals

Bug: 205124386
Change-Id: Ib9c895592ed67e10cb965890cd67499bd55e444d
Test: atest ComponentNameTest
This commit is contained in:
Santiago Seifert
2022-10-24 18:17:28 +00:00
parent ddc82226b3
commit 868f2e071f

View File

@@ -314,17 +314,14 @@ public final class ComponentName implements Parcelable, Cloneable, Comparable<Co
*/
@Override
public boolean equals(@Nullable Object obj) {
try {
if (obj != null) {
ComponentName other = (ComponentName)obj;
// Note: no null checks, because mPackage and mClass can
// never be null.
return mPackage.equals(other.mPackage)
&& mClass.equals(other.mClass);
}
} catch (ClassCastException e) {
if (obj instanceof ComponentName) {
ComponentName other = (ComponentName) obj;
// mPackage and mClass can never be null.
return mPackage.equals(other.mPackage)
&& mClass.equals(other.mClass);
} else {
return false;
}
return false;
}
@Override