397 Commits

Author SHA1 Message Date
Alan Treadway
44a1808154 Merge "Add explicit and persistent user provisioning state." 2016-01-26 09:59:40 +00:00
Benjamin Franz
6d00903727 Add SmallTest annotation to DevicePolicyManagerTest
Adding this annotation makes sure that the tests get picked up by
continuous integration tests.

Change-Id: Ia9166898803dd0037f6bb20cb6a12333ed347fd3
2016-01-26 09:49:51 +00:00
Alan Treadway
afad878369 Add explicit and persistent user provisioning state.
Add explicit modelling of provisioning state so that integration
of management provisioning flows with packages such as setup-wizard
are cleaner, and can be more direct. Previously we relied upon
USER_SETUP_COMPLETE secure setting and HOME intents to signal intent,
but this is not very clear and can be fragile.

Bug: 25858670
Change-Id: Idc56a040f710c3aee281db420f21717da3960722
2016-01-25 15:46:30 +00:00
Esteban Talavera
fe434a15d6 Merge "Add additional APIs supported work on the parent DPM instance" 2016-01-25 15:19:06 +00:00
Bartosz Fabianowski
4c052f237a Implement user affiliation
A user/profile is considered affiliated if it is managed by the same
entity as the device. This is determined by having the device owner and
profile owners specify a set of opaque affiliation ids each. If the sets
intersect, they must have come from the same source, which means that the
device owner and profile owner are controlled by the same entity.

BUG=25599229

Change-Id: I393fe0de70272307ed3c811aaba4b48a5109c562
2016-01-25 14:18:43 +01:00
Esteban Talavera
6239991850 Add additional APIs supported work on the parent DPM instance
Bug: 22543972
Change-Id: I05061e34d120c64d5c49ca6b7b4014d7dadb68f4
2016-01-25 12:57:12 +00:00
Jeff Davidson
c48e3b602e Merge "Implement roaming tracking in NetworkStats summary queries." 2016-01-20 01:43:02 +00:00
Jeff Davidson
a6a78076ee Implement roaming tracking in NetworkStats summary queries.
Whether a network is deemed roaming or not was already being tracked
as part of the NetworkIdentitySet, so the underlying data store
already tracks roaming and native data separately. However, this data
was being aggregated together in NetworkStatsCollection#getSummary,
since the NetworkIdentitySet is converted to an iface name for the
purposes of matching, and the iface name will be identical whether or
not the iface is considered roaming. Now it is separated.

Also fixes a long-standing bug in NetworkIdentitySet where an identity
read from a saved file would always be considered roaming == false,
even if it wasn't at the time it was written.

Bug: 25813438
Change-Id: I11ab5b51182ed8da7af8fde468df065f9fdc3dad
2016-01-19 16:57:51 -08:00
Suprabh Shukla
3ee3b9d17b Merge "Keeping only running users recents in memory" 2016-01-16 02:00:00 +00:00
Suprabh Shukla
09a88f5f3e Keeping only running users recents in memory
Currently, all the users' recent tasks are loaded into memory and kept
in sync with the persistent storage. This changes the system so
that it loads a users recents into memory lazily (i.e. when
getRecentTasks is called for that user) and unloads them from the
memory as soon as the user is stopped. This also required bucketizing
the taskIds per user, so that the next available taskId can be assigned
without having knowledge of all the tasks that are stored away in
persistent storage but are not available in memory.
Bug-Id: b/24569398

Change-Id: Ia5cb64d9f4ee727225dce34e45ca63e946ac27a8
2016-01-15 17:45:35 -08:00
Shreyas Basarge
17971e383f Merge "Added priority to JobScheduler scheduling" 2016-01-15 13:54:08 +00:00
Shreyas Basarge
5db09084c8 Added priority to JobScheduler scheduling
Priority can be assigned to jobs. Higher priority
jobs can preempt lower priority ones. Reason for
calling onStopJob (timeout, preempt, etc.) is set
on the JobParameters object.

Reference:
https://docs.google.com/document/d/1fuVO5rBCkODx8wjk6uulFCP1Uzfx7IVsw2EyKKrGqVA

Change-Id: Ic36016514cec076984d44086316d8d00d896b3aa
2016-01-14 19:09:03 +00:00
Udam Saini
b6bb986889 Merge "Makes captive portal server calculation in one place." 2016-01-12 18:40:45 +00:00
Jeff Sharkey
4175be2f4e Triage SearchManagerService for missing apps.
Searchables aren't available until after the user is unlocked.  We
could scan for them while locked, but we're aiming for a minimalist
environment, and scanning them while locked would require us to send
a changed broadcast on every boot.

