1122 Commits

Author SHA1 Message Date
Benjamin Franz
751cbc64b6 Merge "Update lock task features name and javadoc" 2018-02-22 14:08:33 +00:00
Benjamin Franz
caffa7789c Update lock task features name and javadoc
Remove reference to recent and replace by overview. Also throw an IAE
if recents is enabled without home.

Also address API council feedback for ActivityOption.setLockTaskMode

Bug: 72807036
Bug: 72799389
Bug: 71790952
Bug: 71866618
Test: atest FrameworksServicesTests:DevicePolicyManagerTest
Change-Id: I70bed3b46137870e6bf0af5bf7f0846dc51f91ab
2018-02-19 16:47:28 +00:00
arangelov
32618aae9e Fix TransferOwnershipMetadataManager tests.
Test: bit FrameworksServicesTests:com.android.server.devicepolicy.TransferOwnershipMetadataManagerTest
Bug: 73448505
Change-Id: I06fc52b13ed27a77213cfb3b15dff3f7161f5be0
2018-02-19 13:07:29 +00:00
TreeHugger Robot
e6823b8199 Merge "Frameworks: Annotate trivial @GuardedBy in services/ misc" 2018-02-08 20:21:26 +00:00
Andreas Gampe
bbab23ff97 Frameworks: Annotate trivial @GuardedBy in services/ misc
Add @GuardedBy for simple functions that require a single lock
and are named XYZLocked.

Derived by errorprone.

Bug: 73000847
Test: m
Test: m javac-check-framework RUN_ERROR_PRONE=true
Change-Id: Id1d9fbe5018250e3b9d1466fc5f670d5ad902fa3
2018-02-08 02:19:42 -08:00
Pavel Grafov
b745540445 Run and log BoringSSL self-test for NIAP compliance.
Bug: 70886042
Test: manual, using "adb shell su system logcat -b security"
Change-Id: I46f243838e2fb432995c7c89e4279d36a4788678
2018-02-07 18:59:43 +00:00
Vladislav Kuzkokov
622b9f9212 Make printing policy a restriction.
Use existing API instead of creating new method.

Bug: 64140119
Test: cts-tradefed run cts-dev --module CtsDevicePolicyManagerTestCases --test com.android.cts.devicepolicy.MixedDeviceOwnerTest#testPrintingPolicy

Change-Id: I9ff94f4d73824e7bf9aedbb64811ad60fccf9779
2018-02-05 22:30:05 +01:00
Pavel Grafov
5bb5a6219d Introduce "adb shell dpm force-security-logs"
This command fetches the most recent batch of the logs
and makes them available to the DPC. Primary purpose is
to make security logging testable in CTS without having
to either wait for 2 hours or relying on implementation
details.

To prevent the user from abusing the command and
annoying the DPC, it is throttled if run more than once
per 10 seconds. Waiting happens in Dpm command.

Test: adb shell dpm force-security-logs
Bug: 70886042
Bug: 62251154
Change-Id: Ic5acd5a3e5c3b060881385c472df2b972961b626
2018-02-02 14:20:41 +00:00
Sudheer Shanka
a64df69b38 Merge "Update the logic for getting metered data disabled pkgs in DPMS." 2018-01-31 02:08:17 +00:00
Sudheer Shanka
3bf7fd2d39 Update the logic for getting metered data disabled pkgs in DPMS.
Bug: 63700027
Test: atest com.android.cts.devicepolicy.MixedProfileOwnerTest#testSetMeteredDataDisabled
Test: atest com.android.cts.devicepolicy.MixedProfileOwnerTest#testSetMeteredDataDisabled
Test: atest com.android.server.devicepolicy.DevicePolicyManagerTest
Change-Id: I207f7d43d3aade7e91ae98f32e9b775b16b2153e
2018-01-30 15:46:24 -08:00
Alex Chau
596c2880b3 API Review: Return status code for user management APIs
- Replaced boolean return value with error code

