Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f23a5e10 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

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
parent ddc3bfdd
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -28100,6 +28100,7 @@ package android.net {
    method public static void incrementOperationCount(int, int);
    method public static void setThreadStatsTag(int);
    method public static void setThreadStatsTagBackup();
    method public static void setThreadStatsTagCode();
    method public static void setThreadStatsTagRestore();
    method public static void setThreadStatsUid(int);
    method public static void tagDatagramSocket(java.net.DatagramSocket) throws java.net.SocketException;
+27 −13
Original line number Diff line number Diff line
@@ -109,25 +109,26 @@ public class TrafficStats {
     */
    public static final int TAG_SYSTEM_RESTORE = 0xFFFFFF04;

    /**
     * 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_CODE = 0xFFFFFF05;

    /** @hide */
    public static final int TAG_SYSTEM_DHCP = 0xFFFFFF05;
    public static final int TAG_SYSTEM_DHCP = 0xFFFFFF40;
    /** @hide */
    public static final int TAG_SYSTEM_NTP = 0xFFFFFF06;
    public static final int TAG_SYSTEM_NTP = 0xFFFFFF41;
    /** @hide */
    public static final int TAG_SYSTEM_PROBE = 0xFFFFFF07;
    public static final int TAG_SYSTEM_PROBE = 0xFFFFFF42;
    /** @hide */
    public static final int TAG_SYSTEM_NEIGHBOR = 0xFFFFFF08;
    public static final int TAG_SYSTEM_NEIGHBOR = 0xFFFFFF43;
    /** @hide */
    public static final int TAG_SYSTEM_GPS = 0xFFFFFF09;
    public static final int TAG_SYSTEM_GPS = 0xFFFFFF44;
    /** @hide */
    public static final int TAG_SYSTEM_PAC = 0xFFFFFF0A;

    /**
     * Sockets that are strictly local on device; never hits network.
     *
     * @hide
     */
    public static final int TAG_SYSTEM_LOCAL = 0xFFFFFFAA;
    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.