916 Commits

Author SHA1 Message Date
TreeHugger Robot
4d600d150f Merge "Clear affiliation ids and lock task packages when clearing DO/PO" 2017-02-06 12:58:55 +00:00
Esteban Talavera
a7bd04e892 Clear affiliation ids and lock task packages when clearing DO/PO
Test: runtest -c com.android.server.devicepolicy.DevicePolicyManagerTest    frameworks-services
Change-Id: I38eea34cff82766c7e3b8cd79dd9757a212bb451
2017-02-03 12:20:20 +00:00
Rubin Xu
a55b168b5d Small tweaks in LockSettingsService
Paves way for synthetic password flow: Two notable changes:
1. when unify/un-unify work challenges, provide the old work profile password.
2. when clearing lock, supply old credentials.

Test: Unit test to be added in a follow up CL.
Bug: 33126414
Change-Id: I2a9553c5e7cc701338436e99e5a1289cebd1eda9
2017-02-02 18:44:46 +00:00
Makoto Onuki
f1e276384d DO NOT MERGE Do not call RecoverySystem with DPMS lock held am: 2317451acc am: 01f971dcdc
am: 963cba5b5b

Change-Id: I3a1421f656d1a90970eac6156e0840625662fb17
2017-02-02 01:15:44 +00:00
Makoto Onuki
963cba5b5b DO NOT MERGE Do not call RecoverySystem with DPMS lock held am: 2317451acc
am: 01f971dcdc

Change-Id: If5f5e5d47b97e2b8480adc5ca2cb08702056ca87
2017-02-02 01:10:43 +00:00
Makoto Onuki
01f971dcdc DO NOT MERGE Do not call RecoverySystem with DPMS lock held
am: 2317451acc

Change-Id: Id3441141d4feea4c7291350c9670bd59ec017240
2017-02-02 01:03:21 +00:00
Esteban Talavera
bdcada9762 Affiliated profile owners can set lock task packages
Mentioned that in the documentation, cleaned up the code
a bit and added unit tests

Bug: 34614754

Test: runtest -c com.android.server.devicepolicy.DevicePolicyManagerTest    frameworks-services
Change-Id: I91232bbe494398015094ab977c6a2adce339811f
2017-02-01 15:02:22 +00:00
Makoto Onuki
2317451acc DO NOT MERGE Do not call RecoverySystem with DPMS lock held
Note DPM.wipeData() on a secondary user is now blocking, just like
it's been always blocking on the primary user.

Test: Manually tested wipeData() with ApiDemos, both on 1) the primary user,
2) a secondary user and 3) work profile.

Test: adb shell am instrument -e class com.android.server.devicepolicy.DevicePolicyManagerTest -w com.android.frameworks.servicestests

Bug 30681079

Change-Id: Ia832bed0f22396998d6307ab46e262dae9463838
Merged-in: Ia832bed0f22396998d6307ab46e262dae9463838
(cherry picked from commit efdec8f5688ce6b0a287eddb6d5dad93ffa0e1ee)
2017-01-31 21:21:36 +00:00
Edman Anjos
9e62c3111e Update in DPM delegation documentation.
Add note on DPM#setDelegatedScopes documentation regarding the
broadcast sent to the delegate package to notify its new scopes; and
change the admin ComponentName annotation to @Nullable in
DPM#getDelegatedScopes.

Bug: 33099995
Test: cts-tradefed run cts-dev --module CtsDevicePolicyManagerTestCases --test com.android.cts.devicepolicy.MixedDeviceOwnerTest#testDelegation
Change-Id: I28fe3a631c05a9e6b8dae766ce6c42881f2e3a00
2017-01-30 17:11:40 +01:00
Edman Anjos
a5ec280b4a Fix delegation broadcast to send an ArrayList<String> extra.
Change DPMS to call Intent#putStringArrayListExtra to ensure the extra
is sent as an array list of strings.

Bug: 33099995
Test: cts-tradefed run cts-dev --module CtsDevicePolicyManagerTestCases --test com.android.cts.devicepolicy.MixedDeviceOwnerTest#testDelegation
Change-Id: I1466fb457e34adbfb7704320c021210c1569f55f
2017-01-30 17:11:40 +01:00
Esteban Talavera
b3231029b5 Merge "Profile owners on a user can communicate with device owners" 2017-01-30 11:33:38 +00:00
Makoto Onuki
efdec8f568 Do not call RecoverySystem with DPMS lock held
Note DPM.wipeData() on a secondary user is now blocking, just like
it's been always blocking on the primary user.

