410 Commits

Author SHA1 Message Date
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
Alan Treadway
883f12ac5a Merge "Revert "Disable multiple user for corp-liable mode"" 2015-11-23 17:58:39 +00:00
Alan Treadway
86e5d6b868 Revert "Disable multiple user for corp-liable mode"
This reverts commit 1dc510eb5bc7f279002a3479f24761f08cc390f7.

Change-Id: I12ea8275369cbdc4e95b21c7f5d51b4f0e5da7b2
2015-11-23 17:40:54 +00:00
Ricky Wai
9aa233899f Merge "Add work contacts directory support in Quick Contacts API" 2015-11-23 14:50:06 +00:00
Ricky Wai
494b95d302 Add work contacts directory support in Quick Contacts API
Bug: 25764505

Change-Id: I61f9d13ea03352e3df1686ee4b3bcc43e9a9a760
2015-11-23 13:32:45 +00:00
Mahaver Chopra
71c84e515e Merge "Disable multiple user for corp-liable mode" 2015-11-23 10:07:43 +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
Mahaver Chopra
1dc510eb5b Disable multiple user for corp-liable mode
Bug: 25443050
Change-Id: Iad34e7ad0d3679626880f905f9bab9b6c2a192ed
2015-11-20 16:10:42 +00:00
Sudheer Shanka
d7b43dd4bb Merge "Add per-user version of DevicePolicyManager.getUserRestrictions." 2015-11-20 12:23:54 +00:00
Makoto Onuki
1fae502824 Merge "More work on layered user restrictions." 2015-11-19 22:53:37 +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
Jeff Sharkey
ba51235ef5 More file-based encryption work.
Add new "am unlock-user" command so we can trigger changes from the
command line.

Move FBE check to static method so it can safely be called early
during boot before the mount service is ready.  Move FBE emulation
to persisted system property, and start reading/writing that value.

Change default permission grants to ignore current encryption-aware
flags, since many of the target apps aren't crypto aware.

Always prepare package data directories, which is how we create the
new "user_de" paths during boot.

Bug: 22358539
Change-Id: I6f58ea2d34b3a466d3775d614f8a13de92272621
2015-11-19 11:02:30 -07:00
Makoto Onuki
a87401054f Merge "Allow PO to clear password even if the same apk has DA" 2015-11-17 22:11:20 +00:00
Makoto Onuki
c2f521a7d8 Allow PO to clear password even if the same apk has DA
Bug 25645900

Change-Id: I7d2d9fbf6a4dc65ac63fb14e6ee6b9abc1f1c0e7
2015-11-17 14:10:12 -08:00
Sudheer Shanka
1c277a5d8f Add per-user version of DevicePolicyManager.getUserRestrictions.
Bug: 25663001
Change-Id: Ic5b34fee7b57670c338f11263330a1c702002edc
2015-11-17 19:28:15 +00:00
Alan Treadway
0c9ce28c12 Fix edge-cases for split-user provisioning cases.
Split-user systems will allow for combinations of management modes,
specifically managed-{user,profile} on systems with a device-owner.

Bug: 25671630
Bug: 25680065
Change-Id: I5716f55eb6c8318129b4614adc22897d53901bee
2015-11-17 17:41:41 +00:00
Alan Treadway
46dd449420 Add new ACTION_PROVISION_MANAGED_SHAREABLE_DEVICE intent action.
Bug: 25462877
Change-Id: I14bcabf993436d9936091aa82fab698eced9e4d6
2015-11-13 10:22:53 +00:00
Makoto Onuki
70f929eede Disallow DA to reset password, also fix all DO checks
Now pure DA (not PO, not DO) aren't allowed to change the password
if one is already set.

Also update "isDeviceOwner" check and make sure we always take
user-id into account.  If one really wishes to check the package name
only, then use getgetDeviceOwner() instead.

Also change the enforceNotManagedProfile() check to what's more
generic in the FBE world.

Bug 25645900
Bug 25547523
Bug 25643916

Change-Id: I588ecf9452fe3acc1fb0b4ca0457ad662382fcd2
2015-11-12 16:08:53 -08:00
Andrei Stingaceanu
bfd2290824 Merge "Introduce APIs in DPM for setting/getting the device owner info" 2015-11-12 10:47:07 +00:00
Makoto Onuki
54b5f25b85 Merge "Revert "Do not call into ActivityManager from DPMS within DPMS lock"" 2015-11-12 01:39:44 +00:00
Makoto Onuki
219bbafc3f Revert "Do not call into ActivityManager from DPMS within DPMS lock"
Bug 25567963

This reverts commit 53de36f9c40c9a4ac1eb9cca8f458aa6c998c1fd.

Change-Id: I4faaa0b4c50d75e208f37b99bc1d6e2f0fff8127
2015-11-12 01:38:47 +00:00
Andrei Stingaceanu
6644cd9630 Introduce APIs in DPM for setting/getting the device owner info
This information, if set, will be shown in the lock screen instead
of the user owner information and the settings tile will be made readonly
(implementation in following CLs).

