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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Instead of exposing internal storage details, offer getValues()
accessor which populates values into a recycled structure.
Change-Id: I5228d7099a8f61b2018a435a813435a67dae49b4
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Wrote initial suite of tests for ThrottleService, checking a variety
of edge cases. Checks going over limits, updating policies, and reset
after cycle elapses.
Moved NTP code in ThrottleService into new TrustedTime interface,
which makes it easier to understand, and allows tests to provide custom
clocks.
Change-Id: I0d62b8b3a169516a2ab2d33025f6fe30dc792be8
- Create /data/user directory and symlink /data/user/0 -> /data/data for
backward compatibility
- Create data directories for all packages for new user
- Remove data directories when removing a user
- Create data directories for all users when a package is created
- Clear / Remove data for multiple users
- Fixed a bug in verifying the location of a system app
- pm commands for createUser and removeUser (will be disabled later)
- symlink duplicate lib directories to the original lib directory
Change-Id: Id9fdfcf0e62406a8896aa811314dfc08d5f6ed95
Some API stubs for managing users and storing their details.
List of users is stored in an xml file.
Each user's properties are stored in a separate xml file.
Some unit tests for modifying the XML files.
Change-Id: If2ce2420723111bd426f6762def3c2afc19a0ae5
a. The CountryDetector detects the country the user is in
in order of mobile network, location, sim card or locale.
It will be used by contact and contact provider.
b. All added APIs are hidden at this stage.
Change-Id: I4ba278571ffb6ab6ded0996d4f440a18534f8ed4
We can't use Parcel.writeValue() to write the ParcelFileDescriptor, otherwise
it leaks when returning the value to the caller (the flag gets lost). Change
the way DropBoxManager.Entry gets serialized so that it uses a bit of its own
flags value to track whether the data is a byte[] or a ParcelFileDescriptor.
Modify the dropbox unit test to add extensive checking of Entry serialization
and deserialization under various circumstances, and to include a regression
test to ensure that FD leaking doesn't happen.
Bug: 2847738
Change-Id: I4ccd17dd03ffab234340cd359e6f3510fdf81193