1

The problem is that it is broken for me. I customized quite a bit, specifically installing a firewall that uses root and disabling broadcast receivers and services in many Huawei and Google apps that came preinstalled. I guess one of these must be responsible for capturing how much data flows over each interface and from which app it originates, since the feature broke.

Which process (on any Android phone, I can probably find the equivalent once I know where to look) is responsible for doing this?

  • So your "settings -> data" isn't tracking right? – rogerdpack Sep 20 at 17:22
  • @rogerdpack Yes – Luc Sep 21 at 9:56
2

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 NetworkPolicyManager and NetworkManagementService. At back end netd inserts/deletes 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.


REFERENCES:

1. The one we can access with dumpsys netstats
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 cmd netpolicy
6. Using modules owner and quota2
7. Based on owner module and depends on socket module

  • 1
    Woa, I had never expected such a detailed answer since it's very niche. Very glad I decided to ask the question anyway. Thanks a lot! I'm going to dive into this, but just catting /proc/net/xt_qtaguid/stats it looks like this is the usage data I'm looking for and it's just the settings data usage screen that is broken (I can parse csvs manually, no problem). Just gotta figure out over which period this tracking is and what all the columns mean (like cnt_set). I'll dive into this when I have some time in a few hours :) – Luc Sep 22 at 10:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.