Commit graph android_packages_modules_Co.../services/java
Message SHA1
Merge "Avoid reading network stats when disabled."
Jeff Sharkey   authored and   Android (Google) Code Review   commited 2011-12-14 10:12:17 -08:00
47a0212ace
Avoid reading network stats when disabled.
Bug: 5518868
Change-Id: Idb5c588b018bf735597ad7ff904ecc69224dd0a0

Jeff Sharkey   commited 2011-12-13 15:43:47 -08:00
675c43125f
am d808bd6e: am f0bbc494: Merge "Avoid NPE when missing network stats." into ics-mr1
* commit 'd808bd6e22':
  Avoid NPE when missing network stats.

Jeff Sharkey   authored and   Android Git Automerger   commited 2011-12-12 20:23:47 -08:00
c431e2b9b5
Avoid NPE when missing network stats.
Bug: 5750339
Change-Id: I4b739dbd076b270a5a2b2e2a1e0f6e445d8c124e

Jeff Sharkey   commited 2011-12-12 18:51:26 -08:00
3511b086bc
Move native netd calls to varargs.
Uses argument escaping inside NativeDaemonConnector, using varargs
to separate boundaries.  Also introduces Command object to help build
argument lists.

Bug: 5472606
Change-Id: I357979fc19bb0171a056e690064e01b5a7119501

Jeff Sharkey   commited 2011-12-02 13:08:26 -08:00
36ff7058f6
Move NativeDaemonConnector to varargs.
Perform uniform argument escaping inside NativeDaemonConnector, using
varargs to separate boundaries.  Also move to parsed NativeDaemonEvent
instances instead of raw Strings.

Bug: 5472606
Change-Id: I1270733e2b2eeb2f6b810240df82ab24d38ebf40

Jeff Sharkey   commited 2011-11-29 12:09:06 -08:00
cd257fbaaf
Only write network stats when already loaded.
Bug: 5584564
Change-Id: Ife2a68804bf3691e9bccdc167807204bce8a85b2

Jeff Sharkey   commited 2011-11-17 12:05:46 -08:00
7047ec62ab
Update NTP outside locks, log large trim events.
Move NTP updates outside locks to avoid blocking ShutdownThread.  Add
logging around trim events that remove substantial history.  Include
history start in sample events.

Bug: 5627247, 5584564
Change-Id: If9bbd93842c710efcdec94e68da87e9e42a5f961

Jeff Sharkey   commited 2011-11-16 17:58:47 -08:00
344b8bfa9e
Conservatively trim data usage stats.
Instead of trusting NTP time alone, use the most-conservative of
system clock and NTP.

Bug: 5584564
Change-Id: I5dd87fc009959b1cf0a7d660e385a0b1a8be238b

Jeff Sharkey   commited 2011-11-14 20:11:38 -08:00
ee0174da5e
Clamp non-monotonic stats instead of dropping.
When encountering non-monotonic stats rows, recover remaining data by
clamping to 0.  In particular, this avoids edge-case where persisting
threshold checks would never trigger.  Also recover when tethering
snapshots are missing.

Bug: 5600785, 5433871, 5600678
Change-Id: I1871954ce3955cc4ac8846f9841bae0066176ffe

Jeff Sharkey   commited 2011-11-10 17:54:23 -08:00
42f4043633
Merge "Bootstrap stats before registering listeners." into ics-mr1
Jeff Sharkey   authored and   Android (Google) Code Review   commited 2011-11-08 23:43:58 -08:00
35226c4c27
Bootstrap stats before registering listeners.
Also move ISE to handled NonMonotonicException.

Bug: 5570872
Change-Id: I793f349287ef5589185f117dfbec6f1fad73a661

Jeff Sharkey   commited 2011-11-08 18:24:12 -08:00
29f15bb4b3
Make operation counts monotonically increase.
Bug: 5585704
Change-Id: I5247a68acdb209a4ef0f5aac18944595c295e6ca

Jeff Sharkey   commited 2011-11-08 17:35:28 -08:00
e2de8f08d4
Correct proc file reader, optimizations.
Moved away from BufferedReader, which only reads the first 8KB of
some proc files because it aggresively fills its buffer.  Optimized
proc parsing, now double the speed.  Tests to cover.

