541 Commits

Author SHA1 Message Date
Victor Chang
c754dffe19 Merge "Create a new device policy for controlling work contacts search" 2016-01-12 11:51:01 +00:00
Victor Chang
1060c61866 Create a new device policy for controlling work contacts search
BUG=25981902

Change-Id: I5cea59d7d09bf54051ae0e56e824e4d3a08a49e7
2016-01-12 11:31:16 +00:00
Clara Bayarri
3e826effed Create parent APIs in DevicePolicyManager
This change creates the infrastructure for a parent
DPM and implements the actual parent APIs for
- set/getPasswordQuality
- isActivePasswordSufficient

This is part of the Separate Work Challenge

Change-Id: I0477051b3162cbb26aac79467da08932f22fd1b7
2016-01-07 10:55:24 +00: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
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
Sudheer Shanka
137241c714 Update an error message.
Change-Id: Ifc32120ccccd14e8e821770995de91008ed518d7
2015-12-30 18:09:10 +00:00
Esteban Talavera
f3378a29e9 Merge "Device or profile owner can let another app manage app restrictions" 2015-12-17 10:59:16 +00:00
Mahaver Chopra
699d537d1b Merge "Adding DPM.reboot" 2015-12-17 10:59:01 +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
Andrei Stingaceanu
1e2839188f Wire call to suspend a package
Adds APIs in DevicePolicyManager and PackageManager for allowing
a device admin to suspend a package. PackageManagerService sets
or unsets a new PackageUserState 'suspended' setting. Terminal
command to suspend/unsuspend has been added via
PackageManagerShellCommand (as root).

Next steps:
* use the new 'suspended' setting for denying access to start app
(probably in ActivityStackSupervisor)
* broadcast a PACKAGE_(UN)SUSPENDED intent for launchers to pick up
* remove app from recents (go further and kill it if it is running)
* erase existing notifications for this app

Bug: 22776576
Change-Id: I718b3498f6a53cc0c6fdfb6d15031e53ddca4353
2015-12-16 18:14:14 +00:00
Mahaver Chopra
1ce53bc571 Adding DPM.reboot
Adding new policy in DPM to trigger reboot on the device.
Requirement: Device owner can reboot the device if it is stuck or is
not useable due to some unresponsive UI.

Bug: 25304994
Change-Id: I7a6d5c8ad611de9c1cf6619378e492a306b41626
2015-12-16 17:55:54 +00:00
Esteban Talavera
5b9f167a8e Only system can set application restrictions via UserManager
Preventing apps with MANAGE_USERS from managing application
restrictions via UserManager. Application restrictions should
only be set via DevicePolicyManager.setApplicationRestrictions,
or via Settings (for restricted profiles).

Bug: 22541936
Change-Id: Ieed51ef54b4c23a73f383465e9af9b3bcf18a514
2015-12-15 18:36:34 +00: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
Makoto Onuki
55c46f291d Clean up DPM/DPMS to reduce code size.
Change-Id: Id6c1666ef4cdba795e3b6e4ddcb9c32e6ee90665
2015-12-10 15:38:32 -08:00
Robin Lee
fbc65644b9 DevicePolicy API to remove an installed KeyPair
The keypair is specified by alias and removed via a call to the
KeyChainService, which will have installed the pair in the first place.

Bug: 22541933
Change-Id: I37317e7c22e89816156e6e9a7abf4c5a59e8440a
2015-12-08 16:40:56 +00:00
Robin Lee
ee3a437464 Send pwchange broadcast to caller only in FBE case
When per-user encryption is set up and we change the password of a
profile, the parent and other profiles shouldn't receive an
ACTION_PASSWORD_CHANGED as they have their own distinct passwords.

Change-Id: I70d4ec81277a9bdc3ac6cd952b84cd769a2800b4
2015-12-07 13:39:11 +00:00
Clara Bayarri
10ad84a17d Create a separate Work Challenge check
This allows us to tell lock checks from FBE checks separately,
and will be useful when dealing with password unification.

Change-Id: Ifbea425f749fee4d6d51faddd8b64bf717a1a5f8
2015-12-03 16:18:53 +00:00
Clara Bayarri
29fcf1b1db Apply Admin password restrictions to work profile
When the Work Challenge is in place, re-route the
enforcing of Admin policies on the password to the
work profile. The Admin should not be allowed to
dictate policies on the device lock in this case.

