diff --git a/core/java/android/net/NetworkIdentity.java b/core/java/android/net/NetworkIdentity.java index ccef122c0a..aa6400bbf5 100644 --- a/core/java/android/net/NetworkIdentity.java +++ b/core/java/android/net/NetworkIdentity.java @@ -19,6 +19,7 @@ package android.net; import static android.net.ConnectivityManager.isNetworkTypeMobile; import android.content.Context; +import android.os.Build; import android.telephony.TelephonyManager; import com.android.internal.util.Objects; @@ -68,7 +69,7 @@ public class NetworkIdentity { subTypeName = Integer.toString(mSubType); } - final String scrubSubscriberId = mSubscriberId != null ? "valid" : "null"; + final String scrubSubscriberId = scrubSubscriberId(mSubscriberId); final String roaming = mRoaming ? ", ROAMING" : ""; return "[type=" + typeName + ", subType=" + subTypeName + ", subscriberId=" + scrubSubscriberId + roaming + "]"; @@ -90,6 +91,17 @@ public class NetworkIdentity { return mRoaming; } + /** + * Scrub given IMSI on production builds. + */ + public static String scrubSubscriberId(String subscriberId) { + if ("eng".equals(Build.TYPE)) { + return subscriberId; + } else { + return subscriberId != null ? "valid" : "null"; + } + } + /** * Build a {@link NetworkIdentity} from the given {@link NetworkState}, * assuming that any mobile networks are using the current IMSI. diff --git a/core/java/android/net/NetworkTemplate.java b/core/java/android/net/NetworkTemplate.java index 1ef0d9d077..cd4902308b 100644 --- a/core/java/android/net/NetworkTemplate.java +++ b/core/java/android/net/NetworkTemplate.java @@ -16,10 +16,11 @@ package android.net; +import static android.net.ConnectivityManager.TYPE_ETHERNET; import static android.net.ConnectivityManager.TYPE_WIFI; import static android.net.ConnectivityManager.TYPE_WIMAX; -import static android.net.ConnectivityManager.TYPE_ETHERNET; import static android.net.ConnectivityManager.isNetworkTypeMobile; +import static android.net.NetworkIdentity.scrubSubscriberId; import static android.telephony.TelephonyManager.NETWORK_CLASS_2_G; import static android.telephony.TelephonyManager.NETWORK_CLASS_3_G; import static android.telephony.TelephonyManager.NETWORK_CLASS_4_G; @@ -119,7 +120,7 @@ public class NetworkTemplate implements Parcelable { @Override public String toString() { - final String scrubSubscriberId = mSubscriberId != null ? "valid" : "null"; + final String scrubSubscriberId = scrubSubscriberId(mSubscriberId); return "NetworkTemplate: matchRule=" + getMatchRuleName(mMatchRule) + ", subscriberId=" + scrubSubscriberId; } @@ -150,7 +151,7 @@ public class NetworkTemplate implements Parcelable { } /** - * Test if this network matches the given template and IMEI. + * Test if this network matches the given template and IMSI. */ public boolean matches(NetworkIdentity ident) { switch (mMatchRule) { @@ -170,7 +171,7 @@ public class NetworkTemplate implements Parcelable { } /** - * Check if mobile network with matching IMEI. Also matches + * Check if mobile network with matching IMSI. Also matches * {@link #TYPE_WIMAX}. */ private boolean matchesMobile(NetworkIdentity ident) { @@ -183,7 +184,7 @@ public class NetworkTemplate implements Parcelable { } /** - * Check if mobile network classified 3G or lower with matching IMEI. + * Check if mobile network classified 3G or lower with matching IMSI. */ private boolean matchesMobile3gLower(NetworkIdentity ident) { if (isNetworkTypeMobile(ident.mType) && Objects.equal(mSubscriberId, ident.mSubscriberId)) { @@ -198,7 +199,7 @@ public class NetworkTemplate implements Parcelable { } /** - * Check if mobile network classified 4G with matching IMEI. Also matches + * Check if mobile network classified 4G with matching IMSI. Also matches * {@link #TYPE_WIMAX}. */ private boolean matchesMobile4g(NetworkIdentity ident) {