Test: Manually tested wipeData() with ApiDemos, both on 1) the primary user,
2) a secondary user and 3) work profile.

Test: adb shell am instrument -e class com.android.server.devicepolicy.DevicePolicyManagerTest -w com.android.frameworks.servicestests

Bug 30681079

Change-Id: Ia832bed0f22396998d6307ab46e262dae9463838
Merged-in: Ib97a92a6af87a5589d2643b9ae0522395735e1a5
2017-01-27 14:08:01 -08:00
TreeHugger Robot
695417c252 Merge "Fix DPM.getPermissionGrantState()" 2017-01-27 15:23:14 +00:00
Bartosz Fabianowski
2dbf9ae67a Fix DPM.getPermissionGrantState()
The recent addition of DPM API access delegation introduced a bug in
this method. When a system app (UID 1000) called the method, it would
crash.

Bug: 34760123
Test: DPM unit tests
Change-Id: I69390ca30270d64a4d28a74c13a7679f14a62959
2017-01-27 14:47:17 +01:00
Esteban Talavera
2f897917fd Profile owners on a user can communicate with device owners
Allow device owners and profile owners on a user
to communicate with each other, rather than restricting
it to device owners and managed profile owners as it is
at the moment

Bug: 34429083

Test:  runtest -c com.android.server.devicepolicy.DevicePolicyManagerTest    frameworks-services
Test: cts-tradefed run cts -a armeabi-v7a --module DevicePolicyManager --test com.android.cts.devicepolicy.DeviceOwnerPlusManagedProfileTest
Change-Id: I81561a9838c3ccb623354a1b718da2fc6a5af1fe
2017-01-26 18:40:59 +00:00
Michal Karpinski
f329254053 Merge "Change batch finalization timeout mechanism from Handler#sendMessageDelayed() to a wakeful alarm" 2017-01-26 15:15:14 +00:00
Michal Karpinski
1710e5f079 DO NOT MERGE Change batch finalization timeout mechanism from
Handler#sendMessageDelayed() to a wakeful alarm

Messages sent with Handler#sendMessageDelayed() didn't get delivered
until the device woke up after being idle, which resulted in
potentially very long windows of logs accumulation and highly possible
network log loss from before the device becaming idle.

Bug: 34157435
Test: manual with decreased timeout over a few timeout iterations
Change-Id: I22d9cc743acb1a478d2da5407c5718e7f95e89cb
2017-01-26 12:48:56 +00:00
Michal Karpinski
9a2e4207d7 Change batch finalization timeout mechanism from
Handler#sendMessageDelayed() to a wakeful alarm

Messages sent with Handler#sendMessageDelayed() didn't get delivered
until the device woke up after being idle, which resulted in
potentially very long windows of logs accumulation and highly possible
network log loss from before the device becaming idle.

Bug: 34157435
Test: manual with decreased timeout over a few timeout iterations
Change-Id: I50b29b9f132856a629e28f46c022f21976bd92fb
2017-01-26 12:45:45 +00:00
phweiss
73145f4e60 Create public API for policy transparency outside of Settings
The new DPM.createAdminSupportIntent() returns an intent that shows the
"This action was disabled by your admin"-dialog from settings.
This enables apps to inform the user about the cause of restricted
functionality.

A new extra for the intent allows to specialize the dialog for different
restricted features, instead of a generic message for all features.

Bug: 31215663
Test: runtest -c com.android.server.devicepolicy.DevicePolicyManagerTest frameworks-services

Change-Id: I3de7aeec0f88b8f013a63957aec803cd123fbedc
2017-01-25 22:20:46 +01:00
Edman Anjos
452efaac32 Merge changes I50d2903e,Ieb347ce3
* changes:
  Add DPMS delegation scopes.
  Add block uninstall delegation in DPMS.