This is part of the Separate Work Challenge feature.

Change-Id: I757973e540797b5fb10bea7a2fd1925561655bc9
2015-12-03 16:18:53 +00:00
Robin Lee
968dea0969 DPMS: Replace ArrayList<>(1) with SingletonList
Change-Id: I78f8230d959f17c3aa2f248122973a8cd5c96693
2015-12-03 14:54:38 +00:00
Robin Lee
574f038a57 Resolve merge conflicts of 5ec51457e1 to master.
Change-Id: I70c12ad663c3b4d3b5e3b8f40bc659cb94d82c14
2015-12-02 13:48:32 +00:00
Svet Ganov
9c165d7601 Add optional permission review for legacy apps - framework
For some markets we have to allow the user to review permissions
for legacy apps at runtime despite them not supporting the new
permission model. This is achieved by showing a review UI before
launching any app component. If an update is installed the user
should see a permission review UI for the newly requested
permissions.

To allow distinguishing which permissions need a review we set
a special flag in the permission flags that a review is required.
This flag is set if a runtime permission is granted to a legacy
app and the system does not launch any app components until this
flag is cleared. Since install permissions are shared across all
users the dangerous permissions for legacy apps in review mode
are represented as always granted runtime permissions since the
reivew requirement is on a per user basis.

Whether the build supports permission review for legacy apps is
determined by a build constant allowing us to compile away the
unnecessary code for markets that do not require a permissions
review.

If an app launches an activity in another app that has some
permissions needing review, we launch the permissions review
UI and pass it a pending intent to launch the activity after
the review is completed.

If an app sends a broadcast to another app that has some permissions
needing review, we do not deliver the broadcast and if the sending
app is in the foreground plus the broadcast is explicit (has a
component) we launch the review UI giving it a pending intent to
send the broadcast after the review is completed.

If an app starts a service in another app that has some permissions
needing review, we do not start the service and if the calling app
is in the foreground we launch the review UI and pass it a pending
intent to start the service after the review is completed.

If an app binds to a service in another app that has some permissions
needing review, we schedule the binding but do not spin the target
service's process and we launch the review UI and pass it a callback
to invoke after the review is completed which spins the service
process and completes the binding.

If an app requests a content provider in another app that has some
permissions needing review we do not return the provider and if
the calling app is in the foreground we show the review UI.

Change-Id: I550f5ff6cadc46a98a1d1a7b8415eca551203acf
2015-12-02 04:23:02 +00:00
Alan Treadway
28860b7570 Fix for being able to setup Managed User from system user.
Also move feature flag check to ensure it is used in all cases.

Change-Id: If42787c5bc9ab824449c70f90fb827cf2da7507f
2015-11-30 16:48:26 +00:00
Yohei Yukawa
777ef95ebf Use Context.getSystemService(Class<T>) for InputMethodManager.
This is a mechanical replacement of Context.getSystemService(String)
with Context.getSystemService(Class<T>) when retrieving
InputMethodManager.  Note those are bundled code.  Hence we don't need
to make sure Build.VERSION.SDK_INT >= 23.

Change-Id: Icc64942ad8f11e44bf84f8d4fe476b2fdd1257f3
2015-11-26 00:02:05 -08: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
Mahaver Chopra
15a46b07c5 Add method isManagedProfile and isSystemOnlyUser
Adding method isManagedProfile() and isSystemOnlyUser() for DPC to know
if running in a managed profile or system only user

Bug: 24464823
Change-Id: I79974fdfd60d2bfe52dee3b4c95becf47a5bf0b1
2015-11-24 15:00:18 +00: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
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
Robin Lee
5145df278b DevicePolicy: Always send ACTION_PASSWORD_CHANGED
The old check looks a lot like an equality check, but it's not valid
because two passwords can share the same parameters.

For example:
  '11Aa' and
  'Y99z'

Are not different according to the old logic.

Bug: 25319928
Change-Id: Ia69861d9103670d1fc1dbf0130516e18e85e8de0
2015-11-19 19:45:44 +00: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