825 Commits

Author SHA1 Message Date
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
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
Andrew Scull
3aac3ebee1 resolve merge conflicts of ad4aa1ce7d3d to nyc-mr1-dev
am: eb35ad9969

Change-Id: I4fd9ce4c79db5a10f28008c89205fc9c8ef2888f
2017-01-13 17:17:49 +00:00
Bartosz Fabianowski
a34f53f61b Add install reason
This CL allows a reason to be specified when installing a package. The
install reason is a sticky piece of metadata: When a package is e.g.
installed via enterprise policy and an update is then manually
installed or sideloaded, the install reason will remain "policy."
The install reason is tracked separately for each user.

With this CL, two install reasons exist: "policy" and "unknown." Other
install reasons will likely be supported in the future.

Bug: 32692748
Bug: 33415829
Test: Tested manually with "adb install" / "adb uninstall"

Change-Id: I0c9b9e1b8eb666bb6962564f6efd97e41703cd86
2017-01-13 16:51:28 +01:00
Andrew Scull
eb35ad9969 resolve merge conflicts of ad4aa1ce7d3d to nyc-mr1-dev
Change-Id: I97ef31536cd06495a08a3f94f81df2d1376186e0
2017-01-13 15:28:36 +00:00
Andrew Scull
ad4aa1ce7d resolve merge conflicts of e4cefbf4fce4 to nyc-dr1-dev
Change-Id: Ib536a33ba381c28397320edd516d52727e5bdacc
2017-01-13 13:16:09 +00:00
Andrew Scull
a7d1580547 Merge "Save password metrics on non-FBE devices." 2017-01-13 11:49:20 +00:00
Michal Karpinski
4da4a5d0c8 [DPM] Improvements to the network logs batch finalization mechanism
The full batch will still be available to DPC if there were no
network logs pending.
Added some more debug logging to better investigate the issues.

Test: manual for both cases - pending batch was empty and non-empty,
      with locally decreased timeout
Test: cts-tradefed run cts --module DevicePolicyManager --test com.android.cts.devicepolicy.DeviceOwnerTest#testNetworkLoggingWithSingleUser

Bug: 34245471
Bug: 29748723
Change-Id: Iee229d74d4b0a06025b305a15687f336a0aa337e
2017-01-12 17:10:02 +00:00
Andrew Scull
e4cefbf4fc Don't save password metrics to disk.
On FBE devices, don't save the metrics to disk but compute them when the
password is first entered and only store them in RAM.

Merged-in: 5daf273b7e3272269c53eda20ce494d0e7a365b5
Bug: 32793550
Change-Id: Icee7f615167761177b224b342970a36c7d90f6ba
2017-01-12 16:01:59 +00:00
Michal Karpinski
3dcd39c14a [DPM] Improvements to the network logs batch finalization mechanism
The full batch will still be available to DPC if there were no
network logs pending.
Added some more debug logging to better investigate the issues.

Test: manual for both cases - pending batch was empty and non-empty,
      with locally decreased timeout
Test: cts-tradefed run cts --module DevicePolicyManager --test com.android.cts.devicepolicy.DeviceOwnerTest#testNetworkLoggingWithSingleUser

Bug: 34157435
Bug: 29748723
Change-Id: Iee229d74d4b0a06025b305a15687f336a0aa337e
2017-01-12 15:05:12 +00:00
TreeHugger Robot
3e17ea13c1 Merge "[DPM] Allow lower strong auth timeout on debuggable builds" 2017-01-12 13:46:09 +00:00
Andrew Scull
7df0cb2924 Save password metrics on non-FBE devices.
DPM.setActivePasswordSufficient() can be called by a DPC before the
password has been entered on non-FBE devices. The metrics must be saved
so this API can work correctly.

Bug: 32793550
Test: manual
Change-Id: I078d0f1f98875d577aeaf25f12dc9c27e3f80658
2017-01-12 12:28:14 +00:00
Michal Karpinski
2df5919faa [DPM] Allow lower strong auth timeout on debuggable builds
Timeout can be set to lower than 1h on debuggable builds (eng, user-debug)
using persist.sys.min_str_auth_timeo system property. This allows manual
testers to more easily carry out testing scenarios.