2017-01-25 18:00:03 +00:00
Esteban Talavera
8f3b34338a Merge "Wipe device or profile if max failed attempt reached" 2017-01-25 16:17:38 +00:00
Edman Anjos
52088e4859 Add DPMS delegation scopes.
Implement the permission grant, package access, enable system app, and
keep uninstalled packages delegation scope APIs in the
DevicePolicyManagerService.

This feature gives a device owner or profile owner the ability to
delegate some of its privileges to another application.

Bug: 33105287, 33105284, 33105719
Test: cts-tradefed run cts-dev --module CtsDevicePolicyManagerTestCases --test com.android.cts.devicepolicy.MixedDeviceOwnerTest#testDelegation
Change-Id: I50d2903eb73ae7844ec1f6fe07e41101ea2760ea
2017-01-25 16:53:50 +01:00
Edman Anjos
a5f2fb1a43 Add block uninstall delegation in DPMS.
Implement the uninstall blocker delegation scope API in
DevicePolicyManagerSercice.

This feature gives a device owner or profile owner the ability to
delegate some of its privileges to another application.

Bug: 33105718
Test: cts-tradefed run cts-dev --module CtsDevicePolicyManagerTestCases --test com.android.cts.devicepolicy.MixedDeviceOwnerTest#testDelegation
Change-Id: Ieb347ce3fb6219fe7f04cafbcd1e6b7359b31a10
2017-01-25 16:31:13 +01:00
Edman Anjos
4877b9c298 Merge "Refactor DPMS Cert Installer and App Restrictions delegation." 2017-01-25 15:19:28 +00:00
Victor Chang
954cfce18d Merge "Send DEVICE_OWNER_CHANGED to manifest receivers in background" 2017-01-25 12:13:36 +00:00
Esteban Talavera
b88f42b6b1 Wipe device or profile if max failed attempt reached
If the device or profile owner have set a max password failed
attempts policy, the device or profile should be wiped even if
DISALLOW_FACTORY_RESET / DISALLOW_REMOVE_USER /
DISALLOW_REMOVE_MANAGED_PROFILE was set by that admin. However
it should still fail if another device admin set the policy - this
is in line with what wipeData() does at the moment.

Bug: 34450538

Test: runtest -c com.android.server.devicepolicy.DevicePolicyManagerTest    frameworks-services
Test: cts-tradefed run cts --module DevicePolicyManager --test com.android.cts.devicepolicy.DeviceOwnerPlusManagedProfileTest#testWipeData
Test: cts-tradefed run cts --module DevicePolicyManager --test com.android.cts.devicepolicy.ManagedProfileTest#testWipeData
Test: cts-tradefed run cts --module DevicePolicyManager --test com.android.cts.devicepolicy.DeviceOwnerTest#testDisallowFactoryReset
Change-Id: Ifac240692ce74432f7b57f3dfbbbac2a7282297b
2017-01-25 12:07:37 +00:00
Victor Chang
94666c0570 Send DEVICE_OWNER_CHANGED to manifest receivers in background
- DEVICE_OWNER_CHANGED is an event that could happen maximum of 2 times
after device factory reset. The event rarely
happens, and it shouldn't affect any system health

Fix: 34446573
Test: adb shell am instrument -w -e class
com.android.server.devicepolicy.DevicePolicyManagerTest
com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner

Change-Id: Ic1af2016f590e1200bb3e56f63caa0e0b12f71f8
2017-01-25 12:01:09 +00:00
Edman Anjos
f994677626 Refactor DPMS Cert Installer and App Restrictions delegation.
The DevicePolicyManagerService currently supports delegation of
certificate installation and application restriction management, both
of which are individually handled by DPMS.

Upcoming framework features will add four more delegation types,
namely: block uninstall; app permission management; app access
management; and system app enabler. At this moment it makes sense to
refactor the underlying delegation system in DPMS so that current and
future delegates can be handled in a more generic way.

Bug: 33099995
Test: DPMS unit tests
Change-Id: I9e350143572c6690febdd59d1ed5149af8ee4388
2017-01-25 13:00:40 +01:00
Nicolas Prevot
d37c4a99b2 Allow DO to provision even if it has set disallow remove mp.
If the device owner has set DISALLOW_REMOVE_MANAGED_PROFILE,
and there is already a managed profile:
it should be allowed to provision a new managed profile by
deleting the old one.
Test: adb shell am instrument -e class
com.android.server.devicepolicy.DevicePolicyManagerTest
-w
com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner
BUG:34116228