Bug: 71866621
Test: com.android.cts.devicepolicy.DeviceOwnerTest#testCreateAndManageUser_StartInBackground
Test: com.android.cts.devicepolicy.DeviceOwnerTest#testCreateAndManageUser_StartInBackground_MaxRunningUsers
Test: com.android.cts.devicepolicy.DeviceOwnerTest#testCreateAndManageUser_CannotStopCurrentUser
Test: com.android.cts.devicepolicy.DeviceOwnerTest#testCreateAndManageUser_StopUser
Test: com.android.cts.devicepolicy.DeviceOwnerTest#testCreateAndManageUser_LogoutUser
Test: com.android.cts.devicepolicy.DeviceOwnerPlusProfileOwnerTest#testCannotStartManagedProfileInBackground
Test: com.android.cts.devicepolicy.DeviceOwnerPlusProfileOwnerTest#testCannotStopManagedProfile
Test: com.android.cts.devicepolicy.DeviceOwnerPlusProfileOwnerTest#testCannotLogoutManagedProfile
Change-Id: Iddc3e33c91c3f9584d53e537dbab3f61b8772fb1
2018-01-30 17:34:07 +00:00
Sudheer Shanka
bef8a1bef7 Merge "Add a DPM api to check if a pkg is restricted to use metered data." 2018-01-29 22:01:35 +00:00
TreeHugger Robot
56021c402d Merge "Make device owner user command foreground" 2018-01-29 19:36:47 +00:00
Sudheer Shanka
5be44ff31c Add a DPM api to check if a pkg is restricted to use metered data.
We need this so that Settings can check if an app is
restricted by admin from using metered data.

Bug: 63700027
Test: manual
Test: atest com.android.server.devicepolicy.DevicePolicyManagerTest
Change-Id: I9a2ea9c458b0f10a3c3c6edcbe82da9eccaa51c3
2018-01-29 11:24:46 -08:00
Pavel Grafov
a77e198ea8 Merge "Log additional events in security log." 2018-01-29 18:41:41 +00:00
TreeHugger Robot
6fa646ab95 Merge "Reduce pss collection amount, improve logging." 2018-01-29 16:52:08 +00:00
Pavel Grafov
ce72ef0f57 Log additional events in security log.
These events are required for US NIAP MDFPP v3.1 compliance.

Bug: 70886042
Test: manual
Change-Id: I1752469cf4c7ff499eb4356fa1c94f3146d4c9b8
2018-01-29 16:32:49 +00:00
TreeHugger Robot
81f7471a22 Merge "Remove return value in clearApplicationUserData" 2018-01-29 15:41:28 +00:00
TreeHugger Robot
206593e49c Merge "Add freeze period support in SystemUpdatePolicy" 2018-01-28 16:11:37 +00:00
Dianne Hackborn
e17b445b6c Reduce pss collection amount, improve logging.
Tuned rates that we collect PSS, to reduce how much we do
that heavy operation.  Added a new way to determine
whether a process has changed to a state for the
"first" time -- now this is when it has gone to that
state for the first time since it was in a lower state.
This will reduce the amount of time we consider a
process to be first to only when it has previously
gone into a higher state than it had before.

Keep track of more fine-grained information about why we
collect a PSS sample (not just internal, but for a single
process, all processes because of a mem state change, all
processes because of a poll).

Started collecting RSS in various places, so we can start
looking at that w.r.t. PSS and see about transitioning to
it is a new primary metric.

Added logging for many of the places where the system
writes its configuration files, so we can more easily
see any bad behavior going on in those areas.

Added some currently disabled code to read smaps directly
instead of using fgets().  Probably won't help, but want
tot test.

Bug: 70859548
Test: atest CtsAppTestCases
Change-Id: I400dba0f3ae9c024df51c946cfa592561028b598
2018-01-26 15:15:04 -08:00
Rubin Xu
29b9a7d1f4 Add freeze period support in SystemUpdatePolicy
Freeze period is defined as a pair of calendar dates (recurring annually)
during which the system should block any incoming system updates, including
security patches. They are set on top of existing system udpate policy
types (automatic, windowed, postpone) such that outside the freeze
periods existing policy semantics will still apply. They are created to
allow admin to keep their device fleet from any destabilizing changes during
critical period of the year, for example during Christmas sales period.

Device Owner can set several freeze periods, although to prevent the device
from not receiving OTAs indefinitely, each single freeze period is
restricted to be at most 90 days, and adjacent freeze periods need to be at
least 60 days apart. To properly enforce these restrictions, any freeze
periods the device previously experienced is tracked by DevicePolicyManager
and are validated against any new policy. This is to deal with corner cases
such as the admin repeatedly set a short but overlapping freeze period on a
rolling basis, hence bypassing the 90-day freeze period restriction.