Log when NetworkStats counters roll backwards when subtracting, and
optimizations around findIndex().  When system removes UID, also
remove from last stats snapshot to avoid xt counters from rolling
backwards.

Bug: 5472949, 5458380
Change-Id: I07c08fe5233156fac2b84450f6291868bf9bfaf2

Jeff Sharkey   commited 2011-11-02 15:14:11 -07:00
cd5559a856
Validate commands and arguments.
Bug: 5465176
Change-Id: I9402054c20ea6cae42781c35bfc2ade90aac31ce

Jeff Sharkey   commited 2011-10-17 14:51:42 -07:00
92c7838ca3
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

Jeff Sharkey   commited 2011-10-05 23:31:57 -07:00
0787a3616f
Track xtables summary, move tether stats, time.
Begin tracking xtables summary of data usage to compare with values
reported from /proc/net/dev.  Roll tethering directly into UID stats
to trigger UID stats persisting when crossing threshold.

Include xtables summary and authoritative time in samples.

Bug: 5373561, 5397882, 5381980
Change-Id: Ib7945522caadfbe0864fdf391582dc820f4f371e

Jeff Sharkey   commited 2011-10-03 17:21:05 -07:00
f1369459ed
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

Jeff Sharkey   commited 2011-09-22 16:19:06 -07:00
6a2cbb63b3
Upload correct txPackets count.
Bug: 5321340
Change-Id: Ie4dc7a91bf1cdc4d64c75ff09ae0cdd0fb141b5d

Jeff Sharkey   commited 2011-09-19 18:37:11 -07:00
ed94a3c766
DO NOT MERGE: 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

Jeff Sharkey   commited 2011-09-18 16:17:51 -07:00
b10824574c
Collect and persist tethering stats.
Use new "gettetherstats" netd command to retrieve statistics for
active tethering connections.  Keep tethering poll events separate
from UID poll, even though they end up same historical structures.

Bug: 5244846
Change-Id: Ia0c5165f6712c12b51586f86c331a2aad4ad6afb

Jeff Sharkey   commited 2011-09-16 16:05:51 -07:00
987f5ff357
Network stats flag to force complete poll.
Devices currently delay collecting UID stats during common operations
like global alerts to reduce parsing load.  Here we introduce a flag
to always collect UID and iface stats together to aid debugging.

Bug: 5321340
Change-Id: Ia8e1daf1a6f9d5f5cf1f64a04b6b6766ee965ab6

Jeff Sharkey   commited 2011-09-14 19:47:05 -07:00
4d675fdcf6
Poll UID stats during iface changes, enforce idx.
When ifaces change, poll UID stats without persisting, since they
depend on knowing active iface to store correctly.  Log dropped UID
stats when iface is unknown.  Switch to using flags when calling
performPoll().

Enforce that "idx" values are consistent from xt_qtaguid.  Transition
to using Log.wtf() for important checks, mostly around file I/O,
kernel stats parsing, and kernel module control.  Increase stats
persist threshold to 2MB to reduce churn.

Bug: 5269476, 5270106
Change-Id: I721215bfb65127f95775c71cf135e907cd567e92

Jeff Sharkey   commited 2011-09-07 18:06:30 -07:00
d905762784
Sample network statistics for sanity check.
After detailed poll events, sample high-level network statistics to
sanity check iface totals against UID totals.

Bug: 5248382
Change-Id: I1c1fbb7c094c9ff0c9dde416467c563dda68f478

Jeff Sharkey   commited 2011-09-01 15:07:19 -07:00
b63138c9b9
Introduce immediate CONNECTIVITY_ACTION variant.
New broadcast that is dispatched immediately after connectivity
changes have been handled by ConnectivityService, bypassing any
applicable CONNECTIVITY_CHANGE_DELAY.

Also protect CONNECTIVITY_CHANGE broadcasts, since they should only
be sent by system.

Bug: 5198167
Change-Id: I75f1fb44b21da1879f0ab960bcaa481126d70fde

