OSDN Git Service

Allow applications to query for foreground/background data usage.
authorLorenzo Colitti <lorenzo@google.com>
Mon, 2 Apr 2018 07:48:31 +0000 (16:48 +0900)
committerLorenzo Colitti <lorenzo@google.com>
Mon, 2 Apr 2018 10:58:24 +0000 (19:58 +0900)
commit84b317cecfa5b849dc7632a3a2fb56568cee18ca
treee11cbf280c8306b83684b506ad18af9e7bb15a8a
parentcd21f1c5c2d0145ec48c727c13e07377b4b22312
Allow applications to query for foreground/background data usage.

Currently the NetworkStatsManager APIs allow applications to
query for their own data usage by UID and tag, but do not allow
applications to query by foreground/background state.

This is causing popular apps to resort to parsing xt_qtaguid
stats files directly. Because this is no longer allowed for apps
targeting P and above, provide replacement functionality.

This API allows apps to query for data usage for a given state,
but not to receive data usage broken down by state. This is
consistent with how the current UID and tag APIs work. It is also
not an undue burden on apps: there are currently only two states
of interest (FOREGROUND and everything else), and even if we add
states in the future, unmodified apps can still obtain total
traffic using STATE_ALL.

Bug: 72977484
Test: New CTS test added in other change in this topic.
Change-Id: Ic8c9194569ffd599b49e4a8197c5c2ea0ec3f7f7
api/current.txt
core/java/android/app/usage/NetworkStats.java
core/java/android/app/usage/NetworkStatsManager.java