Bug: 22547309
Change-Id: Ic826d8049bc67f5e8fcfa6a91aa2017247c93b11
2015-11-11 14:00:43 +00:00
Makoto Onuki
246b5a0993 Merge "Do not call into ActivityManager from DPMS within DPMS lock" 2015-11-10 22:57:05 +00:00
Makoto Onuki
53de36f9c4 Do not call into ActivityManager from DPMS within DPMS lock
This will allow AMS to call into DPMS within the AMS lock instead,
which will help  I1537bd57b34696768ee81a979d53bb396efbc12a.

- AM.clearApplicationUserData() will not be allowed for any DA
apps.

Bug 25567963

Change-Id: I9f0d071c815a011be4f4c85c502c39d0fe0fe5e8
2015-11-10 14:55:30 -08:00
Mahaver Chopra
5e73256a48 Add ACTION_PROVISION_MANAGED_USER
Adding ACTION_PROVISION_MANAGED_USER to DevicePolicyManager.

Bug: 25462684
Change-Id: Ic90c3471f3a9c431d728197a19ab25b9946f090a
2015-11-10 10:58:51 +00:00
Nicolas Prévot
d59262667c Merge "Add method to tell the dpc if provisioning is allowed." 2015-11-09 13:49:31 +00:00
Makoto Onuki
6d2beef6a8 Merge "Add DPM.getUserRestrictions()" 2015-11-06 18:32:35 +00:00
Makoto Onuki
3a3092fab0 Add DPM.getUserRestrictions()
This returns per-DO/PO restrictions.

Bug 23902097

Change-Id: I225c1b01444fe2f60e5a6674d327182cc9bb15dc
2015-11-06 10:30:08 -08:00
Makoto Onuki
86cd001e36 Merge "Have AudioService listen to DISALLOW_UNMUTE_MICROPHONE and" 2015-11-06 18:29:12 +00:00
Makoto Onuki
0953033842 Merge "Do not allow DO and PO running on the same user." 2015-11-06 18:28:55 +00:00
Makoto Onuki
803d6757fd Do not allow DO and PO running on the same user.
Bug 25346603

Change-Id: Ic5fbed82466a538fbf64ef802fc2624dd67313bb
2015-11-05 14:11:53 -08:00
Makoto Onuki
d45a4a2ecb Have AudioService listen to DISALLOW_UNMUTE_MICROPHONE and
... DISALLOW_ADJUST_VOLUME, instead of UserManager pushing
new settings to AudioService.

Also:
- Allow PO to set these two restrictions.

- Now AS.setMasterMuteInternal() respects mUseFixedVolume to make
it consistent with readPersistedSettings().

- When a user switches and restores the mute state in
AS.readPersistedSettings(), also check the current user restrictions
in addition to system settings. Because of the delay in AudioService
before persisting the mute settings in setMasterMuteInternal() and
setMicrophoneMute(), there's was an edge case
DISALLOW_UNMUTE_MICROPHONE and DISALLOW_ADJUST_VOLUME would be ignored
when the user switches right after they are set.

Bug 24981972

Change-Id: I4d9b709a0a0e6812319204568c6e44d6664bdeb4
2015-11-04 14:29:31 -08:00
Nicolas Prevot
07387fedfa Add method to tell the dpc if provisioning is allowed.
The DPC can use it to tell if provisioning a managed profile or for
device owner would work or not.

BUG:25338478
Change-Id: I09ea6a9f23a8e88e4ed37c048170b2a68213086e
2015-11-04 14:50:22 +00:00
Clara Bayarri
965da39942 Create a File Based Encryption check API
Change-Id: Ibf41f98818ea801b9f690200c340be80c3b9bf31
2015-11-04 12:27:39 +00:00
Fyodor Kupolov
8240275381 Introduced short-term lock for UMS internal state
Added mUsersLock - short-term lock for internal state, when interaction and
synchronization with PM is not required. Modifications to mUsers and
mRemovingUserIds must be guarded by 3 locks: mInstallLock, mPackagesLock and
mUsersLock. While reads can use mUsersLock.

Testing revealed that the following methods in UMS often cause contention:
- exists
- getUserInfo
- getProfileParent

They all now use a short-term lock mUsersLock for reads.

Bug: 24979571
Change-Id: Ie3a22ea7cbb450c7969800fe2a4a2b2516165e5b
2015-11-03 11:56:33 -08:00
Makoto Onuki
4f16073556 Make UserManager enforce user restrictions, not DPM.
- Now even if a user restriction is set via UserManager, it'll be correctly
enforced.

- Changed the way AudioService enforces the OP_MUTE_MICROPHONE and
OP_AUDIO_MASTER_VOLUME app ops -- previously, when they're set, even a muting
call would be rejected.  This was why DPMS.setUserRestriction() used different
calling orders for DISALLOW_UNMUTE_MICROPHONE/DISALLOW_ADJUST_VOLUME depending
on setting them or clearing them.
Now, even when the app ops are set, we still allow muting calls.

