summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2011-06-19 01:08:12 -0700
committerJeff Sharkey <jsharkey@android.com>2011-06-19 01:08:12 -0700
commitb09540f33a6cabe50edec0ef32d0b1d0b0d96fff (patch)
treec185b8dd5cd0ad100803547c684c74c59346bc5c /core/java/android
parent1b5a2a96f793211bfbd39aa29cc41031dfa23950 (diff)
downloadframeworks_base-b09540f33a6cabe50edec0ef32d0b1d0b0d96fff.zip
frameworks_base-b09540f33a6cabe50edec0ef32d0b1d0b0d96fff.tar.gz
frameworks_base-b09540f33a6cabe50edec0ef32d0b1d0b0d96fff.tar.bz2
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
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/net/NetworkIdentity.java10
-rw-r--r--core/java/android/net/NetworkState.java10
-rw-r--r--core/java/android/net/TrafficStats.java8
3 files changed, 25 insertions, 3 deletions
diff --git a/core/java/android/net/NetworkIdentity.java b/core/java/android/net/NetworkIdentity.java
index f82d922..23ebbab 100644
--- a/core/java/android/net/NetworkIdentity.java
+++ b/core/java/android/net/NetworkIdentity.java
@@ -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;
}
diff --git a/core/java/android/net/NetworkState.java b/core/java/android/net/NetworkState.java
index 749039a..704111b 100644
--- a/core/java/android/net/NetworkState.java
+++ b/core/java/android/net/NetworkState.java
@@ -29,18 +29,27 @@ public class NetworkState implements Parcelable {
public final NetworkInfo networkInfo;
public final LinkProperties linkProperties;
public final LinkCapabilities linkCapabilities;
+ /** Currently only used by testing. */
+ public final String subscriberId;
public NetworkState(NetworkInfo networkInfo, LinkProperties linkProperties,
LinkCapabilities linkCapabilities) {
+ this(networkInfo, linkProperties, linkCapabilities, null);
+ }
+
+ public NetworkState(NetworkInfo networkInfo, LinkProperties linkProperties,
+ LinkCapabilities linkCapabilities, String subscriberId) {
this.networkInfo = networkInfo;
this.linkProperties = linkProperties;
this.linkCapabilities = linkCapabilities;
+ this.subscriberId = subscriberId;
}
public NetworkState(Parcel in) {
networkInfo = in.readParcelable(null);
linkProperties = in.readParcelable(null);
linkCapabilities = in.readParcelable(null);
+ subscriberId = in.readString();
}
/** {@inheritDoc} */
@@ -53,6 +62,7 @@ public class NetworkState implements Parcelable {
out.writeParcelable(networkInfo, flags);
out.writeParcelable(linkProperties, flags);
out.writeParcelable(linkCapabilities, flags);
+ out.writeString(subscriberId);
}
public static final Creator<NetworkState> CREATOR = new Creator<NetworkState>() {
diff --git a/core/java/android/net/TrafficStats.java b/core/java/android/net/TrafficStats.java
index e163abf..cb47193 100644
--- a/core/java/android/net/TrafficStats.java
+++ b/core/java/android/net/TrafficStats.java
@@ -42,6 +42,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.
*