History log of /frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
44eae19b24473d1b1bf8bfcac1d965078cb55768 23-May-2018 Jeff Sharkey <jsharkey@google.com> Merge "Last-ditch clamping of negative NetworkStats." into pi-dev
b5a97e6f63bfe8b828224f606f8cb8585d9f28ec 22-May-2018 Jeff Sharkey <jsharkey@android.com> Last-ditch clamping of negative NetworkStats.

We've seen reports of negative values flowing through to attempt
being recorded, which will outright crash. This change does one
last-ditch check to see if we're about to work with negative values,
reporting any trouble and clamping them to zero so we don't crash.

This gives us the data we need to continue investigating without
triggering runtime restarts in the field.

Bug: 80057433
Test: atest android.net.NetworkStatsTest
Change-Id: I8174391c6cf5dadc2c2c10a8d841ee07e1f7d934
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
004998251ba1909870c6b2486187a8b94234404e 19-May-2018 Chenbo Feng <fengc@google.com> Check for bpf support at NetworkStatsService start

The current implementation check for bpf map existance whenever a
NetworkStats request comes in. The check is not efficient and may
require additional permission for threads. So a member variable is added
to NetworkStatsService to store the bpf configuration status and is
initialized when NetworkStatsService start.

Test: -m CtsNetTestCases -t android.net.cts.TrafficStatsTest
-m CtsUsageStatsTestCases -t android.app.usage.cts.NetworkUsageStatsTest
Bug: 79994577

Change-Id: I872ae18fb3e9631a4e6c4d773fefbba32e60a03b
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
c3c8d16380e3d7a54aa290061c8ea5a127027c46 20-Apr-2018 Jeff Sharkey <jsharkey@android.com> Give CTS a way to force-poll network stats.

Collecting network statistics is pretty heavy, which is why we're
throttling callers. However, to keep CTS running fast, we provide a
way for tests to force a poll event, instead of making them wait for
the throttle timeout.

Bug: 77908520
Test: atest cts/tests/tests/app.usage/src/android/app/usage/cts/NetworkUsageStatsTest.java
Change-Id: Ia792f0cd495023366ff8c4839df54e7da2ae8331
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
146bb336ecb36bfa27529828172ec7593d4fb2f5 18-Apr-2018 Jeff Sharkey <jsharkey@android.com> Never interact with "phone" while holding locks.

We've seen devices where heavy communication between "system_server"
and the "phone" process can exhuast Binder threads, especially when
calling while holding locks. To mitigate this, we now interact with
the "phone" process before acquiring any locks.

Update our internal data structures either when we see a connectivity
change, or when SubscriptionManager tells us something changed.

Fix bug in resolveSubscriptionPlan() that always picked the 0'th
SubscriptionPlan instead of looking for the currently active plan;
we now use the same logic for both NSS and NPMS.

Bug: 77908520, 77154412
Test: atest com.android.server.NetworkPolicyManagerServiceTest
Test: atest com.android.server.net.NetworkStatsServiceTest
Change-Id: I177d3fa6cddc78d745b35a9ede12451d458b892c
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
00072395e2fbc196cc781f3072b61f6ba11cf022 12-Apr-2018 Jeff Sharkey <jsharkey@android.com> Add tracing for network statistics and policy.

These trace points surround areas of heavy lifting to help us debug
code that might be taking longer than expected. (For example, slow
getting data from eBPF, slow recording into data structures, slow
writing to disk, or slow evaluating policy.)

Typical timings on a taimen:

performPollLocked: 25.5ms
snapshotUid: 4.4ms
snapshotXt: 1.4ms
[persisting]: 13.4ms
updateNotifications: 3.3ms

Bug: 77908520, 77808546, 77853238, 77154412
Test: builds, boots
Change-Id: I072bfecffee01eeec7e4cbad439bd1cdc166febc
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
050151e0529c16fc878b7273fbf2b951f8039fd7 13-Apr-2018 Jeff Sharkey <jsharkey@android.com> Don't process broadcasts until really ready.

Someone started setting mSystemReady too early, when we really want
to know SystemServer's real ready state. Add a variable to track
that, and don't process broadcasts until that's set.

Bug: 78020762
Test: builds, boots
Change-Id: I65213e46044c95fb0a8a4b09b9aa463bb15c1844
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
abc6e18d56c6bab0729518d10ea0ced6c2f64c97 12-Apr-2018 Remi NGUYEN VAN <reminv@google.com> Add rate limiting and logging for NetworkStats.

