• Home
  • History
  • Annotate
  • only in /frameworks/base/services/java/com/android/server/net/
History log of /frameworks/base/services/java/com/android/server/net/
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
6a328afbab37981f34d8578972dbb2bf1abb7c41 01-Dec-2012 Jeff Sharkey <jsharkey@android.com> Avoid null mobile interfaces.

Bug: 7634215
Change-Id: I6745f6a78c07ba11d98b4562a6b53386112ef652
etworkStatsService.java
8b2c3a14603d163d7564e6f60286995079687690 12-Nov-2012 Jeff Sharkey <jsharkey@android.com> Useful annotations for code documentation.

Bug: 6537978
Change-Id: I806c3c09e3255f8789455f13bf37c1dde2a93f1f
etworkPolicyManagerService.java
etworkStatsService.java
625239a05401bbf18b04d9874cea3f82da7c29a1 27-Sep-2012 Jeff Sharkey <jsharkey@android.com> Migrate more Secure settings to Global.

Migrate networking, storage, battery, DropBox, and PackageManager
related Secure settings to Global table.

Bug: 7232014, 7231331, 7231198
Change-Id: I772c2a9586a2f708c9db95622477f235064b8f4d
etworkStatsService.java
daa57e8d1866fe4579c280c41604f3660db7cd01 19-Sep-2012 Jeff Sharkey <jsharkey@android.com> Migrate network stats from removed users.

When a user is removed, migrate all network stats belonging to that
user into special UID_REMOVED bucket. Also removes those stats from
kernel to avoid double-counting if another user is created.

Bug: 7194784
Change-Id: I03f1d660fe3754566326b7749cae8068fc224ea9
etworkStatsCollection.java
etworkStatsRecorder.java
etworkStatsService.java
0b81be6f79ec3d1b9441c21a3cefc629be1450c8 19-Sep-2012 Jeff Sharkey <jsharkey@android.com> Lockdown should only augment connected networks.

Bug: 7148397
Change-Id: I20e2194c874544b272b9ec8b63391d91b0a22f49
ockdownVpnTracker.java
d0c6ccbafdebc73d03cf3cd47f02f9f6c78a69ff 15-Sep-2012 Jeff Sharkey <jsharkey@android.com> Move NetworkPolicy from apps to UID.

For multi-user devices, switch to storing policy per-user instead of
per-app. Also watch for user added/removed broadcasts to clean up
policies and apply global restrictions.

Bug: 7121279
Change-Id: Ia7326bd0ebe0586fa4ec6d3a62f6313dc8814007
etworkPolicyManagerService.java
e6e6197d7c2eb5c29224bcddb0131a302267f6de 14-Sep-2012 Jeff Sharkey <jsharkey@android.com> Actually move to Global settings.

Also add better ConnectivityService logging.

Bug: 7157464
Change-Id: Ia235a7e62ed809240913c4782920c1410c7d597d
etworkStatsService.java
023c05a341b87d0899c89bf355b6ae27d138bb03 14-Sep-2012 Jeff Sharkey <jsharkey@android.com> Move to Global.NETSTATS and Global.NTP constants.

Bug: 7157464
Change-Id: Ief10fd37940f62420f5684940994c9f93802e0be
etworkStatsService.java
91c6a64a04c2d8b27b886d96a56800ae24efb7a9 07-Sep-2012 Jeff Sharkey <jsharkey@android.com> Event logging for lockdown VPN state changes.

Bug: 7079350
Change-Id: I3670efe7f09c0fca55552b6a04a2be159b9beb3c
ockdownVpnTracker.java
4120375d46091df8527bb701882e056fbb0e6b06 31-Aug-2012 Dianne Hackborn <hackbod@google.com> Remove Binder.getOrigCallingUid().

Replaced all remaining places that used it with explicit user
specification.

While doing this, I ran into stuff that was creating PendingIntent
objects (that now need to specify the explicit user they are for),
which are also posting notifications... but have no way to specify
the user for the notification.

So the notification manager in the system process now also gets a
formal concept of a user associated with the notification, which
is passed in to all the necessary aidl calls. I also removed the
old deprecated aidl interface for posting/cancelling notifications,
since we now always need a user supplied.

There is more work that needs to be done here, though. For example
I think we need to be able to specify USER_ALL for a notification that
should be shown to all users (such as low storage or low battery).
Along with that, the PendingIntent creation needs to be tweaked to
be able to handle USER_CURRENT by evaluating the user at the point the
pending intent is sent.

That's for another change, however.

Change-Id: I468e14dce8def0e13e0870571e7c31ed32b6310c
etworkPolicyManagerService.java
5ac72a29593ab9a20337a2225df52bdf4754be02 30-Aug-2012 Dianne Hackborn <hackbod@google.com> Improve multi-user broadcasts.

You can now use ALL and CURRENT when sending broadcasts, to specify
where the broadcast goes.

Sticky broadcasts are now correctly separated per user, and registered
receivers are filtered based on the requested target user.

New Context APIs for more kinds of sending broadcasts as users.

Updating a bunch of system code that sends broadcasts to explicitly
specify which user the broadcast goes to.

Made a single version of the code for interpreting the requested
target user ID that all entries to activity manager (start activity,
send broadcast, start service) use.

Change-Id: Ie29f02dd5242ef8c8fa56c54593a315cd2574e1c
etworkPolicyManagerService.java
etworkStatsService.java
580dd31a68c65b4af68147d52d57f60e0bd52dbe 30-Aug-2012 Jeff Sharkey <jsharkey@android.com> Locking when clearing VPN source rules.

Otherwise lockdown VPN reset is racy and can bring down system_server.

Change-Id: Ib8eecde1d0857a1669c3ca5506a46198c71b1b51
ockdownVpnTracker.java
69ddab4575ff684c533c995e07ca15fe18543fc0 25-Aug-2012 Jeff Sharkey <jsharkey@android.com> Always-on VPN.

