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
This commit is contained in:
Jeff Sharkey
2011-07-17 15:53:33 -07:00
parent 2f60c2d402
commit 861849e10e
2 changed files with 20 additions and 7 deletions

View File

@@ -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.

View File

@@ -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) {