931 Commits

Author SHA1 Message Date
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
Amith Yamasani
0a5aeecf4e Merge "Revert "[DPM] Allow lower strong auth timeout on debuggable builds"" 2016-12-15 22:15:46 +00:00
Amith Yamasani
960128c9c6 Revert "[DPM] Allow lower strong auth timeout on debuggable builds"
Reverting because the length of the prop key is out of bounds.

Bug: 33662416
This reverts commit 60d1feed92bcca9f437a9b323152609d8d5fc714.

Change-Id: I66a3f7f18e668acbf2ddaf60ab8efa2584799906
2016-12-15 20:18:39 +00:00
Nicolas Prévot
1548d5c43b Merge "Use affiliation ids when checking bind target users." 2016-12-15 14:31:39 +00:00
Michal Karpinski
b775737e95 Merge "Make NetworkLogger.mIsLoggingEnabled an AtomicBoolean" 2016-12-15 12:57:04 +00:00
Michal Karpinski
92cd0ce92d DO NOT MERGE Make NetworkLogger.mIsLoggingEnabled an AtomicBoolean
Fixes a potential race condition - when enabling/disabling the logging
some events might have been lost.

Bug: 29748723
Change-Id: I8a436d525393b2314805e287eddcea26d4ec073b
2016-12-15 12:54:36 +00:00
Michal Karpinski
d8145f6743 Make NetworkLogger.mIsLoggingEnabled an AtomicBoolean
Fixes a potential race condition - when enabling/disabling the logging
some events might have been lost.

Bug: 29748723
Change-Id: I8a436d525393b2314805e287eddcea26d4ec073b
2016-12-15 12:53:48 +00:00
Michal Karpinski
67ed651dab Merge "[DPM] Allow lower strong auth timeout on debuggable builds" 2016-12-15 12:20:27 +00:00
Michal Karpinski
60d1feed92 [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_strong_auth_timeout system property.

Bug: 29825955
Change-Id: I51d421c3e10625787ecfdbe011f9128cd47cb2a2
2016-12-14 15:23:35 +00:00
Nicolas Prevot
d5b036014d Use affiliation ids when checking bind target users.
BUG:32764274
Test: adb shell am instrument -e class
com.android.server.devicepolicy.DevicePolicyManagerTest -w
com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner

Change-Id: Ic79b58dcb583b1d9eb9e7af0d1501cf8cfd0ee86
2016-12-14 15:15:10 +00:00
Esteban Talavera
6c9116a643 Create DISALLOW_{ADD,REMOVE}_MANAGED_PROFILE user restrictions
Bug: 31952368

Test: runtest -c com.android.server.devicepolicy.DevicePolicyManagerTest    frameworks-services
Test: runtest -c com.android.server.pm.UserManagerTest frameworks-services
Test: cts-tradefed run cts --module DevicePolicyManager --test com.android.cts.devicepolicy.UserRestrictionsTest

Change-Id: I240ab99c2409bbabffbc574bef202f2457026905
2016-12-13 18:14:19 +00:00
Michal Karpinski
c4e7c32063 DO NOT MERGE Logging when the new batch of network logs broadcast is sent to DO
Test: this only adds a log message
Bug: 29748723

(cherry picked from commit bcf1c58ec25f275fa25f8aab1c265da868e64e29)

Change-Id: Iad57528c60f35d4820a2f0196cccc92f7c4d3830
2016-12-13 17:24:55 +00:00
Michal Karpinski
504fa62f9e DO NOT MERGE Disable DO single user features when clearDeviceOwner() is called
regardless of the amount of users

Bug: 32901196
Bug: 29748723
Change-Id: Ie419b5e496e23656cbe5436942d9aba402bfe68e
2016-12-13 17:24:17 +00:00
Michal Karpinski
5c64223da4 DO NOT MERGE Fix disabling DO single user features when clearDeviceOwner() is called
We should disable those features before the DO is actually cleared.

Bug: 32901196
Bug: 29748723

(cherry picked from commit c44e67961170ddfb668372dc6e9ce6b391e3740f)

Change-Id: I74679abc26753585f302f3d52bca81fe21e2e668
2016-12-13 17:23:42 +00:00
Michal Karpinski
896b9db8ed DO NOT MERGE [DPM] Minor code fixes in NetworkLoggingHandler
Added a comment and renamed field to follow mConvention.

Test: will be CTS tested once APIs unhidden
Bug: 29748723

(cherry picked from commit aabe96db87838501d3abeb96c25a4b1c50b9c12c)

Change-Id: I7ef118723d13ce1d313c3c56299c2dca2411eee6
2016-12-13 17:22:53 +00:00
Michal Karpinski
bbf352a2c1 DO NOT MERGE [DPM] DO uses batch token to retrieve network logs, and can retrieve
the same batch many times

This allows DO to:
a) know that some logs were dropped (by trying with token and not
getting anything)
b) know how many logs were there in each batch (useful especially
for the dropped ones)
c) retry batch retrieval if it failed

