From 861849e10e1f54907ecb98a86f72e5ee668e8c20 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Sun, 17 Jul 2011 15:53:33 -0700 Subject: [PATCH] Data usage notifs, newly installed apps, defaults. Only show warning/limit notifications for active networks, since they aren't actionable for inactive IMSI. Include IMSI in debug output on engineering builds. Move default policy warning to be configured through overlay. Watch for newly installed packages to enforce global policy. Bug: 5038729, 5038541, 4979026, 5023634 Change-Id: I8fc8ab4c23c440a3091504ea16133ed6ababf58e --- core/java/android/net/NetworkIdentity.java | 14 +++++++++++++- core/java/android/net/NetworkTemplate.java | 13 +++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) 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) {