541 Commits

Author SHA1 Message Date
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
Makoto Onuki
287971d613 Make sure DO user is running even if caller is shell/root.
Bug 23827706
Bug 23994401

Change-Id: Ie2fbc3ab07901e3d0a9898c910c69d993583084e
2015-09-11 13:38:22 -07:00
Makoto Onuki
cb150cd81a Merge "Fix the "User not running: 0" issue" 2015-09-11 18:31:26 +00:00
Makoto Onuki
299878c9cf Fix the "User not running: 0" issue
Bug 23994401

Change-Id: I580730e7c895f00adf278a2d6709284fff0fc28b
2015-09-11 11:28:48 -07:00
Makoto Onuki
688b5f4f29 Merge "Cleanup: rename loadDeviceOwner() to loadOwners()" 2015-09-10 22:42:26 +00:00
Makoto Onuki
58b684f1cd [split system] Tentatively support running DO on meat user
- setDeviceOwner() now takes a user ID.  (We can infer it from Binder, but
we still need it for the dpm command.)

- Change broadcast target UID for DO to the DO user

- Start the DO user on boot complete.
TODO Investigate whether this is actually the good timing.

TODO Prevent the DO user from being killed

Bug 23827706

Change-Id: I227dbd444f1f4e94d98c317489d151554fe79d91
2015-09-08 11:24:58 -07:00
Makoto Onuki
f024f048de Cleanup: rename loadDeviceOwner() to loadOwners()
Change-Id: I68e3367b1e70022f9501cf998e1860a6ce7d496b
2015-09-04 13:31:13 -07:00
Makoto Onuki
2714d448b1 Replace all occurrences of HashMap/HashSet with ArrayMap/ArraySet.
Also fix the command line for OwnersTest in javadoc.

Change-Id: I53c222aa13eee179c5abf7e6ba95c6cbe9a7f47f
2015-09-02 16:57:30 -07:00
Makoto Onuki
c9754cf0df Add unit tests for file persisting in Onwers.
Bug 23432442

Change-Id: If10ed5a46084695b2aca1286713b8baea8c2a418
2015-09-01 09:33:41 -07:00
Makoto Onuki
2898838318 Fix bug in Owners
It was always failing to read policy files.

Bug 23432442

Change-Id: Ia71a746bbed279c4b27a9ebdf454a3cb4dfa786d
2015-08-31 14:38:38 -07:00
Makoto Onuki
99aeac27eb Rename DeviceOwner to Owners
Bug 23432442

Change-Id: Ic59c880d45126fbcf50b1bd31e37b2b64e2f3a6d
2015-08-31 11:44:44 -07:00
Makoto Onuki
39e784dd46 Split device owner config files
DPMS.mDeviceOwner is now always non-null, so no null checks are needed.

Bug 22802261
Bug 23432442

Change-Id: Ia8e5f114ecfc0add44b0d1be7d043ef6e37019ef
2015-08-28 12:12:49 -07:00
Rubin Xu
ed969e18f8 Reactivate backup service after device owner is cleared.
Bug: 23474411
Change-Id: I99da846493eb749828517d27f4384ab3fe647df5
2015-08-27 09:51:53 +00:00
Adrian Roos
e3b07451c3 resolved conflicts for merge of bcc26c02 to master
Change-Id: I4260ff0d090cfa9741fd3adcfcadcbbff6839388
2015-08-21 18:08:58 -07:00
Adrian Roos
b5e4722891 Add StrongAuthTracker
Bug: 22846469
Bug: 22115393
Change-Id: I6ef5322d02e540fc043e7f20d3aabf595ce7c224
2015-08-21 13:28:00 -07:00
Nicolas Prevot
4afb83e912 Clear cross-profile intent filters in the right user.
Clear them in the parent, who is not always the owner.

BUG:23105562
Change-Id: Iae2adbfa6b4d6e982f6f2a4075dd8bd55b11c37e
2015-08-21 15:19:53 +01:00
Nicolas Prevot
741abfc120 Fix cross-profile intent filters with system-user split.
Don't assume that the parent is always the user owner.

BUG:23105562
Change-Id: Ia98ed608e2b6d1d82d95a73110134d85274c6abf
2015-08-20 12:14:37 +00:00
Nicolas Prevot
2af03d2a7a Send the MANAGE_PROFILE_ADDED broadcast to the correct user.
Send it to the parent, who is not always the user owner.

BUG:22753960
Change-Id: Ibd0edb78be4b3bdfc9fc31fd05e50fe3bf8bb493
2015-08-20 11:32:10 +00:00
Dianne Hackborn
c1836bb0f1 Merge "Change MNC codename to just M." into mnc-dev 2015-07-31 17:11:58 +00:00
Rubin Xu
9a81a182df Merge "Don't always transfer device owner status to other users." into mnc-dev 2015-07-31 13:11:08 +00:00