Commit graph android_packages_modules_Co.../services/java/com/android/server/net
Message SHA1
am 1f8f2839: am ed3fba65: Merge "Avoid null mobile interfaces." into jb-mr1.1-dev
* commit '1f8f283975c7cf51081acd3ea494de2b5f431607':
  Avoid null mobile interfaces.

Jeff Sharkey   authored and   Android Git Automerger   commited 2012-12-03 11:40:23 -08:00
bf76d97d78
Avoid null mobile interfaces.
Bug: 7634215
Change-Id: I6745f6a78c07ba11d98b4562a6b53386112ef652

Jeff Sharkey   commited 2012-11-30 17:49:39 -08:00
17ffba9700
am ae0edeb3: am c88047bf: Merge "Move NTP updates outside locks"
* commit 'ae0edeb3e56c6aae113f8c5eaa3a03b79c00a93e':
  Move NTP updates outside locks

Kenny Root   authored and   Android Git Automerger   commited 2012-11-27 13:00:01 -08:00
49e27d5f9d
Move NTP updates outside locks
When the ServerThread handles ACTION_SHUTDOWN intent it sometimes get
stuck on mStatsLock in NetworkStatsService.java.
0  com.android.server.net.NetworkStatsService$5.onReceive()
1  android.app.LoadedApk$ReceiverDispatcher$Args.run()
2  android.os.Handler.handleCallback()
3  android.os.Handler.dispatchMessage()
4  android.os.Looper.loop()
5  com.android.server.ServerThread.run()
This happens when the NetworkStats thread is already holding the
mStatsLock while updating NTP.
0  libcore.io.Posix.getaddrinfo()
1  libcore.io.ForwardingOs.getaddrinfo()
2  java.net.InetAddress.lookupHostByName()
3  java.net.InetAddress.getAllByNameImpl()
4  java.net.InetAddress.getByName()
5  android.net.SntpClient.requestTime()
6  android.util.NtpTrustedTime.forceRefresh()
7  com.android.server.net.NetworkStatsService.performPoll()
8  com.android.server.net.NetworkStatsService.access$100()
9  com.android.server.net.NetworkStatsService$2.onReceive()
10 android.app.LoadedApk$ReceiverDispatcher$Args.run()
11 android.os.Handler.handleCallback()
12 android.os.Handler.dispatchMessage()
13 android.os.Looper.loop()
14 android.os.HandlerThread.run()
Since the NTP update consists of several socket operations it may get
stuck long enough to trigger a System Server Watchdog even though the
socket timeout is set to 20 second.
Further, the NTP update doesn't actually need to be performed inside
the locks and an attempt to change this was made earlier, but the code
wasn't actually moved outside the locks.

Change-Id: Ib37a2b8c2d51a01adb7ff01764f82309433703f0

Anders 3 Fridlund   authored and   Henrik Baard   commited 2012-11-16 13:28:29 +01:00
0e851c78e3
Useful annotations for code documentation.
Bug: 6537978
Change-Id: I806c3c09e3255f8789455f13bf37c1dde2a93f1f

Jeff Sharkey   commited 2012-11-12 12:42:17 -08:00
526438dbe6
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

Jeff Sharkey   commited 2012-09-27 16:22:53 -07:00
c783695df2
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

Jeff Sharkey   commited 2012-09-19 14:54:05 -07:00
8c8309a6fe
Actually move to Global settings.
Also add better ConnectivityService logging.

Bug: 7157464
Change-Id: Ia235a7e62ed809240913c4782920c1410c7d597d

Jeff Sharkey   commited 2012-09-14 13:47:51 -07:00
77127d1c93
Move to Global.NETSTATS and Global.NTP constants.
Bug: 7157464
Change-Id: Ief10fd37940f62420f5684940994c9f93802e0be

Jeff Sharkey   commited 2012-09-14 13:14:21 -07:00
633746dc75
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

Dianne Hackborn   commited 2012-08-30 14:33:22 -07:00
692107e827
Make generic BaseNetworkObserver.
This makes it easier to add new INetworkManagementEventObserver events
in future.

Change-Id: I432263d745558de4b878f313c1951230ed9db2b1

Jeff Sharkey   commited 2012-08-05 14:32:41 -07:00
0066733be0
Make AtomicFile a public API. It's about time!
Change-Id: Ib34e294747405b7ab709cb0bbb2d9a0cc80ce86a

Dianne Hackborn   commited 2012-07-31 17:54:52 -07:00
3dfb8b498a
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

Jeff Sharkey   commited 2012-05-17 10:10:39 -07:00
3ddc9b3745
Avoid updating thresholds during shutdown.
Bug: 6472388
Change-Id: I70e1ed5dc75056840f2f0b130ce0dfecb06f385e

Jeff Sharkey   commited 2012-05-09 19:59:07 -07:00
b9439a4c2a
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

Jeff Sharkey   commited 2012-05-09 13:43:19 -07:00
585bc91d22
Ack, wrap advisePersistThreshold() in lock.
Bug: 6449725
Change-Id: I702dc2ff9d4b237c46d89bcae41289bc3e9ef2f8

Jeff Sharkey   commited 2012-05-07 11:08:49 -07:00
24a69bbd60
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

Jeff Sharkey   commited 2012-05-03 12:12:10 -07:00
c78bc60039
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

Jeff Sharkey   commited 2012-05-01 21:04:26 -07:00
cfed18ad5b
Clear identity when checking if bandwidth enabled.
Change-Id: I0f10f86dc14483e29609057c671454b322da4826

