How to get an overview of which app are allowed to background data for Android 7 A user can enable or disable background data usage by following the following steps:


From the Home screen, tap the app slider, then open "Settings".
Select "Data usage".
Select "Cellular data usage".
Select the app you want to limit background data on.
Toggle "Background data" to "On" or "Off" as desired.




The question is - is there anyway to do it on a mass scale for all apps so that a user do not need to keep repeating the five steps as described above?

Example, a user just need to follow the following steps:


From the Home screen, tap the app slider, then open "Settings".
Select "Data usage".
Select "Background data usage", which will list all the apps. Each row will display the app name, the app version and a "On/Off" switch. If the app was "On" for background data, it will be a "On" for that switch.
Toggle "Background data" to "On" or "Off" as desired thru scrolling on the same page.


(Step 3 should look something like the picture below, which the picture illustrate which WIFI to be "On" or "Off" as a metered Wifi network.)
Not sure about GUI interface you want or a third party app that may do this for you, you can use CLI (terminal app or adb shell):

~$ dumpsys netpolicy | grep '^[ ]*UID=.*METERED_BACKGROUND'
  UID=10173 policy=4 (ALLOW_METERED_BACKGROUND)
  UID=10176 policy=1 (REJECT_METERED_BACKGROUND)


File /data/system/netpolicy.xml can also be read directly with root access.

~# awk '$2==10173 || $2==10176 {print $2,$1}' /data/system/packages.list
10173 com.whatsapp
10176 com.simplemobiletools.gallery.pro


Or:

~$ pm list packages -U | sed 's/package://; s/uid://' | grep -E '10173$|10176$'
com.whatsapp 10173
com.simplemobiletools.gallery.pro 10176


It shows that WhatsApp has Unrestricted data usage allowed, while Gallery app is denied Background data usage at all. Rest of the apps have default behavior i.e. they can use background data but not in Data Saver mode.

You can do some further scripting with aapt tool to get e.g. app label / name.