Change-Id: I9e6f39924107aee40b57d22e638487a1ea3132de
2017-01-24 16:36:14 +00:00
Jason Parks
841cb0a37f Allow the profile owner to enforce auto time.
Test: runtest -c com.android.server.devicepolicy.DevicePolicyManagerTest frameworks-services

Change-Id: I1cb04cce5d232fba668535dd391459a050d62dd7
2017-01-23 17:32:53 -06:00
Charles He
dea0c3b654 DPM: Notify DO/PO of security updates.
We add a variant of notifyPendingSystemUpdate method which takes an
additional isSecurityPatch boolean flag. This information, if available,
will be persisted and available to device and profile owners when they
call getPendingSystemUpdate method.

Test: gts-tradefed run gts -m GtsGmscoreHostTestCases -t com.google.android.gts.devicepolicy.DeviceOwnerTest#testPendingSystemUpdate
Test: gts-tradefed run gts -m GtsGmscoreHostTestCases -t com.google.android.gts.devicepolicy.ManagedProfileTest#testPendingSystemUpdate
Bug: 33102479
Bug: 30961046
Change-Id: If3f1b765bb18a359836ac43ac9a0a9f29e9f8428
2017-01-23 09:38:49 +00:00
Pavel Grafov
b271f34625 Merge "Store pending OTA state and make it accessible via polling api." 2017-01-19 11:09:32 +00:00
TreeHugger Robot
e247432035 Merge "Fix test DevicePolicyManagerTest#testSetRequiredStrongAuthTimeout_DeviceOwner" 2017-01-18 17:58:04 +00:00
Kenny Guy
1894632864 Fix issue with saving admins before finishing loading. am: f98ed6863a am: b275a205af
am: ee9f03d1ed

Change-Id: Ic724588cbab8d4282eeb5bc806f8c67791189a05
2017-01-18 17:33:33 +00:00
Kenny Guy
ee9f03d1ed Fix issue with saving admins before finishing loading. am: f98ed6863a
am: b275a205af

Change-Id: I01487d9c39f4e82b63961cdd43df238f2bfd2b89
2017-01-18 17:27:10 +00:00
Bartosz Fabianowski
094119df3e Merge "Allow system to retrieve permission grant state" 2017-01-18 17:25:49 +00:00
Bartosz Fabianowski
4b0624fee4 Allow system to retrieve permission grant state
To inform the user which apps were granted permissions by the admin,
the Settings app needs to access this information without being a DO/PO.

Bug: 32692748
Test: FrameworksServicesTests unit test

Change-Id: I3770ec6343b85be9c6f7655675ed6db5cb50612c
2017-01-18 18:22:50 +01:00
Kenny Guy
b275a205af Fix issue with saving admins before finishing loading.
am: f98ed6863a

Change-Id: I7f816c164548df86f9607c86772902efd0d53620
2017-01-18 17:13:31 +00:00
Michal Karpinski
d084ca5fad Fix test DevicePolicyManagerTest#testSetRequiredStrongAuthTimeout_DeviceOwner
1) Started returning the default value for getLong() on SystemProperties mock
2) Added a test that the minimum timeout cannot be changed using a system
   property on non-debuggable builds
3) Added new within range test for completeness.
4) Started using TimeUnit instead of ms constants.

Test: runtest --path frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
Bug: 34317979
Change-Id: I0409451ae39e74ec3d96a098042302291ec3408f
2017-01-18 16:25:17 +00:00
Kenny Guy
f98ed6863a Fix issue with saving admins before finishing loading.
Saving device policy managers settings to clear out
password stats was happening before initializing mAdminList
so could wipe active admins.

Test: manual - flash with N2G05C add google account with dmagent flash wth this fix, check dmagent is still an active admin, reboot check admin is still active.
Test: runtest -c com.android.server.devicepolicy.DevicePolicyManagerTest frameworks-services

Bug: 34277435
Change-Id: I13660b47f30e9aba001eb13f2e457c3b3f36da3e
(cherry picked from commit adbda7474cc1968b66e9948aee566dc346e71340)
2017-01-18 12:01:55 +00:00
Pavel Grafov
eaed75d923 Merge "Make ENSURE_VERIFY_APPS global even when set by PO." 2017-01-18 11:15:28 +00:00
Kenny Guy
4228bcadb4 Fix issue with saving admins before finishing loading. am: adbda7474c
am: 4cccc791f4