Adds support for always-on VPN profiles, also called "lockdown." When
enabled, LockdownVpnTracker manages the netd firewall to prevent
unencrypted traffic from leaving the device. It creates narrow rules
to only allow traffic to the selected VPN server. When an egress
network becomes available, LockdownVpnTracker will try bringing up
the VPN connection, and will reconnect if disconnected.

ConnectivityService augments any NetworkInfo based on the lockdown
VPN status to help apps wait until the VPN is connected.

This feature requires that VPN profiles use an IP address for both
VPN server and DNS. It also blocks non-default APN access when
enabled. Waits for USER_PRESENT after boot to check KeyStore status.

Bug: 5756357
Change-Id: If615f206b1634000d78a8350a17e88bfcac8e0d0
ockdownVpnTracker.java
f02b60aa4f367516f40cf3d60fffae0c6fe3e1b8 16-Aug-2012 Dianne Hackborn <hackbod@google.com> Rename UserId to UserHandle.

This is the start of turning this into a formal public API.

Change-Id: I5786d2c320f1de41a06ed5d0f65adb68967287a0
etworkPolicyManagerService.java
258848d2ae04f447ff1c18023fa76b139fcc0862 11-Aug-2012 Amith Yamasani <yamasani@google.com> User Manager service to manage users and query user details

Moved a bunch of methods from PackageManager to UserManager.

Fix launching of activities from recents to correct user.

Guest creation APIs

Change-Id: I0733405e6eb2829675665e225c759d6baa2b708f
etworkPolicyManagerService.java
216c181e76ee11a47a0b2a180f9af96740ab38ad 05-Aug-2012 Jeff Sharkey <jsharkey@android.com> Make generic BaseNetworkObserver.

This makes it easier to add new INetworkManagementEventObserver events
in future.

Change-Id: I432263d745558de4b878f313c1951230ed9db2b1
aseNetworkObserver.java
etworkAlertObserver.java
etworkPolicyManagerService.java
etworkStatsService.java
39606a007a5b1309dd000234f2b8cf156c49fd0f 01-Aug-2012 Dianne Hackborn <hackbod@google.com> Make AtomicFile a public API. It's about time!

Change-Id: Ib34e294747405b7ab709cb0bbb2d9a0cc80ce86a
etworkPolicyManagerService.java
etworkStatsCollection.java
db3c8678e5cbdfec011afaf25bde2091152c30ad 20-Jun-2012 Haoyu Bai <bhy@google.com> Network data activity change intent for network interfaces.

The activity notification is received from netd, an intent
DATA_ACTIVITY_CHANGE is then raised for other part of the system to
consume.

Change-Id: Idfcc4763c51c5b314c57f546c12557082f06bebf
etworkAlertObserver.java
0abe556d28f5f5d395559cc6567b05939d1b2640 19-Jun-2012 Jeff Sharkey <jsharkey@android.com> Handle SCREEN_ON/OFF broadcasts without blocking.

NetworkPolicy currently uses a single background thread to process
various broadcasts. When processing other broadcasts, this thread
can block our handling of SCREEN_ON/OFF, which are sent as ordered
broadcasts.

This change moves SCREEN_ON/OFF handling to the main thread, and
dispatches a one-way message to the background thread, allowing the
ordered broadcast to always proceed.

Bug: 6677047
Change-Id: I52de2c7b75beb8059bb87e123689ba4a9c4ae349
etworkPolicyManagerService.java
6c0b4f393ae8e728c7a7943bfbdcdd27d6642192 13-Jun-2012 Jeff Sharkey <jsharkey@android.com> Clear identity when snoozing limit.

Continues to check MANAGE_NETWORK_POLICY permission. This allows
SystemUI to invoke snoozeLimit() without CONNECTIVITY_INTERNAL.

Bug: 6653091
Change-Id: I464bf62b79f2647c6b6db151251a0036897d0cc0
etworkPolicyManagerService.java
a93c2c117d502ee57dd27705a0b5efca4bf65011 01-Jun-2012 Dianne Hackborn <hackbod@google.com> Extend process observer to be usable for media routing.

It now has a new callback to report changes in the "importance"
of processes. Rewrote the dispatching code to be a bit more
efficient now that we are sending more reports.

Change-Id: Ie865cfd286455819f04e8c14e9b6fd54d028f8f2
etworkPolicyManagerService.java
e19f39b79c831aea4d51a3309025acdf69d1e609 24-May-2012 Jeff Sharkey <jsharkey@android.com> Advise persist threshold outside NPMS lock.

Bug: 6492166
Change-Id: Ibebdc7e9b8cae27c12fd7b61b53ab60287a0364d
etworkPolicyManagerService.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
etworkStatsCollection.java
etworkStatsService.java
20f5c3d4135809ca0b72c23e0c8daf2a8e4e84b2 10-May-2012 Jeff Sharkey <jsharkey@android.com> Avoid updating thresholds during shutdown.

Bug: 6472388
Change-Id: I70e1ed5dc75056840f2f0b130ce0dfecb06f385e
etworkStatsService.java
6de357e4d10fa5977ab9a6c665dc858765e95d34 09-May-2012 Jeff Sharkey <jsharkey@android.com> Recover from Throwable in FileRotator, dump.

In rewriteSingle(), catch Throwable to rollback to backup file,
instead of just IOException. Also add dumpAll() to pack up contents
for later debugging, and use it when encountering bad stats.

Bug: 6467868
Change-Id: Ic8e287cf5a235706811a304a88d71d11d3a79cd4
etworkStatsRecorder.java
etworkStatsService.java
fb0caad42353687e63cd560dc7fb028b8439edde 07-May-2012 Jeff Sharkey <jsharkey@android.com> Merge "Ack, wrap advisePersistThreshold() in lock." into jb-dev
5801597a90949240e99c3980c0bb889deeec2e5c 07-May-2012 Jeff Sharkey <jsharkey@android.com> Ack, wrap advisePersistThreshold() in lock.

