184 Commits

Author SHA1 Message Date
Kenny Guy
e9acb59a91 Only switch user if current user is being wiped
Only try and switch to owner if the current user
is being removed.

Bug: 19252449
Change-Id: I0143d87360db0834876821cbf52fec4933ecbd35
2015-02-04 17:55:42 +00:00
Benjamin Franz
6d16b8614a Merge "Avoid NullPointerException if createUser returns null" into lmp-mr1-dev 2015-01-26 10:49:48 +00:00
Zoltan Szatmary-Ban
414ea81ea3 Merge "Ensure notifications are sent when locking/unlocking location share" into lmp-mr1-dev 2015-01-26 10:36:14 +00:00
Benjamin Franz
f87b174dac Avoid NullPointerException if createUser returns null
If createUser returns null, we run into a NullPointerException
in createAndInitializeUser. This can happen when the policy
DISALLOW_ADD_USER is set.

Bug: 19121141
Change-Id: Id4bda832a243fa42c31eb5a176ecaa248aee68f5
2015-01-23 17:04:16 +00:00
Benjamin Franz
266303fdb0 Merge "Avoid SecurityException when calling getUserData" into lmp-mr1-dev 2015-01-23 14:33:06 +00:00
Zoltan Szatmary-Ban
871fa7343a Ensure notifications are sent when locking/unlocking location share
When the restriction 'DISALLOW_SHARE_LOCATION' is applied or removed on a user
it is important to send out notifications to content observers of
LOCATION_PROVIDERS_ALLOWED.

Bug: 18995405
Change-Id: I8b3910a423a012ea9d15470eec101723c9f0eaf7
2015-01-23 14:08:30 +00:00
Benjamin Franz
fadb2b3a27 Avoid SecurityException when calling getUserData
Currently we risk getting a SecurityException in a number of places,
where getUserData is called for a different user than the calling user.
To avoid this, the caller is cleared in a helper function.

Bug: 18662452
Change-Id: Ibc131c602e52d9f013fe739a9c18e693181ded67
2015-01-22 16:16:16 +00:00
Kenny Guy
212037f7cd Sync file before using JournaledFile commit.
Ext4 doesn't guarantee that write file.new / close file.new
rename file.new to file will mean data in file.new makes it
to file atomically. The rename may happen with previous contents
of file.new and then later update to new contents
See docs for noauto_da_alloc
So rebooting the device during JournaledFile.commit may
mean we are left with an empty file.

Bug: 18590558
Change-Id: I35322c82871bed30c2c6ebbd1388338f0471f3ba
2015-01-15 18:48:01 +00:00
Robin Lee
7f7ea82c28 Profile owner hint in warning for extra CAs
The version of the warning with a named installer should be shown in
the case of a managed profile, not only a managed device.

Bug: 18224038
Change-Id: I27865f77e963b9b15416f2e4a4ffc38fed8f5532
2015-01-09 11:25:04 +00:00
Robin Lee
e53b7dd066 Revert "Profile owner hint in warning for extra CAs"
This reverts commit e1d8dcd9e170c1ed8a13b6e1256ea1fb22c26c49.

Something funny happened in the process of submitting this,
swathes of strings.xml became mis-encoded.

Bug: 18224038
Change-Id: I0276ff3f880fe749546e8cc7e3e2f41c22c27705
2015-01-08 22:08:42 +00:00
Robin Lee
e1d8dcd9e1 Profile owner hint in warning for extra CAs
The version of the warning with a named installer should be shown in
the case of a managed profile, not only a managed device.

Bug: 18224038
Change-Id: I58bddb162799481d5e8feb169b0c0bff17cbeeb7
2015-01-05 19:52:54 +00:00
Robin Lee
b4b14e391d Merge "Revert "DevicePolicy: Don't warn about managed profile CAs"" into lmp-mr1-dev 2014-12-23 12:30:28 +00:00
Robin Lee
853964927c Revert "DevicePolicy: Don't warn about managed profile CAs"
This reverts commit 80559f4aadb3419eecdf6bf61945af584cd2aa8a.

