Commit graph

4,287 commits

Message SHA1
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
d723e62717
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
d57635406d
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
de450f98eb
Notify policy listeners about metered ifaces.
Currently, kernel definition of metered networks is applied at the
interface level.  This change maintain list of those metered ifaces
and notifies policy listeners, like ConnectivityService.  (This gives
us a consistent picture of when a network would be blocked.)

Bug: 4601393
Change-Id: I277d5ca96ab967a1c1c3f1da8f9587557cd6d74c

Jeff Sharkey   commited 2011-06-17 16:49:21 -07:00
a47d7a1a70
Merge "DownloadManager flags for network policy."
Jeff Sharkey   authored and   Android (Google) Code Review   commited 2011-06-16 13:39:02 -07:00
29fc3322d5
DownloadManager flags for network policy.
Handful of DownloadManager flags to record when a download was paused
because of NetworkPolicyManager rules.

Change-Id: I99fc47f529cb6c8a42dbeca049e0cd0f1556eac4

Jeff Sharkey   commited 2011-06-16 13:04:34 -07:00
4434b0b55b
am 00ca322d: am 5f350512: Merge "Reset connections AFTER we take down the network." into honeycomb-LTE
* commit '00ca322d5d':
  Reset connections AFTER we take down the network.

Robert Greenwalt   authored and   Android Git Automerger   commited 2011-06-16 12:50:46 -07:00
9d145fde31
am 5f350512: Merge "Reset connections AFTER we take down the network." into honeycomb-LTE
* commit '5f3505121b761dbd3bba62d1603fbab49de139b9':
  Reset connections AFTER we take down the network.

Robert Greenwalt   authored and   Android Git Automerger   commited 2011-06-16 12:42:15 -07:00
00ca322d5d
Reset connections AFTER we take down the network.
If you do it before you have a race condition and some apps will
manage to reconnect on the dieing network before it goes and then
get no notification when it goes.

bug: 3408025
Change-Id: I5386ff313c759b3f687bc38731454ab43dbe76b8

Robert Greenwalt   commited 2011-06-16 11:26:54 -07:00
36ea869426
VPN: migrate from generic Bundle to our own Parcelable VpnConfig.
Note that VpnConfig is for internal use only.
Also remove hidden methods from ConnectivityManager.

Change-Id: Ic298c4dc9a2c6c452bd8f4be6fa84e7ac489c0c4

Chia-chi Yeh   commited 2011-06-15 17:08:58 -07:00
75cacd5525
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
97abbe95cd
Persist UID stats, lazy loading, resize buckets.
Persisting detailed UID stats in separate "netstats_detail.bin" file
to enable different schedules for summary and detail polling.  Only
load detailed UID history on demand, since it's not needed during
boot.  Add test to verify UID stats are persisted across simulated
reboot.

Move external settings into well-named interface, which is still
backed by Settings.Secure.  During periodic poll events, resize any
history to match current bucket duration setting.  Test to verify.

Change-Id: I6366f3583a591f8ba859b0e5987daf8cafa4e95a

Jeff Sharkey   commited 2011-06-11 17:55:56 -07:00
837b4ebf7e
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

Jeff Sharkey   commited 2011-06-09 10:14:13 -07:00
ebbebc73a0
The service part of the user space VPN support.
The dialogs will be in another change.

Change-Id: I0cdfd2ef21ffd40ee955b3cbde5ada65dbfdb0bc

Chia-chi Yeh   commited 2011-06-08 14:16:42 -07:00
9a4ad7d52c
resolved conflicts for merge of 510d0a75 to master
Change-Id: Ic4d8aae7dd457457d9cc8ba081b273e425729f86

Robert Greenwalt   commited 2011-06-08 10:01:06 -07:00
269d732e13
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

Jeff Sharkey   commited 2011-06-07 23:54:28 -07:00
512b757b08
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

Jeff Sharkey   commited 2011-06-07 23:09:25 -07:00
21062e7c7e
Merge "Do not register the callbacks in the constructor."
Chia-chi Yeh   authored and   Android (Google) Code Review   commited 2011-06-07 18:18:56 -07:00
ab2c05370e
am f17deff9: resolved conflicts for merge of 8de47a2f to honeycomb-LTE
* commit 'f17deff97b':
  Reveal some network constants.

Robert Greenwalt   authored and   Android Git Automerger   commited 2011-06-07 13:12:29 -07:00
510d0a756a
resolved conflicts for merge of 8de47a2f to honeycomb-LTE
Change-Id: I8193235a4c7e574635e17b2eb05bb5420a3c6749

Robert Greenwalt   commited 2011-06-07 12:45:41 -07:00
f17deff97b
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