Change-Id: Ifa4c9557a3c7f505e6ced657ecd42cd0242a5ea4
2017-01-18 01:40:47 +00:00
Kenny Guy
adbda7474c Fix issue with saving admins before finishing loading.
Saving device policy managers settings to clear out
password stats was happening before initializing mAdminList
so could wipe active admins.

Test: manual - flash with N2G05C add google account with dmagent flash wth this fix, check dmagent is still an active admin, reboot check admin is still active.
Test: runtest -c com.android.server.devicepolicy.DevicePolicyManagerTest frameworks-services

Bug: 34277435
Change-Id: I13660b47f30e9aba001eb13f2e457c3b3f36da3e
2017-01-17 23:37:57 +00:00
Pavel Grafov
d65799ee81 Store pending OTA state and make it accessible via polling api.
Change-Id: Ieb71dfb902371a683b17561f51ba9c2c730eb37b
Test: gts-tradefed run gts -a armeabi-v7a -m GtsGmscoreHostTestCases -t com.google.android.gts.devicepolicy.DeviceOwnerTest
Bug: 31000521
2017-01-17 15:06:22 +00:00
Pavel Grafov
6a40f09083 Make ENSURE_VERIFY_APPS global even when set by PO.
Currently only device owner can set global user restrictions.
With this CL ENSURE_VERIFY_APPS will be global no matter who
enforces it, DO or PO.

To make it possible for system apps to check who enforces a
particular restriction in this case a new API method is added
to UserManager: getUserRestrictionSources which returns a list
of users who enforce the restriction.

Bug:31000521
Test: cts-tradefed run cts -m CtsDevicePolicyManagerTestCases -t com.android.cts.devicepolicy.UserRestrictionsTest (ag/1732744)
Test: runtest --path frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
Test: runtest --path frameworks/base/services/tests/servicestests/src/com/android/server/pm/UserRestrictionsUtilsTest.java
Test: runtest --path frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerServiceMigrationTest.java
Test: installed M on a Nexus5x device, created a managed profile with some user restrictions, and checked that after upgrading M->O all restrictions are preserved and split correctly into base, global and local.
Change-Id: I543d3ec9ef0cf2b730da6f7406021c0bba43b785
2017-01-16 18:29:01 +00:00
TreeHugger Robot
ef99fb85f9 Merge "Make device wide DO features available if all users affiliated" 2017-01-16 18:09:51 +00:00
Esteban Talavera
d36dd15d9b Make device wide DO features available if all users affiliated
Currently, those features are available on single user devices only
(since they collect privacy sensitive data device wide). Now making
them available as long as all users are affiliated.

It'll take a certain amount of time between user creation and the DPC
of that new user setting the appropriate affiliation ids. The DO won't
be able to access the logs during that time (and won't get any "logs
ready" callback). Once the affiliation ids are set, if they match,
logs become available again - this includes logs collected while the
user was being setup. Some logs might be lost though if the amount of
data exceeds the internal limit.

Test: runtest -c com.android.server.devicepolicy.DevicePolicyManagerTest frameworks-services

Test: cts-tradefed run cts -a armeabi-v7a --module CtsDevicePolicyManagerTestCases --test com.android.cts.devicepolicy.DeviceOwnerTest

Bug: 32326223

Change-Id: Idfe881dd6497d3ad2bead10addfd37b98b8a6e2b
2017-01-16 11:13:01 +00:00
TreeHugger Robot
18de051c98 Merge "Send EXTRA_USER with DevicePolicy lock broadcasts" 2017-01-14 17:12:57 +00:00
Bartosz Fabianowski
9e0642287e Merge "Add install reason" 2017-01-14 12:58:20 +00:00
Andrew Scull
3c9b36482f resolve merge conflicts of ad4aa1ce7d3d to nyc-mr1-dev am: eb35ad9969
am: 3aac3ebee1

Change-Id: Id7be6d9656b292ec1bf526750db8081022267c4a
2017-01-13 21:16:31 +00:00