Jeff Sharkey   commited 2012-04-23 14:39:19 -07:00
f6d43ea959
Better assertions when bandwidth module disabled.
Also disable some verbose logging in WifiStateTracker.

Bug: 6368329
Change-Id: I9a5219bc1b3fd870468f7de46cdf4f173a437c59

Jeff Sharkey   commited 2012-04-21 15:36:48 -07:00
32c773b16a
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

Jeff Sharkey   commited 2012-04-12 14:53:32 -07:00
8308b9b2af
Migrate to @Override to remove warnings.
Bug: 6303344
Change-Id: I0d33b2ed448467379d576ccd71fb5ae20c878852

Jeff Sharkey   commited 2012-04-09 10:57:21 -07:00
1ba1b673f5
Splice operations before collapsing ifaces.
Bug: 6241038
Change-Id: Ide9058703f7305df8fb070af149ddce0653a0abf

Jeff Sharkey   commited 2012-04-09 10:27:55 -07:00
27421b1665
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

Jeff Sharkey   commited 2012-04-06 13:38:29 -07:00
920d9046bc
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

Jeff Sharkey   commited 2012-04-05 16:02:25 -07:00
3bd888f411
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

Jeff Sharkey   commited 2012-03-16 11:35:29 -07:00
8e38f3ddde
Avoid updating network stats after shutdown.
Bug: 6109476
Change-Id: I9a3a8b182c8fa56d83ddc755d204d5b267c9bc5d

Jeff Sharkey   commited 2012-03-06 19:59:57 -08:00
0097f85348
Disable verbose NetworkStats logging.
Bug: 6076584
Change-Id: I4efcda2b474f623f4fe70db8b43b0aa69017d749

Jeff Sharkey   commited 2012-02-28 15:13:08 -08:00
30aab0989d
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

Jeff Sharkey   commited 2012-02-07 12:08:58 -08:00
ff81c2eebc
List rotated netstats files during --checkin dump.
Also disable verbose logging.

Change-Id: I4c51e05d695eac43f0d9c28f9699f1655c642a99

Jeff Sharkey   commited 2012-02-06 17:35:11 -08:00
25e3ec70aa
Unify shorthand for byte-based units.
Change-Id: If990859dee3f0973e1d4c48f05312c84071b3328

Jeff Sharkey   commited 2012-02-03 14:50:13 -08:00
94a315cec5
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

Jeff Sharkey   commited 2012-02-02 13:09:52 -08:00
9a21249a6c
Clear identity when updating network stats.
Bug: 5945461
Change-Id: Ie51ea3f107a705c395b65684f21bf4c28c7f4d33

Jeff Sharkey   commited 2012-01-31 17:13:09 -08:00
2ed12477de
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

Jeff Sharkey   commited 2012-01-24 11:13:14 -08:00
bfe82685e7
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

Jeff Sharkey   commited 2012-01-10 17:24:44 -08:00
ef7bded347
Move NMS to CONNECTIVITY_INTERNAL permission.
Change-Id: I6043c1b9cb10aeeafb93d1b5c60da571d2fec5c9

Jeff Sharkey   commited 2011-12-14 17:51:13 -08:00
41a1247dea
Merge "Avoid reading network stats when disabled."
Jeff Sharkey   authored and   Android (Google) Code Review   commited 2011-12-14 10:12:17 -08:00
47a0212ace
Avoid reading network stats when disabled.
Bug: 5518868
Change-Id: Idb5c588b018bf735597ad7ff904ecc69224dd0a0

Jeff Sharkey   commited 2011-12-13 15:43:47 -08:00
675c43125f
Avoid NPE when missing network stats.
Bug: 5750339
Change-Id: I4b739dbd076b270a5a2b2e2a1e0f6e445d8c124e

Jeff Sharkey   commited 2011-12-12 18:51:26 -08:00
3511b086bc
Only write network stats when already loaded.
Bug: 5584564
Change-Id: Ife2a68804bf3691e9bccdc167807204bce8a85b2

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

Bug: 5627247, 5584564
Change-Id: If9bbd93842c710efcdec94e68da87e9e42a5f961

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

Bug: 5584564
Change-Id: I5dd87fc009959b1cf0a7d660e385a0b1a8be238b

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

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

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

Bug: 5570872
Change-Id: I793f349287ef5589185f117dfbec6f1fad73a661

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

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

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

Bug: 5472949, 5458380
Change-Id: I07c08fe5233156fac2b84450f6291868bf9bfaf2

Jeff Sharkey   commited 2011-11-02 15:14:11 -07:00
cd5559a856
Refine random stats generation.
Offer parameters to pick out specific list of packages, and to change
duration and total data.

Bug: 5416742
Change-Id: I6970a5e76f3198ef23a400c079037212b000ca6b

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

Include xtables summary and authoritative time in samples.

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

Jeff Sharkey   commited 2011-10-03 17:21:05 -07:00
f1369459ed
Watch network subtype, tethering teardown, empty.
Watch for changes to telephony network subtype, and update iface
mapping to persist stats under correct type.  Update network stats
before removing tethering NAT rules.

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

Bug: 5360042, 5359860, 5335674, 5334448
Change-Id: I8aa37b568e8ffb70647218aa1aff5195d3e44d5a

Jeff Sharkey   commited 2011-09-22 16:19:06 -07:00
6a2cbb63b3