History log of /frameworks/base/core/java/android/net/NetworkStatsHistory.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
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/core/java/android/net/NetworkStatsHistory.java
1f99a483e410811473b12d8efedd79c738df7af3 11-Jul-2013 Jeff Sharkey <jsharkey@android.com> Recover from corrupt network stats.

When encountering corrupt stats, throw as IOException to allow
recovery at a higher level.

Bug: 9794832
Change-Id: I38d000b3bd8a4c99389c40a87ee0699efb6e9049
/frameworks/base/core/java/android/net/NetworkStatsHistory.java
b0a579f83369ca2daa885222a35f1cd3c054ab11 02-Nov-2012 Jeff Sharkey <jsharkey@android.com> Sanity check network stats coming from disk.

Throw early when structure is unstable, which allows the normal
recoverFromWtf() path to recover automatically.

Bug: 7440485
Change-Id: Ic150d17daac4de7c9ff3489025403a9b485b4620
/frameworks/base/core/java/android/net/NetworkStatsHistory.java
70c70530bd6793869736ec894498e4ebf5dc9b20 16-May-2012 Jeff Sharkey <jsharkey@android.com> Transition from DEV network stats to XT.

When XT stats are available, transition to prefer them over DEV,
since they aren't subject to hardware driver bugs. Only switches at
the first atomic XT bucket, and adds a Settings.Secure flag to force
back to DEV if needed. Includes tests to cover transition.

Fix tests where device overlay would change which network types
reflected data usage. Test both history and summary APIs. Fixed
collection timestamps to reflect full buckets.

Bug: 6504744
Change-Id: Idd7f3b2fdb064c36547c85c51c214fd938c59b7e
/frameworks/base/core/java/android/net/NetworkStatsHistory.java
bfdd680ab44da173a4a39fcd6feccdebb9d1f855 09-Apr-2012 Jeff Sharkey <jsharkey@android.com> Migrate to @Override to remove warnings.

Bug: 6303344
Change-Id: I0d33b2ed448467379d576ccd71fb5ae20c878852
/frameworks/base/core/java/android/net/NetworkStatsHistory.java
63abc37356728c0575d6a62a203102ae6d97953b 12-Jan-2012 Jeff Sharkey <jsharkey@android.com> Move network stats to FileRotator pattern.

Split existing network stats into two separate classes: a recorder
which generates historical data based on periodic counter snapshots,
and a collection of historical data with persistance logic.

Recorder keeps a pending history in memory until outstanding data
crosses a specific threshold. Persisting is handled through a given
FileRotator. This pattern significantly reduces disk churn and
memory overhead. Separate UID data from UID tag data, enabling a
shorter rotation cycle. Migrate existing stats into new structure.

Remove "xt" stats until iptables hooks are ready. Avoid consuming
Entry values when recording into NetworkStatsHistory. Assign
operation counts to default route interface.

Introduce "Rewriter" interface in FileRotator with methods to enable
rewriteAll(). Introduce IndentingPrintWriter to handle indenting in
dump() methods.

Bug: 5386531
Change-Id: Ibe086230a17999a197206ca62d45f266225fdff1
/frameworks/base/core/java/android/net/NetworkStatsHistory.java
293779f9c63cbae0dde564449f0270b595593b0d 06-Oct-2011 Jeff Sharkey <jsharkey@android.com> Refine random stats generation.

Offer parameters to pick out specific list of packages, and to change
duration and total data.

Bug: 5416742
Change-Id: I6970a5e76f3198ef23a400c079037212b000ca6b
/frameworks/base/core/java/android/net/NetworkStatsHistory.java
367d15ab1a33b6159447fa8542d4fa8ff148371c 22-Sep-2011 Jeff Sharkey <jsharkey@android.com> Watch network subtype, tethering teardown, empty.

Watch for changes to telephony network subtype, and update iface
mapping to persist stats under correct type. Update network stats
before removing tethering NAT rules.

Skip recording that would create empty historical buckets. Query UID
stats before iface stats to always skew positive when counters are
actively rolling forward.