Jeff Sharkey   commited 2011-06-01 17:44:52 -07:00
d26449fd76
Policy and rules work for ConnectivityManager.
Teach ConnectivityManager about UID-specific rules derived from policy,
such as rejecting network traffic on "paid" interfaces.  Calls that
return NetworkInfo now filter based on any REJECT rules in effect for
the calling UID.  (Added uid parameter if callers that still want all
interfaces.)

Changed NetworkPolicyManager to derive rules based on current policy
combined with PowerManager and ActivityManager status, which it passes
to ConnectivityService for eventual enforcement through netd.  When
rules change the usability of a NetworkInfo for a specific UID, it also
dispatches CONNECTIVITY_ACTION broadcasts to that UID.  Combined paid
and background policy together to match current working definition.

Change-Id: I797ea49439fcc487cfe2cbc16703d4b91ceb9af6

Jeff Sharkey   commited 2011-06-01 17:00:42 -07:00
921ebf2ee5
Reveal some network constants.
Since we've already decided to inc the sdk version we should try to get these in too.

bug:4500218
Change-Id: I6dcb401bf30f1b06f02be0a93681a190d7ee5775

Robert Greenwalt   commited 2011-05-31 12:06:08 -07:00
6a9d45449d
Move stringToFile utility from ConnectivityService to FileUtils
Change-Id: I59a2dc649d59677f6b5e7ade252587c7c151ec06
Signed-off-by: Mike Lockwood <lockwood@android.com>

Mike Lockwood   commited 2011-05-28 13:28:12 -04:00
0d5916c21e
Merge "APIs to profile network usage for current UID."
Jeff Sharkey   authored and   Android (Google) Code Review   commited 2011-05-23 18:38:04 -07:00
0d49ed3ca8
Do not register the callbacks in the constructor.
Change-Id: Ic7509c35cfb17b022a2af3cc14170942d6510e2d

Chia-chi Yeh   commited 2011-05-23 15:08:29 -07:00
f3204aad8e
am e0f7bc0b: resolved conflicts for merge of dec3dda8 to honeycomb-plus-aosp
* commit 'e0f7bc0b84':
  Simplfy getActive* calls in ConnectivityService

Robert Greenwalt   authored and   Android Git Automerger   commited 2011-05-21 21:35:38 -07:00
1b507045bd
APIs to profile network usage for current UID.
Added startDataProfiling() and stopDataProfiling() to TrafficStats,
which can be used by apps to measure network usage delta between two
points in time.  Currently takes two NetworkStats snapshots and returns
delta, which will eventually include tag-level granularity.  Added
tests for NetworkStats delta subtraction.

Added NMS.getNetworkStatsUidDetail() that returns stats for specific
UID.  Always gives stats access for the calling UID, otherwise enforces
that caller has permission.  Fix readSingleLongFromFile(), since
/proc/ files don't have well-defined lengths.

Change-Id: Ic5b6414d8effbd66846e275b00d4b8a82c74589d

Jeff Sharkey   commited 2011-05-21 15:02:58 -07:00
f65d11df61
resolved conflicts for merge of dec3dda8 to honeycomb-plus-aosp
Change-Id: If14c7fc51c4549524c2f39797a902093582bae6d

Robert Greenwalt   commited 2011-05-20 15:45:55 -07:00
e0f7bc0b84
Reconcile with honeycomb-release
Change-Id: I83818e0c61f0fcb53b154cd0a85f18924745912f

The Android Open Source Project   commited 2011-05-20 14:33:41 -07:00
991f5f4ec9
Reconcile with gingerbread-release
Change-Id: If7c568d850eaffbcfc237e8b875bc5684c6dc651

The Android Open Source Project   commited 2011-05-20 13:50:51 -07:00
969a009cbd
Simplfy getActive* calls in ConnectivityService
One had been simplified on GB, but somehow it didn't make it here.
bug: 4463770

Change-Id: Ica51e836b1a7a489526a223168910b8e06c99c2b

Robert Greenwalt   commited 2011-05-20 12:23:41 -07:00
e1544bb9ea
am 2a4ebb81: am 049694bf: Merge "Reset connection while data state changed." into honeycomb-LTE
* commit '2a4ebb810d':
  Reset connection while data state changed.

Wink Saville   authored and   Android Git Automerger   commited 2011-05-19 11:32:27 -07:00
1dc369c378
am 049694bf: Merge "Reset connection while data state changed." into honeycomb-LTE
* commit '049694bfa2':
  Reset connection while data state changed.