Bug: 6449725
Change-Id: I702dc2ff9d4b237c46d89bcae41289bc3e9ef2f8
etworkStatsService.java
8c1dc72b1402d55dae388a294476565b2473a87a 04-May-2012 Jeff Sharkey <jsharkey@android.com> Disable policy when bandwidth module missing.

Bug: 6447017
Change-Id: I705a223dac15fc41e231bb9c81a96a287caaf094
etworkPolicyManagerService.java
ac3fcb1590e1da21324c13ce237ec48f2bf488bf 03-May-2012 Jeff Sharkey <jsharkey@android.com> Reduce persist threshold for lower warning/limit.

Default is 2MB persist threshold, but even that can be substantial
for devices on 100MB/month plans. This change gradually reduces the
persist threshold up to 8x lower (256kb outstanding) based on lowest
active policy.

Bug: 5382676
Change-Id: Ief4e8cdb169bfb151a3d1b45722a8eaa01926508
etworkPolicyManagerService.java
etworkStatsCollection.java
etworkStatsRecorder.java
etworkStatsService.java
e8914c36276710de50b347c1e6aecfa45d6a56cd 02-May-2012 Jeff Sharkey <jsharkey@android.com> Begin collecting xtables iface counters.

Add method to parse new iface_stat_fmt proc stats, or return null
when kernel support is unavailable. Add test and remove older, unused
parsing code. Create new "xt" recorder to persist the new xtables
counters when available.

Add SSID support to NetworkIdentity to fix policy tests.

Bug: 6422414
Change-Id: I77f70e9acb79a559ab626f3af5c4f3599801ed43
etworkStatsRecorder.java
etworkStatsService.java
f166f480f0f29b310a27fe001ee26d7dfac84fdd 01-May-2012 Jeff Sharkey <jsharkey@android.com> Roaming always metered, relax DHCP metered check.

Always treat roaming connections as metered, and relax DHCP test to
match any substring for forward compatibility.

Bug: 6382737, 6375399
Change-Id: I9781a60f55fbe35da6f8bfc7a1d609608e8f0951
etworkPolicyManagerService.java
00a10a1494954d124e1b11bc1ba3128e47b8ffbd 28-Apr-2012 Irfan Sheriff <isheriff@google.com> Handle null SSID cleanly

Bug: 6411912
Change-Id: I12f9df403c9633d928d898ae675ce36303dda1a8
etworkPolicyManagerService.java
5294a2fc2f401cd248a4bc3f0f9ee1e2854f4e9a 25-Apr-2012 Jeff Sharkey <jsharkey@android.com> Relax global restrict for system services.

Since we control system services, we can ensure they are using little
data when data usage is globally restricted. Continue restricting
AID_MEDIA and AID_DRM, since they respond to app requests.

Bug: 6377903, 5772564
Change-Id: I196bf334f903397ea6a67e6802240ee792e47b54
etworkPolicyManagerService.java
49c1d1764bce02cf12a68e9312f3aa9dfa2e25ce 23-Apr-2012 Jeff Sharkey <jsharkey@android.com> Clear identity when checking if bandwidth enabled.

Change-Id: I0f10f86dc14483e29609057c671454b322da4826
etworkStatsService.java
4190a047ca1c5eb19a1f7e5d599ef1d532da71c7 22-Apr-2012 Jeff Sharkey <jsharkey@android.com> Better assertions when bandwidth module disabled.

Also disable some verbose logging in WifiStateTracker.

Bug: 6368329
Change-Id: I9a5219bc1b3fd870468f7de46cdf4f173a437c59
etworkStatsService.java
9f6e4ba50e7e73704c7fbd3ba65fe73bdf8ad73f 20-Apr-2012 Jeff Sharkey <jsharkey@android.com> Connect metered DHCP hint for Wi-Fi networks.

When DHCP lease includes vendor info indicating that remote Wi-Fi
network is metered, advise NetworkPolicy. Users can still manually
change the metered flag in Settings.

Also remove any policies belonging to removed Wi-Fi networks, and
teach isNetworkMetered() about ethernet networks.

Bug: 6344821, 6369307, 6365872
Change-Id: I108606c6fddf2d02828fcab011f3a1501415f1bc
etworkPolicyManagerService.java
123328778e99b5bbc68b80ab8efc43ca506a6a2c 16-Apr-2012 Jeff Sharkey <jsharkey@android.com> Merge "Move TrafficStats iface counters to xt_qtaguid."
7bf8fba6f0e0fe8072201a0b174727b905437990 16-Apr-2012 Jeff Sharkey <jsharkey@android.com> Merge "API to report if active network is metered."
9f7cbf0e50bcb7e9163b23524814003ba8784732 13-Apr-2012 Jeff Sharkey <jsharkey@android.com> API to report if active network is metered.

Report to developers if active network is "metered" and define it
as the user being sensitive to heavy data usage.

Bug: 3001465
Change-Id: I855ca3cd3eb1de3c4814148d70ccf24957af898a
etworkPolicyManagerService.java
854b2b1670bda1eeb87a14b7ac3d222024f0aad6 14-Apr-2012 Jeff Sharkey <jsharkey@android.com> Surface list of apps with given network policy.

Bug: 6007276
Change-Id: I0f0e939ee6481496480c4afaa108c99eb158547c
etworkPolicyManagerService.java
234766a36af6214644fa8205202287084ca9cf93 11-Apr-2012 Jeff Sharkey <jsharkey@android.com> Move TrafficStats iface counters to xt_qtaguid.

Use xt_qtaguid iface_stat_all counters, which are monotonic during
a single boot.

Track all ifaces associated with mobile networks since boot, and
move TrafficStats to using these ifaces. This will include usage of
networks omitted from config_data_usage_network_types, specifically
on devices that recycle network interfaces across APNs.

Split wildcard template matching, and move NetworkStatsService to
use mobile wildcard when logging stats.

