97 Commits

Author SHA1 Message Date
Amith Yamasani
2a00329c6d UserHandle to UserSerialNo mapping
Use AtomicFile for usermanager files.

Added a MANAGE_USERS permission that apps (signature permission) can use
to create/query/modify/remove users.

Change-Id: I5cf232232d0539e7508df8ec9b216e29c2351cd9
2012-08-17 09:06:10 -07:00
Dianne Hackborn
f02b60aa4f Rename UserId to UserHandle.
This is the start of turning this into a formal public API.

Change-Id: I5786d2c320f1de41a06ed5d0f65adb68967287a0
2012-08-16 12:46:38 -07:00
Amith Yamasani
258848d2ae 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
2012-08-11 18:24:07 -07:00
Jeff Sharkey
fb878b66b9 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
2012-08-08 16:23:41 -07:00
Amith Yamasani
b8151ecd6e Add an icon to the user information.
Store the icon in the user folder under /data/system,
similar to how the wallpaper is stored.

Change-Id: Id8ccb55b9e2ba7b4c557505a7f69f04eca1518cf
2012-06-12 18:18:29 -07:00
Jeff Sharkey
787c9ec558 Merge "Transition from DEV network stats to XT." into jb-dev 2012-05-18 11:40:42 -07:00
Jeff Sharkey
70c70530bd 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
2012-05-17 10:10:39 -07:00
Svetoslav Ganov
53e184d34e Accessibility service needs to request permission to be bound to.
1. Every accessibility services targeting JellyBean or higher has
   to request a special permission for the system to bind to it.

Change-Id: I6e579326bdf3597f148d6c67317455701ec8af68
2012-05-16 15:57:15 -07:00
Geremy Condra
3d33c268cc Adds support for the CertBlacklister.
The CertBlacklister is a mechanism for allowing is to use gservices
to blacklist certs by serial number or public key.

Change-Id: Ie4b0c966a8a43c9823fb550c0b1691204f133ae7
2012-05-12 13:09:45 -07:00
Jeff Sharkey
0cf6de0c93 Fix network stats and policy tests.
Bug: 6299195
Change-Id: I1941b5f7329940cc7469bd3fda17c3dc3a656250
2012-05-04 15:15:42 -07:00
Jeff Sharkey
ac3fcb1590 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
2012-05-03 12:12:10 -07:00
Jeff Sharkey
e8914c3627 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
2012-05-01 21:04:26 -07:00
Jeff Sharkey
bfdd680ab4 Migrate to @Override to remove warnings.
Bug: 6303344
Change-Id: I0d33b2ed448467379d576ccd71fb5ae20c878852
2012-04-09 10:57:21 -07:00
Jeff Sharkey
b52e3e5509 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
2012-04-06 13:38:29 -07:00
Jeff Sharkey
8fc27e8b87 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
2012-04-05 16:02:25 -07:00
Amith Yamasani
135936072b User management and switching
Broadcast intents that get sent out when users are added/removed/switched.

More work on generating user-specific information in package manager queries.
APIs to update user name and query a user by id.
Removed Package.mSetStopped and mSetEnabled, since they're not user specific.

User removal:
- Cleanup ActivityManager, PackageManager, WallpaperManager, AppWidgetService
  and AccountManager.
- Shutdown processes belonging to the user.

Don't show vibrate option in long-press power if there's no vibrator.

Lock the screen when switching users, to force unlocking.

Change-Id: Ib23a721cb75285eef5fd6ba8c7272462764038fa
2012-03-27 11:23:01 -07:00
Jeff Sharkey
6143f31537 Merge "NetworkPolicy multi-user tests." 2012-03-22 15:29:40 -07:00
Jeff Sharkey
cae04a29da NetworkPolicy multi-user tests.
Bug: 6214004
Change-Id: If13023a689dadfefe1475e0ef2f192922f2e7753
2012-03-22 15:18:57 -07:00
Amith Yamasani
ad812a23df Merge "Package restrictions per user" 2012-03-22 15:11:51 -07:00
Jeff Sharkey
4b63d69759 Fix test breakage.
Change-Id: I2c5fc8c3bf7795ccdd474caa3f858e9a56f026ed
2012-03-22 12:36:45 -07:00
Amith Yamasani
483f3b06ea Package restrictions per user
Packages can be enabled/disabled per user.
This requires maintaining stopped/launched states and
enabled / disabled components and packages per user.

Refactored pm.Settings and PackageSettingsBase to keep
track of states per user.

Migrated the stopped-packages.xml to users/<u>/package-restrictions.xml

Changed intent resolution to handle individual user restrictions.
Bunch of IPackageManager calls now have a userId argument.
Make AppWidgetService handle removals of packages.

