Commit graph android_packages_modules_Co.../services/tests
Message SHA1
Made AlarmClockInfo a nested class in AlarmManager
Bug: 16959028
Change-Id: I150eaaff765d1e214c3621c1bf50162ec0dac8ec

Jose Lima   authored and   Jose Ricardo Lima   commited 2014-08-14 02:10:41 +00:00
765b3ba313
Remove dead code 2.
Removing ConnectivityService.NetworkFactory.  This requires disabling
the ConnectivityServiceTest, but that's been broken since we stopped
using NetworkStateTrackers anyway.

Change-Id: I9b86bd37eb9d018c40f60dca5b00d62c36d4e3ad

Robert Greenwalt   commited 2014-07-28 14:48:52 -07:00
39bb79b986
Cleanup: Delete dead code.
Bug: 15413389
Change-Id: I315468832ef18ffc84174e54774ab63b86d284dc

Sreeram Ramachandran   commited 2014-07-22 15:46:34 -07:00
c05e2a9093
Add AlarmClock API to AlarmManager
Adds a new kind of alarm that represents an alarm clock and
a way to query the next scheduled alarm clock.

Deprecates Settings.System.NEXT_ALARM_FORMATTED.

Bug: 14589952
Change-Id: I297eeeff36d07adcda010afac183d0f5ee37dc99

Adrian Roos   commited 2014-07-10 17:07:36 +00:00
c4a8f21352
Fix build.
Change-Id: I5dab09d2d8a9cff56fa17bb4e8c14b365449399b

Sreeram Ramachandran   authored and   Lorenzo Colitti   commited 2014-05-14 03:56:33 -07:00
9ccfb02776
Get ConnectivityServiceTest building again after 307dd58.
Change-Id: I4520011ba2076d8fac1ca234cb9a79c774992671

Paul Jensen   authored and   Lorenzo Colitti   commited 2014-05-14 03:56:33 -07:00
e54dc09048
Update the tests to deal with the new timestamps in idletimer module.
Change-Id: I1a8368d84ef806f1501b0a1f5e817388a1d10518

Ashish Sharma   commited 2014-03-18 16:38:58 -07:00
5a07255d7e
Add address flags and scope to LinkAddress.
This is necessary so that the framework can know whether an IPv6
address is likely to be usable (i.e., if it's global scope and
preferred). Also, it will simplify the address notification
methods in INetworkManagementEventObserver, which currently take
the address, the flags, and the scope as separate arguments.

1. Add flags and scope to the class and update the unit test.
   Use the IFA_F_* and RT_SCOPE_* constants defined by libcore.
   Since most callers don't know about flags and scope, provide
   constructors that default the flags to zero and determine the
   scope from the address. Addresses notified by the kernel will
   have these properly set. Make multicast addresses invalid.
   Update the class documentation.
2. Provide an isSameAddressAs() method that compares only the
   address and prefix information between two LinkAddress
   objects. This is necessary because an interface can't have
   two addresses with the same address/prefix but different
   flags.
3. Update LinkProperties's addLinkAddress and removeLinkAddress
   to identify existing addresses to add/remove using
   isSameAddressAs instead of implicit equals(). Specifically:
   - If addLinkAddress is called with an address that is already
     present, the existing address's flags and scope are updated.
     This allows, for example, an address on an interface to go
     from preferred to deprecated when it expires, without it
     having to be removed and re-added.
   - If removeLinkAddress is called with an address that is
     present but with different flags, it deletes that address
     instead of failing to find a match.
4. Update the INetworkManagementEventObserver address
   notification methods to take just a LinkAddress instead of
   LinkAddress, flags, and scope. While I'm at it, change the
   order of the arguments for consistency with the other
   functions in the interface.

Change-Id: Id8fe0f09a7e8f6bee1ea3b52102178b689a9336e

Lorenzo Colitti   commited 2013-12-06 13:54:35 +09:00
4ea70b7743
Use LinkAddress in address notifications.
Currently address{Updated,Removed} pass in the address as a
string such as "fe80::1/64". Use LinkAddresses instead, since
that's what it is.

This makes the code more robust in the unlikely case that netd
passes in an invalid string. In the future we can move flags and
scope into the LinkAddress itself and simplify the code further.

Bug: 9180552
Change-Id: I66599f9529cf421caa7676fdd0141bb110b8589e

Lorenzo Colitti   commited 2013-11-26 21:55:15 +09:00
3ac3fea4e7
Pass DNS server info notifications to observers.
These are sent if the device receives IPv6 Router Advertisements
with DNS server configuration options. Currently, nothing listens
to them; in a future change we will use them as IPv6 DNS servers.

[Cherry-pick of d3b7821c8f]

Bug: 9180552
Change-Id: I05000c0cd3867a68ab390102e8470b6912a9d3aa

Lorenzo Colitti   commited 2013-11-25 17:27:17 +09:00
ea5c0e2c48
Minor cleanups to NetdCallbackReceiver.onEvent.
- Clean up identical error messages.
- Fix the array length check for InterfaceAddressChange.

[Cherry-pick of 4f85a08091]