Switch to using new SystemService lifecycle for faster event
delivery.  Restore broken global search observer.  Verified that
apps on external storage are handled correctly.

Bug: 26471205
Change-Id: Id99ffe2ea6db37a394454cc7dfa4eab10280ff35
2016-01-09 14:57:47 -07:00
Udam Saini
b7c2487c8b Makes captive portal server calculation in one place.
This also creates a hidden api for the captive portal server calculation
so that the Setup Wizard can use this as well.

bug:13246857
Change-Id: I4dfd0916df97cfce13252c7cc15f7bd05ed95f77
2016-01-08 14:38:31 -08:00
Jeff Sharkey
51f3908c6a Merge "Consistent naming for PackageManager methods." 2016-01-06 22:26:16 +00:00
Jeff Sharkey
e06b4d1d9f Consistent naming for PackageManager methods.
When hidden PackageManager methods take a userId argument, they
should be named explicitly with the "AsUser" suffix.  This fixes
several lagging examples so that we can pave the way to safely
start passing flags to new methods without scary overloading.

Also fix spacing issues in various logging statements.

Change-Id: I1e42f7f66427410275df713bea04f6e0445fba28
2016-01-06 15:21:06 -07:00
Kenny Guy
028d6906d5 Merge "Add support message for device admins" 2016-01-06 16:27:18 +00:00
Kenny Guy
06de4e77c2 Add support message for device admins
Allow admins to set a long and short support
message for settings to display.

Bug: 25659579
Change-Id: Ib645490785642e49c69d8dbc65455eb3398547ee
2016-01-05 19:07:04 +00:00
Chris Wren
51017d0e23 implement assistant service connection
Added a guest-mode to ManagedServices.
Like system services, the lifecycle of a guest is not managed.
Unlike system services, guests are not considered privledged.

The Assistant gets all the usual listener events.
Implemented adjustImportance.
Future work: enqueued, clicked, visibility, removed, annotations

Bug: 22455414
Change-Id: Ic41c0bf625b5e98cb577b49098bba23a539bb507
2016-01-04 11:22:37 -05:00
Mahaver Chopra
f8373b5afc DPM Test: DA and PO cannot call DPM.reboot()
Bug: 25304994
Change-Id: Ifaccf3625314f4bfcd7f99413abc9067cc3dd2f9
2015-12-29 15:39:02 +00:00
Esteban Talavera
bf60f728cc Device or profile owner can let another app manage app restrictions
The device or profile owner can allow another
package to set app restrictions for any app in that user

Similar to the way it can give permission to access
CA certificate related APIs from M.

Bug: 22541936
Change-Id: I0c1b0804ad300dfa4fbdc1c7721c5d8653d77861
2015-12-17 10:57:09 +00:00
Jeff Davidson
40e2ce37d3 Merge "Relax permissions around NetworkStatsManager APIs." 2015-12-15 19:04:25 +00:00
Jeff Davidson
c14fb58da8 Merge "Fix bit-rotted NetworkStatsServiceTest." 2015-12-15 17:48:46 +00:00
Jeff Davidson
1efb133581 Relax permissions around NetworkStatsManager APIs.
Currently, access to network usage history and statistics requires a
signature|privileged permission, an AppOps bit (associated with the
PACKAGE_USAGE_STATS permission), or device/profile ownership. Once
access is granted via one of these mechanisms, it generally applies to
any UID running in the same user as the caller.

This CL expands access as follows:

-Any app can access its own usage history with no extra requirements.
-Carrier-privileged applications can access usage history for the
entire device.
-Device owners can access per-UID breakdowns for usage. Previously
they could access the summary for the whole device, but not the
individual breakdowns.

We simplify the permission model by defining three access levels -
DEFAULT (own app only), USER (all apps in the same user), and DEVICE
(all apps on the device), and propagate these levels throughout.

Finally, this CL fixes an apparent bug in
NetworkStatsSerice#hasAppOpsPermissions - if the AppOp bit was in
MODE_DEFAULT, hasAppOpsPermission would always return false instead of
falling back to the PackageManager permission check.

Bug: 25812859
Bug: 25813856
Change-Id: Ic96e0776e2a4215a400163872acea1ededfaced9
2015-12-14 17:16:37 -08:00
Jeff Davidson
b7e3fd80e5 Fix bit-rotted NetworkStatsServiceTest.
Breakages:

-ag/574873 - Renders testReportXtOverDev obsolete as this is no longer
             a supported mode. Test has been removed.