Bug: 29825955
Test: manual without setting the property: if timeout is set to less than 1h, it's clamped to 1h
Test: manual with setting the property: on user-debug build with "adb root && adb shell setprop persist.sys.min_str_auth_timeo 30000"
Change-Id: I8cd871e3d04b2c6c7164f684b9a6a24e7292bfab
2017-01-12 11:36:20 +00:00
Pavel Grafov
a902e5c255 Merge "Let profile owners also receive OTA notification." 2017-01-12 11:12:01 +00:00
Pavel Grafov
19b3ecb9c8 Let profile owners also receive OTA notification.
Also removed the code that sends broadcast to all device admins
in profile owner package since it was used for legacy
provisioning of the whole package and now should be migrated
by findOwnerComponentIfNecessaryLocked().

Test: gts-tradefed run gts -a armeabi-v7a -m GtsGmscoreHostTestCases -t com.google.android.gts.devicepolicy.ManagedProfileTest
Change-Id: I6316df7375fd24da133c83c7930815ba909194f2
Bug:31000521
2017-01-11 18:08:10 +00:00
phweiss
df7bfcfc22 Add ticker text for network logging notification
Set ticker text to title for accessibility.

Bug:31207965
Test: manual

Change-Id: I0b78f9e6464dd470b74e0db97813623b335835d9
(cherry picked from commit d4a54bbfd1902dccb0e4de03f15bfbbba50b9531)
2017-01-11 15:04:00 +00:00
phweiss
d4a54bbfd1 Add ticker text for network logging notification
Set ticker text to title for accessibility.

Bug:31207965
Test: manual

Change-Id: I0b78f9e6464dd470b74e0db97813623b335835d9
2017-01-11 14:38:29 +01:00
Andrew Scull
54402aab14 Merge "Evict CE key on request and when work mode is turned off." 2017-01-10 13:20:49 +00:00
phweiss
971236480c Dismiss network logging notification when disabling logging
Bug:34116213
Bug:29748723
Test: CTSVerifier in a separate CL.

Change-Id: Ie652505ff57665f626712c67837577833f1595d6
(cherry picked from commit 82ed31c1efeb98acba60d79d1fc0a291b1440dc2)
2017-01-10 10:16:12 +00:00
Philipp Weiß
18315230f6 Merge "Dismiss network logging notification when disabling logging" 2017-01-10 10:15:26 +00:00
Robin Lee
d2a73ed211 Send EXTRA_USER with DevicePolicy lock broadcasts
DeviceAdmins inside profiles may receive broadcasts referring either
to the parent profile or to themselves.

We need a way to differentiate that.

Same commit fixes a bug in DevicePolicyManagerTest where USER_SYSTEM
is returned twice in getProfiles() when called for a managed profile of
USER_SYSTEM. This does not happen in the real API.

Bug: 30185351
Bug: 31001762
Test: runtest -x services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
Change-Id: Iea2735357f4019b2b81b6784e7ea6aead63f2636
2017-01-09 18:56:12 +00:00
phweiss
82ed31c1ef Dismiss network logging notification when disabling logging
Bug:34116213
Bug:29748723
Test: CTSVerifier in a separate CL.

Change-Id: Ie652505ff57665f626712c67837577833f1595d6
2017-01-09 18:52:35 +01:00
Makoto Onuki
a755fb1030 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 TestDPC, both on 1) the primary user,
2) a secondary user and 3) work profile.
* Modified TestDPC so it supports secondary users

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

Bug 30681079

Change-Id: Ib97a92a6af87a5589d2643b9ae0522395735e1a5
2017-01-04 16:44:22 -08:00
Makoto Onuki
cbfec5d491 Follow-up to I1e4dd97
Don't check the accounts when the caller is not ADB.

MR2 already has this change.