Bug: 77908520, 77808546, 77853238, 77154412
Test: atest com.android.server.net.NetworkStatsServiceTest
Test: manual: flashed, verified network usage updated
Change-Id: I905dbea85e00f80103916939f6d4bf8cab931d03
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
75525b39f4deb8409825fd43195d5f82628ef3e5 27-Feb-2018 Remi NGUYEN VAN <reminv@google.com> Fix network usage stats on 464xlat tethered.

Usage stats corrections for 464xlat in NetworkStatsFactory are not applied
to tethered traffic. Add adjustments in NetworkStatsService. After
migrating external callers off NetworkStatsFactory, we will be able to
only apply adjustments in NetworkStatsService and remove stacked
interface tracking from NetworkStatsFactory.
Bug: 72107146
Fixes: 72107146
Test: runtest frameworks-net & manual - checked corrected network usage
Merged-In: Ieb25c41c651499fdd01225ae5ac21d95e3d823f5
Merged-In: I016722f3a0ae2ae0a1d48bfacc4fe07ee3578ef7
(cherry-pick of aosp I5ce450e616b4fddf21f2a491fe5d0c9e9f969bda)

Change-Id: Id41cf22a0f9a63cb1832e9375bfb045861f08e52
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
b6a920124f28422877f59bfb32719099a0067d76 05-Mar-2018 Remi NGUYEN VAN <reminv@google.com> Add method to NetworkStatsService for UID stats.

Useful for clients such as BatteryStats which currently rely
on NetworkStatsFactory. Data at that stage is incomplete as
it does not account for tethering, VT data and corresponding
464xlat corrections.

Test: runtest frameworks-net, CTS tests pass.
Bug: b/72107146
Merged-In: I31c5b9b4a7c6e72910152415894a137f000a5858
Merged-In: I2527d95000c7500c824ede70f87ecb38e21ed323
(cherry picked from aosp 088ff6824f13145ea52207bdead0d7e454a6f3ce)

Change-Id: Ie80f1bb21124241f3414f9be77aceac9a44ec6d1
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
e0c2995d0f16246336d4385d5ebe631a60e12e86 21-Feb-2018 Jeff Sharkey <jsharkey@android.com> Name specific app for rapid data usage.

When a single app is responsible for more than half of the data usage
that caused us to trigger a "rapid usage" alert, name that app in the
notification. Tests to verify.

Move NPMS->NSS direct calls to "Internal" pattern, following
best-practices to avoid unnecessary AIDL exposure.

Remove 3G/4G split mobile plan support, which has been deprecated for
years and was never supported in a shipping product.

Move MultipathPolicyTracker in tree to reflect its package name.

Test: bit FrameworksNetTests:*
Test: bit FrameworksServicesTests:com.android.server.NetworkPolicyManagerServiceTest
Bug: 69263587, 64221505, 73431080, 72746951
Exempt-From-Owner-Approval: approved in previous PS
Change-Id: I3e4ec1ae2222d51b232f76f32faca93d4f8cd272
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
4e0d30757e2c1d61dacc33655110268be165ec8a 20-Feb-2018 Jeff Sharkey <jsharkey@android.com> Only emit debug logging when requested.

Test: builds, boots
Bug: 72556865
Change-Id: I69d5d760221ef907eeea38490f56243f0a3b9dcb
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
c3e4916301b421700ca80a338c6086c5cb33a844 17-Feb-2018 Jeff Sharkey <jsharkey@google.com> Merge "Leave NetworkStatsService around during shutdown."
92af3dbda1918c8590bd493d01d8a15d65fec44c 17-Feb-2018 Jeff Sharkey <jsharkey@android.com> Leave NetworkStatsService around during shutdown.

We've seen system code continue to ask about network statistics
during a shutdown, so keep our objects around to avoid crashing
with NPEs.

Test: builds, boots
Bug: 73323432
Change-Id: I2654d37a59eb830ff32a2151ae6ad6a999a41677
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
9911a28adb3b1196fe912ff5b65b8d5cbc7321ec 15-Feb-2018 Jeff Sharkey <jsharkey@android.com> Better handling of NTP-based clocks.

Now that we have a nice Clock abstraction, we can use it to represent
a clock backed by an NTP fix. (This makes testing logic much easier
to write.)

