Add tagSocket/untagSocket NDK APIs
Provide native APIs to tag the various sockets used for network transfer, which helps apps tracking down data usage inside their app. We've had equivalent Java APIs since API level 14. https://developer.android.com/reference/android/net/TrafficStats.html#tagSocket(java.net.Socket) https://developer.android.com/reference/android/net/TrafficStats.html#untagSocket(java.net.Socket) Given that these Java APIs are implemented in native side, providing NDK APIs directly will be easier for native users to use it. Bug: 29761778 Bug: 202086915 Test: Tests in change Ic6554d9b98cef9b41b7eae06315d284c574c0a45 Change-Id: I802ce62f82199ce087bf8feb03afb26de1ce526e
This commit is contained in:
@@ -18,6 +18,10 @@ LIBANDROID_NET {
|
||||
android_getprocnetwork; # llndk
|
||||
android_setprocdns; # llndk
|
||||
android_getprocdns; # llndk
|
||||
# These functions have been part of the NDK since API 33.
|
||||
android_tag_socket_with_uid; # llndk
|
||||
android_tag_socket; # llndk
|
||||
android_untag_socket; # llndk
|
||||
local:
|
||||
*;
|
||||
};
|
||||
|
||||
@@ -161,3 +161,15 @@ int android_res_nsend(net_handle_t network, const uint8_t *msg, size_t msglen,
|
||||
void android_res_cancel(int nsend_fd) {
|
||||
resNetworkCancel(nsend_fd);
|
||||
}
|
||||
|
||||
int android_tag_socket_with_uid(int sockfd, int tag, uid_t uid) {
|
||||
return tagSocket(sockfd, tag, uid);
|
||||
}
|
||||
|
||||
int android_tag_socket(int sockfd, int tag) {
|
||||
return tagSocket(sockfd, tag, -1);
|
||||
}
|
||||
|
||||
int android_untag_socket(int sockfd) {
|
||||
return untagSocket(sockfd);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user