Test: will be CTS tested once APIs unhidden
Bug: 29748723

(cherry picked from commit a9ff206af26871695bfce54969428b8ad03e31e6)

Change-Id: Iac10e61cdf3b100719a9c029ff897bd5ef5c8e2f
2016-12-13 17:22:07 +00:00
Michal Karpinski
4c47adef60 DO NOT MERGE [DPM] Management and retrieval of network logs
This CL follows up on ag/1530343 and adds:
1) Various network events.
2) Retrieval method in DPM and APIs in DeviceAdminReceiver.
3) Extension of NetworkLogger and it's NetworkLoggingHandler.

Test: runtest --path frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/NetworkEventTest.java
Bug: 29748723
Change-Id: I42a1a477e7c75c109a3982f809c22732b814e8b2
2016-12-13 17:19:22 +00:00
Michal Karpinski
c3abd34cfe DO NOT MERGE [DPM] DO can start network logging and listen for events
This CL adds:
1) Setter and getter in DPM to manipulate logging switch (retrieval
method to come in a subsequent CL(s)).
2) A way for DPM to register to listen for events.
3) Skeleton of NetworkLogger class (more to come in subsequent CL(s)).

Bug: 29748723
Change-Id: I5c04662ccc6febd2ba294b0eaca1ed1da9c16e47
2016-12-13 17:15:38 +00:00
Philipp Weiß
9498f5a81b Merge "Add network logging icon to Quicksettings when enabled" 2016-12-09 16:31:41 +00:00
phweiss
a4e169ed68 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.

BUG: 33126618
BUG: 29748723
Test: runtest --path frameworks/base/packages/SystemUI/tests
Change-Id: Ib35d323605ab11f883a4b6199d1db79b9e53c49b
2016-12-08 16:34:25 +01:00
TreeHugger Robot
3c41744b8c Merge "Clear DISALLOW_ADD_USER user restriction when dpm remove-active-admin is called from shell" 2016-12-08 13:54:41 +00:00
Victor Chang
d9758e7479 Clear DISALLOW_ADD_USER user restriction when dpm remove-active-admin is called from shell
- Make the CTS hermetic and not adding new restriction after CTS test
- DeviceOwner can't clear this user restriction in CTS, as it's set by ManagedProvisioning
- It can be only clear when testOnly DPC becomes deviceOwner, and being removed by remove-active-admin in shell

Bug:31856203
Test: build successfully

Change-Id: I75b91629ef09c54e9dbe7253df6a52894a938e83
2016-12-07 20:26:43 +00:00
Mahaver Chopra
abf86385f8 Merge "Return error code from isProvisioningAllowed" 2016-12-06 09:45:05 +00:00
Mahaver Chopra
849fd6f58e Return error code from isProvisioningAllowed
Added hidden pre condition codes for PO and DO provsioning.
Added hidden api checkProvisioningPreCondition, which returns codes
instead of boolean. Managed provisioning can use this to show
useful debug information and user facing error dialogs.