Test: cts-tradefed run cts --skip-device-info --skip-preconditions --skip-system-status-check com.android.compatibility.common.tradefed.targetprep.NetworkConnectivityChecker -a armeabi-v7a -m CtsDevicePolicyManagerTestCases -t com.android.cts.devicepolicy.AccountCheckHostSideTest
* without having Id49f2bd5dfa80ecf35b3a23c789100ade38c2656 *

Test: adb shell am instrument -e class com.android.server.devicepolicy.DevicePolicyManagerTest -w com.android.frameworks.servicestests
Change-Id: I654c41d0e7434c5fce75eb2df5fd7686a54e9093
2017-01-04 11:01:29 -08:00
Makoto Onuki
fd24353d75 Get account features before taking lock (cherry-pick from master)
Test: cts-tradefed run cts --skip-device-info --skip-preconditions --skip-system-status-check com.android.compatibility.common.tradefed.targetprep.NetworkConnectivityChecker -a armeabi-v7a -m CtsDevicePolicyManagerTestCases -t com.android.cts.devicepolicy.AccountCheckHostSideTest
* without having Id49f2bd5dfa80ecf35b3a23c789100ade38c2656 *

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

Bug: 33481725
Change-Id: Ie2fe9aea87d1a7167581f4cd74ae063ef24a4567
Merged-in: I1e4dd9701a76ca366f86fdaf2fc6c282e9dbe5c1
2017-01-04 09:04:09 -08:00
Makoto Onuki
9bab1c4dd5 Merge "Get account features before taking lock" 2017-01-03 21:34:41 +00:00
Makoto Onuki
606da7778f Get account features before taking lock
Test: cts-tradefed run cts --skip-device-info --skip-preconditions --skip-system-status-check com.android.compatibility.common.tradefed.targetprep.NetworkConnectivityChecker -a armeabi-v7a -m CtsDevicePolicyManagerTestCases -t com.android.cts.devicepolicy.AccountCheckHostSideTest
* without having Id49f2bd5dfa80ecf35b3a23c789100ade38c2656 *

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

Bug: 33481725
Change-Id: I1e4dd9701a76ca366f86fdaf2fc6c282e9dbe5c1
2017-01-03 10:58:23 -08:00
Robin Lee
f8ced7790a Merge "Don't check for monitoring CA certs in cryptkeeper" 2017-01-03 18:43:52 +00:00
Robin Lee
a04a29ae02 Don't check for monitoring CA certs in cryptkeeper
Change-Id: I35dc031e4cd652a79174d03f6a9f02120f46abd2
Test: CtsVerifier (ca certificate test)
Fix: 33454899
2016-12-23 16:38:00 +00:00
TreeHugger Robot
43769ddb2c Merge "Add DISALLOW_ADD_MANAGED_PROFILE to existing device owners" 2016-12-22 10:29:31 +00:00
Esteban Talavera
548a04b8f8 Add DISALLOW_ADD_MANAGED_PROFILE to existing device owners
For device owners set pre-O, that restriction will not
be set via setDeviceOwner(). Therefore set it during
first boot after O OTA.

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

Bug: 31952368

Change-Id: I7db9b14c49a75ae2760e6923a1f3f7cde0e2784b
2016-12-21 10:57:12 +00:00
phweiss
923d2cc9d9 DO NOT MERGE Show notification when network logging is enabled
A notification is shown after network logging is enabled
and after the next three reboots that are at least one day apart.

Clicking it sends an intent to quick settings to shown its device monitoring
dialog.

Cherry-picked from master.

Bug: 29748723
Bug: 33126577

(cherry-picked from commit a0cb251ca6a8ea8df17ff8089573bc50f2f1849f)

Test: Manual, CTS-Verifier tests will be added later
Change-Id: I2bf517bd27ab23ad3f66270602dbf062efab8cbb
2016-12-20 19:23:58 +01:00
Andrew Scull
85a63bc1a0 Evict CE key on request and when work mode is turned off.
DPMS.lockNow takes a flag which can request the managed profile CE key to
be evicted.