Jeff Sharkey   commited 2011-08-29 16:10:43 -07:00
b4d8c1fd1c
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

Jeff Sharkey   commited 2011-08-26 14:19:54 -07:00
dcaeff3175
Register for kernel global data usage alerts.
Instead of polling every 15 minutes, register for alerts that trigger
when system-wide traffic passes a threshold.  Still mixed with polling
to persist UID stats, but relaxed to 30 minutes.  Currently watches
for every 512kB.

Make persistence decision separately for network versus UID, and use
total delta bytes when making decision.  Use light bootstrap during
systemReady() instead of heavy poll, which had been force-loading all
UID data unnecessarily.

Bug: 5023631
Change-Id: I04b723d6c4bf872fb1028071122dba66a8e1b576

Jeff Sharkey   commited 2011-08-23 18:46:14 -07:00
93db945091
Merge "Foreground/background network stats using sets."
Jeff Sharkey   authored and   Android (Google) Code Review   commited 2011-08-15 18:44:15 -07:00
2665eeb9d4
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

Jeff Sharkey   commited 2011-08-15 17:30:25 -07:00
806d1fdf9a
Add NativeDaemonConnector users to watchdog.
To catch instances where NativeDaemonConnector hangs while executing
commands, add users to system_server watchdog.  Also moved qtaguid
enabler to separate thread to prevent blocking systemReady().

Bug: 5145437
Change-Id: I4c6c1dc09864a1c05f9486a31faa1b366548e911

Jeff Sharkey   commited 2011-08-10 13:42:01 -07:00
7b331c0451
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

Jeff Sharkey   commited 2011-08-03 17:21:07 -07:00
c76817d370
NativeDaemonConnector: offload callbacks to another thread.
Now callbacks can communicate to the same daemon without causing a
deadlock. This also improves the latency of calls because they no
longer need to wait for the callbacks for the pending events.

Change-Id: I153fcf16bd64de79ee1c1a57d3cfdb12b354cf47

Chia-chi Yeh   commited 2011-08-03 14:42:11 -07:00
4ac474e88b
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

Jeff Sharkey   commited 2011-07-29 22:24:01 -07:00
7407e09009
Acquire wakelock during network stats collection.
Bug: 4517275
Change-Id: I01dfe3b13d7aca84605446e9e9927d0648623552

Jeff Sharkey   commited 2011-07-17 13:03:29 -07:00
2f60c2d402
Hide NetworkTemplate details, buffered stats I/O.
Move template matching to builder methods instead of exposing the
internal constants.  Also rule to match Ethernet usage.  Buffer
reading and writing of network stats, making operations 5x faster.

Change-Id: Iedb2d0ab3b26a976811c050f84a164e909eb74b6

Jeff Sharkey   commited 2011-07-14 20:43:27 -07:00
1bb88919c7
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

Jeff Sharkey   commited 2011-07-12 20:20:56 -07:00
3a0b70f80c
Hide NetworkStatsHistory internals.
Instead of exposing internal storage details, offer getValues()
accessor which populates values into a recycled structure.

Change-Id: I5228d7099a8f61b2018a435a813435a67dae49b4

Jeff Sharkey   commited 2011-07-12 13:57:06 -07:00
188480b216
Cached NTP time for system services.
Uses NTP server and timeout from secure settings, or fallback to
defaults in resources.  Update various system services to use cached
NTP time when fresh enough, or force updates as needed.

Bug: 4517273
Change-Id: Ie1c4c4883836013d02ca0bbd850cf8949f93b34b

Jeff Sharkey   commited 2011-07-10 14:25:18 -07:00
1c69b98734
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

Jeff Sharkey   commited 2011-06-30 15:47:51 -07:00
830d546f6b
Better network stats parsing, integer tags, async.
Change NMS parsing to handle extended /proc/ stats formats by pairing
values with header keys.  Move TrafficStats to integer tags to match
kernel internals, and offer well-known tags for system services.

Async policy event dispatch from NPMS, and update tests to block for
event dispatch.  Narrow app policy to exclude apps signed with system
key, which are usually critical.

Bug: 4948913, 4903489, 4585280