Bug: 5360042, 5359860, 5335674, 5334448
Change-Id: I8aa37b568e8ffb70647218aa1aff5195d3e44d5a
/frameworks/base/core/java/android/net/NetworkStatsHistory.java
34c73acf88c8190b8cd51d8b8f2b9c22aa7f7941 18-Sep-2011 Jeff Sharkey <jsharkey@android.com> Sample atomic network stats buckets, full poll.

When sampling network stats, always use atomic buckets instead of
interpolating. Always poll iface and UID together so we distribute
into buckets equally. Move stale bucket trimming to just before
writing stats.

Bug: 5321340
Change-Id: I78a2226778a79c875f3668336e39ea24a7b4d5c4
/frameworks/base/core/java/android/net/NetworkStatsHistory.java
69b0f63af2e3babc2e9f048c4682032a0c17d9d0 12-Sep-2011 Jeff Sharkey <jsharkey@android.com> Data usage structure optimizations.

Driven by traceview hotspots found in Settings UI.

Change-Id: I614a049523c526b7fcd12fffdf53a3e4723623e4
/frameworks/base/core/java/android/net/NetworkStatsHistory.java
47eb102b40cd1324d89816a7fb0fecd14fd7a408 26-Aug-2011 Jeff Sharkey <jsharkey@android.com> Always splice historical data stats, debug info.

When reading network counters, always splice in xt_qtaguid values
to avoid counting backwards. Test to verify.

Remove verbose logging around global alerts, and add dumpsys debug
info for NMS and MDST. Also fix subtle bug around stats persisting
and dumping.

Bug: 5212893, 5211028
Change-Id: I783e5286637a67ee2dd2b09878198711a926d0cb
/frameworks/base/core/java/android/net/NetworkStatsHistory.java
558a23200697d306b75750cf4612cf0717e73537 25-Aug-2011 Jeff Sharkey <jsharkey@android.com> Data usage buckets active time, parsing ISE.

When recording data usage, measure the actual active time, since
buckets can be quite long. Offer incrementOperationCount() version
that reads thread stats tag for caller. Rethrow any NPE as ISE
during stats parsing, which callers already handle.

Bug: 5171812, 5184508, 5180659
Change-Id: I6da80ccc0162be68bee279529e3a23b6f98ebd87
/frameworks/base/core/java/android/net/NetworkStatsHistory.java
b5d55e302d2253e4bfb233ea705caf258cdc4cb9 11-Aug-2011 Jeff Sharkey <jsharkey@android.com> Foreground/background network stats using sets.

Teach NetworkStats about "counter sets" coming from kernel, and use
them to track usage in foreground/background. Add AID_NET_BW_ACCT to
system_server so it can control counter sets.

Move to composite key of NetworkIdentitySet, UID, set, and tag when
recording historical usage. Persisting still clusters by identity,
since that is heaviest object.

Request async stats poll during systemReady() to bootstrap later
delta calculations. Reset kernel counters when UID removed. Update
various tests.

Bug: 5105592, 5146067
Change-Id: Idabec9e3ffcaf212879821515602ecde0a03de8c
/frameworks/base/core/java/android/net/NetworkStatsHistory.java
04cd0e47dbc1e9769ac6f258c923d5b17fa57986 05-Aug-2011 Jeff Sharkey <jsharkey@android.com> Fix random stats generation for debugging.

Change-Id: I53f0e9ea9b15fbf7b99886ea8604eda8d3958d8d
/frameworks/base/core/java/android/net/NetworkStatsHistory.java
63d27a9233fed934340231f438493746084a681d 04-Aug-2011 Jeff Sharkey <jsharkey@android.com> Network stats with varint, omit parcel fields.

Persist NetworkStatsHistory using variable-length encoding; since
most buckets have small numbers, we can encode them tighter. Initial
test showed 44% space savings. Also persist packet and operation
counters.

Let NetworkStatsHistory consumers request which fields they actually
need to reduce parcel overhead.

Tests for verify varint and history field requests, also verify end-
to-end by persisting history into byte[] and restoring. Expose
bandwidth control enabled state. Extend random generation to create
packet and operation counts. Moved operation counts to long.

Fix bug that miscalculated bytes since last persist, which would
cause partial stats loss when battery pulled.