Bug: 18224038
Change-Id: I108a4e8cf185401fef4806e1ad8c2cc78992e843
2014-12-22 13:22:11 +00:00
Fyodor Kupolov
22afe6261a Merge "Added isRemovingAdmin method" into lmp-mr1-dev 2014-12-05 19:28:12 +00:00
Fyodor Kupolov
96fb932666 Added isRemovingAdmin method
Added isRemovingAdmin method, so that clients can query if device
admin is currently being removed.

Bug: 17609838
Change-Id: I82547a9eeb228fcf8ac2a6e639ca1a75fa41d161
2014-12-04 17:53:45 -08:00
Amith Yamasani
a0116afeaf Potential fix for accidental deactivation of profile owner
This is a safeguard to only check for changing packages when
re-validating active admins.
1. If package is being removed, only check if it's not being
   replaced.
2. If package is changing, only check the changing package that
   matches one of the active admins.
3. If package is being added and is a replacement (update), then
   check if it affects any matching active admins and verify the
   validity of the receivers.

If by any chance some package broadcast was occuring at a time when
an admin was being updated, or the package removed broadcast was
coming in much before the update was registered with package manager
then this will help in avoiding accidental deactivation.

Bug: 18590558
Change-Id: I7f4897e8836f81aa037b8be87d399942ce78b1a2
2014-12-04 14:49:24 -08:00
Paul Crowley
77e25331ca Merge "Add flag for wiping factory reset protection data." into lmp-mr1-dev 2014-11-25 21:13:30 +00:00
Paul Crowley
a7e87acb24 Add flag for wiping factory reset protection data.
Bug: 18366448
Change-Id: If8904888a6bf8611d34647e6d65d2347d824dbb3
2014-11-25 20:48:41 +00:00
Robin Lee
80559f4aad DevicePolicy: Don't warn about managed profile CAs
Setting up a managed profile should have included a step to warn about
this sort of thing already. As the user should trust the profile owner
anyway it's hard to argue this warning is needed.

Bug: 18224038
Change-Id: Ie86ba26851af726c0dec30eb9c32894ed6bb4a00
2014-11-25 15:48:48 +00:00
Adrian Roos
702d9e31b1 Merge "Fix DPM.resetPassword("")" into lmp-mr1-dev 2014-11-24 16:02:11 +00:00
Amith Yamasani
3a3d212a51 Different messages when wiping user and not device
There are 3 types of users
1. Primary - device will be wiped
2. Managed profile - profile will be removed
3. Secondary user - user will be removed

Show different messages for almost wipe and wipe in each
of these 3 cases.

Bug: 16843155
Change-Id: Icecfe520622773da9e45465bf2217e8ed38b266e
2014-11-21 13:57:48 -08:00
Zoltan Szatmary-Ban
08229e817e Merge "Shutdown backup manager service when device owner is set" into lmp-mr1-dev 2014-11-21 15:21:07 +00:00
Adrian Roos
f8f56bce42 Fix DPM.resetPassword("")
While we're at it, also fix some multi-user issues in
LockPatternUtils.

Bug: 17496766
Change-Id: I8e557ea640fa589817c8f8f818c91463585d5ea7
2014-11-21 13:34:06 +01:00
Rubin Xu
735f22850e Merge "Remove permission check in DevicePolicyManager.isUninstallBlocked()" into lmp-mr1-dev 2014-11-18 23:43:17 +00:00
Rubin Xu
3a7d3fc60e Merge "Fix equality test in getProfileOwnerAdmin()" into lmp-mr1-dev 2014-11-18 23:42:21 +00:00
Rubin Xu
a97855b784 Remove permission check in DevicePolicyManager.isUninstallBlocked()
This is to allow Play to use this API to find out whether a package
is uninstallable due to profile or device owner policy's restriction.