We now rely completely on NetworkTimeUpdateService to keep our NTP
fix up to date, instead of trying to refresh in the middle of
critical paths which could trigger random ANRs.

Add internal FallbackClock to make it easier to handle missing NTP
fixes. Add internal SimpleClock to let implementers focus on single
millis() method.

Test: bit FrameworksNetTests:com.android.server.net.NetworkStatsServiceTest
Test: bit FrameworksServicesTests:com.android.server.NetworkPolicyManagerServiceTest
Bug: 69714690, 72320957
Change-Id: Ic32cdcbe093d08b73b0e4b23d6910b23ea8e1968
Exempt-From-Owner-Approval: approved in previous PS
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
a36dc621ef0b86a0bd46f1d4f5a719a466ba1800 06-Feb-2018 Andreas Gampe <agampe@google.com> Frameworks: Annotate trivial @GuardedBy in services/core

Add @GuardedBy for simple functions that require a single lock
and are named XYZLocked.

Derived by errorprone.

Bug: 73000847
Test: m
Test: m javac-check-framework RUN_ERROR_PRONE=true
Change-Id: I6993325b11c71a4ec27c21935fb54a954d95455f
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
aedd6a3bdcb0b63c0bd6c6f01b720cddfedd51b8 21-Nov-2017 Chenbo Feng <fengc@google.com> Add BPF support for NetworkStatsService

Add the native implementation for NetworkStatsService to read the
uidStatsMap and tagStatsMap to get the network traffic information.
Currently the implementation only try to get the data from bpf for a
reference but the final value returned is still from old xt_qtaguid
module. So the result will not be effected. The bpf implementation is
depending on libbpf inside netd.

Bug: 30950746
Test: CtsNetTestCases -t android.net.cts.TrafficStatsTest

Change-Id: Ia85e4d4d602f6bd536739d89085e6dc37ad82e15
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
d3e4a1e250194bbf59b1e04b60711f97001f61f8 18-Jan-2018 Lorenzo Colitti <lorenzo@google.com> Track and persist in stats whether traffic is on the default network.

This change adds the defaultNetwork to the ident based on current
system networking state, and persists that value to flash.

Bug: 35142602
Test: runtest frameworks-net
Test: downloaded files using default/non-default networks while watching dumpsys netstats
Change-Id: Id8776d149b2977548a9eb455ad4926af55e25aba
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
ada23ed56addb7c06a489c7464ae228a46588b95 18-Jan-2018 Lorenzo Colitti <lorenzo@google.com> Add the default network to NetworkStats and NetworkStatsCollection.

This allows us to maintain NetworkStats entries that track
whether the traffic was on the default network.

At the moment, the stats collection code always passes in
DEFAULT_NETWORK_NO. However, this value is a no-op, since it is
not persisted to disk. Only the ident, the uid/set/tag, and the
packet/byte/operation counters are persisted.

A future change will add defaultNetwork to the ident and start
persisting it.

Bug: 35142602
Test: runtest frameworks-net
Change-Id: Ifa291c62c0fa389b88e5561086a29dcd7cee2253
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
c78da2937cf79e11d439df7730fa29c82b177ab3 18-Jan-2018 Lorenzo Colitti <lorenzo@google.com> Pass all default networks to NetworkStatsService

This will allow NetworkStatsService to treat traffic on these
networks differently from traffic where the app selects a network
that is not the default.

Bug: 35142602
Test: runtest frameworks-net
Change-Id: I5ea9d200d9fb153490c6108bb9390bf152f297da
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
d3d9c4ed9baa97f70858e639a01345a3cd78f42d 15-Nov-2017 Chenbo Feng <fengc@google.com> Use NetworkStatsService to get stats for apps

Move the native implementation of TrafficStats to NetworkStatsService
and apps need to get the NetworkStatsService binder interface from
system_server in order to get the network usage stats since boot. This
implementation can hide the detail of retrieving network traffic
information from apps and the NetworkStatsService can choose which
methoed it use to get the data depending on the kernel version of the
device.

Bug: 30950746
Test: CtsNetTestCases -t android.net.cts.TrafficStatsTest
Change-Id: I53bbefd19aa0b783b9b4b42ea4d76db3e9ec07a3
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
4635f10b789810d2726d5936f921dcec557078da 01-Sep-2017 Jeff Sharkey <jsharkey@android.com> Don't over-acquire NPMS locks.