Change-Id: Idb357227ccaa617906411f309371cea18d7bc519

Jeff Sharkey   commited 2011-06-28 17:59:00 -07:00
9279006a00
NetworkStatsService: disabled by default
For now, there is still too much breakage around the kernel's new
qtaguid netfilter.
So no netstats up front.

But enable on the device until wiped:

  ./vendor/google/tools/override-gservices secure:netstats_enabled=1
  adb reboot


Bug: 4903513

Change-Id: I230bd2d4efab85cac5c9abaa7d638c94f5e0c7d6
Signed-off-by: JP Abgrall <jpa@google.com>

JP Abgrall   commited 2011-06-27 22:16:04 -07:00
2778a1ea73
NetworkStatsService: check kernel bandwidth support before enabling
And catch the actual errors reported by the other side of NetworkManager.


Change-Id: I9a9393b659d6f896ee1bf40a8deaca7853ef8f94
Signed-off-by: JP Abgrall <jpa@google.com>

JP Abgrall   commited 2011-06-23 14:13:28 -07:00
27cb1fa96b
Enable bandwidth module from stats service.
During systemReady(), tell netd to enable bandwidth tracking module,
which is used to provide detailed stats and controls.

Change-Id: Iecfd8b17a3b90f5a817d731fbe1c71777681ed6e

Jeff Sharkey   commited 2011-06-22 21:44:12 -07:00
2e546ddbde
Teach NetworkIdentity about roaming.
And correctly upgrade NetworkIdentitySet written to disk, assuming
that old values aren't roaming.

Bug: 4724762
Change-Id: Ic25897ebbaf43be2390174d8e5fd08386bc8a345

Jeff Sharkey   commited 2011-06-19 22:21:05 -07:00
3bc842e4c3
Persist "tagged" network stats along with UIDs.
Now stores tags other than TAG_NONE (0x0), which are useful for app
debugging.  Combine UID and tag together into single long key, and
expose tag data through AIDL when requested.  Change NMS to track
TAG_NONE as total UID traffic, matching the kernel definition.

Added TAG_MAX_HISTORY to control how long tag-granularity statistics
are stored; overall UID usage is still kept for UID_MAX_HISTORY.  Fix
bug to trim NetworkStatsHistory outside normal polling loops to catch
non-active networks and UIDs.

Test to verify UID and tag packing, and to verify that UID traffic on
two networks are combined to match MOBILE_ALL template.

Change-Id: If0e039416d9e7f63b1a39e04cddfb1133b5a78ee

Jeff Sharkey   commited 2011-06-19 21:58:39 -07:00
b590477065
Handle removed UIDs in network stats and policy.
When UID_REMOVED, clean up any existing UID network policy so it
doesn't linger for future apps.  Also move any NetworkStatsHistory
to special UID_REMOVED tracking bucket.

Tests for new removal code.  Also test detailed UID stats, including
network changes to verify template matching logic.

Bug: 4584212
Change-Id: I9faadf6b6f3830eb45d86c7f1980a27cdbcdb11e

Jeff Sharkey   commited 2011-06-19 01:08:12 -07:00
c04cda602c
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

Jeff Sharkey   commited 2011-06-18 22:23:11 -07:00
0d5baa3f21
Avoid clobbering UID stats when not yet loaded.
Bug: 4690822
Change-Id: Ia6c9e8f89e89739cf3380c4b98b9da6f52db48fa

Jeff Sharkey   commited 2011-06-17 11:18:27 -07:00
dbffe5a999
Data usage warning and limit notifications.
Watch for network statistics to cross NetworkPolicy warning or limit,
and show notifications to user as needed.  Currently checks during
any statistics update, but will eventually move to event registration
through netd when kernel supports.

Fixed accounting bug in getSummaryForNetwork().  Only apply UID policy
to applications; applying to system processes could break critical
services like RIL.

Change-Id: Iac0f20e910e205f3cbc54ec96395ff268b1aa379

Jeff Sharkey   commited 2011-06-14 22:43:08 -07:00
3ce93600fd
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

Jeff Sharkey   commited 2011-06-11 22:17:17 -07:00
755000588f