Test: runtest -c com.android.server.devicepolicy.SystemUpdatePolicyTest frameworks-services
Bug: 64813061
Change-Id: I2864192797dc194edd9c183b881da6cfe3fdba5e
2018-01-26 23:07:59 +00:00
Alex Chau
9bd54c1cd8 Make device owner user command foreground
- Without this change there will be a 10 second delay before device owenr can receive the broadcast. Device owner is most likely in background when receiving the broadcast.
- The role of device owner is to manage user life cycle, e.g. create, remove, swithc, start, stop, it needs timely information to react quickly to provie smooth user experience. If every action requires a long time it will be a very bad user experience
- e.g. previous user finished, takes 10s for DO to realize user is logout, takes another 10s to realize user is created, 10s for new user is started etc. before DO can do the next action e.g. switch user, is a very sluggish user experience

Bug: 72305621
Test: With TestDPC, command now arrive faster
Change-Id: I8b0438efe75fbe2f029d7a3a111bf8f5035ce1a8
2018-01-26 17:41:33 +00:00
Alex Chau
1033e3861e Remove return value in clearApplicationUserData
Bug: 65280228
Test: cts-tradefed run singleCommand cts -m DevicePolicyManager --test com.android.cts.devicepolicy.MixedDeviceOwnerTest#testClearApplicationData_testPkg
Test: cts-tradefed run singleCommand cts -m DevicePolicyManager --test com.android.cts.devicepolicy.MixedDeviceOwnerTest#testClearApplicationData_deviceProvisioning
Test: cts-tradefed run singleCommand cts -m DevicePolicyManager --test com.android.cts.devicepolicy.MixedDeviceOwnerTest#testClearApplicationData_activeAdmina
Change-Id: I8808ba49492771321a3b7eb1773f1bda9c595bc6
2018-01-26 11:43:44 +00:00
arangelov
7ccd97e46e Fix writing transfer ownership bundle
Test: cts-tradefed run cts-dev --module DevicePolicyManager --test com.android.cts.devicepolicy.MixedDeviceOwnerHostSideTransferTest#testAreTransferParametersPersisted
Test: cts-tradefed run cts-dev --module DevicePolicyManager --test com.android.cts.devicepolicy.MixedProfileOwnerHostSideTransferTest#testAreTransferParametersPersisted
Change-Id: I6701dc7c1fc69876b7c624f37d8b94139b1d4d02
2018-01-25 17:48:59 +00:00
Antoan Angelov
2a5a43d61c Merge changes from topic "dpc-migration-atomic"
* changes:
  Notify DO after PO ownership transfer when they belong to affiliated users.
  Tests for owner transfer atomicity.
  Make owner transfer an atomic operation.
2018-01-24 20:11:54 +00:00
Vladislav Kuzkokov
f4e01170b8 Merge "Fix Printing policy in profile owner." 2018-01-24 20:11:31 +00:00
arangelov
b46faf35c8 Notify DO after PO ownership transfer when they belong to affiliated users.
Test: Locally modified TransferDPC to print the callback after manually setting DO, PO and then transfering PO owner.
Bug: 72218214
Change-Id: I6c9af00bcfa703c81d9d5b35fe534c928991ff93
2018-01-24 19:20:37 +00:00
arangelov
91201bdbca Make owner transfer an atomic operation.
Test: bit FrameworksServicesTests:com.android.server.devicepolicy.TransferOwnershipMetadataManagerTest
Test: runtest -x frameworks/base/services/tests/servicestests/src/com/android/server/devicepolicy/OwnerTransferParamsManagerTest.java
Test: bit FrameworksServicesTests:com.android.server.devicepolicy.DevicePolicyManagerTest#testRevertDeviceOwnership_noMetadataFile
Test: bit FrameworksServicesTests:com.android.server.devicepolicy.DevicePolicyManagerTest#testRevertDeviceOwnership_adminAndDeviceMigrated
Test: bit FrameworksServicesTests:com.android.server.devicepolicy.DevicePolicyManagerTest#testRevertDeviceOwnership_deviceNotMigrated
Test: bit FrameworksServicesTests:com.android.server.devicepolicy.DevicePolicyManagerTest#testRevertDeviceOwnership_adminAndDeviceNotMigrated
Test: bit FrameworksServicesTests:com.android.server.devicepolicy.DevicePolicyManagerTest#testRevertProfileOwnership_noMetadataFile
Test: bit FrameworksServicesTests:com.android.server.devicepolicy.DevicePolicyManagerTest#testRevertProfileOwnership_adminAndProfileMigrated
Test: bit FrameworksServicesTests:com.android.server.devicepolicy.DevicePolicyManagerTest#testRevertProfileOwnership_profileNotMigrated
Test: bit FrameworksServicesTests:com.android.server.devicepolicy.DevicePolicyManagerTest#testRevertProfileOwnership_adminAndProfileNotMigrated
Bug: 69543005