Bug: 5324515
Change-Id: I2211c374c05d1b598cc647f2f873630538955ffe
etworkStatsService.java
bfdd680ab44da173a4a39fcd6feccdebb9d1f855 09-Apr-2012 Jeff Sharkey <jsharkey@android.com> Migrate to @Override to remove warnings.

Bug: 6303344
Change-Id: I0d33b2ed448467379d576ccd71fb5ae20c878852
etworkPolicyManagerService.java
etworkStatsCollection.java
etworkStatsRecorder.java
etworkStatsService.java
21a547823de52806de48f70b8360353344a5ad88 09-Apr-2012 Jeff Sharkey <jsharkey@android.com> Splice operations before collapsing ifaces.

Bug: 6241038
Change-Id: Ide9058703f7305df8fb070af149ddce0653a0abf
etworkStatsService.java
b52e3e55098c4a6e3dbfe19885895411cfb38911 06-Apr-2012 Jeff Sharkey <jsharkey@android.com> INetworkStatsSession with lifecycle for caching.

Users outside system_server now explicitly communicate their
lifecycle, which keeps a strong-reference chain to any fully loaded
NetworkStatsCollection histories.

Bug: 6236498
Change-Id: I8e22739b6e89a626b676967a736d7117fd000778
etworkPolicyManagerService.java
etworkStatsRecorder.java
etworkStatsService.java
8fc27e8b87bd1def854a03d84009143b315d4176 05-Apr-2012 Jeff Sharkey <jsharkey@android.com> Support metered Wi-Fi NetworkPolicy.

Add networkId field to NetworkIdentity to identify Wi-Fi networks by
SSID. Add support for policies without usage cycles.

Only apply mobile policies when SIM state is ready, which is cleaner
than just checking for airplane mode. Also avoids creating no-op
default policies when subscriberId is null.

Bug: 3001465, 3291052
Change-Id: I1f8aaa49a5db306df022c402ea7f3f5d4bc0cfc7
etworkIdentitySet.java
etworkPolicyManagerService.java
etworkStatsService.java
8a8b581e669f6187b397f856a567a76ed8aba2c2 22-Mar-2012 Jeff Sharkey <jsharkey@android.com> Move network policy to per-appId (instead of UID).

To support multi-user, store network policy per-appId and expand to
apply rules to all UserInfo on device.

Bug: 6140462
Change-Id: Ic0866b4d41c8c60cc1c0a597f0de927b92b65b1e
etworkPolicyManagerService.java
3a66cf3e86f351f0957188a4b874a3e65edfa40f 21-Mar-2012 Jeff Sharkey <jsharkey@android.com> Avoid data usage notifications in airplane mode.

Only for mobile networks.

Bug: 5995839
Change-Id: I6a6dba8cfe98c8e72861f90665c3e41da6d9a474
etworkPolicyManagerService.java
837f9242ae2e8f5f380d0b30b8fffbc68494914f 21-Mar-2012 Jeff Sharkey <jsharkey@android.com> Remember when NetworkPolicy was inferred.

This helps future-proof NPMS if we need to correct default policies
after an upgrade.

Change-Id: I0ddfdeaf41757a46aeb867c91d495ccf981d544b
etworkPolicyManagerService.java
d4dd7716fb825f29a609c5c4cb31204eea78183a 16-Mar-2012 Jeff Sharkey <jsharkey@android.com> Combine network subtypes by default.

Subtype controls (3G-vs-4G) aren't exposed in the UI, so tracking
data with that granularity creates unnecessary overhead. For example,
some GSM networks can regularly flap between two subtypes.

Bug: 6118868
Change-Id: Id098891dba52336d00d0f96632a7924e228b4713
etworkStatsService.java
9bf3150cfae03421c9dd237b46657714859d871c 10-Mar-2012 Jeff Sharkey <jsharkey@android.com> Save timezone when setting data cycle reset date.

Instead of cycle reset at midnight UTC, use midnight of timezone
active when user last set cycle reset date. Tests to verify, and
also to test leap year behavior.

Bug: 5938567
Change-Id: Ie06f7f0fa242d23110f9586a3f4f7037af87b31b
etworkPolicyManagerService.java
6341fcecc8826924a4bb24169aaf80fec9a20894 07-Mar-2012 Jeff Sharkey <jsharkey@android.com> Avoid updating network stats after shutdown.

Bug: 6109476
Change-Id: I9a3a8b182c8fa56d83ddc755d204d5b267c9bc5d
etworkStatsService.java
e7bb71d26943fbb053139e1e34203df4c2afaa9b 29-Feb-2012 Jeff Sharkey <jsharkey@android.com> Disable verbose NetworkStats logging.

Bug: 6076584
Change-Id: I4efcda2b474f623f4fe70db8b43b0aa69017d749
etworkStatsRecorder.java
1f8ea2dcd1ed3cde4b84fbb27b5a55b3fea7ff2a 07-Feb-2012 Jeff Sharkey <jsharkey@android.com> Send broadcast when changing restrict background.

When changing global restrict background status, send connectivity
change broadcast, since it radically changes DISCONNECTED/BLOCKED
status system-wide.

Also reduce verbose stats logging.

Bug: 5854466
Change-Id: I3b612c520f50cc3000a3a569b7e0ab5f691cc2bd
etworkPolicyManagerService.java
etworkStatsRecorder.java
706498d387eaceb574cf4aa982fee3c288819dad 07-Feb-2012 Jeff Sharkey <jsharkey@android.com> List rotated netstats files during --checkin dump.

Also disable verbose logging.

Change-Id: I4c51e05d695eac43f0d9c28f9699f1655c642a99
etworkStatsService.java
241dde2306202e7655fdf41d5381f2874e47e108 03-Feb-2012 Jeff Sharkey <jsharkey@android.com> Unify shorthand for byte-based units.

Change-Id: If990859dee3f0973e1d4c48f05312c84071b3328
etworkPolicyManagerService.java
etworkStatsService.java
0e2e5f8b564bebd5798c9fa387fbff96429ab5d2 03-Feb-2012 Jeff Sharkey <jsharkey@android.com> Support snoozing of data warning notification.

