[ipsec-qtaguid] Tag sockets upon creation of encap sockets
Added calls to tag encap sockets to that of the UID for which the encap socket is being created on behalf of. This ensures that all data accounting generated for the UDP-encap-ESP socket is correctly billed to the right UID. Bug: 62994731 Test: New tests added to IpSecServiceTest.java, passing Change-Id: I15365ea9c982fd7b4e3cdeff314ddfba2289c86e
This commit is contained in:
@@ -19,6 +19,7 @@ package android.net;
|
||||
import android.annotation.RequiresPermission;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.SystemApi;
|
||||
import android.annotation.TestApi;
|
||||
import android.app.DownloadManager;
|
||||
import android.app.backup.BackupManager;
|
||||
import android.app.usage.NetworkStatsManager;
|
||||
@@ -154,6 +155,8 @@ public class TrafficStats {
|
||||
|
||||
private static Object sProfilingLock = new Object();
|
||||
|
||||
private static final String LOOPBACK_IFACE = "lo";
|
||||
|
||||
/**
|
||||
* Set active tag to use when accounting {@link Socket} traffic originating
|
||||
* from the current thread. Only one active tag per thread is supported.
|
||||
@@ -542,6 +545,30 @@ public class TrafficStats {
|
||||
return nativeGetIfaceStat(iface, TYPE_RX_BYTES);
|
||||
}
|
||||
|
||||
/** {@hide} */
|
||||
@TestApi
|
||||
public static long getLoopbackTxPackets() {
|
||||
return nativeGetIfaceStat(LOOPBACK_IFACE, TYPE_TX_PACKETS);
|
||||
}
|
||||
|
||||
/** {@hide} */
|
||||
@TestApi
|
||||
public static long getLoopbackRxPackets() {
|
||||
return nativeGetIfaceStat(LOOPBACK_IFACE, TYPE_RX_PACKETS);
|
||||
}
|
||||
|
||||
/** {@hide} */
|
||||
@TestApi
|
||||
public static long getLoopbackTxBytes() {
|
||||
return nativeGetIfaceStat(LOOPBACK_IFACE, TYPE_TX_BYTES);
|
||||
}
|
||||
|
||||
/** {@hide} */
|
||||
@TestApi
|
||||
public static long getLoopbackRxBytes() {
|
||||
return nativeGetIfaceStat(LOOPBACK_IFACE, TYPE_RX_BYTES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return number of packets transmitted since device boot. Counts packets
|
||||
* across all network interfaces, and always increases monotonically since
|
||||
|
||||
Reference in New Issue
Block a user