(cherry picked from commit 5a6d391dedcdec13fcc4cf1770e7bf9fc1be8643)

Change-Id: Ic2d729d48fdb47b0ebd60030b45615b0cec174a2
2018-01-24 19:20:36 +00:00
Jason Parks
5511634f52 Merge "Allow unaffiliated Profile Owners to use lock task" 2018-01-24 17:07:17 +00:00
Vladislav Kuzkokov
fef75eee1d Fix Printing policy in profile owner.
Sometimes app inside profile can't get package info for its owner.
Instead of relying on calling user id, we make PrintManagerService switch to
system id and pass user that called print() explicitly.

Bug: 72309652
Test: cts-tradefed run cts-dev --module CtsDevicePolicyManagerTestCases --test com.android.cts.devicepolicy.MixedDeviceOwnerTest#testPrintingPolicy
Test: cts-tradefed run cts-dev --module CtsDevicePolicyManagerTestCases --test com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testPrintingPolicy
Test: cts-tradefed run cts-dev --module CtsDevicePolicyManagerTestCases --test com.android.cts.devicepolicy.MixedProfileOwnerTest#testPrintingPolicy
Test: bit FrameworksServicesTests:com.android.server.devicepolicy.DevicePolicyManagerTest
Change-Id: Ib97018f56693549fbca506dba6efaadb6dd010b3
2018-01-24 15:24:08 +01:00
yuemingw
e3d9c099e5 Add APIs to manipulate Override APN.
Add APIs to add, update, query and remove Override APN. Add APIs to enable
Override APNs or query if Override APNs are currently enabled.

Bug: 68208301
Test: cts test in b/68208416

Change-Id: I65ebbb948d2ac4e31a73e1e761e32dc8ba1502c3
2018-01-24 06:13:57 +00:00
Jason Parks
3c13b64267 Allow unaffiliated Profile Owners to use lock task
Bug: 64948750
Test: bit FrameworksServicesTests:com.android.server.devicepolicy.DevicePolicyManagerTest
Change-Id: Ib775161dd62c819e7975744eaa074fc60d9a6b1b
2018-01-23 20:57:34 -06:00
Sudheer Shanka
811c3765be Merge "Add DPM API to block apps from using metered data." 2018-01-23 23:02:40 +00:00
Sudheer Shanka
04d61ae6c3 Add DPM API to block apps from using metered data.
Bug: 63700027
Test: cts-tradefed run singleCommand cts-dev -m CtsDevicePolicyManagerTestCases -t \
      com.android.cts.devicepolicy.MixedDeviceOwnerTest#testSetMeteredDataDisabled
Test: cts-tradefed run singleCommand cts-dev -m CtsDevicePolicyManagerTestCases -t \
      com.android.cts.devicepolicy.MixedProfileOwnerTest#testSetMeteredDataDisabled
Test: atest com.android.server.devicepolicy.DevicePolicyManagerTest#testSetGetMeteredDataDisabled
Change-Id: I147399d316f375c68b415dc6ede837c53cd1aad0
2018-01-22 19:33:09 -08:00
TreeHugger Robot
3c365cb21d Merge "Policy transparency for mandatory backups." 2018-01-22 09:17:50 +00:00
Sudheer Shanka
c53c47fa3a Load admin data in DPMS asynchronously during boot.
Bug: 71902030
Bug: 71710099
Test: atest services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
Test: Ran boot tests - go/run-boottest
Test: manual
Change-Id: I34970c6f41877c7e3ece4843d47831374d455067
2018-01-19 11:12:44 -08:00
Lenka Trochtova
16a91c0ca7 Policy transparency for mandatory backups.
Bug: 64012357
Test: atest FrameworksServicesTests:com.android.server.devicepolicy.DevicePolicyManagerTest#testCreateAdminSupportIntent

Change-Id: I54140d676285eb78345bda28427aa02339f65e5b
2018-01-19 20:01:24 +01:00
TreeHugger Robot
8bd6865532 Merge "Notify device owner when user is started / stopped / switched" 2018-01-19 17:56:28 +00:00
Alex Chau
2c082aeeb7 Notify device owner when user is started / stopped / switched
- Similar to onUserAdded / onUserRemoved, notify DPC when user is started / stopped / switched, as these operation is asynchronous.
Use cases:
1. As a asynchronous callback for startUserInBackground / stopUser / logoutUser / switchUser
2. For COMP, can be used to detect work mode turning on or off

