DataUsageController (a component of Settings app) collects data from
NetworkStatsService (1) which is part of Android framework i.e.
system_server and depends on (2)
TrafficController (a component of
netd native service) which in turn uses libqtaguid to tag network sockets on per app/UID basis. Previously
qtaguid kernel module was used to track tagged sockets (by reading “/proc/net/xt_qtaguid/stats” (3)) which is being replaced with eBPF framework. Now data usage will be available in a virtual filesystem (“/sys/fs/bpf/traffic_uid_stats_map” (4)).
Network policy restrictions (Data/Battery Saver and Background Data (5)) and Data Limit/Warning are implemented mainly by
NetworkManagementService. At back end
iptables rules (6) to enforce restrictions in kernel space.
Both qtaguid (7) and quota2 modules are part of only Android kernel (8) while
owner is part of mainline Linux kernel.
RELATED: How to view network traffic requested by a specific app?
1. The one we can access with
2. Through NetworkStatsManager / TrafficStats / SocketTagger, JNI NetworkManagementSocketTagger, libcutils (qtaguid), NetdClient, Netd's FwmarkServer and possibly others
5. Can be read / set by
dumpsys netpolicy and
6. Using modules owner and quota2
7. Based on owner module and depends on socket module