Bug: 9180552
Change-Id: Id871f481445b530c3ad749725f1548df0e3a1228

Lorenzo Colitti   commited 2013-11-25 17:25:45 +09:00
1f7e433a86
Request all tethering interfaces, fix corruption.
netd now tracks statistics for tethered interfaces across tethering
sessions, so switch to asking for all tethering stats.  (Currently
we're double-counting all tethering data, ever since it started
tracking across sessions.)

Also catch OOME to handle corrupt stats files, which we then dump to
DropBox and then start over.

Bug: 5868832, 9796109
Change-Id: I2eb2a1bf01b993dd198597d770fe0e022466c6b9

Jeff Sharkey   commited 2013-09-10 21:03:30 -07:00
86dc7a89da
Add a simple test for NetworkManagementService.
For now, this only tests network observers. It works by starting
NetworkManagementService with a fake netd socket, feeding it
inputs, and seeing if the appropriate observer methods are
called.

Bug: 10232006
Change-Id: I827681575642a4ee13ae48b81272521544b676bd

Lorenzo Colitti   commited 2013-08-23 18:30:19 +09:00
2e73837a72
Revert "Fix broken unit test"
This reverts commit 9e6dd0ca49.

Change-Id: I67f5e7227a8a874158c4f0954e62a77a317f1edd

David Christie   commited 2013-08-06 17:28:03 +00:00
87893f88f4
Fix broken unit test
Change-Id: I4aa0035233749f6d585c151329436439ae9b2921

David Christie   commited 2013-08-02 12:33:00 -07:00
9e6dd0ca49
Fix build breakage
Change-Id: Ia684fb55db301fdadaa3aae93f82b2cdcfc200af

David Christie   commited 2013-08-02 10:54:55 -07:00
14298807a1
Add WorkSource capability to AlarmManager.
Change-Id: I663ea3078d405f0fa667a04bdaa376ae6652e994

David Christie   commited 2013-08-01 13:22:40 -07:00
a62588a133
fix build
Change-Id: Ie4bd7c3fe9320d22b7da2962e5e5a4abca510bd2

Guang Zhu   commited 2013-07-21 02:01:34 -07:00
f466bf9e1d
Fix build & preserve DHCP scheduling as-is
Change-Id: I4063b18532c476280f343658bf3641495e526ed4

Christopher Tate   commited 2013-07-18 18:23:57 -07:00
53d68e16d8
Always specify an interface for host routes.
Change-Id: I05b4d87e7d7e8237c6f4a70f1fedae00f416f581

Lorenzo Colitti   commited 2013-03-08 16:41:25 -08:00
697e1c0748
Migrate to using Mockito directly.
Change-Id: I1fcc5d1a780f5831bd6685f0735d4c0c6d245735

Jeff Sharkey   commited 2013-02-19 15:28:19 -08:00
c8a2687705
Isolate NetworkStateTracker creation, test.
Change ConnectivityService to use a factory when creating
NetworkStateTrackers, which gives us a good place to inject mocks
for testing.  Add initial tests to verify that network routes are
added and removed as networks changed.

Change-Id: I11cbc61a84c2ed4afa2670036295b1494eab26e1

Jeff Sharkey   commited 2012-08-08 16:23:41 -07:00
6b9021d76c
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
2ffa45267f
Fix network stats and policy tests.
Bug: 6299195
Change-Id: I1941b5f7329940cc7469bd3fda17c3dc3a656250

Jeff Sharkey   commited 2012-05-04 15:15:42 -07:00
0e5fa591b9
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
db613f6a32
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
5cc4da38f0
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
dc164ff128
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
2d9e5a5f9e
Unify shorthand for byte-based units.
Change-Id: If990859dee3f0973e1d4c48f05312c84071b3328

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

Jeff Sharkey   commited 2011-12-15 14:30:04 -08:00
bcd1e340c6
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
e370a59bec
Move battery stats to xt_qtaguid for data stats.
Replace TrafficStats calls by reading values from xt_qtaguid kernel
module. To keep BatteryStatsImpl changes lightweight, cache recently
parsed stats. Tracks mobile ifaces from ConnectivityService.

Refactor xt_qtaguid parsing into factory outside of NMS. Add stats
grouping based on UID, and total based on limiting filters like iface
prefix and UID.

Bug: 4902271
Change-Id: I533f116c434b77f93355bf95b839e7478528505b

Jeff Sharkey   commited 2011-10-09 13:49:08 -07:00
aac2c50385
Read iface stats from single proc file.
When available, use single "iface_stat_all" file instead of reading
values from dozens of files scattered across proc.  Tests to verify.

Bug: 5397840
Change-Id: I0247be518436c1f79b32c4b72216739f49a9e8cc

Jeff Sharkey   commited 2011-10-04 13:22:39 -07:00
d49f1a59f9
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
ad268036a4
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
b6188a1aac
Sample atomic network stats buckets, full poll.
When sampling network stats, always use atomic buckets instead of
interpolating.  Always poll iface and UID together so we distribute
into buckets equally.  Move stale bucket trimming to just before
writing stats.

