History log of /frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
8b2c3a14603d163d7564e6f60286995079687690 12-Nov-2012 Jeff Sharkey <jsharkey@android.com> Useful annotations for code documentation.

Bug: 6537978
Change-Id: I806c3c09e3255f8789455f13bf37c1dde2a93f1f
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.java
39606a007a5b1309dd000234f2b8cf156c49fd0f 01-Aug-2012 Dianne Hackborn <hackbod@google.com> Make AtomicFile a public API. It's about time!

Change-Id: Ib34e294747405b7ab709cb0bbb2d9a0cc80ce86a
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.java
e19f39b79c831aea4d51a3309025acdf69d1e609 24-May-2012 Jeff Sharkey <jsharkey@android.com> Advise persist threshold outside NPMS lock.

Bug: 6492166
Change-Id: Ibebdc7e9b8cae27c12fd7b61b53ab60287a0364d
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.java
8c1dc72b1402d55dae388a294476565b2473a87a 04-May-2012 Jeff Sharkey <jsharkey@android.com> Disable policy when bandwidth module missing.

Bug: 6447017
Change-Id: I705a223dac15fc41e231bb9c81a96a287caaf094
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.java
00a10a1494954d124e1b11bc1ba3128e47b8ffbd 28-Apr-2012 Irfan Sheriff <isheriff@google.com> Handle null SSID cleanly

Bug: 6411912
Change-Id: I12f9df403c9633d928d898ae675ce36303dda1a8
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.java
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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.java
854b2b1670bda1eeb87a14b7ac3d222024f0aad6 14-Apr-2012 Jeff Sharkey <jsharkey@android.com> Surface list of apps with given network policy.

Bug: 6007276
Change-Id: I0f0e939ee6481496480c4afaa108c99eb158547c
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.java
bfdd680ab44da173a4a39fcd6feccdebb9d1f855 09-Apr-2012 Jeff Sharkey <jsharkey@android.com> Migrate to @Override to remove warnings.

Bug: 6303344
Change-Id: I0d33b2ed448467379d576ccd71fb5ae20c878852
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.java
241dde2306202e7655fdf41d5381f2874e47e108 03-Feb-2012 Jeff Sharkey <jsharkey@android.com> Unify shorthand for byte-based units.

Change-Id: If990859dee3f0973e1d4c48f05312c84071b3328
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.java
63abc37356728c0575d6a62a203102ae6d97953b 12-Jan-2012 Jeff Sharkey <jsharkey@android.com> Move network stats to FileRotator pattern.

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

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

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

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

Bug: 5386531
Change-Id: Ibe086230a17999a197206ca62d45f266225fdff1
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.java
7e25b0ea8891ffc0ac472d61f21610a9ac4e270a 09-Nov-2011 Jeff Sharkey <jsharkey@android.com> Dispatch alerts through background thread.

Bug: 5557659
Change-Id: Icc3ad476a98ec3430b33f915723ffcc36ccbfae7
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.java
8ca953da93eb8679574abba535f75f72d50016f2 15-Sep-2011 Jeff Sharkey <jsharkey@android.com> Change data usage warning notification wording.

Bug: 5308710
Change-Id: Ic807640a031a3edb03897634e638473d5a039ecc
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.java
47eb102b40cd1324d89816a7fb0fecd14fd7a408 26-Aug-2011 Jeff Sharkey <jsharkey@android.com> Always splice historical data stats, debug info.

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

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

Bug: 5212893, 5211028
Change-Id: I783e5286637a67ee2dd2b09878198711a926d0cb
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.java
b5d55e302d2253e4bfb233ea705caf258cdc4cb9 11-Aug-2011 Jeff Sharkey <jsharkey@android.com> Foreground/background network stats using sets.

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

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

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

Bug: 5105592, 5146067
Change-Id: Idabec9e3ffcaf212879821515602ecde0a03de8c
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.java
f0ceede8fff5df24e5c98701d81c2b71eb138aa9 03-Aug-2011 Jeff Sharkey <jsharkey@android.com> Expose quota status for active network.

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

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

Bug: 4517283, 5088603
Change-Id: Ic6893a8967f69937e466be226ba7bb86ef5a5d2d
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.java
d37948f6ed1667d077e0e3a38808f42f981ddcc2 12-Jul-2011 Jeff Sharkey <jsharkey@android.com> Hide NetworkStatsHistory internals.

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

Change-Id: I5228d7099a8f61b2018a435a813435a67dae49b4
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.java
350083e36b9db6062e165954403ef921ff3dfdad 29-Jun-2011 Jeff Sharkey <jsharkey@android.com> Migrate bandwidth control to NMS, omit history.

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

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

Bug: 4982115, 4770435, 4515856
Change-Id: I257820b057af2f0f99c736fb4f61e55b9fdc3e66
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.java
50fd36d7c38c40b087c8f3e3172478abe0c051d9 16-Jun-2011 Ashish Sharma <ashishsharma@google.com> Push interface quota rules from NetworkPolicyManager to kernel.

Change-Id: Id2b758f561820b44839f69bf5fbd676cae771fe3
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.java
1b5a2a96f793211bfbd39aa29cc41031dfa23950 19-Jun-2011 Jeff Sharkey <jsharkey@android.com> Read "qtaguid" network stats, refactor templates.

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

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

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

Change-Id: I0447b5e7d205d73d28e71c889c568e536e91b8e4
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.java
fcc79771f092f34505b1accb80365cbcaa379667 14-Jun-2011 Jeff Sharkey <jsharkey@android.com> Generate default policy for devices without IMSI.

Change-Id: I38500919ea60f78d99684608589c8fc3092bf239
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.java
af11d4859582a9736aa204562f0beac5a7d60934 13-Jun-2011 Jeff Sharkey <jsharkey@android.com> Fix test-related build breakage.

Change-Id: I48a3dbbdc49d742d6ad19cff34ee8da4b3949bb8
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.java
d2a458750e5a3d490af09cecb5c28370baf0a913 29-May-2011 Jeff Sharkey <jsharkey@android.com> Map network identity using ConnectivityService.

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

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

Cleaned up Objects and Preconditions.

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

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

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

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

Change-Id: Ia27d1289556a2bf9545fbc4f3b789425a01be53a
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.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
/frameworks/base/services/java/com/android/server/net/NetworkPolicyManagerService.java