Bug 23902097
Bug 24981972

Change-Id: I865b5de43e15f5955f94006475a5ec6254904d31
2015-11-02 14:07:11 -08:00
Makoto Onuki
759a763f5f Allow DO to disable camera device-wise.
Bug 24538855

Change-Id: I421690f14ee57fa818d2b233fe48a90a0a575a9e
2015-11-02 13:33:58 -08:00
Makoto Onuki
068c54a5be Layer user restrictions
- Now DPMS remembers user restrictions set by DO / PO in their ActiveAdmin.

- User restrictions set by DO/PO will no longer be saved by UserManger.  Instead,
when needed, UMS will consult DPMS to build "effective" user restrictions.

- UM.getUserRestrictions() will now always return "effective" user restrictions.

- DPMS migrates existing user restrictions per the eng spec.

- Also now UM.setUserRestrictions() will crash.  UMS.setUserRestrictions() has
been removed.
This was needed because UM.setUserRestrctions(UM.getUserRestrictions()) will no
longer be a valid use like it used to be.

- Also introduced a fined-grained lock for user restrictions in UM to avoid
deadlock between DPMS and also for better performance.

Bug 23902097

Change-Id: If0e1e49344e2f3e9226532d00777976d1eaa7df3
2015-10-27 14:26:06 -07:00
Xiaohui Chen
6655630c96 Clean up UserHandle.isOwner() in frameworks
Bug: 24869636
Change-Id: Ibebd7d0762f5375ee93ec101e7ab5578769bd9f6
2015-10-21 20:57:04 +00:00
Clara Bayarri
07b668e3ab Enable Work Profile passphrase verify/write with FBE
When File Based Encryption is present, allow the verify/write of
passphrases to be per-user (it used to always bubble up to the parent
user assuming it is a per-device passphrase).

This is part of the work for the Separate Work Challenge.

Change-Id: I5ae6b7b6ed1dd25aed0843d495b6f5f36e01c4eb
2015-10-19 17:21:26 +01:00
Makoto Onuki
a52562ca9a setDeviceOwner() now requires a full component name.
Bug 20149907

Change-Id: I24e66159d1d966925aa3a494b1e2839b07cdafa2
2015-10-05 16:05:15 -07:00
Makoto Onuki
a4f119790e First cut of user restriction layering.
- Start persisting restrictions set by DO/PO.

- Also dump user restrictions on dumpsys

- More changes will follow, including migration.

- Now System settings are mockable.

Bug 23902097
Bug 23902477

Change-Id: I0bda22f484e1a8e259a1feb2df83c5f4a29116da
2015-10-05 15:20:07 -07:00
Craig Lafayette
e7ee54ee7f Remove device initializer agent
Bug: 23216982
Change-Id: I867c0b5f4165983d1ed2623a655f6a2a5e3770bb
2015-10-02 13:11:57 -04:00
Makoto Onuki
72a3a0c7d2 Fix OwnersTest when run with -e package
It was because UserManager.get() returns a static cached instance but
we should always be using the mock instance that's created for each test.

Bug 24378326

Change-Id: Id4663e7676d2d0130622055a97fbde0884714349
2015-09-25 16:01:43 -07:00
Makoto Onuki
b643fb0e67 Use a factory class for dependency injection, add more tests.
- Extracting into a factory allows us to use mocks in other classes.
(Such as Owners.)

- Also removed broken test ApplicationRestrictionsTest.  Instead added a new
simplified test to DevicePolicyManagerTest.

- Also stop caching rarely used instances in DPMS.

Bug 24061108
Bug 24275172

Change-Id: Ice9e57204b18e7b5f6b115126dab2209041439c2
2015-09-25 15:36:29 -07:00
Makoto Onuki
f76b06a6b5 Test more DPM APIs.
Bug 24061108

Change-Id: Ia9da19f62c0f4edf53ca1f4c213f0368ec1983ba
2015-09-23 13:26:31 -07:00
Xiaohui Chen
f85c977414 Cleanup USER_OWNER in DPMS
This cl assumes device owner will continue running under user 0.

Bug: 19913735
Change-Id: I65c97f6f14fb362acbdcb6588b73787291100698
2015-09-23 18:49:00 +00:00
Makoto Onuki
cc4bbeb76a Make DPM/DPMS unit-testable
- Now all services that DPMS uses are injectable.
- Introduce some wrappers to make static methods and final class mockable.
(e.g. for Binder.getCallingUid())

- In unit tests we replace those with Mockito mocks, except we use a partial
mock for PackageManager, because we use way too many methods of this and
most of them are okay to use directly.

- To install a partial mock to PackageManager, I needed to make
ApplicationPackageManager @hide public non-final.

- For a starter, added tests for DPM.setAmin().

Bug 24061108

Change-Id: I2afd51d8bc0038992d5f9be38c686260be775b75
2015-09-22 12:47:44 -07:00