Test: com.android.cts.devicepolicy.ManagedProfileTest#testLockNowWithKeyEviction*
Bug: 31000719
Change-Id: I68f4d6eed4b041c39fd13375f7f284f5d6ac33da
2016-12-20 17:37:03 +00:00
Philipp Weiß
cbe76a0f1e Merge "Show notification when network logging is enabled" 2016-12-20 15:58:44 +00:00
Philipp Weiß
f84f98c4e2 Merge "DO NOT MERGE Add network logging icon to Quicksettings when enabled" into nyc-mr2-dev 2016-12-19 17:57:16 +00:00
phweiss
a0cb251ca6 Show notification when network logging is enabled
A notification is shown after network logging is enabled
and after the next three reboots that are at least one day apart.

Clicking it sends an intent to quick settings to shown its device monitoring
dialog.

Bug: 29748723
Bug: 33126577

Test: Manual, CTS-Verifier tests will be added later
Change-Id: I2bf517bd27ab23ad3f66270602dbf062efab8cbb
2016-12-19 15:59:58 +01:00
Andrew Scull
7cd4536e80 Merge "Don't save the password metrics to disk." 2016-12-19 14:48:37 +00:00
TreeHugger Robot
805e893e35 Merge "Enforce DISALLOW_ADD_MANAGED_PROFILE" 2016-12-19 11:57:13 +00:00
Esteban Talavera
01576869a3 Enforce DISALLOW_ADD_MANAGED_PROFILE
Only the device owner should be able to create a managed
profile if that restriction is set

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

Bug: 31952368

Change-Id: Ia5170e54594ccba1e5bcedffaec98c2af42264c0
2016-12-19 11:54:11 +00:00
phweiss
c94b637305 DO NOT MERGE Add network logging icon to Quicksettings when enabled
Add the network logging icon in Quick Settings' footer if
network logging is enabled, possible next to the VPN icon.
Quicksettings has to be able to tell that network logging
is enabled, so this CL changes DPM.isNetworkLoggingEnabled() to be
callable from the device owner or from any app with the MANAGE_USERS
permission.

The icon is only a placeholder until the official icon is finished.

CTS Verifier tests will be added when all Network logging UX changes are
done.

Cherry-picked from master, and then modified to work in N:
I had to remove the QSFooterTest change because the testing infrastructure
is not there in N. Also, I had to add DPMS.enforceDeviceOwnerOrManageUsers()
to which did not exist in N before.

BUG: 33126618
BUG: 29748723
Test: Manual, CTS-Verifier tests will be added in a follow-up

(cherry picked from commit a4e169ed68ee57aa249e5e79fcd6bff5df46199e)

Change-Id: Ib35d323605ab11f883a4b6199d1db79b9e53c49b
2016-12-16 19:25:29 +01:00
Michal Karpinski
a775ad997b Initialize AtomicBoolean for NetworkLogger#mIsLoggingEnabled
Test: cts-tradefed run cts --module DevicePolicyManager --test com.android.cts.devicepolicy.DeviceOwnerTest#testNetworkLoggingWithSingleUser
Bug: 29748723

(cherry picked from commit e4dfd2d0028ff1c7088ec58a4d3eaf8f222311e6)

Change-Id: Ib175f1d57093590b0080f32dc5f6c60ea50066e0
2016-12-16 18:18:57 +00:00
Michal Karpinski
e4dfd2d002 Initialize AtomicBoolean for NetworkLogger#mIsLoggingEnabled
Test: cts-tradefed run cts --module DevicePolicyManager --test com.android.cts.devicepolicy.DeviceOwnerTest#testNetworkLoggingWithSingleUser
Bug: 29748723
Change-Id: Ib175f1d57093590b0080f32dc5f6c60ea50066e0
2016-12-16 18:09:12 +00:00
Andrew Scull
5daf273b7e Don't save the password metrics to disk.
Only store the metrics in RAM, computing them at first log in.

Test: com.android.cts.devicepolicy.DeviceAdminHostSideTestApi24
Bug: 32793550
Change-Id: Iaf9516c193f054331e3e2c68cb3f627bd543b408
2016-12-16 15:30:14 +00:00