370 Commits

Author SHA1 Message Date
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
Nicolas Prevot
e2a4a6ff8a Don't always transfer device owner status to other users.
A device owner cannot use device or profile owner policies on
other users unless it is profile owner there. Also limit device
initializer to system apps only.

Bug: 21800830
Change-Id: Ie1abbd891945b91b17ecdf7f73ba93aaa19819be
2015-07-31 09:32:15 +01:00
Dianne Hackborn
0e3de6caca Change MNC codename to just M.
Change-Id: I4281d200ff6560791c47cf9073ceea1cb509361e
2015-07-29 15:20:21 -07:00
Nicolas Prevot
0079900883 Send a public broadcast when the device owner is set.
Make it a protected broadcast.

BUG: 22623518
Change-Id: Ia36e8f0b80a6301d7d8e0461476842c78762b5e8
2015-07-28 21:11:27 +01:00
Jeff Brown
c1aebfa02c Merge "Clean up USB Manager and fix ADB." into mnc-dev 2015-07-09 20:03:29 +00:00
Jeff Brown
460a146eb8 Clean up USB Manager and fix ADB.
Moved functions which parse the USB functions list into one common
place on UsbManager.

Deleted the no longer supported USB_FUNCTION_MASS_STORAGE.

Ensured that the UserManager.DISALLOW_USB_FILE_TRANSFER rule is
consistently applied during user switch and when changing the
current USB functions and make sure it only affects MTP and PTP.

Collapsed the boot completed and user switched receivers to
ensure consistent ordering of side-effects.

Validate the list of functions passed to setCurrentFunction() so
that the separation of concerns is clearer.  It was somewhat
ambiguous as to whether functions such as ADB could / should be
enabled through that interface.  Improved the docs for clarity.

Fixed a bunch of broken stuff related to the USB config
persistent property (list of default functions) that could cause
ADB and other functions to not work at all.  Added new failsafes
to ensure that we reliably get back into a happy state.

Bug: 22206076
Change-Id: I02915ddfce7193a8f67a14f0d76bab22fc575dfa
2015-07-09 12:55:56 -07:00
Kenny Guy
70e0c58c22 Mute correct user from device policy manager.
Add per user versions of mute methods so
device policy manager can mute the correct
user.
Just persist change if the calling user
isn't the current user.
Treat calls to audio manager coming from uid
1000 as if they were coming from current user
rather than user 0 so that the correct user's
user restriction is checked.

Bug: 21782066
Bug: 21778905
Change-Id: I51469b741096d8a2ffdc520eaf5b3fd754f2c819
2015-07-08 19:33:13 +01:00
Alex Chau
7ce2bd2161 Clear "profile wiped" notification when a new porfile is created
Make use of ACTION_MANAGED_PROFILE_ADDED to clear the notification.

Bug: 22186884

Change-Id: I08514ebc308f2e2fb61f837500e2ba712ccf8703
2015-06-30 15:19:55 +01:00
Esteban Talavera
fef8cbd6a6 Merge "Marking some globals from setGlobalSetting as not supported" into mnc-dev 2015-06-30 08:55:38 +00:00
Esteban Talavera
656fa7f5d1 Marking some globals from setGlobalSetting as not supported
Those globals don't have the intended behaviour any more.

Bug: 19967818
Change-Id: I8c7891e59280f9deb88b1f0ffead3de07f4eca56
2015-06-29 17:41:39 +01:00
Rubin Xu
e8490f1d78 Use StorageManager.wipeAdoptableDisks to wipe external disks
Retire FORMAT_AND_FACTORY_RESET which is more fragile.

Bug: 9433509
Change-Id: I158ee987274bb4db41d466de9f1e3c60ffc1d140
2015-06-26 15:58:21 +01:00
Esteban Talavera
28b9570d02 Reset permission policy to default when device owner goes away
Otherwise after the Device Owner is gone, runtime
permissions might still be auto granted/denied.
I understand that there are many other policies that
we don't reset after the device/profile owner goes
away (e.g. keyguard enabled/disabled). At least now
we have a single method when we could clear the
ones that we care about.

Bug: 21889278
Change-Id: I6997655e6ef6d474bd25ae1c323eca5b17944b16
2015-06-24 17:19:19 +01:00
Amith Yamasani
0bf8f7cc39 Runtime permissions cannot be set on legacy apps by device policy
Clarify docs that runtime permissions can be granted or revoked by
a profile owner/device owner only for MNC apps and not legacy apps.

Check the targetSdkVersion and return false if legacy app.

Remove all policy flags from permissions when cleaning up
a device or profile owner.

Bug: 21835304
Bug: 21889278
Change-Id: I4271394737990983449048d112a1830f9d0f2d78
2015-06-23 12:01:36 -07:00
Zoltan Szatmary-Ban
2c3c66a2cf Merge "Introduce Settings.Global.WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN" into mnc-dev 2015-06-23 08:44:49 +00:00
Robin Lee
58e706d754 Merge "Let device owners handle onChoosePrivateKey" into mnc-dev 2015-06-22 23:51:02 +00:00
Robin Lee
deee7735d8 Let device owners handle onChoosePrivateKey
Bug: 21959745
Change-Id: Ifad3901015937d2ea700124bb5f61982cd580ad8
2015-06-22 11:11:13 -07:00
Benjamin Franz
1046ba518b Add DISALLOW_CREATE_WINDOWS to Device Owner only user restrictions
Even though the documentation of DISALLOW_CREATE_WINDOWS says it is for
Device Owners and Profile Owners on User 0 only, it was previously not
part of DEVICE_OWNER_USER_RESTRICTIONS and was therefore callable from
a profile owner on a managed profile or secondary user.

Bug: 19726884
Change-Id: If6443eacbc28b7ee6c0845754923573a79f8bde3
2015-06-17 16:13:31 +01:00
Jeff Sharkey
2cc03e5606 Yet another user restriction.
Change-Id: Ia2952da19cb974a6a9ba0271a298a10df58b8d18
2015-06-15 21:50:47 -07:00
Alex Chau
b24f01f473 Merge "Notification shown upon work profile deletion" into mnc-dev 2015-06-12 10:14:27 +00:00
Craig Lafayette
77b2d49abb Merge "Remove device initializer status messages" into mnc-dev 2015-06-11 17:45:03 +00:00
Alex Chau
c51b72acc0 Notification shown upon work profile deletion
Bug: 18543323

Change-Id: Ibd9bd20637a7bd019e080da306a19c94d9e82576
2015-06-11 15:17:53 +01:00
Robin Lee
83881bdbde Policy: make bulk CA uninstalls happen in service
Fewer round trips, only one point of contact for bugs to creep in.

Bug: 21650477
Change-Id: I1764faa753bd674ecb0d13149d778d99bd2ff4c4
2015-06-10 19:40:44 +00:00