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

Commit 5a8ca580 authored by Alon Albert's avatar Alon Albert Committed by Android (Google) Code Review
Browse files

Merge "Add a getter for the active tag"

parents 060e3cad eaef351a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -11291,6 +11291,7 @@ package android.net {
    method public static long getMobileRxPackets();
    method public static long getMobileTxBytes();
    method public static long getMobileTxPackets();
    method public static int getThreadStatsTag();
    method public static long getTotalRxBytes();
    method public static long getTotalRxPackets();
    method public static long getTotalTxBytes();
+9 −0
Original line number Diff line number Diff line
@@ -96,6 +96,15 @@ public class TrafficStats {
        NetworkManagementSocketTagger.setThreadSocketStatsTag(tag);
    }

    /**
     * Get the active tag used when accounting {@link Socket} traffic originating
     * from the current thread. Only one active tag per thread is supported.
     * {@link #tagSocket(Socket)}.
     */
    public static int getThreadStatsTag() {
        return NetworkManagementSocketTagger.getThreadSocketStatsTag();
    }

    /**
     * @deprecated unsupported, will eventually be removed
     */
+5 −3
Original line number Diff line number Diff line
@@ -18,8 +18,8 @@ package com.android.server;

import android.os.SystemProperties;
import android.util.Log;

import dalvik.system.SocketTagger;
import libcore.io.IoUtils;

import java.io.FileDescriptor;
import java.io.FileOutputStream;
@@ -28,8 +28,6 @@ import java.math.BigInteger;
import java.net.SocketException;
import java.nio.charset.Charsets;

import libcore.io.IoUtils;

/**
 * Assigns tags to sockets for traffic stats.
 */
@@ -59,6 +57,10 @@ public final class NetworkManagementSocketTagger extends SocketTagger {
        threadSocketTags.get().statsTag = tag;
    }

    public static int getThreadSocketStatsTag() {
        return threadSocketTags.get().statsTag;
    }

    public static void setThreadSocketStatsUid(int uid) {
        threadSocketTags.get().statsUid = uid;
    }