Bug: 5321340
Change-Id: I78a2226778a79c875f3668336e39ea24a7b4d5c4

Jeff Sharkey   commited 2011-09-18 16:27:21 -07:00
f444762587
NetworkManagement SocketTagger: Migrate QTagUid support to JNI.
* Instead of javaland trying to write commands to
   /proc/net/xt_qtaguid/ctrl
use the libcutils/qtaguid.c support via JNI.
* Get rid of tagToKernel() handled by qtaguid library.

Requires libcutils changes from c/132538/

Change-Id: I9de5b3fa4a596c56835024c6d376769a0eea7db1

JP Abgrall   commited 2011-09-15 02:29:03 -07:00
7682298a7d
Network stats flag to force complete poll.
Devices currently delay collecting UID stats during common operations
like global alerts to reduce parsing load.  Here we introduce a flag
to always collect UID and iface stats together to aid debugging.

Bug: 5321340
Change-Id: Ia8e1daf1a6f9d5f5cf1f64a04b6b6766ee965ab6

Jeff Sharkey   commited 2011-09-14 19:47:05 -07:00
d34133cad7
Data usage structure optimizations.
Driven by traceview hotspots found in Settings UI.

Change-Id: I614a049523c526b7fcd12fffdf53a3e4723623e4

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

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

Bug: 5269476, 5270106
Change-Id: I721215bfb65127f95775c71cf135e907cd567e92

Jeff Sharkey   commited 2011-09-07 18:06:30 -07:00
d1a5951ed9
Selectively add stats based on iface active state.
Only combine /proc/net/dev and xt_qtaguid stats when iface is marked
as active.  When inactive, only return xt_qtaguid stats.  When iface
is unknown to xt_qtaguid, always pass through /proc/net/dev stats.

Bug: 5242730
Change-Id: I469fc6abe45309f794afebca814cbb39e4f13af5

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

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

Bug: 5198167
Change-Id: I75f1fb44b21da1879f0ab960bcaa481126d70fde

Jeff Sharkey   commited 2011-08-29 16:10:43 -07:00
971cd16561
Always splice historical data stats, debug info.
When reading network counters, always splice in xt_qtaguid values
to avoid counting backwards. Test to verify.

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

Bug: 5212893, 5211028
Change-Id: I783e5286637a67ee2dd2b09878198711a926d0cb

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

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

Bug: 5023631
Change-Id: I04b723d6c4bf872fb1028071122dba66a8e1b576

Jeff Sharkey   commited 2011-08-23 18:46:14 -07:00
d3b657612d
Foreground/background network stats using sets.
Teach NetworkStats about "counter sets" coming from kernel, and use
them to track usage in foreground/background.  Add AID_NET_BW_ACCT to
system_server so it can control counter sets.

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

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

Bug: 5105592, 5146067
Change-Id: Idabec9e3ffcaf212879821515602ecde0a03de8c

Jeff Sharkey   commited 2011-08-15 17:30:25 -07:00
9c11e89fe2
Network stats with varint, omit parcel fields.
Persist NetworkStatsHistory using variable-length encoding; since
most buckets have small numbers, we can encode them tighter. Initial
test showed 44% space savings. Also persist packet and operation
counters.

Let NetworkStatsHistory consumers request which fields they actually
need to reduce parcel overhead.

Tests for verify varint and history field requests, also verify end-
to-end by persisting history into byte[] and restoring. Expose
bandwidth control enabled state. Extend random generation to create
packet and operation counts. Moved operation counts to long.

Fix bug that miscalculated bytes since last persist, which would
cause partial stats loss when battery pulled.

Bug: 4581977, 5023706, 5023635, 5096903
Change-Id: If61e89f681ffa11fe5711471fd9f7c238d3d37b0

Jeff Sharkey   commited 2011-08-03 17:21:07 -07:00
13d6787be8
Add operation counts to network statistics.
Provide API to increment "operation counts" for a UID and tag, used
to eventually derive bytes/operation stats.  Internally is stored at
network layer, but should belong at data layer.  Switch profiling
to use data layer stats, which are emulated by summarizing network
layer details.

Read packet counts from new /proc/ columns and collect them into
NetworkStatsHistory.  Prevent double-counting by ignoring values from
first snapshot.  Watch for duplicate /proc/ entries.  Update tests
to verify packet and operation counters.

Bug: 5052136, 5097392
Change-Id: I1832f65a2b8a9188f8088f253474a667c21a2f09

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

Change-Id: Iedb2d0ab3b26a976811c050f84a164e909eb74b6

Jeff Sharkey   commited 2011-07-14 20:43:27 -07:00
5a0a7aa5a4
Include full network history around current time.
When requesting historical values with time ranges, always include
full values for buckets that span current time.  (It doesn't make
sense to interpolate partial data.)  Move getTotalData() to return
full Entry objects to prepare for packet counts.

Bug: 4691901
Change-Id: I717bd721be9f1d4a47c4121e46e07a56cb15bbf1

Jeff Sharkey   commited 2011-07-12 20:20:56 -07:00
26f35e29cd