Introduce second snooze timestamp to support dismissal of data usage
warning notification. Also explicitly set notification "when" to
avoid fighting with other notifications, such as ongoing downloads.

Bug: 5443756, 5262414
Change-Id: I03342c25b0410b1b2db84de9a40884f04cb1d8ae
etworkPolicyManagerService.java
25ce9ed57f137dc0b21045ab90fe595640ebf926 02-Feb-2012 Jeff Sharkey <jsharkey@android.com> Avoid NDC deadlock when re-arming network alert.

When NDC delivers limitReached() event, NMS re-arms the alert, which
makes another call back to NDC. If NDC already started processing
another call, this causes deadlock.

Fix this by re-arming on a handler thread.

Bug: 5879848
Change-Id: I46fa78fe1f1122c5f31dd6020483e5ae89a9f39d
etworkStatsService.java
e630f7b31bb1e77a2eb4ef3102a25f2927cfd5c3 01-Feb-2012 Jeff Sharkey <jsharkey@android.com> Clear identity when updating network stats.

Bug: 5945461
Change-Id: Ie51ea3f107a705c395b65684f21bf4c28c7f4d33
etworkStatsService.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
etworkPolicyManagerService.java
etworkStatsCollection.java
etworkStatsRecorder.java
etworkStatsService.java
5a7bcf31a44d9875ca5fc010dc213aa2bd5b1168 11-Jan-2012 Jeff Sharkey <jsharkey@android.com> Move non-monotonic reporting to interface.

Report non-monotonic NetworkStats through an observer interface
instead of throwing, since those events are still recoverable.

Change-Id: Ic0749f4634b0ac05dbe90e95ca490957ec8b2f23
etworkStatsService.java
f60d0afd1ef08a24121d015bb016df05265b6d07 01-Dec-2011 Jeff Sharkey <jsharkey@android.com> Restrict app data on metered networks.

This separates the definition of "metered network" and "network with
limit." For now, all mobile networks are considered metered.

Bug: 5571454
Change-Id: I394cd385bd33add75e53bfc9cf2fefd06a00208a
etworkPolicyManagerService.java
4529bb66c47fd02b990ecb0810031157b4f36c2f 14-Dec-2011 Jeff Sharkey <jsharkey@android.com> Move NMS to CONNECTIVITY_INTERNAL permission.

Change-Id: I6043c1b9cb10aeeafb93d1b5c60da571d2fec5c9
etworkStatsService.java
17b289048766d6b101e70061fe5774ec8f370b55 14-Dec-2011 Jeff Sharkey <jsharkey@android.com> Merge "Avoid reading network stats when disabled."
418d12dc8f2c518b673ebc522de4af6f7dbf0bf3 14-Dec-2011 Jeff Sharkey <jsharkey@android.com> Avoid reading network stats when disabled.

Bug: 5518868
Change-Id: Idb5c588b018bf735597ad7ff904ecc69224dd0a0
etworkStatsService.java
d04ff11d6fa5eb26ca19ac9962b899d9fb0470f0 13-Dec-2011 Jeff Sharkey <jsharkey@android.com> Avoid NPE when missing network stats.

Bug: 5750339
Change-Id: I4b739dbd076b270a5a2b2e2a1e0f6e445d8c124e
etworkStatsService.java
c506ff615080082515b1f634ad49b19fd2111669 17-Nov-2011 Jeff Sharkey <jsharkey@android.com> Only write network stats when already loaded.

Bug: 5584564
Change-Id: Ife2a68804bf3691e9bccdc167807204bce8a85b2
etworkStatsService.java
684c54a2eb860062f1960f4eba6bc71aa1cfa71d 17-Nov-2011 Jeff Sharkey <jsharkey@android.com> 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
etworkPolicyManagerService.java
etworkStatsService.java
7ee8658453fe4efe04781bea9a14368e1d5ff41f 15-Nov-2011 Jeff Sharkey <jsharkey@android.com> 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
etworkStatsService.java
d4ef8c8fc9ea70448e5d8138bf8bc96f4e69903f 11-Nov-2011 Jeff Sharkey <jsharkey@android.com> 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
etworkStatsService.java
630a13bdd88723599a7617ca4df20ab923e7ffbb 09-Nov-2011 Jeff Sharkey <jsharkey@android.com> Merge "Bootstrap stats before registering listeners." into ics-mr1
4c48d2ff6937e1e3a2fb93cc4cc29324b20542a5 09-Nov-2011 Jeff Sharkey <jsharkey@android.com> Merge "Make operation counts monotonically increase." into ics-mr1
3359aca7655a7d18615c1ada6cbabeff403947d1 09-Nov-2011 Jeff Sharkey <jsharkey@android.com> Bootstrap stats before registering listeners.

Also move ISE to handled NonMonotonicException.

Bug: 5570872
Change-Id: I793f349287ef5589185f117dfbec6f1fad73a661
etworkStatsService.java
7e25b0ea8891ffc0ac472d61f21610a9ac4e270a 09-Nov-2011 Jeff Sharkey <jsharkey@android.com> Dispatch alerts through background thread.

Bug: 5557659
Change-Id: Icc3ad476a98ec3430b33f915723ffcc36ccbfae7
etworkPolicyManagerService.java
4abb1b8ef64dc4cd71966b59dc5d72a15055bf13 09-Nov-2011 Jeff Sharkey <jsharkey@android.com> Make operation counts monotonically increase.

Bug: 5585704
Change-Id: I5247a68acdb209a4ef0f5aac18944595c295e6ca
etworkStatsService.java
3f3115b27733a822104385284b1ec1f39d91f839 09-Nov-2011 Jeff Sharkey <jsharkey@android.com> Make policy data enabled flag static.

For devices with both CDMA and GSM stack, ConnectivityService only
connects with the GSM variant. Making this flag static communicates
the policy state between all DCT.