Added some tests for pm.Settings and PackageManager.

Change-Id: Ia83b529e1df88dbcb3bd55ebfc952a6e9b20e861
2012-03-22 10:08:24 -07:00
Jeff Sharkey
9bf3150cfa 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
2012-03-09 17:10:05 -08:00
Jeff Sharkey
241dde2306 Unify shorthand for byte-based units.
Change-Id: If990859dee3f0973e1d4c48f05312c84071b3328
2012-02-03 14:50:13 -08:00
Jeff Sharkey
0e2e5f8b56 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
2012-02-02 16:22:33 -08:00
Jeff Sharkey
63abc37356 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
2012-01-24 11:13:14 -08:00
Jeff Sharkey
f60d0afd1e 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
2011-12-15 14:30:04 -08:00
Makoto Onuki
f9165b7e43 MCC detection fixes for CountryDetector
- Don't get and cache phone tpe at the initialization time.  At this point
TelephonyManager is probably not ready yet.

- Refresh MCC whenever we get the service state changed callback, even when
the state hasn't actually changed, in order to make sure we get refresh
country properly when MCC changes.

- Also remove the initialization of mPhoneStateListener, which prevented us from
registering phone state listener properly.

- Also fix tests which were already failing.

Bug 5670680

Change-Id: Id45abeba1b1e843053ac2c946861b439ca568de4
2011-12-09 17:55:18 -08:00
Jeff Sharkey
31c6e4817f Move NativeDaemonConnector to varargs.
Perform uniform argument escaping inside NativeDaemonConnector, using
varargs to separate boundaries.  Also move to parsed NativeDaemonEvent
instances instead of raw Strings.

Bug: 5472606
Change-Id: I1270733e2b2eeb2f6b810240df82ab24d38ebf40
2011-11-29 12:09:06 -08:00
Nick Kralevich
8549aeea0a Merge "Rename EntropyService to EntropyMixer" 2011-11-17 15:30:46 -08:00
Nick Kralevich
6967cbc959 Rename EntropyService to EntropyMixer
EntropyService implies that this program provides entropy to other
programs, and is misleading. The EntropyMixer class is designed purely
to stir the existing entropy pool with some possibily random-ish data,
and carryover entropy across device reboots.

Change-Id: I086cd339a3b652d32371521e61e1b1f555ce2280
2011-11-17 13:29:58 -08:00
Jeff Sharkey
c506ff6150 Only write network stats when already loaded.
Bug: 5584564
Change-Id: Ife2a68804bf3691e9bccdc167807204bce8a85b2
2011-11-17 12:05:46 -08:00
Jeff Sharkey
7ee8658453 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
2011-11-14 20:11:38 -08:00
Jeff Sharkey
163e6443f2 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
2011-11-02 15:14:11 -07:00
Jeff Sharkey
1059c3c30a 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
2011-10-09 13:49:08 -07:00
Jeff Sharkey
ae2c181083 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
2011-10-04 13:22:39 -07:00
Jeff Sharkey
905b5891d2 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
2011-10-03 17:21:05 -07:00
Kenny Root
8a663c89a3 Merge "Allow non-required package verifiers" 2011-09-26 09:53:06 -07:00
Kenny Root
05ca4c9064 Allow non-required package verifiers
* 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
2011-09-23 16:03:03 -07:00
Jeff Sharkey
367d15ab1a 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
2011-09-22 16:19:06 -07:00
Jeff Sharkey
34c73acf88 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
2011-09-18 16:27:21 -07:00
JP Abgrall
98a4f7e7e1 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
2011-09-15 02:29:03 -07:00
Jeff Sharkey
991d1b1b3f 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
2011-09-14 19:47:05 -07:00
Jeff Sharkey
69b0f63af2 Data usage structure optimizations.
Driven by traceview hotspots found in Settings UI.

Change-Id: I614a049523c526b7fcd12fffdf53a3e4723623e4
2011-09-12 16:13:20 -07:00
Jeff Sharkey
b3d5957604 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
2011-09-07 18:06:30 -07:00
Jeff Sharkey
0fea823673 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
2011-09-01 15:23:38 -07:00
Jeff Sharkey
961e304583 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
2011-08-29 16:10:43 -07:00
Jeff Sharkey
47eb102b40 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
2011-08-26 14:19:54 -07:00
Jeff Sharkey
8e9992ae50 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
2011-08-23 18:46:14 -07:00
Jeff Sharkey
8e28b7d782 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
2011-08-23 18:45:44 -07:00
Jeff Sharkey
b5d55e302d 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
2011-08-15 17:30:25 -07:00