Handle removed UIDs in network stats and policy.

When UID_REMOVED, clean up any existing UID network policy so it
doesn't linger for future apps.  Also move any NetworkStatsHistory
to special UID_REMOVED tracking bucket.

Tests for new removal code.  Also test detailed UID stats, including
network changes to verify template matching logic.

Bug: 4584212
Change-Id: I9faadf6b6f3830eb45d86c7f1980a27cdbcdb11e
This commit is contained in:
Jeff Sharkey
2011-06-19 01:08:12 -07:00
parent 0d5baa3f21
commit c04cda602c
3 changed files with 75 additions and 12 deletions

View File

@@ -95,9 +95,13 @@ public class NetworkIdentity {
final String subscriberId;
if (isNetworkTypeMobile(type)) {
final TelephonyManager telephony = (TelephonyManager) context.getSystemService(
Context.TELEPHONY_SERVICE);
subscriberId = telephony.getSubscriberId();
if (state.subscriberId != null) {
subscriberId = state.subscriberId;
} else {
final TelephonyManager telephony = (TelephonyManager) context.getSystemService(
Context.TELEPHONY_SERVICE);
subscriberId = telephony.getSubscriberId();
}
} else {
subscriberId = null;
}

View File

@@ -41,6 +41,14 @@ public class TrafficStats {
*/
public final static int UNSUPPORTED = -1;
/**
* Special UID value used when collecting {@link NetworkStatsHistory} for
* removed applications.
*
* @hide
*/
public static final int UID_REMOVED = -4;
/**
* Snapshot of {@link NetworkStats} when the currently active profiling
* session started, or {@code null} if no session active.