Bug: 5586935
Change-Id: Iff0384027303470dd382d5173558d2d091ce4bf6
etworkPolicyManagerService.java
163e6443f27884a9bfcb9a48ef606dc635852c23 01-Nov-2011 Jeff Sharkey <jsharkey@android.com> 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
etworkPolicyManagerService.java
etworkStatsService.java
6f7af03cf13f76f48e63937e13e4a1c508d100d6 02-Nov-2011 Jeff Sharkey <jsharkey@android.com> Process AMS events in NetworkPolicy handler.

When a process changes foreground status or dies, NetworkPolicy
updates its internal state with a lock held. In cases where there
is contention, this can block the AMS handler and prevent other
events, such as broadcasts, from being dispatched.

This change moves the incoming AMS events to an existing internal
NetworkPolicy handler thread, where they can execute without
blocking AMS.

Bug: 5497544
Change-Id: Ie0c620a620fd9f0f4eb02af510bd819efa4deb6a
etworkPolicyManagerService.java
50e7e51d68e3b01c3362fe9ab7b3448132e48b43 11-Oct-2011 Jeff Sharkey <jsharkey@android.com> Over-limit within handful of MTU's, update assets.

Consider a network over-limit when it's measured usage is within a
handful of MTU's, since kernel completely drops packets that trigger
limit alert.

Update notification drawables.

Bug: 5433359, 5224629
Change-Id: I10b19cc34c34b47775904229829a25208cd85d25
etworkPolicyManagerService.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
etworkStatsService.java
905b5891d2aa802f447ac2ce5d77b6c5ba06277a 01-Oct-2011 Jeff Sharkey <jsharkey@android.com> 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
etworkStatsService.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
etworkStatsService.java
92cefaeb319b2642d119abb8640828ff0bbf2ac7 20-Sep-2011 Jeff Sharkey <jsharkey@android.com> Upload correct txPackets count.

Bug: 5321340
Change-Id: Ie4dc7a91bf1cdc4d64c75ff09ae0cdd0fb141b5d
etworkStatsService.java
1f0b13b9d64085dd8342ba942f39b6063b6d534d 18-Sep-2011 Jeff Sharkey <jsharkey@android.com> 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
etworkStatsService.java
cdd02c5d76d3dd4e21b5bb922d7fcfb86efec85f 16-Sep-2011 Jeff Sharkey <jsharkey@android.com> 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
etworkStatsService.java
fc0ab4c065babdda912d0a1b9fce9ab59140482a 15-Sep-2011 Jeff Sharkey <jsharkey@android.com> Merge "Network stats flag to force complete poll."
8ca953da93eb8679574abba535f75f72d50016f2 15-Sep-2011 Jeff Sharkey <jsharkey@android.com> Change data usage warning notification wording.

Bug: 5308710
Change-Id: Ic807640a031a3edb03897634e638473d5a039ecc
etworkPolicyManagerService.java
991d1b1b3f303ad247a959881b1d5b57766f678b 15-Sep-2011 Jeff Sharkey <jsharkey@android.com> 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
etworkStatsService.java
b3d5957604f8fcaafe72bd76052bc76b682bf443 08-Sep-2011 Jeff Sharkey <jsharkey@android.com> 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
etworkPolicyManagerService.java
etworkStatsService.java
07b0dd9a092273f0451cd9881312cb9b22a7af3f 01-Sep-2011 Jeff Sharkey <jsharkey@android.com> 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
etworkStatsService.java
961e30458319cfd50e1892ba7dd14a1d0ebe4cc7 30-Aug-2011 Jeff Sharkey <jsharkey@android.com> 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
etworkPolicyManagerService.java
etworkStatsService.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
etworkPolicyManagerService.java
etworkStatsService.java
8e9992ae5053a3ac52d28a5a892aed0a0798c7ab 24-Aug-2011 Jeff Sharkey <jsharkey@android.com> 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
etworkPolicyManagerService.java
etworkStatsService.java
8e28b7d78232f6cf08739ca0d129cc7f9e650801 19-Aug-2011 Jeff Sharkey <jsharkey@android.com> Proactively disable data when over policy limit.

Add policy controls to NetworkStateTracker which are combined with
other user preference and internal flags to decide if data connection
should be established. Better locking around enabled flags.

When data network would be over limit, proactively disable data on
that network. Enable when policy is snoozed or when cycle resets.

Track and dismiss notifications from now-stale policies.

Bug: 4587023, 5178147
Change-Id: Ibfcc9f73cda7c369209af701b46eddd3d1943f2d
etworkPolicyManagerService.java
3a844fcf5a0e70a19c38dc500306b9ebe4e1413b 16-Aug-2011 Jeff Sharkey <jsharkey@android.com> Background data notification, API clean up.

When restricting background data, show ongoing notification to give
easy access to re-enable. Deprecate getBackgroundDataSetting() API
to always return true, since NetworkInfo.isConnected() is new source
of truth. Handle upgrade path by reading from existing secure value,
and kick one last broadcast when changing value. Remove background
data code from ConnectivityService.

Remove warning alerts, since they push ifaces into restricted list;
should only happen when iface has limit.

Bug: 5163559, 5129421
Change-Id: I0064d9d643656a4d32aaae51d4a58bce49fe295f
etworkPolicyManagerService.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
etworkPolicyManagerService.java
etworkStatsService.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
etworkStatsService.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
etworkPolicyManagerService.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
etworkStatsService.java
4664500de0c1b270bce4991a400ab439ff2ef77b 28-Jul-2011 Jeff Sharkey <jsharkey@android.com> Maintain separate "restrict background data" flag.

Since "restrict background" depends on active networks, separate its
definition from setBackgroundDataSetting().

Bug: 4979025
Change-Id: I12bfe3a2e606375b39c67706270caa7a1bb0214e
etworkPolicyManagerService.java
41ff7ec82422a5b6d00892afdb3232bc0e53d851 26-Jul-2011 Jeff Sharkey <jsharkey@android.com> Revise data limit notifs, watch kernel alerts.