We only need to hold mNetworkPoliciesSecondLock when working with
subscription plans; before this CL we could end up acquiring the two
NPMS locks out of order, resulting in a deadlock.

Also annotate objects in NSS that require mStatsLock to be held.

Test: builds, boots
Bug: 65268076
Change-Id: I06497564424316ef895dc8dceba72ae784781dc3
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
f4de294297de47d8c594956b2d8607e314e71836 29-Aug-2017 Jeff Sharkey <jsharkey@android.com> Augment network stats based on SubscriptionPlan.

When a carrier provides an "anchor" of data usage at a specific
moment in time, augment the network statistics used by warning/limit
thresholds and Settings UI. For example, if the OS measured 500MB
of usage, but the carrier says only 400MB has been used, we "squish"
down the OS measured usage to match that anchor.

Callers using the hidden API will have their data augmented by
default, and the public API offers a way to opt-into augmentation.

Thorough testing to verify behavior.

Test: bit FrameworksNetTests:android.net.,com.android.server.net.
Test: cts-tradefed run commandAndExit cts-dev -m CtsUsageStatsTestCases -t android.app.usage.cts.NetworkUsageStatsTest
Bug: 64534190
Change-Id: Id3d4d7625bbf04f57643e51dbf376e3fa0ea8eca
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
5356a35c3bcfcdf2d184c620af6bfbf9bddf35c5 17-Aug-2017 Lorenzo Colitti <lorenzo@google.com> Add tether offload traffic to interface stats as well.

Currently, we only count add tethering traffic to per-UID
stats, but not to total data usage (i.e., dev and XT stats). This
is correct for software tethering, because all software forwarded
packets are already included in interface counters, but it is
incorrect for hardware offload, because such packets do not
increment interface counters.

To fix this:
1. Add an argument to ITetheringStatsProvider#getTetherStats to
indicate whether per-UID stats are requested. For clarity,
define integer constants STATS_PER_IFACE and STATS_PER_UID
to represent these operations.
2. Make NetdTetheringStatsProvider return stats only if per-UID
stats are requested. (Otherwise tethering traffic would be
double-counted).
3. Make OffloadController's stats provider return the same
stats regardless of whether per-UID stats were requested or
not.
4. Make NetworkStatsService add non-per-UID tethering stats to
the dev and XT snapshots. The per-UID snapshots were already
correctly adding in per-UID stats.

Bug: 29337859
Bug: 32163131
Test: runtest frameworks-net
Test: runtest frameworks-telephony
Change-Id: I7a4d04ab47694d754874136179f8edad71099638
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
9f09e6a73df1748e980eff26a57e611d68c7ee9a 26-Jun-2017 Jeff Sharkey <jsharkey@android.com> Unify permissions under UPDATE_DEVICE_STATS.

The UPDATE_DEVICE_STATS permission has become the de-facto mechanism
that platform components use to shift blame for resource usage, so
it's confusing to also have a separate MODIFY_NETWORK_ACCOUNTING
permission. So this change replaces MODIFY_NETWORK_ACCOUNTING with
UPDATE_DEVICE_STATS.

Bug: 62483389
Test: builds, boots
Exempt-From-Owner-Approval: Bug 63673347
Change-Id: I872759f02327b6d531ec2338bd876890aded60ad
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
f9d559ce7c794c1930bea5b3bf2bea1aa26fe853 27-May-2017 Jack Yu <jackyu@google.com> Added video calling data usage per-uid support

Now the VT call data usage will be counted under
current dialer's data usage as well as the total
device data usage.

Test: Manual
bug: 37671326

Change-Id: I8351e9ae17c84210f7ca6c319d3bddcbb0043341
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
fe9a53bc45fd0124a876dc0a49680aaf86641d3e 31-Mar-2017 Jeff Sharkey <jsharkey@android.com> Consistent dump() permission checking.

This change introduces new methods on DumpUtils that can check if the
caller has DUMP and/or PACKAGE_USAGE_STATS access. It then moves all
existing dump() methods to use these checks so that we emit
consistent error messages.

Test: cts-tradefed run commandAndExit cts-dev -m CtsSecurityTestCases -t android.security.cts.ServicePermissionsTest
Bug: 32806790
Change-Id: Iaff6b9506818ee082b1e169c89ebe1001b3bfeca
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
48be310e69ddd9598d5d7235d1690ab789ec7f6f 20-Mar-2017 Ryuki Nakamura <ryuki.x.nakamura@sonymobile.com> Merge "Fix NPE while performing NetworkStatsService.removeUidsLocked()" am: a6ce3f3021 am: 900620cffc
am: 06659047f0

