From eedcb9525ba5befee2ba6ebb7a9ee3f13395c2a3 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Tue, 17 May 2011 14:55:15 -0700 Subject: APIs to profile network usage for current UID. Added startDataProfiling() and stopDataProfiling() to TrafficStats, which can be used by apps to measure network usage delta between two points in time. Currently takes two NetworkStats snapshots and returns delta, which will eventually include tag-level granularity. Added tests for NetworkStats delta subtraction. Added NMS.getNetworkStatsUidDetail() that returns stats for specific UID. Always gives stats access for the calling UID, otherwise enforces that caller has permission. Fix readSingleLongFromFile(), since /proc/ files don't have well-defined lengths. Change-Id: Ic5b6414d8effbd66846e275b00d4b8a82c74589d --- core/java/android/net/NetworkPolicyManager.java | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'core/java/android/net/NetworkPolicyManager.java') diff --git a/core/java/android/net/NetworkPolicyManager.java b/core/java/android/net/NetworkPolicyManager.java index 2312bd9..1913aa7 100644 --- a/core/java/android/net/NetworkPolicyManager.java +++ b/core/java/android/net/NetworkPolicyManager.java @@ -16,6 +16,7 @@ package android.net; +import android.content.Context; import android.os.RemoteException; /** @@ -43,6 +44,10 @@ public class NetworkPolicyManager { mService = service; } + public static NetworkPolicyManager getSystemService(Context context) { + return (NetworkPolicyManager) context.getSystemService(Context.NETWORK_POLICY_SERVICE); + } + /** * Set policy flags for specific UID. * -- cgit v1.1