Test: All DevicePolicyManagerTest pass

Bug: 27467633
Change-Id: I7d2a79921bc3ac2e12d506629a35563fc7ff62bf
2016-12-05 17:48:42 +00:00
Amith Yamasani
f81df2d5e5 Merge "Secure MATCH_UNINSTALLED_PACKAGES across users" 2016-12-01 17:01:07 +00:00
TreeHugger Robot
3db81ae38d Merge "Revise when to throw SecurityException in bindDeviceAdminServiceAsUser" 2016-12-01 11:52:05 +00:00
Amith Yamasani
0d1fd8d091 Secure MATCH_UNINSTALLED_PACKAGES across users
Introduce a new internal flag MATCH_ANY_USER for genuine uses
of searching through all apps on the device.

Some temporary accommodations for Launchers that reach across
to the work profile until we have a new LauncherApps API to do
that officially.

Bug: 31000380
Test: CTS tests added
Change-Id: I2e43dc49d6c2e11814a8f8d1eb07ef557f31af34
2016-11-30 13:24:53 -08:00
Bartosz Fabianowski
365a3db470 Allow setting managing organization for the device
The Profile Owner of a managed profile can set a string that will be
shown in the UI to identify the organization managing the profile.
This CL extends the functionality to the Device Owner of a managed
device.

Bug: 32692748
Test: DevicePolicyManagerTest unit test + CTS test in separate CL

Change-Id: I47295da2fd6485ebf0e890da13990a044accaf17
2016-11-30 18:28:10 +01:00
Tony Mak
700c6ae748 Revise when to throw SecurityException in bindDeviceAdminServiceAsUser
1. No longer throw SecurityException when we fail to resolve the intent.
   Return false instead.

2. Throw IllegalArgumentException early if the incoming intent is not
   explicit.

3. Throw SecurityException with different error message. It makes debug
   easier and allows tests to verify a particular thing happened.

Bug: 33197200

Test: cts-tradefed run cts --module DevicePolicyManager --test com.android.cts.devicepolicy.DeviceOwnerPlusManagedProfileTest

Change-Id: I723ab7f434c10407aa4e7dc8e9a6e3e9bb9f2059
2016-11-30 14:59:39 +00:00
Bartosz Fabianowski
dd7f8dafd8 Allow DO to access DevicePolicyManager.isDeviceManaged()
This CL makes DPM.isDeviceManaged() accessible to the DO so that it
can be CTS-tested.

Bug: 32692748
Test: Device policy manager unit test + CTS & GTS in separate CLs

Change-Id: I5326e86b0ffee81d04bd48f0267044463a899b78
2016-11-30 11:09:22 +01:00
TreeHugger Robot
9f9e453b64 Merge "Unit test for getBindDeviceAdminTargetUsers" 2016-11-30 09:58:11 +00:00
TreeHugger Robot
b57bd791bf Merge "Add user affiliation APIs" 2016-11-29 16:09:10 +00:00
Esteban Talavera
c9bb378a8b Add user affiliation APIs
Make setAffiliationIds public so that it can be used for COMP.
That way we can allow network logging and other features to
work on devices that have a DO and a managed profile.
Those features are currently restricted to single user devices but we'll
open them up to devices where all users are affiliated.

Also create a getter for that API.

Bug: 32326223
Test: m FrameworksServicesTests &&
 adb install \
   -r ${ANDROID_PRODUCT_OUT}/data/app/FrameworksServicesTests/FrameworksServicesTests.apk &&
 adb shell am instrument -e class com.android.server.devicepolicy.DevicePolicyManagerTest \
   -w com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner

