summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2012-07-31 12:09:54 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-07-31 12:09:54 -0700
commit16ef57791766b92b8e34de4f752db2f522f34c82 (patch)
tree220e69cf69428f93185e8062cda796af88d381bf /core
parent18a917250d4d595759a054e354c99c4c1e633768 (diff)
parente7ed1ce4c84fe92caafc97b1f9044c6647aa3f7f (diff)
downloadframeworks_base-16ef57791766b92b8e34de4f752db2f522f34c82.zip
frameworks_base-16ef57791766b92b8e34de4f752db2f522f34c82.tar.gz
frameworks_base-16ef57791766b92b8e34de4f752db2f522f34c82.tar.bz2
Merge "API to adjust network stats. DO NOT MERGE." into jb-mr1-dev
Diffstat (limited to 'core')
-rw-r--r--core/java/android/net/INetworkStatsService.aidl3
-rw-r--r--core/java/android/net/TrafficStats.java28
2 files changed, 31 insertions, 0 deletions
diff --git a/core/java/android/net/INetworkStatsService.aidl b/core/java/android/net/INetworkStatsService.aidl
index b7b8731..4d46334 100644
--- a/core/java/android/net/INetworkStatsService.aidl
+++ b/core/java/android/net/INetworkStatsService.aidl
@@ -45,4 +45,7 @@ interface INetworkStatsService {
/** Advise persistance threshold; may be overridden internally. */
void advisePersistThreshold(long thresholdBytes);
+ /** Adjust recorded network stats. */
+ void adjustNetworkStats(int uid, int tag, long rxBytes, long rxPackets, long txBytes, long txPackets, long operationCount);
+
}
diff --git a/core/java/android/net/TrafficStats.java b/core/java/android/net/TrafficStats.java
index e437d2e..b66c2fe 100644
--- a/core/java/android/net/TrafficStats.java
+++ b/core/java/android/net/TrafficStats.java
@@ -88,6 +88,13 @@ public class TrafficStats {
*/
public static final int TAG_SYSTEM_BACKUP = 0xFFFFFF03;
+ /**
+ * Default tag value for cloud messaging traffic.
+ *
+ * @hide
+ */
+ public static final int TAG_SYSTEM_CLOUD_MESSAGING = 0xFFFFFF04;
+
private static INetworkStatsService sStatsService;
private synchronized static INetworkStatsService getStatsService() {
@@ -246,6 +253,27 @@ public class TrafficStats {
}
}
+ /**
+ * Adjust network statistics for the given UID and tag by the requested
+ * amount. This can be used to correctly account network usage performed on
+ * behalf of another application. Values can be negative.
+ * <p>
+ * Requires that caller holds
+ * {@link android.Manifest.permission#MODIFY_NETWORK_ACCOUNTING} permission.
+ *
+ * @see #setThreadStatsUid(int)
+ * @hide
+ */
+ public static void adjustNetworkStats(int uid, int tag, long rxBytes, long rxPackets,
+ long txBytes, long txPackets, long operationCount) {
+ try {
+ getStatsService().adjustNetworkStats(
+ uid, tag, rxBytes, rxPackets, txBytes, txPackets, operationCount);
+ } catch (RemoteException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
/** {@hide} */
public static void closeQuietly(INetworkStatsSession session) {
// TODO: move to NetworkStatsService once it exists