Change-Id: Ia7c8309f68d85a88e2a26169509d3e45d4d2ff69
a47b0c97a2aa21cff8c9f87eb9ccef68ed54d67c 01-Mar-2017 Ryuki Nakamura <ryuki.x.nakamura@sonymobile.com> Fix NPE while performing NetworkStatsService.removeUidsLocked()

Symptom:
NPE occurred while performing NetworkStatsService.removeUidsLocked().

Root cause:
NetworkStatsService refers to mUidRecorder at
NetworkStatsService.removeUidsLocked() when mUserReceiver received
Intent.ACTION_USER_REMOVED.
However NetworkStatsService sets mUidRecorder to null without
unregistering mUserReceiver when mShutdownReceiver received
Intent.ACTION_SHUTDOWN.
Therefore NPE occurred when mUserReceiver received
Intent.ACTION_USER_REMOVED after mShutdownReceiver received
Intent.ACTION_SHUTDOWN.

Solution:
Unregister mUserReceiver before setting mUidRecorder to null when
mShutdownReceiver received Intent.ACTION_SHUTDOWN.

Bug: 36015339

Change-Id: I9279e4c6ae07d94e7ec519c40b2d973c84d8fef1
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
da65a52f87ca1a31c9e01e99756e38d37d7e7202 13-Jan-2017 Makoto Onuki <omakoto@google.com> Support protofied dumpsys for NetStats

Bug 34228873
Test: manual tests with "incident_report netstats"

Change-Id: I359b364c64d9798fd4229018a905658d5d46ea5c
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
27574b22a8b50c61b46c8d53772ba14dbe4ac186 14-Dec-2016 Jeff Davidson <jpd@google.com> Merge "Add Log.wtf when getSummaryForAllUid NPEs."
39583b53d1fd1bb9f6878ad32e03bf5d55f2d140 12-Dec-2016 Jeff Davidson <jpd@google.com> Add Log.wtf when getSummaryForAllUid NPEs.

This will provide stack trace information from the system process
which should enable us to more easily track down where the crash is
occurring.

Test: Builds locally
Bug: 33427276
Change-Id: I584a568fc038771afb28a534e2eefe2f763ed5e1
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
0d1fd8d09163566d2c7eb72037f63b6404ada642 12-Oct-2016 Amith Yamasani <yamasani@google.com> Secure MATCH_UNINSTALLED_PACKAGES across users

Introduce a new internal flag MATCH_ANY_USER for genuine uses
of searching through all apps on the device.

Some temporary accommodations for Launchers that reach across
to the work profile until we have a new LauncherApps API to do
that officially.

Bug: 31000380
Test: CTS tests added
Change-Id: I2e43dc49d6c2e11814a8f8d1eb07ef557f31af34
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
b6587eac06c00c964b6f541e18d307df8c4a9a50 22-Jun-2016 Jack Yu <jackyu@google.com> Added a virtual interface for Video Telephony call usage counting

1. Added a virtual VT interface.
2. Qeury VT usage from telephony service.

bug: 20888836
Change-Id: I3df0c22922f8394554230b53f8ae091e17c95595
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
4ff3bcfa0c143ad14c81d07f90ed6dc375701ab1 15-Jun-2016 Jeff Davidson <jpd@google.com> Fix runtime restart when using aggregated net observers.

When observing network traffic on a per-iface basis (as opposed to a
per-iface+uid basis), do not attempt to redistribute VPN traffic,
because it is unnecessary and will lead to a crash further down the
stack.

This is a one-line functional change, but some comments have been
added throughout to clarify behavior.

Bug: 29390363
Change-Id: Icca13f181d7698ca3ddc92aa9248f06f130d49a3
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
6965c1869aa8499706522d057b5143bbc240178b 30-Mar-2016 Antonio Cansado <acansado@google.com> Addressing API council comments on NetworkStatsManager.

Callbacks
- DataUsageCallback renamed to UsageCallback
- DataUsagePolicy removed; passing in params directly to register method
- making it an abstract class
- passing in (networkType, subscriberId) that reached its threshold
- renaming onLimitReached to onThresholdReached to match existing naming
- only monitor single network,subscriberId
- no monitoring of specific uids; using device or user wide instead