Bug: 17914630
Change-Id: I4ce2963884ecdf3306805f36db80ed1ebf04d88f
2014-11-18 17:53:46 +00:00
Zoltan Szatmary-Ban
26ac6a6fd0 Shutdown backup manager service when device owner is set
Bug: 16641441
Change-Id: I3fe54e43324c15dabd56834a923e8e8cb4eea98d
2014-11-13 20:49:43 +00:00
Fyodor Kupolov
d01ff6d4c3 Added synchronization to handlePackagesChanged method
Method handlePackagesChanged modifies the policy data without holding the
lock. It also calls methods which expect a lock to be held -
validatePasswordOwnerLocked, syncDeviceCapabilitiesLocked, saveSettingsLocked.

Bug: 18262633
Change-Id: Ia4bdc6edc66bccf8a4288e048171ff20858ae2f6
2014-11-12 11:27:21 -08:00
Amith Yamasani
52c39a16db Allow profile owners to set the unknown source setting
This allows work profile MDM to enable unknown sources
even if the user doesn't have UI for it. Installing an
app from an unknown source will still prompt the user
with the package installer dialog, so it's not like the
MDM can now quietly install apps from non-market sources.

Bug: 18316350

Change-Id: Ia8f4fe36f12a258aa888e085acc0b358925f4817
2014-11-11 23:38:24 +00:00
Jeff Brown
5ce1cb240b Move device admin max screen off timeout to internal interface.
The setting was previously exposed in IPowerManager but it
doesn't need to be there.

Bug: 17656076
Change-Id: If3ed0cbe89f67c60aa00376be0c54b1bd9656144
2014-11-06 19:34:21 -08:00
Jim Miller
e303bf4435 Update TrustAgentService API after review
This change incorporates API council feedback and enables the
TrustAgent whitelisting API.

It also contains a minor cleanup of DPM's use of UserHandle
to eliminate unnecessary object creation.

Fixes bug 17008504

Change-Id: I63cc50169fde54b34406845818bcaf6aadc1a3db
2014-11-05 18:17:56 -08:00
Rubin Xu
d7892e71a8 Fix equality test in getProfileOwnerAdmin()
The equality test should compare a ComponentName, which admin.info is not.

Bug: 18186447
Change-Id: If984ae2e0da958889564ba30716d65245a78d60f
2014-10-30 17:57:23 +00:00
Benjamin Franz
f5c00c1c11 Merge "Send ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED Broadcast when a user restriction has been changed." into lmp-mr1-dev 2014-10-28 16:13:05 +00:00
Benjamin Franz
0572054261 Send ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED Broadcast when a user restriction has been changed.
Bug: 17916693
Change-Id: I6bca83ad6224ab6f1e4bdf41a10f514823c66755
2014-10-22 16:41:58 +00:00
Robin Lee
e69bdca44b DevicePolicy: Restore CA warning to K behaviour
Some tests rely on this being dismissible. Additionally it turns out
some users don't like having a hulking great notification follow them
around everywhere.

Bug: 17985258
Change-Id: If05a07b9eaa402a48f9a14647effc1df32c796e1
2014-10-20 20:55:40 +00:00
Amith Yamasani
cd410ba4e8 Use the correct method to check if device is encrypted
DPM's method will return false if encrypted by default password,
preventing the changing of encryption password to lockscreen password.

Check if the device is encrypted by some means, instead.

Also fix a SecurityException when Device Admin queries encryption state
(recent regression)

Bug: 17881324
Change-Id: Id897e61c5e254ab3f8dc569285428a73005303ea
2014-10-17 11:43:57 -07:00
Jim Miller
3836c9a4c1 Fix getStorageEncryptionStatus() in DevicePolicyManager
This fixes a bug introduced by a change where the function
ignores systems with default encryption where it's disabled.

The fix also checks to see if vold thinks the device is secure.

Fixes bug 17881324

Change-Id: I2c40f76cf990d90d1a825955aa3b080b21684426
2014-10-15 13:15:52 -07:00
Amith Yamasani
2c3886cb34 Merge "Fix admin policies in managed profiles" into lmp-dev 2014-10-15 17:44:24 +00:00
Amith Yamasani
242f4b1259 Fix admin policies in managed profiles
Some of the admin policies are throwing security exceptions in
a managed profile without being documented correctly and others
shouldn't be throwing security exceptions.