Bug: 4581977, 5023706, 5023635, 5096903
Change-Id: If61e89f681ffa11fe5711471fd9f7c238d3d37b0
/frameworks/base/core/java/android/net/NetworkStatsHistory.java
f0ceede8fff5df24e5c98701d81c2b71eb138aa9 03-Aug-2011 Jeff Sharkey <jsharkey@android.com> Expose quota status for active network.

Create API to expose quota status derived from underlying network
policy. This is designed to support applications making informed
decisions when performing network requests.

Fix bug with random stats generation, and write policy when changing
restrict background data flag. Deprecate EXTRA_NETWORK_INFO, since
it varies based on UID.

Bug: 4517283, 5088603
Change-Id: Ic6893a8967f69937e466be226ba7bb86ef5a5d2d
/frameworks/base/core/java/android/net/NetworkStatsHistory.java
a63ba59260cd1bb3f5c16e395ace45a61f1d4461 20-Jul-2011 Jeff Sharkey <jsharkey@android.com> Add operation counts to network statistics.

Provide API to increment "operation counts" for a UID and tag, used
to eventually derive bytes/operation stats. Internally is stored at
network layer, but should belong at data layer. Switch profiling
to use data layer stats, which are emulated by summarizing network
layer details.

Read packet counts from new /proc/ columns and collect them into
NetworkStatsHistory. Prevent double-counting by ignoring values from
first snapshot. Watch for duplicate /proc/ entries. Update tests
to verify packet and operation counters.

Bug: 5052136, 5097392
Change-Id: I1832f65a2b8a9188f8088f253474a667c21a2f09
/frameworks/base/core/java/android/net/NetworkStatsHistory.java
434962e44ea93b1c4d216c55f636a435bf54aa54 13-Jul-2011 Jeff Sharkey <jsharkey@android.com> Include full network history around current time.

When requesting historical values with time ranges, always include
full values for buckets that span current time. (It doesn't make
sense to interpolate partial data.) Move getTotalData() to return
full Entry objects to prepare for packet counts.

Bug: 4691901
Change-Id: I717bd721be9f1d4a47c4121e46e07a56cb15bbf1
/frameworks/base/core/java/android/net/NetworkStatsHistory.java
d37948f6ed1667d077e0e3a38808f42f981ddcc2 12-Jul-2011 Jeff Sharkey <jsharkey@android.com> Hide NetworkStatsHistory internals.

Instead of exposing internal storage details, offer getValues()
accessor which populates values into a recycled structure.

Change-Id: I5228d7099a8f61b2018a435a813435a67dae49b4
/frameworks/base/core/java/android/net/NetworkStatsHistory.java
350083e36b9db6062e165954403ef921ff3dfdad 29-Jun-2011 Jeff Sharkey <jsharkey@android.com> Migrate bandwidth control to NMS, omit history.

Both stats and policy make NMS calls that depend on bandwidth control
being enabled, so move enable/disable into NMS and drop calls when
disabled. This avoids throwing heavy ISE exceptions when disabled.

Only include recent data when writing NetworkStatsHistory as part of
dumpsys call. Introduce manual poll event for Settings UI.

Bug: 4982115, 4770435, 4515856
Change-Id: I257820b057af2f0f99c736fb4f61e55b9fdc3e66
/frameworks/base/core/java/android/net/NetworkStatsHistory.java
1b5a2a96f793211bfbd39aa29cc41031dfa23950 19-Jun-2011 Jeff Sharkey <jsharkey@android.com> Read "qtaguid" network stats, refactor templates.

Teach NMS to read qtaguid stats from kernel, but fall back to older
stats when kernel doesn't support. Add "tags" to NetworkStats entries
to support qtaguid. To work around double-reporting bug, subtract
tagged stats from TAG_NONE entry.

Flesh out stronger NetworkTemplate. All NetworkStatsService requests
now require a template, and moved matching logic into template.

Record UID stats keyed on complete NetworkIdentitySet definition,
similar to how interface stats are stored. Since previous UID stats
didn't have iface breakdown, discard during file format upgrade.

