summaryrefslogtreecommitdiffstats
path: root/services/tests
Commit message (Collapse)AuthorAgeFilesLines
* Read iface stats from single proc file.Jeff Sharkey2011-10-042-0/+16
| | | | | | | | 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
* Track xtables summary, move tether stats, time.Jeff Sharkey2011-10-031-1/+53
| | | | | | | | | | | 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
* Merge "Allow non-required package verifiers"Kenny Root2011-09-261-0/+205
|\
| * Allow non-required package verifiersKenny Root2011-09-231-0/+205
| | | | | | | | | | | | | | | | | | | | * Verifiers can be specified in the AndroidManifest.xml * Those verifiers can respond to the new Intent action * PackageManager API for those verifiers: verifyPendingInstall Change-Id: I4892bce2e6984871e6e93c60a1ca0dae145f5df5
* | Watch network subtype, tethering teardown, empty.Jeff Sharkey2011-09-221-0/+1
|/ | | | | | | | | | | | | 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
* Sample atomic network stats buckets, full poll.Jeff Sharkey2011-09-181-1/+5
| | | | | | | | | | 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
* NetworkManagement SocketTagger: Migrate QTagUid support to JNI.JP Abgrall2011-09-151-7/+0
| | | | | | | | | | | * 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
* Network stats flag to force complete poll.Jeff Sharkey2011-09-141-0/+1
| | | | | | | | | 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
* Data usage structure optimizations.Jeff Sharkey2011-09-123-46/+46
| | | | | | Driven by traceview hotspots found in Settings UI. Change-Id: I614a049523c526b7fcd12fffdf53a3e4723623e4
* Poll UID stats during iface changes, enforce idx.Jeff Sharkey2011-09-071-0/+8
| | | | | | | | | | | | | | | 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
* Selectively add stats based on iface active state.Jeff Sharkey2011-09-011-0/+14
| | | | | | | | | 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
* Introduce immediate CONNECTIVITY_ACTION variant.Jeff Sharkey2011-08-292-14/+14
| | | | | | | | | | | | 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
* Always splice historical data stats, debug info.Jeff Sharkey2011-08-261-0/+12
| | | | | | | | | | | | 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
* Register for kernel global data usage alerts.Jeff Sharkey2011-08-231-8/+46
| | | | | | | | | | | | | | | 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
* Proactively disable data when over policy limit.Jeff Sharkey2011-08-231-43/+72
| | | | | | | | | | | | | | 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
* Foreground/background network stats using sets.Jeff Sharkey2011-08-156-237/+348
| | | | | | | | | | | | | | | | | 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
* Data cycle ends on last second of month.Jeff Sharkey2011-08-041-5/+66
| | | | | | | | | | | When data cycle resets on a day invalid in given month, snap the cycle to last second of month. Previous behavior was to bump fully into next month, but that causes cycle loops. Includes tests to verify. Bug: 4623124 Change-Id: I2f233091f6f1df33a2814284519cbc04532874e9
* Network stats with varint, omit parcel fields.Jeff Sharkey2011-08-031-4/+6
| | | | | | | | | | | | | | | | | | | | | 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
* Add operation counts to network statistics.Jeff Sharkey2011-07-295-85/+146
| | | | | | | | | | | | | | | | 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
* Revise data limit notifs, watch kernel alerts.Jeff Sharkey2011-07-272-16/+196
| | | | | | | | | | | | | | | | | 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
* Touch exploration state set to clients asynchronously and depended on ↵Svetoslav Ganov2011-07-222-14/+28
| | | | | | | | | | | | | | | | | | | | talking service being enabled. 1. Upon registration of an accessibility client the latter received only the accessiiblity state and waiting for the touch exploration state to be sent by the system in async manner. This led the very first check of touch exploration state is checked a wrong value to be reported. Now a state of the accessibility layer is returned to the client upon registration. 2. Removing the dependency on talking accessibility service to be enabled for getting into touch exploration mode. What if the user wants to use an accessibility service that shows a dialog with the text of the touched view? bug:5051546 Change-Id: Ib377babb3f560929ee73bd3d8b0d277341ba23f7
* Touch exploration separate setting and API to poll the latter state.Svetoslav Ganov2011-07-181-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | 1. Seperated touch exploration to be a seperate setting rather being magically enabled by the system of accessiiblity is on the there is at leas one accessibility service that speaks enabled. Now there is a setting for requesting touch exploration but still the system will enabled it only if that makes sense i.e. accessibility is on and one accessibility service that speaks is enabled. 2. Added public API for checking of touch exploration is enabled. 3. Added description attribute in accessibility service declaration which will be shown to the user before enabling the service. 4. Added API for quick cloning of AccessibilityNodeInfo. 5. Added clone functionality to SparseArray, SparseIntArray, and SparseBooleanArray. bug:5034010 bug:5033928 Change-Id: Ia442edbe55c20309244061cd9d24e0545c01b54f
* Hide NetworkTemplate details, buffered stats I/O.Jeff Sharkey2011-07-142-9/+8
| | | | | | | | 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
* Include full network history around current time.Jeff Sharkey2011-07-121-20/+18
| | | | | | | | | | 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
* Hide NetworkStatsHistory internals.Jeff Sharkey2011-07-123-42/+46
| | | | | | | Instead of exposing internal storage details, offer getValues() accessor which populates values into a recycled structure. Change-Id: I5228d7099a8f61b2018a435a813435a67dae49b4
* Return stats from inactive ifaces, packet counts.Jeff Sharkey2011-07-112-8/+66
| | | | | | | | | | | | | When an iface goes inactive, xt_qtaguid maintains historical counters instead of discarding. Now reading and returning those values in NetworkManagementService summary calls. Tests to verify stats are returned. Modify NetworkStats to include rxPackets and txPackets values, and move to Entry to eventually hide internal storage details. Bug: 4984539 Change-Id: I1ba0bb5580c62e946d9dff2cc2a6f64aff403efc
* Migrate bandwidth control to NMS, omit history.Jeff Sharkey2011-06-301-4/+0
| | | | | | | | | | | | 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
* Enforce background data flag, rules through netd.Jeff Sharkey2011-06-301-2/+37
| | | | | | | | | | 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
* Merge "Push interface quota rules from NetworkPolicyManager to kernel."Jeff Sharkey2011-06-291-7/+11
|\
| * Push interface quota rules from NetworkPolicyManager to kernel.Ashish Sharma2011-06-291-7/+11
| | | | | | | | Change-Id: Id2b758f561820b44839f69bf5fbd676cae771fe3
* | Move socket tagging from libcore.Jesse Wilson2011-06-281-2/+2
|/ | | | Change-Id: I7515896936c5bbd212c88e2801b831914219a925
* Better network stats parsing, integer tags, async.Jeff Sharkey2011-06-285-23/+262
| | | | | | | | | | | | | | 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
* Persist "tagged" network stats along with UIDs.Jeff Sharkey2011-06-191-30/+194
| | | | | | | | | | | | | | | | | 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
* Handle removed UIDs in network stats and policy.Jeff Sharkey2011-06-192-15/+185
| | | | | | | | | | | | 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
* Read "qtaguid" network stats, refactor templates.Jeff Sharkey2011-06-183-34/+40
| | | | | | | | | | | | | | | | 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
* Notify policy listeners about metered ifaces.Jeff Sharkey2011-06-171-11/+19
| | | | | | | | | | 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
* Add permission to fix NetworkPolicy tests.Jeff Sharkey2011-06-161-0/+1
| | | | Change-Id: I4d5265b2b08c1ec0c42b71ad0ceeb9952094caa0
* Fix NetworkPolicy tests after notifications.Jeff Sharkey2011-06-151-6/+20
| | | | Change-Id: I569e9ceba6d89459b347ed151fd9bda2909dc892
* Fix test-related build breakage.Jeff Sharkey2011-06-131-5/+9
| | | | Change-Id: I48a3dbbdc49d742d6ad19cff34ee8da4b3949bb8
* Growable NetworkStats object instead of builder.Jeff Sharkey2011-06-113-16/+15
| | | | | | | | | 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
* Persist UID stats, lazy loading, resize buckets.Jeff Sharkey2011-06-111-61/+173
| | | | | | | | | | | | | | 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
* Move data cycle methods to framework object.Jeff Sharkey2011-06-101-1/+1
| | | | | | | 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
* Interface-level network policy, persist policies.Jeff Sharkey2011-06-102-4/+141
| | | | | | | | | | | | | | | 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
* Persist network stats using AtomicFile.Jeff Sharkey2011-06-091-0/+280
| | | | | | | | | | | | 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
* Collect historical network stats.Jeff Sharkey2011-06-011-4/+8
| | | | | | | | | | | | | | | | | | 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
* Tests for NetworkPolicyManager rule generation.Jeff Sharkey2011-06-014-75/+409
| | | | | | | | | | | | 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
* Accessibility serviceconfiguration via meta-dataSvetoslav Ganov2011-05-312-7/+11
| | | | | | | | | | | | | | | | | | Note: This is a part of two CL change and contains the system changes without updates to the settings. 1. Added a mechanism for configuring an accessibility service via XML file specified in a meta-data tag (similar to IMEs). 2. Added property for specifying a settings activity for an accessibility service. 3. Refactored the APIs in AccessibilityManager to return lists of AccessiblityServiceInfo instead ServiceInfo since the former describes an AccessibilityService in particular (similar to IMEs). Change-Id: Ie8781bb7e0cdb329e583b6702a612a507367ad7b
* APIs to profile network usage for current UID.Jeff Sharkey2011-05-211-0/+2
| | | | | | | | | | | | | | | 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
* Return NetworkStats bundle from NM service.Jeff Sharkey2011-05-041-4/+24
| | | | | | | | | | | | | Introduce NetworkStats which is a collection of network statistics, which should match the structure communicated by kernel module through netd. Will introduce tags and fg/bg stats later. Kept entirely in a flat data structure to optimize parcel speed. Initial pass at returning NetworkStats from NetworkManagementService, both summary and details. Will eventually pull data from kernel module over netd connection. Change-Id: I92d9f61678ec8c22e2ce26775fb035a0cf32413f
* Use passive provider for location based country detectionDaisuke Miyakawa2011-04-281-25/+80
| | | | | Bug: 4345419 Change-Id: Ia3e071b97c6971538ea994fdee6029db928201d6