Changed setCameraDisabled() to not throw an exception. It now just
prevents work profile apps from using the camera.

Changed wipeData() to allow passing in ERASE_EXTERNAL_STORAGE. In
secondary users/profiles, this is just going to remove the user, so
the flag is harmless.

Updated documentation for setKeyguardDisabledFeatures() and resetPassword()
to indicate that they cannot be called in a managed profile.

Bug: 17987913
Change-Id: I8060be4c2d32bdd4edb46ce543551fabb9c8c983
2014-10-15 10:42:17 -07:00
Svetoslav
28433dbdab Fix a NPE in device policy manager service.
It is possible that the device does not have an owner. If there
is no owner we get a NPE when asking the device policy manager
for cross-profile widget providers.

bug:17989189

Change-Id: I5759f2dec160ed8076ab47fdf09134f78c57458d
2014-10-14 15:53:17 -07:00
Robin Lee
d0130e8539 DevicePolicy: One cert tracker warning per profile
Shows one notification per profile instead of one notification per
user or (previously) one notification per device.

Bug: 17794425
Change-Id: I6f0d34a16fa2a45082941387ac765dd99eefa131
2014-10-09 12:46:13 +01:00
Kenny Guy
baa05930ec Merge "Ignore badly formed ComponentNames when loading device_owner.xml" into lmp-dev 2014-09-25 16:42:11 +00:00
Kenny Guy
be16357f40 Ignore badly formed ComponentNames when loading device_owner.xml
In the past we wrote out badly formed ComponentNames with no
class part. Loading these results in a null pointer exception
blocking boot.

Bug: 17652534
Change-Id: Iec592343425a23c7ada5f73cf30b8646d31eae81
2014-09-25 17:03:53 +01:00
Jeff Sharkey
004a4b20f8 Include reason when wiping data.
This will help us track down who requested a data wipe.

Bug: 17412160
Change-Id: If8413e5d6377773f37e8b34ae3d26347226a027c
2014-09-24 13:58:09 -07:00
Amith Yamasani
8d9f121618 Merge "Allow primary user profile owner to set device restrictions" into lmp-dev 2014-09-19 15:51:39 +00:00
Jessica Hummel
dd31a10c7f bug fix: Allow enableSystemApps to be called by profile and device owner.
We had an additional check for managed profile in there, so it wasn't working for device owners. Also needed to look at uninstalled packages.

Change-Id: I4813f23b00d7905e92ade582ce082a6f295a322d
Bug: 17384318
2014-09-19 09:56:19 +00:00
Amith Yamasani
c34dc7cdeb Allow primary user profile owner to set device restrictions
In addition to device owners, profile owners on the primary user
can also set user restrictions that are necessary to lock down the
user.

This is to enable the case of a profile owner registered after setup
wizard is completed, on the primary user.

Also make managed profile vs. profile wording consistent in the
DevicePolicyManager docs.

Bug: 17555025
Change-Id: Ib9d08b8af34a99b25e11757fa7dc83673a7deb32
2014-09-18 15:14:26 -07:00
Amith Yamasani
d616a33578 Prevent device owner registration after setup is complete
This change prevents adding a device owner after setupwizard
has finished provisioning. Only the new dpm shell command
can set a device owner.

Bug: 17316711
Change-Id: I98bdfd9b8c8da3042111c45e2e7fd2b559fac510
2014-09-12 11:25:51 -07:00
Esteban Talavera
d09fbafa92 Merge "Add new adb dpm (= DevicePolicyManager) command" into lmp-dev 2014-09-12 10:35:44 +00:00
Esteban Talavera
b5ef162129 Add new adb dpm (= DevicePolicyManager) command
Adds new adb command to execute DevicePolicyManager tasks. First subcommand
allows us to set a device owner on a provisioned device (provided no accounts
are associated with the device). This is required as GTS tests run on provisioned
devices. We plan to add more subcomands required for new GTS tests, such as the
ability to create a managed profile.

Bug: 17312478, 17316711
Change-Id: I2613178ea82a6c6268e7f8012e74c4a852fea0d4
2014-09-12 11:33:59 +01:00