Change-Id: I0447b5e7d205d73d28e71c889c568e536e91b8e4
/frameworks/base/core/java/android/net/NetworkStatsHistory.java
4a97122ebf4d92a3f94402041729d77905e6c0c0 12-Jun-2011 Jeff Sharkey <jsharkey@android.com> Growable NetworkStats object instead of builder.

NetworkStats now grows in place with arraycopy() instead of callers
needing to know record count a priori. Better growth calculation for
both NetworkStats and NetworkStatsHistory; 50% each time. Better
estimates of buckets needed in calling services.

Change-Id: I3adbffa0b7407612cc6349d9135a8b4eb63cd440
/frameworks/base/core/java/android/net/NetworkStatsHistory.java
3f3913550c10792edb8aecf66cc83c3db5c8b311 06-Jun-2011 Jeff Sharkey <jsharkey@android.com> Persist network stats using AtomicFile.

Implements read/write of network stats using AtomicFile, along with
magic number and versioning. Stores in "/data/system/netstats.bin"
for now. Tests to verify that stats are persisted across a simulated
reboot, and to verify that TEMPLATE_WIFI is working.

Fixed bug where kernel counters rolling backwards would cause negative
stats to be recorded; now we clamp deltas at 0.

Change-Id: I53bce26fc8fd3f4ab1e34ce135d302edfa34db34
/frameworks/base/core/java/android/net/NetworkStatsHistory.java
19862bf5d058b6ab0c2979e7a5e0297dae6b170b 03-Jun-2011 Jeff Sharkey <jsharkey@android.com> Compute range-based usage in NetworkStatsHistory.

When given a start/end range, interpolate between buckets to return
the total network usage. Used to summarize detailed UID stats. Method
to combine NetworkStatsHistory regardless of bucket size. Used to
combine all histories matching a template.

Added tests for both methods.

Change-Id: Ia463910c0ecf7cf08dcf97c658ad99742bd6b882
/frameworks/base/core/java/android/net/NetworkStatsHistory.java
61ee0bbb5b87fb5c4c3dc219868d52743def3d2b 30-May-2011 Jeff Sharkey <jsharkey@android.com> UID network stats, secure settings, and random.

Collect UID-granularity network stats during regular poll event. Add
dumpsys argument to generate fake historical data for debugging, and
move stats parameters to Settings.Secure.

Change-Id: I09b36a2955dc10c697d4b9c3ff23dcb3ac37bd70
/frameworks/base/core/java/android/net/NetworkStatsHistory.java
d2a458750e5a3d490af09cecb5c28370baf0a913 29-May-2011 Jeff Sharkey <jsharkey@android.com> Map network identity using ConnectivityService.

Instead of deriving network identity based on raw subsystem broadcasts,
listen for updates from ConnectivityService. Added atomic view of all
active NetworkState, and build map from "iface" to NetworkIdentity set
for stats tracking.

To avoid exposing internal complexity, INetworkStatsService calls use
general templates. Added TelephonyManager mapping to classify network
types using broad labels like "3G" or "4G", used to drive templates.

Cleaned up Objects and Preconditions.

Change-Id: I1d4c1403f0503bc3635a59bb378841ba42239a91
/frameworks/base/core/java/android/net/NetworkStatsHistory.java
75279904202357565cf5a1cb11148d01f42b4569 25-May-2011 Jeff Sharkey <jsharkey@android.com> Collect historical network stats.

Periodically records delta network traffic into historical buckets to
support other services, such NetworkPolicyManager and Settings UI.

Introduces NetworkStatsHistory structure which contains sparse, uniform
buckets of data usage defined by timestamps. Service periodically
polls NetworkStats and records changes into buckets. It only persists
to disk when substantial changes have occured. Current parameters
create 4 buckets each day, and persist for 90 days, resulting in about
8kB of data per network.

Only records stats for "well known" network interfaces that have been
claimed by Telephony or Wi-Fi subsystems. Historical stats are also
keyed off identity (such as IMSI) to support SIM swapping.

Change-Id: Ia27d1289556a2bf9545fbc4f3b789425a01be53a
/frameworks/base/core/java/android/net/NetworkStatsHistory.java