Tags
- only owner uid can read its tags
- exposing only TAG_NONE to match service side

BUG: 27530098

Change-Id: I2b2664da71806868a1e937d2bf4d1f234637509b
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
cd42acd9515bdce89d4f1401ee2888d684bf1918 17-Feb-2016 Antonio Cansado <acansado@google.com> Implementation of data usage callbacks.

NetworkStatsService will register data usage requests
and keep data usage stats scoped to the request.

There are different types of data usage requests
- scoped to a set of NetworkTemplate; these are restrictred to
device owners and carrier apps and allow the caller to monitor
all activity on the specified interfaces.
- scoped to all uids visible to the user, if the user has
android.Manifest.permission#PACKAGE_USAGE_STATS permission.
The set of uids may change over time, so we keep track of that.
- scoped to a set of uids given by the caller, granted that
the caller has access to those uids.
- scoped to the caller's own data usage. This doesn't require
PACKAGE_USAGE_STATS.

Bug: 25812785
Change-Id: Ie11f35fc1f29d0dbe82f7fc924b169bb55c76708
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
3a8b343ce5220086c4f71e63f5d42f2d28434c4b 21-Jan-2016 Zoltan Szatmary-Ban <szatmz@google.com> Introduce DEVICESUMMARY access level to NetworkStatsAccess.

Apps with PACKAGE_USAGE_STATS app op or READ_NETWORK_USAGE_HISTORY
granted can query the summarized device data usage (but not individual
uids running in other users or profiles).

Bug:26677052
Change-Id: Id51631638f338a8cf48172c9b41746228a335084
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
1efb1335814aea8ee0696144ca0ab24159b86e54 10-Dec-2015 Jeff Davidson <jpd@google.com> Relax permissions around NetworkStatsManager APIs.

Currently, access to network usage history and statistics requires a
signature|privileged permission, an AppOps bit (associated with the
PACKAGE_USAGE_STATS permission), or device/profile ownership. Once
access is granted via one of these mechanisms, it generally applies to
any UID running in the same user as the caller.

This CL expands access as follows:

-Any app can access its own usage history with no extra requirements.
-Carrier-privileged applications can access usage history for the
entire device.
-Device owners can access per-UID breakdowns for usage. Previously
they could access the summary for the whole device, but not the
individual breakdowns.

We simplify the permission model by defining three access levels -
DEFAULT (own app only), USER (all apps in the same user), and DEVICE
(all apps on the device), and propagate these levels throughout.

Finally, this CL fixes an apparent bug in
NetworkStatsSerice#hasAppOpsPermissions - if the AppOp bit was in
MODE_DEFAULT, hasAppOpsPermission would always return false instead of
falling back to the PackageManager permission check.

Bug: 25812859
Bug: 25813856
Change-Id: Ic96e0776e2a4215a400163872acea1ededfaced9
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
72027d2e424a94f002452d1e16310d00f3696d00 16-Jun-2015 Zoltan Szatmary-Ban <szatmz@google.com> Expose time-interval detail query on INetworkStatsSession

Also, force polling when a session is opened for NetworkStatsManager.

Bug: 21864554
Bug: 21754685
Change-Id: I24ea822c2d5bc1421ec7ee65d0cfe27cf02dd69e
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
cccbe885b94f2dca088c01b2f38addac3054c402 30-Apr-2015 Zoltan Szatmary-Ban <szatmz@google.com> Fix potential NPE on devices without DPMS

Bug: 20563108
Change-Id: Ie2bda65c834ddad9db8753f7616c2754072551cd
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
9c5dfa5c79fff17f96bf977b86c0c9ceb8c3cf9b 23-Feb-2015 Zoltan Szatmary-Ban <szatmz@google.com> Data Usage public API

Added new API consisting of android.app.usage.NetworkUsageManager and
android.app.usage.NetworkUsageStats. Through them data usage on a
network interface can be programmatically queried. Both summary and
details are available.

Bug: 19208876
Change-Id: I0e0c4b37ae23ad1e589d4b0c955b93f28ba4333e
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
f5ea340aabee6e290448c8cc9fb0925da8b7db5e 04-Mar-2015 Wenchao Tong <tongwenchao@google.com> NetworkStatsService to adjust VPN stats before recording.

