Ujanja Ni Uhai (Hustling Is Life)

Mobile data tracking working on Tab 7 Plus CM9

With Android 4.0 “Ice Cream Sandwich” came an interesting new feature: mobile data usage tracking. It tracks, graphs, and logs your data usage (and the applications which were responsible for using the data).

I don’t know how accurate it is, but it does appear to work; you can see it has named and shamed Google Play Store and Chrome.

Background

The Android platform apparently requires the kernel network data logging functionality, but many pre-ICS devices using Linux kernels < 3.0 don't have it. The Honeycomb-based Galaxy Tab 7.0 Plus and Tab 7.7, for example, are using Linux kernel 2.6.36.
Android is quite noisy about the missing stats when using a device without the appropriate kernel support:

The fix(es)

You need to patch your kernel to have the appropriate "Quota, tag, owner" match and stats support for netfilter. If you’re lucky you’ll find someone who’s already backported the support for your kernel version (or at least something close). In our case, I found that Cyanogen himself had already patched another 2.6.36 kernel with this functionality and, much to my surprise, the patches applied cleanly to our kernel.

After that, you need to make sure CONFIG_NETFILTER_XT_MATCH_QTAGUID=y in your kernel config, and then you should be golden.