Teach NetworkPolicy limits to "snooze" when requested by user, and
notify with both dialog and notification. Register for network alerts
through NMS to trigger updates immediately instead of waiting for
next stats update.

Enforce that all NetworkPolicy are unique on a template basis, and
move SCREEN_ON/OFF broadcasts to background thread. Launch SystemUI
and Settings directly instead of using actions, and include full
NetworkTemplate in extras.

Tests to verify notification and snooze behavior.

Bug: 5057979, 5023579, 4723336, 5045721
Change-Id: I03724beff94a7c0547cb5220431ba8d4cd44d077
etworkAlertObserver.java
etworkPolicyManagerService.java
02e21d6a5b5117d494777a36783909854854f751 18-Jul-2011 Jeff Sharkey <jsharkey@android.com> Data usage notifs, newly installed apps, defaults.

Only show warning/limit notifications for active networks, since they
aren't actionable for inactive IMSI. Include IMSI in debug output on
engineering builds.

Move default policy warning to be configured through overlay. Watch
for newly installed packages to enforce global policy.

Bug: 5038729, 5038541, 4979026, 5023634
Change-Id: I8fc8ab4c23c440a3091504ea16133ed6ababf58e
etworkPolicyManagerService.java
6248926e199dca9bde3c76c5f82c486c293cdcdd 17-Jul-2011 Jeff Sharkey <jsharkey@android.com> Acquire wakelock during network stats collection.

Bug: 4517275
Change-Id: I01dfe3b13d7aca84605446e9e9927d0648623552
etworkStatsService.java
4e814c348ce205fcc1a273427f95ef1d100ed60c 15-Jul-2011 Jeff Sharkey <jsharkey@android.com> 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
etworkPolicyManagerService.java
etworkStatsService.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
etworkStatsService.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
etworkPolicyManagerService.java
etworkStatsService.java
104344e507610be42fb70c7deda3c422c543bfcb 10-Jul-2011 Jeff Sharkey <jsharkey@android.com> 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
etworkPolicyManagerService.java
etworkStatsService.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
etworkPolicyManagerService.java
etworkStatsService.java
b3f19ca36c8c1301893c621d8f2150e06210722c 30-Jun-2011 Jeff Sharkey <jsharkey@android.com> Enforce background data flag, rules through netd.

Connect up netd penalty box through NMS, and enforce the existing
background data flag by putting all UIDs in penalty box. Allow
platform applications to have policy applied. Only dispatch unique
rules to netd, avoiding any repeats.

Bug: 4598463, 4965677
Change-Id: Ibf9beff998ba7a1ea92f5e2f7eeba7b483d4b918
etworkPolicyManagerService.java
50fd36d7c38c40b087c8f3e3172478abe0c051d9 16-Jun-2011 Ashish Sharma <ashishsharma@google.com> Push interface quota rules from NetworkPolicyManager to kernel.

Change-Id: Id2b758f561820b44839f69bf5fbd676cae771fe3
etworkPolicyManagerService.java
4414cea13908b8230640f84ef39603d68ff9c377 25-Jun-2011 Jeff Sharkey <jsharkey@android.com> 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
etworkPolicyManagerService.java
etworkStatsService.java
d94585279f0903259c4434aabe0dbdd141b6dbab 28-Jun-2011 JP Abgrall <jpa@google.com> 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>
etworkStatsService.java
b851cc23c80761f19ebd2839a35be49be30d9b14 23-Jun-2011 JP Abgrall <jpa@google.com> 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>
etworkStatsService.java
0a9ee1272b59ad350cea591f931b52290a5e0998 23-Jun-2011 Jeff Sharkey <jsharkey@android.com> 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
etworkStatsService.java
5dc0c26cffbbc62ff84f9f4c8a451e68e2c05d2d 20-Jun-2011 Jeff Sharkey <jsharkey@android.com> Teach NetworkIdentity about roaming.

And correctly upgrade NetworkIdentitySet written to disk, assuming
that old values aren't roaming.

Bug: 4724762
Change-Id: Ic25897ebbaf43be2390174d8e5fd08386bc8a345
etworkIdentitySet.java
etworkPolicyManagerService.java
d03fd3f004e3ba8aaa1692ee0e92e8ae171d2a04 20-Jun-2011 Jeff Sharkey <jsharkey@android.com> 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
etworkStatsService.java
b09540f33a6cabe50edec0ef32d0b1d0b0d96fff 19-Jun-2011 Jeff Sharkey <jsharkey@android.com> 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
etworkPolicyManagerService.java
etworkStatsService.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
nterfaceIdentity.java
etworkIdentity.java
etworkIdentitySet.java
etworkPolicyManagerService.java
etworkStatsService.java
fdfef57f498e3021a34342538aef9f1c7ccbae78 17-Jun-2011 Jeff Sharkey <jsharkey@android.com> 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
etworkPolicyManagerService.java
af8339374fbf1e2f57b0be918c7fc772f4250f13 17-Jun-2011 Jeff Sharkey <jsharkey@android.com> Avoid clobbering UID stats when not yet loaded.

Bug: 4690822
Change-Id: Ia6c9e8f89e89739cf3380c4b98b9da6f52db48fa
etworkStatsService.java
1a303953589fdddf21d88b8fa660136f5b060d0d 16-Jun-2011 Jeff Sharkey <jsharkey@android.com> DownloadManager flags for network policy.

Handful of DownloadManager flags to record when a download was paused
because of NetworkPolicyManager rules.

Change-Id: I99fc47f529cb6c8a42dbeca049e0cd0f1556eac4
etworkPolicyManagerService.java
14711eb5b6a45b587222ae71c57a381beb7b1a7e 15-Jun-2011 Jeff Sharkey <jsharkey@android.com> Include template in data warning/limit intents.

When launching warning/limit UI, include the template that triggered
the notification. Also move actions and extra into contract class.