-ag/600223 - Tests were sending a CONNECTIVITY_ACTION bcast to trigger
             a call to updateIfaces(), but the listener was removed.
             Tests now call forceUpdateIfaces() directly.
-ag/648284 - Calls to get VPN info were not mocked.

Change-Id: I309f2b5d006549104cb1d3cb83e99363dd6dac16
2015-12-14 13:05:30 -08:00
Julia Reynolds
72be84fd8c Merge "use importance instead of score" 2015-12-11 21:21:50 +00:00
Chris Wren
bdf3376616 use importance instead of score
Change-Id: Id3b0a074671943b4fcabb63fe990cbfd1e46bdfd
2015-12-11 16:09:18 -05:00
Makoto Onuki
055d8396ef Merge "Allow PO to set DO restrictions if it's on user 0" 2015-12-11 18:14:19 +00:00
Makoto Onuki
5485ed46ff Allow PO to set DO restrictions if it's on user 0
Bug 26091525

Change-Id: Ie6d2cd4ade076d8d2ec47243ff1280b95b7c9044
2015-12-10 15:54:26 -08:00
Dianne Hackborn
e0e413e2b1 Add new target SDK filtering feature to BroadcastOptions.
You can now control the range of target SDKs that receivers
will be need to have in order to receive your broadcast.

Use this for CONNECTIVITY_ACTION to not allow N+ applications
to receive these broadcasts through their manifest.

Also tweak the broadcast debug output code to now include the
disposition of each receiver in the list.  This is becoming
important as skipping receivers is becoming a more common
thing to have happen.

Change-Id: I251daf68575c07cbb447536286ab4e68b7015148
2015-12-10 12:12:00 -08:00
Xiaohui Chen
b3b9258ab6 UserManager: get/set user account name
Bug: 25935510
Change-Id: I0b621fb300be74209534e08a11f1d1a7c049cd5a
2015-12-07 11:32:50 -08:00
Julia Reynolds
c030986883 Merge "Topics can now have an Importance." 2015-12-04 20:37:28 +00:00
Julia Reynolds
5d25ee7a00 Topics can now have an Importance.
Bug: 22451710
Change-Id: I627121da6c4b85492715a8e8a099656dca52b734
2015-12-04 15:20:34 -05:00
Jeff Sharkey
9d8a1048bb Handle non-encryption-aware accounts and sync.
The system can now boot in a "locked" state where only encryption
aware (EA) components can be safely started.  When in this state,
PackageManager already filters away non-EA components, but system
services like AccountManager and SyncManager need to carefully handle
these temporarily "missing" components.

As a guiding principle, all known Accounts are still present when
the device is locked, but communication with underlying non-EA
authenticators is blocked.

To keep things simple for now, all SyncManager requests are kept
dormant until the user enters the unlocked state.

The core of this logic is that RegisteredServicesCache now works
with all components regardless of EA status, which prevents us from
accidentally thinking a service was removed when the user is locked.

Bug: 25945136
Change-Id: I8714121f6236b00821769023c4df7de1c8a99944
2015-12-04 09:36:39 -07:00
Shreyas Basarge
7ef490fab6 Fix for non persisted jobs being persisted
Bug: 25905179
Change-Id: I5e836f9894089aa8acc1bde382674e29402f0a60
2015-12-04 14:40:28 +00:00
Fyodor Kupolov
9cbfc9e212 Added DISALLOW_RUN_IN_BACKGROUND user restriction
It forces the user to stop instead of going into the background. Also
changed behavior of stopUser method. Now it also attempts to stop related
users along with the specified userId.

Based on ag/807976, with the only difference that it's now a user restriction.

Bug: 24579258
Bug: 24708668
Change-Id: I357298908816fc58feeed83b7e9979fc33d25da6
2015-12-02 10:22:23 -08:00
Lorenzo Colitti
2c1a253f22 Fix one of the breakages of ConnectivityServiceTest in master.
Change-Id: I31c7a019383fa589beb1572486700e54edfb97e8
2015-11-27 11:46:18 +09:00
Makoto Onuki
e7927da1b6 Don't call DPM from UserManager to avoid lock inversion
- Also make sure DPMS.mOwners is always guarded with DPMS.this.
(and remove synchronization from Owners.)

Bug 25796840

Change-Id: I83f7b78e7b437d9c2a2b1d6e714346cd15f95330
2015-11-25 11:17:08 -08:00
Makoto Onuki
3ab6f2e219 DA receiver should be protected with BIND_DEVICE_ADMIN.
- DPM.setActiveAdmin() will not accept DAs without BIND_DEVICE_ADMIN
when it's targeting NYC or above.

