From 8af5ad1575e7a2afef21fd2abf7b4232c91ee68a Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Mon, 26 Jun 2017 19:50:41 -0600 Subject: [PATCH] Allocate well-known tag for app store updates. This way an app store can shift blame for update-related network traffic onto the app that is being updated. Using a well-known tag makes it easy for developers to identify that they didn't explicitly request the traffic at runtime, similar to how backup/restore traffic is handled. Bug: 38282350 Test: builds, boots Change-Id: I003dd7c9615d4ab318250f1e44fa5d195ac94d23 --- core/java/android/net/TrafficStats.java | 44 ++++++++++++++++--------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/core/java/android/net/TrafficStats.java b/core/java/android/net/TrafficStats.java index f9346165df..19857076a0 100644 --- a/core/java/android/net/TrafficStats.java +++ b/core/java/android/net/TrafficStats.java @@ -109,25 +109,26 @@ public class TrafficStats { */ public static final int TAG_SYSTEM_RESTORE = 0xFFFFFF04; - /** @hide */ - public static final int TAG_SYSTEM_DHCP = 0xFFFFFF05; - /** @hide */ - public static final int TAG_SYSTEM_NTP = 0xFFFFFF06; - /** @hide */ - public static final int TAG_SYSTEM_PROBE = 0xFFFFFF07; - /** @hide */ - public static final int TAG_SYSTEM_NEIGHBOR = 0xFFFFFF08; - /** @hide */ - public static final int TAG_SYSTEM_GPS = 0xFFFFFF09; - /** @hide */ - public static final int TAG_SYSTEM_PAC = 0xFFFFFF0A; - /** - * Sockets that are strictly local on device; never hits network. + * Default tag value for code or resources downloaded by an app store on + * behalf of the app, such as app updates. * * @hide */ - public static final int TAG_SYSTEM_LOCAL = 0xFFFFFFAA; + public static final int TAG_SYSTEM_CODE = 0xFFFFFF05; + + /** @hide */ + public static final int TAG_SYSTEM_DHCP = 0xFFFFFF40; + /** @hide */ + public static final int TAG_SYSTEM_NTP = 0xFFFFFF41; + /** @hide */ + public static final int TAG_SYSTEM_PROBE = 0xFFFFFF42; + /** @hide */ + public static final int TAG_SYSTEM_NEIGHBOR = 0xFFFFFF43; + /** @hide */ + public static final int TAG_SYSTEM_GPS = 0xFFFFFF44; + /** @hide */ + public static final int TAG_SYSTEM_PAC = 0xFFFFFF45; private static INetworkStatsService sStatsService; @@ -209,6 +210,19 @@ public class TrafficStats { setThreadStatsTag(TAG_SYSTEM_RESTORE); } + /** + * Set active tag to use when accounting {@link Socket} traffic originating + * from the current thread. The tag used internally is well-defined to + * distinguish all code-related traffic, such as updates performed by an app + * store. + * + * @hide + */ + @SystemApi + public static void setThreadStatsTagCode() { + setThreadStatsTag(TAG_SYSTEM_CODE); + } + /** * Get the active tag used when accounting {@link Socket} traffic originating * from the current thread. Only one active tag per thread is supported.