Wednesday, March 20, 2019

system apps - Which process is responsible for capturing (mobile/WiFi) data usage?


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?



Answer




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.


RELATED: How to view network traffic requested by a specific app?




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


No comments:

Post a Comment

samsung galaxy s 2 - Cannot restore Kies backup after firmware upgrade

I backed up my Samsung Galaxy S2 on Kies before updating to Ice Cream Sandwich. After the upgrade I tried to restore, but the restore fails ...