Add @Nullable annotation to the parameter of Object.equals() methods.
Those annotations could be inferred by some tools (like Kotlin), but the https://checkerframework.org/ doesn't check inherited annotations complaining about all equals() invocations that get nullable argument. The change was generated by running find . -name \*.java | xargs sed -i 's/public boolean equals(Object /public boolean equals(@Nullable Object /' in the frameworks/base directory and by automatically adding and formatting required imports if needed. No manual edits. Bug: 170883422 Test: Annotation change only. Should have not impact. Exempt-From-Owner-Approval: Mechanical change not specific to any component. Change-Id: I5eedb571c9d78862115dfdc5dae1cf2a35343580
This commit is contained in:
@@ -254,7 +254,7 @@ public final class CaptivePortalData implements Parcelable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (!(obj instanceof CaptivePortalData)) return false;
|
||||
final CaptivePortalData other = (CaptivePortalData) obj;
|
||||
return mRefreshTimeMillis == other.mRefreshTimeMillis
|
||||
|
||||
@@ -166,7 +166,7 @@ public final class IpConfiguration implements Parcelable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
public boolean equals(@Nullable Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package android.net;
|
||||
|
||||
import android.annotation.IntRange;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SystemApi;
|
||||
import android.annotation.TestApi;
|
||||
import android.os.Parcel;
|
||||
@@ -127,7 +128,7 @@ public final class IpPrefix implements Parcelable {
|
||||
* @return {@code true} if both objects are equal, {@code false} otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (!(obj instanceof IpPrefix)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -357,7 +357,7 @@ public class LinkAddress implements Parcelable {
|
||||
* @return {@code true} if both objects are equal, {@code false} otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (!(obj instanceof LinkAddress)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1639,7 +1639,7 @@ public final class LinkProperties implements Parcelable {
|
||||
* @return {@code true} if both objects are equal, {@code false} otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (this == obj) return true;
|
||||
|
||||
if (!(obj instanceof LinkProperties)) return false;
|
||||
|
||||
@@ -160,7 +160,7 @@ public final class MacAddress implements Parcelable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
public boolean equals(@Nullable Object o) {
|
||||
return (o instanceof MacAddress) && ((MacAddress) o).mAddr == mAddr;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package android.net;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SystemApi;
|
||||
import android.annotation.TestApi;
|
||||
import android.compat.annotation.UnsupportedAppUsage;
|
||||
@@ -500,7 +501,7 @@ public class Network implements Parcelable {
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (!(obj instanceof Network)) return false;
|
||||
Network other = (Network)obj;
|
||||
return this.netId == other.netId;
|
||||
|
||||
@@ -553,7 +553,7 @@ public class NetworkRequest implements Parcelable {
|
||||
proto.end(token);
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (obj instanceof NetworkRequest == false) return false;
|
||||
NetworkRequest that = (NetworkRequest)obj;
|
||||
return (that.legacyType == this.legacyType &&
|
||||
|
||||
@@ -275,7 +275,7 @@ public class ProxyInfo implements Parcelable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
public boolean equals(@Nullable Object o) {
|
||||
if (!(o instanceof ProxyInfo)) return false;
|
||||
ProxyInfo p = (ProxyInfo)o;
|
||||
// If PAC URL is present in either then they must be equal.
|
||||
|
||||
@@ -539,7 +539,7 @@ public final class RouteInfo implements Parcelable {
|
||||
* Compares this RouteInfo object against the specified object and indicates if they are equal.
|
||||
* @return {@code true} if the objects are equal, {@code false} otherwise.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (this == obj) return true;
|
||||
|
||||
if (!(obj instanceof RouteInfo)) return false;
|
||||
@@ -575,7 +575,7 @@ public final class RouteInfo implements Parcelable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
public boolean equals(@Nullable Object o) {
|
||||
if (!(o instanceof RouteKey)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package android.net;
|
||||
|
||||
import static android.os.UserHandle.PER_USER_RANGE;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
@@ -81,7 +82,7 @@ public final class UidRange implements Parcelable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
public boolean equals(@Nullable Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user