- DAs without BIND_DEVICE_ADMIN targeting MNC or below will still be
accepted. (with a logcat warning)

- DAs that are already set on a device without BIND_DEVICE_ADMIN
will still be accepted regardless of the target API level, even when
it's upgraded to a version targeting NYC.

Bug 24168653

Change-Id: I1914c2ec99135d9dd8cbac3f6914f9e43bafacc8
2015-11-24 16:14:21 -08:00
Makoto Onuki
a31ebbc439 Add DO API to get wifi mac address
Bug 25496044

Change-Id: Ib1f0ce4ca10951edcfaa0aa79ae5c2d142a74599
2015-11-24 15:38:16 -08:00
Makoto Onuki
c8a5a555f1 DPM.isDeviceOwnerApp() and getDeviceOwner() now check calling user
- Previously on MNC, they would return the same result regardless who
the calling user is.

- Now they properly take DO user-id into account.  Meaning, they'll
always return false and null respectively, if the calling user doesn't
run device owner.

- Note isDeviceOwnerApp() is a public API and getDeviceOwner() is
a system API.  Meaning we're changing the behavior or non-private
APIs.

- Also cleaned up hidden APIs, and gave them explicit suffixes
to avoid confusion.  Bundled code should prefer them for clarity.

Now we have:

* APIs that work cross-users: They all require MANAGE_USERS.
boolean isDeviceOwnerAppOnAnyUser(String packageName)
ComponentName getDeviceOwnerComponentOnAnyUser()

int getDeviceOwnerUserId()
boolean isDeviceOwnedByDeviceOwner()

String getDeviceOwnerNameOnAnyUser()

* APIs that work within user.  No permissions are required.

boolean isDeviceOwnerAppOnCallingUser(String packageName)
ComponentName getDeviceOwnerComponentOnCallingUser()

Bug 24676413

Change-Id: I751a907c7aaf7b019335d67065d183236effaa80
2015-11-24 14:54:48 -08:00
Makoto Onuki
42490c074d Merge "Remove UserManager.setSystemControlledUserRestriction()" 2015-11-23 18:42:55 +00:00
Makoto Onuki
ac65e1e1db Remove UserManager.setSystemControlledUserRestriction()
Now that we don't have UM.setUserRestriction*s*() that could remove
all existing restrictions, there's almost no point handling
DISALLOW_RECORD_AUDIO differently.

Now DISALLOW_RECORD_AUDIO is handled just like other restrictions,
except we don't persist it.

Bug 24954662

Change-Id: I27875b4a74dd95a3ce6bb774081eeaf718eaec15
2015-11-23 10:41:42 -08:00
Lorenzo Colitti
b85c7d5bc0 Merge "Add a test that checks the contents of DISCOVER packets." 2015-11-22 16:34:09 +00:00
Fyodor Kupolov
09b108e2bb Merge "Added keep-uninstalled-packages DO policy" 2015-11-20 23:18:29 +00:00
Fyodor Kupolov
cb6fd80721 Added keep-uninstalled-packages DO policy
This policy allows DO to specify a list of apps to cache even without being
installed on any user.

Bug: 23938464
Change-Id: I2eeab7f148409739fc23a5c44e955ad12b63fd04
2015-11-20 14:51:56 -08:00
Przemyslaw Szczepaniak
3f72604be8 Use HexDump instead of java.lang.IntegralToString
java.lang.IntegralToString is being removed, replaced
all its usage by com.android.internal.util.HexDump.

Bug: 24932279
(cherry-picked from 15fc0548a536750110e159e06a39ba943eccdd81)

Change-Id: Id6ab88337af12d93cd73c41775b9d5baa1e61d96
2015-11-20 14:11:02 +00:00
Makoto Onuki
1a2cd74526 More work on layered user restrictions.
- Now when DO/PO sets a user restriction, DPMS pushes it to UMS and
then UMS persists it, in order for UserManager.hasUserRestriction()
to never have to talk with DPMS, which would cause lock inversion.

- Also apply user restrictions when a user start.

- This is an updated version of the abandoned CL -- the difference
is, ActivityManager no longer has to call DPMS.

- Also removed an unnecessary write to userlist.xml in UMS.
upgradeIfNecessaryLP().

Bug 23902097
Bug 25388912
Bug 25354031
Bug 25641040

Change-Id: I0948aea06ad7d0f45fe612a431d765faddfe3c58
2015-11-19 13:37:21 -08:00
Lorenzo Colitti
6c7acb6ec7 Add a test that checks the contents of DISCOVER packets.
Change-Id: I571d560cf7032babf7b7867ad748e2a896116ce7
2015-11-17 16:36:18 +09:00