* Creates a new Parcelable class VpnInfo to hold required
parameters for VPN stats adjustments.
* ConnectivityService to collect infomation and provide
a list of VpnInfo, one for each user.
* NetworkStatsService passes the VpnInfo array to
NetworkStatsRecorder.
* NetworkStatsRecorder calls NetworkStats.migrateTun()
to do the math.
* Poll NetworkStats when the vpn application calls
setUnderlyingNetworks().

Bug: 19536273
Change-Id: I7a4c7726b8243fead10416f7ec6eb5cf95f20183
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
6973634ce61ab7d4c1d51c70be6d51725b89e7b9 08-Dec-2014 Jeff Sharkey <jsharkey@android.com> Direct notification of network interface changes.

Connectivity broadcasts recently changed and are no longer sent for
certain types of network changes. For example, when stacked network
interfaces change for a mobile network. To ensure that we pick up
all these details, directly wire the two services together.

Also remove some unused code for split network types.

Bug: 18666753
Change-Id: I0467bd5b330c0e0cb51af2306d821b41ad16337a
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
55a442e58262e253df965d652bd8219c8d1e72d3 19-Nov-2014 Jeff Sharkey <jsharkey@android.com> Lightweight checkin output for network stats.

Define and print a compact version of network statistics when dump
is requested with the "--checkin" flag. Defaults to last 24 hours,
but included data can be tweaked with various flags.

Groups together detailed network identities into larger umbrella
terms like "mobile" and "wifi."

Bug: 18415963
Change-Id: I70cf9c828ea5c6e5bb6884837d3608f66fbad2e6
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
5274dcc85dc18b524b729ae9a2148c651dc1a654 24-Oct-2014 Jeff Sharkey <jsharkey@android.com> Drop DEV network stats to save RAM.

We migrated to pure XT stats a long time ago, so we no longer need
to keep the DEV stats cached in RAM. This saves ~250KB on a typical
device.

Bug: 18118003
Change-Id: I3d84ba47073fa3500454784afc956c8e53404492
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
92d141fbc2f6bfc85dca1056e40512cba6d1dddb 11-Sep-2014 Vinit Deshpande <vinitd@google.com> Don't require CONNECTIVITY_INTERNAL check for protected broadcasts

This change removes requirement that sender has this permission for
protected broadcasts (since they can only come from framework)

Bug: 17409667

Change-Id: I3431c20a4ed28b3ba2bfc3cf53772e63a3424a2c
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
9da2f1e007268a42248a1778aa9b560e3ce3b704 14-Aug-2014 Jeff Sharkey <jsharkey@android.com> Some networks may have null ifaces, I guess?

Seems like a bug further upstream, but guard ourselves against it
for now.

Bug: 17033841
Change-Id: Id0e5895c3389b63d4e34b1fb064efef8b72cd609
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
eb2c2c790c4b86c9c09245e0b87a38972713434a 12-Aug-2014 Jeff Sharkey <jsharkey@android.com> Hack and ship: NetworkStats edition.

Some devices use clatd for catching raw IPv4 traffic when running on
a pure-IPv6 carrier network. In those situations, the per-UID
stats are accounted against the clat iface, so framework users need
to combine both the "base" and "stacked" iface usage together.

This also means that policy rules (like restricting background data
or battery saver) need to apply to the stacked ifaces.

Finally, we need to massage stats data slightly:

-- Currently xt_qtaguid double-counts the clatd traffic *leaving*
the device; both against the original UID on the clat iface, and
against UID 0 on the final egress interface.

-- All clatd traffic *arriving* at the device is missing the extra
IPv6 packet header overhead when accounted against the final UID.

Bug: 12249687, 15459248, 16296564
Change-Id: I0ee59d96831f52782de7a980e4cce9b061902fff
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java
49782e46c0eb85a25ae2abcf80880c48dbab5aea 20-Dec-2013 Amith Yamasani <yamasani@google.com> am 9158825f: Move some system services to separate directories

* commit '9158825f9c41869689d6b1786d7c7aa8bdd524ce':
Move some system services to separate directories
9158825f9c41869689d6b1786d7c7aa8bdd524ce 22-Nov-2013 Amith Yamasani <yamasani@google.com> Move some system services to separate directories

Refactored the directory structure so that services can be optionally
excluded. This is step 1. Will be followed by another change that makes
it possible to remove services from the build.

Change-Id: Ideacedfd34b5e213217ad3ff4ebb21c4a8e73f85
/frameworks/base/services/core/java/com/android/server/net/NetworkStatsService.java