Change-Id: Ie443be887a6ca61a7f7a07e137757dceab7eb3d3
2016-11-29 12:15:09 +00:00
Tony Mak
2f26b79eea Unit test for getBindDeviceAdminTargetUsers
Was meant to write test for bindDeviceAdminServiceAsUser, but
it can't be done without having tests for
getBindDeviceAdminTargetUsers first as bindDeviceAdminService depends
on getBindDeviceAdminTargetUsers.

A bit shocked by we didn't have any managed profile tests in
DevicePolicyManagerTest. Added managed profile support in the CL.

Bug: 32764274

Test: runtest -x frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java

Change-Id: If412e4f44c3ae998f69e17411f2503a97f80149f
2016-11-28 17:54:51 +00:00
Nicolas Prévot
22b2a81f75 Merge "Send callbacks to DO when a user is added or removed." 2016-11-28 16:50:08 +00:00
TreeHugger Robot
bbef8cdd2a Merge "Logging when the new batch of network logs broadcast is sent to DO" 2016-11-25 17:16:38 +00:00
Michal Karpinski
bcf1c58ec2 Logging when the new batch of network logs broadcast is sent to DO
Test: this only adds a log message
Bug: 29748723
Change-Id: I07ca1613c26a34517f5a452ca848aa763a48f8a0
2016-11-25 15:30:15 +00:00
Bartosz Fabianowski
8d76e72251 Allow DO to access bookkeeping information about its own actions
The getLastSecurityLogRetrievalTime(), getLastBugReportRequestTime()
and getLastNetworkLogRetrievalTime() methods are meant to be used by
system code. However, there is no harm in allowing the DO to access the
information they return - because it is information about actions that
the DO itself took.

The advantage of opening up these methods to the DO is that we can
CTS-test them.

Bug: 32692748
Test: DevicePolicyManager unit test + CTS test in separate CL

Change-Id: I1470fca2a82b9955f7aed5e8b50220bea8b56fc9
2016-11-25 12:36:20 +01:00
TreeHugger Robot
8d4527db19 Merge "Add getBindDeviceAdminTargetUsers API" 2016-11-24 18:02:23 +00:00
Nicolas Prevot
e95c2817f7 Send callbacks to DO when a user is added or removed.
BUG:32764090
Test: manual
Change-Id: Icfac801fd2c9670f3d68cf6971f7aba2332dbb6b
2016-11-24 17:18:25 +00:00
Esteban Talavera
fc291bcbe0 Add getBindDeviceAdminTargetUsers API
Add getBindDeviceAdminTargetUsers API. To be used
for the device or profile owner in a COMP setup to
know the UserHandle of their instance running on
the other profile.

Bug: 31952368,33033966
Test:  cts-tradefed run cts --module DevicePolicyManager --test com.android.cts.devicepolicy.DeviceOwnerPlusManagedProfileTest

Change-Id: I05c9ac0f6c3cdce1ec17cf2910ca7a7214064af2
2016-11-24 16:15:44 +00:00
Michal Karpinski
08be96ec87 Disable DO single user features when clearDeviceOwner() is called
regardless of the amount of users

Bug: 32901196
Bug: 29748723
Change-Id: Ie419b5e496e23656cbe5436942d9aba402bfe68e
2016-11-23 11:42:31 +00:00
TreeHugger Robot
29993074b0 Merge "Keep track of admin actions for DO disclosures" 2016-11-17 21:40:46 +00:00
Bartosz Fabianowski
b21b241f0f Keep track of admin actions for DO disclosures
This CL adds bookkeeping to DPMS which will allow us to tell the user
in the Settings UI whether/when the admin requested a bug report or
retrieved logs from the device.

Bug: 32692748
Test: Full DevicePolicyManagerTest unit test coverage; end-to-end tests
        will follow as Settings CTS verifier tests

Change-Id: I89728fce4b7e0ff061b354c73caf3742e95a3a3e
2016-11-17 20:52:03 +01:00
Nicolas Prévot
554140fc89 Merge "Check user restriction DISALLOW_REMOVE_USER in isProvisioningAllowed." 2016-11-17 11:35:42 +00:00