From 9254db342a57ee04908dbcb871f34c99c0113265 Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Fri, 13 Dec 2013 12:00:26 -0800 Subject: [PATCH] Use java.util.Objects instead on internal API Not needed since java.util.Objects implements all the needed functionality. Change-Id: Icd31d49a9801d1705427f028e9ac927d58e7d34c --- core/java/android/net/NetworkIdentity.java | 8 ++++---- core/java/android/net/NetworkStats.java | 6 +++--- core/java/android/net/NetworkTemplate.java | 13 +++++++------ .../android/server/net/NetworkStatsCollection.java | 6 +++--- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/core/java/android/net/NetworkIdentity.java b/core/java/android/net/NetworkIdentity.java index 3c67bf9e84..36dd2fdfbc 100644 --- a/core/java/android/net/NetworkIdentity.java +++ b/core/java/android/net/NetworkIdentity.java @@ -26,7 +26,7 @@ import android.net.wifi.WifiManager; import android.os.Build; import android.telephony.TelephonyManager; -import com.android.internal.util.Objects; +import java.util.Objects; /** * Network definition that includes strong identity. Analogous to combining @@ -60,7 +60,7 @@ public class NetworkIdentity { @Override public int hashCode() { - return Objects.hashCode(mType, mSubType, mSubscriberId, mNetworkId, mRoaming); + return Objects.hash(mType, mSubType, mSubscriberId, mNetworkId, mRoaming); } @Override @@ -68,8 +68,8 @@ public class NetworkIdentity { if (obj instanceof NetworkIdentity) { final NetworkIdentity ident = (NetworkIdentity) obj; return mType == ident.mType && mSubType == ident.mSubType && mRoaming == ident.mRoaming - && Objects.equal(mSubscriberId, ident.mSubscriberId) - && Objects.equal(mNetworkId, ident.mNetworkId); + && Objects.equals(mSubscriberId, ident.mSubscriberId) + && Objects.equals(mNetworkId, ident.mNetworkId); } return false; } diff --git a/core/java/android/net/NetworkStats.java b/core/java/android/net/NetworkStats.java index 9cb904d4c4..a7aae2ad36 100644 --- a/core/java/android/net/NetworkStats.java +++ b/core/java/android/net/NetworkStats.java @@ -23,12 +23,12 @@ import android.util.SparseBooleanArray; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.ArrayUtils; -import com.android.internal.util.Objects; import java.io.CharArrayWriter; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashSet; +import java.util.Objects; /** * Collection of active network statistics. Can contain summary details across @@ -337,7 +337,7 @@ public class NetworkStats implements Parcelable { public int findIndex(String iface, int uid, int set, int tag) { for (int i = 0; i < size; i++) { if (uid == this.uid[i] && set == this.set[i] && tag == this.tag[i] - && Objects.equal(iface, this.iface[i])) { + && Objects.equals(iface, this.iface[i])) { return i; } } @@ -362,7 +362,7 @@ public class NetworkStats implements Parcelable { } if (uid == this.uid[i] && set == this.set[i] && tag == this.tag[i] - && Objects.equal(iface, this.iface[i])) { + && Objects.equals(iface, this.iface[i])) { return i; } } diff --git a/core/java/android/net/NetworkTemplate.java b/core/java/android/net/NetworkTemplate.java index c189ba4cd6..27197cc8a3 100644 --- a/core/java/android/net/NetworkTemplate.java +++ b/core/java/android/net/NetworkTemplate.java @@ -34,8 +34,9 @@ import android.content.res.Resources; import android.os.Parcel; import android.os.Parcelable; +import java.util.Objects; + import com.android.internal.annotations.VisibleForTesting; -import com.android.internal.util.Objects; /** * Template definition used to generically match {@link NetworkIdentity}, @@ -176,7 +177,7 @@ public class NetworkTemplate implements Parcelable { @Override public int hashCode() { - return Objects.hashCode(mMatchRule, mSubscriberId, mNetworkId); + return Objects.hash(mMatchRule, mSubscriberId, mNetworkId); } @Override @@ -184,8 +185,8 @@ public class NetworkTemplate implements Parcelable { if (obj instanceof NetworkTemplate) { final NetworkTemplate other = (NetworkTemplate) obj; return mMatchRule == other.mMatchRule - && Objects.equal(mSubscriberId, other.mSubscriberId) - && Objects.equal(mNetworkId, other.mNetworkId); + && Objects.equals(mSubscriberId, other.mSubscriberId) + && Objects.equals(mNetworkId, other.mNetworkId); } return false; } @@ -235,7 +236,7 @@ public class NetworkTemplate implements Parcelable { return true; } else { return ((sForceAllNetworkTypes || contains(DATA_USAGE_NETWORK_TYPES, ident.mType)) - && Objects.equal(mSubscriberId, ident.mSubscriberId)); + && Objects.equals(mSubscriberId, ident.mSubscriberId)); } } @@ -280,7 +281,7 @@ public class NetworkTemplate implements Parcelable { private boolean matchesWifi(NetworkIdentity ident) { switch (ident.mType) { case TYPE_WIFI: - return Objects.equal( + return Objects.equals( removeDoubleQuotes(mNetworkId), removeDoubleQuotes(ident.mNetworkId)); default: return false; diff --git a/services/java/com/android/server/net/NetworkStatsCollection.java b/services/java/com/android/server/net/NetworkStatsCollection.java index 3169035786..475482f6dd 100644 --- a/services/java/com/android/server/net/NetworkStatsCollection.java +++ b/services/java/com/android/server/net/NetworkStatsCollection.java @@ -34,7 +34,6 @@ import android.util.AtomicFile; import com.android.internal.util.ArrayUtils; import com.android.internal.util.FileRotator; import com.android.internal.util.IndentingPrintWriter; -import com.android.internal.util.Objects; import com.google.android.collect.Lists; import com.google.android.collect.Maps; @@ -50,6 +49,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import libcore.io.IoUtils; @@ -508,7 +508,7 @@ public class NetworkStatsCollection implements FileRotator.Reader { this.uid = uid; this.set = set; this.tag = tag; - hashCode = Objects.hashCode(ident, uid, set, tag); + hashCode = Objects.hash(ident, uid, set, tag); } @Override @@ -521,7 +521,7 @@ public class NetworkStatsCollection implements FileRotator.Reader { if (obj instanceof Key) { final Key key = (Key) obj; return uid == key.uid && set == key.set && tag == key.tag - && Objects.equal(ident, key.ident); + && Objects.equals(ident, key.ident); } return false; }