Bug: 72092112
Test: com.android.cts.devicepolicy.DeviceOwnerTest#testCreateAndManageUser_StopOnStart
Test: com.android.cts.devicepolicy.DeviceOwnerTest#testCreateAndManageUser_LogoutOnStart
Change-Id: I6fa28711419053694131d7792f3e0d1d2e76ac29
2018-01-19 15:17:00 +00:00
Vladislav Kuzkokov
792d58fbce Implement Policy to disable printing.
This adds a new "isPrintingEnabled" policy (true by default)
and hooks it into PrintManagerService.

Bug: 64140119
Test: manual

Change-Id: Ifb0f6772af51e6185135e9dcf5551e9ef0d88af3
2018-01-18 17:18:54 +01:00
TreeHugger Robot
1721004ec9 Merge "Customize user switch dialog" 2018-01-17 23:55:47 +00:00
Antoan Angelov
f68bf1a819 Merge "Add metadata to validate incoming administrator during transfer of ownership." 2018-01-17 21:32:15 +00:00
Alex Chau
93ae42b04d Customize user switch dialog
- Introduced DevicePolicyManager to set messaging for switching out of and into user 0
- Introduced coressponeding API to get the message

Bug: 71787514
Test: Set start and end session message with TestDPC, change is reflected
Test: Restart the device, switch message is still enforced
Test: Clear the message with TestDPC, reverted back to default
Change-Id: I527eca6f151cee35459abad7ae9dcdeef486148f
2018-01-17 18:51:19 +00:00
TreeHugger Robot
4ba2c3f4ec Merge "Ensure a user's SP does't change." 2018-01-17 18:08:45 +00:00
arangelov
5149d716e5 Add metadata to validate incoming administrator during transfer of ownership.
Bug: 69543092
Test: cts-tradefed run cts-dev --module DevicePolicyManager --test com.android.cts.devicepolicy.MixedDeviceOwnerHostSideTransferTest#testTransfer
Test: cts-tradefed run cts-dev --module DevicePolicyManager --test com.android.cts.devicepolicy.MixedDeviceOwnerHostSideTransferTest#testTransferNoMetadata
Change-Id: Iccefb37836d0f88e9d4f692ecf9aba6d3197ad08
2018-01-17 14:31:19 +00:00
Benjamin Franz
7d0e1f8065 Merge "Also inform activity manager that lock task packages changed" 2018-01-17 10:47:29 +00:00
Lenka Trochtova
c141d08b70 New management API for making backups mandatory.
Let the device owner make backups with a chosen backup
transport mandatory.

BUG: 64012357
Test: make RunFrameworksServicesRoboTests
Test: manually together with the corresponding GmsCore change.
Test: cts-tradefed run cts -m CtsDevicePolicyManagerTestCases --test
com.android.cts.devicepolicy.DeviceOwnerTest#testGetAndSetMandatoryBackupTransport
Test: cts-tradefed run cts -m CtsBackupHostTestCase --test
android.cts.backup.BackupDeviceOwnerHostSideTest#testMandatoryBackupTransport

Change-Id: I9bfae5799beae3459659e697813b75a9b508ae55
2018-01-16 22:24:11 +01:00
Andrew Scull
1416bd022f Ensure a user's SP does't change.
Changes of the SP are caused by untrusted credential reset which can be
triggered by certain admin modes. When such an admin is active, the SP
needs to be cached. Untrusted reset will be removed in a future release
at which point this caching can also be removed.

Bug: 71527305
Test: runtest frameworks-services -p com.android.server.locksettings
Test: cts-tradefed run cts-dev -m CtsDevicePolicyManagerTestCases -t com.android.cts.devicepolicy
Change-Id: I54f3b299b79ce019ba679b5550d37fd090b679fb
2018-01-16 18:14:23 +00:00
Benjamin Franz
832ccb07aa Also inform activity manager that lock task packages changed
When user data is cleared in DevicePolicyManager, we clear the lock
task packages list. We should also forward that information to the
ActivityManager, so they can do relevant clean up; in particular this
will stop any running lock tasks.

Bug: 68688028
Test: manual
Change-Id: I0f40e7e08efd5ad2ca20b50ffa1032ddb13d1adb
2018-01-16 15:47:18 +00:00
TreeHugger Robot
23374d63ec Merge "Move startUserInBackground to standalone and avoid user from being stopped unnecessarily" 2018-01-15 13:56:36 +00:00