Change-Id: Id2e63fd2d2e36a137a3fd8f889c7256038ca5f2e
etworkPolicyManagerService.java
497e4437af386930dff3bd55296d128bd4520959 15-Jun-2011 Jeff Sharkey <jsharkey@android.com> 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
etworkPolicyManagerService.java
etworkStatsService.java
fcc79771f092f34505b1accb80365cbcaa379667 14-Jun-2011 Jeff Sharkey <jsharkey@android.com> Generate default policy for devices without IMSI.

Change-Id: I38500919ea60f78d99684608589c8fc3092bf239
etworkPolicyManagerService.java
af11d4859582a9736aa204562f0beac5a7d60934 13-Jun-2011 Jeff Sharkey <jsharkey@android.com> Fix test-related build breakage.

Change-Id: I48a3dbbdc49d742d6ad19cff34ee8da4b3949bb8
etworkPolicyManagerService.java
22c055e6424e0e9579711545d8f4800c0f796db8 13-Jun-2011 Jeff Sharkey <jsharkey@android.com> External mutation of full NetworkPolicy set.

Instead of embedding complex template coexistence rules into policy
service, rely on external editors to enforce, and offer atomic
get/set operations for full policy sets.

Generate default mobile policy when none exists, using default of 4GB
warning and cycle reset of current day. Dispatch listener events
through Handler when holding internal lock, and catch CLASS_UNKNOWN
networks in 3G_LOWER template.

Change-Id: I063cf1eaf330e32b75d0697b89fc04488e6dfaea
etworkIdentity.java
etworkPolicyManagerService.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
etworkStatsService.java
39ebc2195ed16b9e955dd57f5c95212bb7b934b6 12-Jun-2011 Jeff Sharkey <jsharkey@android.com> 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
etworkStatsService.java
cd2ca4038a027315832c38c68be5076000bc4b53 11-Jun-2011 Jeff Sharkey <jsharkey@android.com> Move data cycle methods to framework object.

Moved so they can be used by both system service and Settings UI, since
they both work with data usage cycles. Still covered by tests.

Change-Id: I01c0c4db6da9457dd867c9167d31a5f9f8e5f5d9
etworkPolicyManagerService.java
21c9c45e5caf62b935354b74392fb40c4bf18529 07-Jun-2011 Jeff Sharkey <jsharkey@android.com> Interface-level network policy, persist policies.

Define NetworkPolicy as cycle-reset day and warning/limit values, and
set/get through NetworkPolicyManager. Watch ConnectivityManager for
network connection events, and apply quota rules based on matching
interfaces. Policy service matches based on strong identity to support
IMSI-specific policy values.

Calculates remaining quota based on current stats recorded since the
last reset cycle day. Tests to verify edge cases around February.

Persist network and UID policies in XML, and restore on boot.

Change-Id: Id40ba7d6eed6094fbd5e18e6331286c606880d80
etworkPolicyManagerService.java
etworkStatsService.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
etworkIdentity.java
etworkStatsService.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
etworkStatsService.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
etworkStatsService.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
nterfaceIdentity.java
etworkIdentity.java
etworkPolicyManagerService.java
etworkStatsService.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
etworkPolicyManagerService.java
etworkStatsService.java
9599cc5f21152860af9d18015b1398b50743da76 22-May-2011 Jeff Sharkey <jsharkey@android.com> Tests for NetworkPolicyManager rule generation.

Verifies that policy changes trigger rule updates that respect current
foregroundActivities status. Also verifies logic that promotes a UID
based on its most-foreground PID. Verifies that policy changes result
in immediate rule changes.

Also verifies that BACKGROUND_DATA_SETTING_CHANGED broadcasts are sent
by policy changes.

Change-Id: I4fd0dad9e1dbccee2c5968244bb1814e6cb2c6e1
etworkPolicyManagerService.java
1b861278a2051f53ce7955fb7992fa536dc975d9 22-May-2011 Jeff Sharkey <jsharkey@android.com> Teach NetworkPolicyManager how to dumpsys itself.

Includes details on all internally known UIDs, which can be used for
debugging purposes.

Change-Id: I340d25212e3c7a76a57de0a94ffeea34b6748941
etworkPolicyManagerService.java
c006f1aec15454782c35e028ad64d79a5c161cc1 20-May-2011 Jeff Sharkey <jsharkey@android.com> 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
etworkPolicyManagerService.java
a4620793038b9a9163b26c6ece882cb454fcbf87 21-May-2011 Jeff Sharkey <jsharkey@android.com> Observe screen on/off events in NetworkPolicy.

The POLICY_REJECT_BACKGROUND policy requires that network traffic be
blocked when a UID goes into the background. Even if the UID has an
activity in the foreground, it's considered "background" if the screen
is turned off.

This changes watches for SCREEN_ON/OFF broadcasts, and rule generation
now observes screen state. It also introduces an observer pattern so
that ActivityManager doesn't directly know about NetworkPolicy, and
moves the service management into SystemServer.

Change-Id: Ie7a84929d3ca60ae4578d47e19d5a8da10fd8d58
etworkPolicyManagerService.java
eedcb9525ba5befee2ba6ebb7a9ee3f13395c2a3 17-May-2011 Jeff Sharkey <jsharkey@android.com> 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
etworkPolicyManagerService.java
d5cdd597b895a48ffa9a8e39f8a2504cd9b905c4 04-May-2011 Jeff Sharkey <jsharkey@android.com> First pass at NetworkPolicy and activity tracking.

New system service that maintains low-level network policy rules and
collects statistics to drive those rules. Will eventually connect to
netfilter kernel module through NetworkManagementService and "netd".

Begin tracking foreground activities in ActivityManagerService, which
is updated as part of OOM adjustment. Eventually a network policy of
POLICY_REJECT_BACKGROUND will reject network traffic from background
processes.

Change-Id: I5ffbbaee1b9628e9c3eff6b9cb2145fc5316e64d
etworkPolicyManagerService.java