Wink Saville   authored and   Android Git Automerger   commited 2011-05-19 11:28:36 -07:00
2a4ebb810d
Merge "Reset connection while data state changed." into honeycomb-LTE
Wink Saville   authored and   Android (Google) Code Review   commited 2011-05-19 11:25:45 -07:00
049694bfa2
Merge f024027b
Change-Id: I70fc4382f832d1a2bded8a5ee7d9b96fac77879b

Jean-Baptiste Queru   commited 2011-05-19 07:54:53 -07:00
65727c9c5d
am a9f139c4: am 3a34041f: Linkproperties update via unsol data call state change.
* commit 'a9f139c4f0':
  Linkproperties update via unsol data call state change.

Kazuhiro Ondo   authored and   Android Git Automerger   commited 2011-05-18 17:48:37 -07:00
842c177850
am 355205c0: Switch to use netd to add/remove routes.
* commit '355205c0cd':
  Switch to use netd to add/remove routes.

Robert Greenwalt   authored and   Android Git Automerger   commited 2011-05-18 16:33:16 -07:00
f024027b55
Reset connection while data state changed.
Check data call states and reset connection if any link properties changed.


Change-Id: I008aea969378648192852161959fdf4aad6211a1

Wink Saville   commited 2011-05-18 15:59:04 -07:00
f23fb20d13
Switch to use netd to add/remove routes.
Also adds support for v6 routes and for removing single routes.

Change-Id: I1c4f08c7938371090944d8d6f603e1e0d6d70c01

Robert Greenwalt   commited 2011-05-18 15:25:43 -07:00
355205c0cd
am 3a34041f: Linkproperties update via unsol data call state change.
* commit '3a34041f80':
  Linkproperties update via unsol data call state change.

Kazuhiro Ondo   authored and   Android Git Automerger   commited 2011-05-18 00:02:31 -07:00
a9f139c4f0
Linkproperties update via unsol data call state change.
Handles the scenario of radio technology handover with IP continuity.
Once RIL/Modem finished a handover operation, an unsol data call state
change will be send up to FW notifying all link propertes changes.
FW will then re-configure the device with new link properties
including iptable used by Tethering.

Change-Id: I05e29f66ac3db8ba4274d3662642607742ba1d12

Kazuhiro Ondo   authored and   Wink Saville   commited 2011-05-17 20:53:40 -07:00
3a34041f80
am ea7aa92a: (-s ours) am 891bdee2: Merge commit \'01ea7f01\' into manualmerge1
* commit 'ea7aa92a95':
  DO NOT MERGE Add DhcpStateMachine

Irfan Sheriff   authored and   Android Git Automerger   commited 2011-05-12 17:39:07 -07:00
bc7d82560f
am 891bdee2: Merge commit \'01ea7f01\' into manualmerge1
* commit '891bdee2ba':
  DO NOT MERGE Add DhcpStateMachine

Irfan Sheriff   authored and   Android Git Automerger   commited 2011-05-12 17:37:06 -07:00
ea7aa92a95
Merge commit '01ea7f01' into manualmerge1
Irfan Sheriff   commited 2011-05-12 17:19:56 -07:00
891bdee2ba
DO NOT MERGE Add DhcpStateMachine
Add DhcpStateMachine for interation with dhcpcd

- Supports wakeup and renewal on dhcp
- Supports multiple controllers to use the state machine
  simultaneously
- Optionally, a controller can request a notification prior
    to DHCP request/renewal being sent

Change-Id: I5324814b19ff19863aa6fa89f1e3f0a202930c98

Irfan Sheriff   commited 2011-05-12 14:10:11 -07:00
9cfe6197fb
am f4c231c4: am 76a118dd: Merge "Fix initialization of RouteInfo" into honeycomb-LTE
* commit 'f4c231c4dc':
  Fix initialization of RouteInfo

Wink Saville   authored and   Android Git Automerger   commited 2011-05-12 14:08:05 -07:00
a8f3f7c298
am 76a118dd: Merge "Fix initialization of RouteInfo" into honeycomb-LTE
* commit '76a118dd9e1bc8be33e1e22b7264b7f918f6f050':
  Fix initialization of RouteInfo

Wink Saville   authored and   Android Git Automerger   commited 2011-05-12 14:03:31 -07:00
f4c231c4dc
Extract NetworkManagementService out from Tethering to ConnectivityService.
and also some minor refactoring.

Change-Id: I0e74f30ef1b035d9ed37571c512fedc15d05db77

Chia-chi Yeh   commited 2011-05-11 17:06:07 -07:00
4df51328bd
Fix initialization of RouteInfo
IPv6 gateway is not correctly set in RouteInfo

Change-Id: I24b1ab71a64e3097c9ba641899240fc27847b86c

Kazuhiro Ondo   authored and   Wink Saville   commited 2011-05-11 16:02:00 -07:00
efa66d9fe9