2348 Commits

Author SHA1 Message Date
Lee Shombert
b53dad8cb0 Merge "Put a binder cache on DevicePolicyManager APIs" into tm-dev 2022-03-31 15:09:47 +00:00
Lee Shombert
fdd45a5c80 Put a binder cache on DevicePolicyManager APIs
Bug: 190489030

Put a binder cache in front of IDevicePolicyManager APIs.  The
following APIs are cached:
 * getKeyguardDisabledFeatures()
 * hasDeviceOwner()
 * getProfileOwnerOrDeviceOwnerSupervisionComponent()
 * isOrganizationOwnedDeviceWithManagedProfile()
 * getDeviceOwnerOrganizationName()
 * getOrganizationNameForUser()
 * isNetworkLoggingEnabled()

The caches use a shared key which means that all are invalidated at
the same time.  This is slightly less efficient than API-specific
invalidation but it greatly simplifies the invalidation logic in the
server.  The cost of invalidating all caches at the same time is small
if invalidation happens infrequently (less than one an hour, on
average).

The test classes are modified to disable caches in the local process.

Test:
 * atest FrameworksServicesTests:DevicePolicyConstantsTest
 * atest FrameworksServicesTests:DevicePolicyEventLoggerTest
 * atest FrameworksServicesTests:DevicePolicyManagerServiceMigrationTest
 * atest FrameworksServicesTests:DevicePolicyManagerTest
 * atest FrameworksServicesTests:EnterpriseSpecificIdCalculatorTest
 * atest FrameworksServicesTests:OverlayPackagesProviderTest
 * atest FrameworksServicesTests:OwnersTest
 * atest FrameworksServicesTests:PolicyVersionUpgraderTest
 * atest FrameworksServicesTests:SecurityEventTest
 * atest FrameworksServicesTests:SystemUpdatePolicyTest
 * atest FrameworksServicesTests:TransferOwnershipMetadataManagerTest

Change-Id: Iead8644cb413b45f3b6f3da81ff00a61788941a2
2022-03-30 12:49:05 -07:00
Alex Johnston
4ff9d8d3f7 Merge "Update lost mode location logic" into tm-dev 2022-03-30 07:12:52 +00:00
Eric Biggers
7126988ee8 Merge changes Iccf50955,I17ab54dd am: 92ed348a6d am: 7d85933c4c am: fa29af8061
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2046823

Change-Id: Ic6ef33bfc157597a1b4d3790be621c36d3144c78
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-03-29 19:09:58 +00:00
Eric Biggers
fa29af8061 Merge changes Iccf50955,I17ab54dd am: 92ed348a6d am: 7d85933c4c
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2046823

Change-Id: I978a5e2e943154d876f868a6d682cf3d0ba3c2ec
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-03-29 18:54:45 +00:00
Alex Johnston
252e17132a Update lost mode location logic
* Send location from the fused, network and gps providers (in order)
* Do not loop though all location providers

Bug: 223148704
Test: atest android.devicepolicy.cts.LostModeLocationTest
      atest com.android.server.devicepolicy.DevicePolicyManagerTest

Change-Id: I2d73130c304e01e9342c40f4589791f34747f4a5
2022-03-29 17:47:53 +00:00
Rubin Xu
cf4afcdd95 Merge "Small fixes for reset password token" into tm-dev 2022-03-29 09:53:23 +00:00
Eric Biggers
fd38747356 Stop checking StorageManager.inCryptKeeperBounce() in DPM
FDE (Full Disk Encryption) is no longer supported, so
StorageManager.inCryptKeeperBounce() is now hard-coded to return false.
In preparation for removing this method, stop calling it from the device
policy manager.

Bug: 208476087
Change-Id: I17ab54dd622aaf749e8c2df925b71f042f440ef8
2022-03-28 18:57:54 +00:00
Kholoud Mohamed
bc16160052 Merge "Persist bypassDevicePolicyMmanagementRoleQualification in global setting" into tm-dev 2022-03-28 16:44:18 +00:00
Pavel Grafov
66de8ccfc8 Merge "Simplyfy DPM binder by using WifiSsidPolicy." into tm-dev 2022-03-28 15:32:01 +00:00
kholoud mohamed
cfe99b7774 Persist bypassDevicePolicyMmanagementRoleQualification in global setting
Bug: 226386138
Test: manual
Change-Id: I7db40e4e0bcde98d190e6d6e9e841355da506aed
2022-03-28 14:15:46 +00:00
Rubin Xu
fc41b7231d Small fixes for reset password token
1. Fail early when token handle is invalid
2. Dump out token handle in DPMS

Bug: 203411634
Test: dumpsys device_policy
Change-Id: I4d87b07113f746ea7e7457fada865f39a22a629e
2022-03-25 17:47:21 +00:00
Pavel Grafov
8d2caa2b01 Simplyfy DPM binder by using WifiSsidPolicy.
WifiSsidPolicy is parcelable, so there is no need to marshall it
explicitly as a deny- or allow-list using separate getters and
setters.

Test: atest com.android.server.devicepolicy.DevicePolicyManagerTest
test: atest WifiSsidRestrictionTest
Bug: 218495535
Change-Id: Iee06acb6b136766fb16cef2d60a46bd7373b5c56
2022-03-25 12:59:11 +00:00
Rubin Xu
498f7bf260 Merge "device policy: ignore unknown permission in setPermissionGrantState" into tm-dev 2022-03-25 10:12:43 +00:00
Rubin Xu
d71c0ce305 device policy: ignore unknown permission in setPermissionGrantState
When setting a permission grant on a non-existent permission,
implementation currently throws RemoteException but that's not
propagated across binder causing the client cide to stuck until
the timeout. Replace this with an immediate fail.

Bug: 197200931
Test: manual with TestDPC
Change-Id: I9a0ea42e52d68259eb0464194a5a1d9fbfc2a216
2022-03-24 16:26:58 +00:00
Rubin Xu
7997d581f5 [automerge] Secure REMOTE_BUGREPORT_DISPATCH 2p: f62904fd70
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17378906

Bug: 171495100
Change-Id: Iea8e133f8bd93b2568b6de21a6a7e2a95cf02ed0
Merged-In: I7649b4f22b74647d152d76bb46d5ca70bfa3617d
2022-03-24 14:55:11 +00:00
Rubin Xu
f62904fd70 Secure REMOTE_BUGREPORT_DISPATCH
In remote bugreport collection, Shell sends REMOTE_BUGREPORT_DISPATCH to
DevicePolicyManagerService which in turn notifies Device Owners that a
bug report is ready for collection. There existed a threat where a
malicous user could spoof the REMOTE_BUGREPORT_DISPATCH broadcast via
ADB to send a crafted bugreport to the Device Owner. Securing
REMOTE_BUGREPORT_DISPATCH is not as easy as it appears: putting a
permission on REMOTE_BUGREPORT_DISPATCH does not work since both the
legitimate sender and the malicious user are UID_SHELL. Instead, we
introduces a nonce which was sent from DPMS to Shell when bugreport is
triggered, and DPM will only accept REMOTE_BUGREPORT_DISPATCH when
a matching nonce is seen.

Ignore-AOSP-First: security fix

Bug: 171495100
Test: atest DeviceOwnerTest#testRemoteBugreportWithTwoUsers
Test: atest DeviceOwnerTest#testAdminActionBookkeeping
Test: atest BugreportManagerTest
Change-Id: I7649b4f22b74647d152d76bb46d5ca70bfa3617d
Merged-In: I7649b4f22b74647d152d76bb46d5ca70bfa3617d
(cherry picked from commit a4131c50d07c7b58c496bd82b9ab3389b6721654)
2022-03-24 14:54:42 +00:00
Alex Johnston
f7a1a20815 Require TRIGGER_LOST_MODE permission for sendLostModeLocationUpdate
Changes:
* Use TRIGGER_LOST_MODE permission to gate the
  DevicePolicyManager API sendLostModeLocationUpdate

Bug: 223148704
Test: atest android.devicepolicy.cts.LostModeLocationTest
Change-Id: If15388a377c75b7581c9c2a35b3d9828f78e13fc
Merged-In: If15388a377c75b7581c9c2a35b3d9828f78e13fc
2022-03-24 12:29:28 +00:00
Felipe Leme
894e925fc6 Merge changes from topic "presubmit-am-d8e1f50ef5264701a2f9994dfc715425" into sc-v2-dev-plus-aosp am: fa749e7324
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17224796

Change-Id: I81679315c79c70308fab2b8690719bc5c4eda93a
2022-03-23 23:03:02 +00:00
Felipe Leme
2ddeab712a Merge "Disable user switching when the device is factory resetting." into sc-v2-dev 2022-03-23 21:09:25 +00:00
Sooraj Sasindran
2844eaf9f7 Merge "Get device owner app admin" into tm-dev 2022-03-23 17:21:00 +00:00
Rubin Xu
a441d81b3a Merge "Secure REMOTE_BUGREPORT_DISPATCH" into tm-dev 2022-03-23 11:26:52 +00:00
Ayush Sharma
e0934dadbe Merge "Fix deadlock in DPMS" into tm-dev 2022-03-23 10:10:43 +00:00
Sooraj Sasindran
3d14e32aa6 Get device owner app admin
Get device owner app admin when prefentialNetworkService is
configured by device owner

Bug: 219651203
Test: cts
Change-Id: Ic748227e8d12896361216f6ea67776660b752e4e
2022-03-22 17:23:56 +00:00
TreeHugger Robot
8c9047c870 Merge "RESTRICT AUTOMERGE Fixed and reenabled failing DevicePolicyManagerTest" into tm-dev 2022-03-22 12:32:19 +00:00
Rubin Xu
a4131c50d0 Secure REMOTE_BUGREPORT_DISPATCH
In remote bugreport collection, Shell sends REMOTE_BUGREPORT_DISPATCH to
DevicePolicyManagerService which in turn notifies Device Owners that a
bug report is ready for collection. There existed a threat where a
malicous user could spoof the REMOTE_BUGREPORT_DISPATCH broadcast via
ADB to send a crafted bugreport to the Device Owner. Securing
REMOTE_BUGREPORT_DISPATCH is not as easy as it appears: putting a
permission on REMOTE_BUGREPORT_DISPATCH does not work since both the
legitimate sender and the malicious user are UID_SHELL. Instead, we
introduces a nonce which was sent from DPMS to Shell when bugreport is
triggered, and DPM will only accept REMOTE_BUGREPORT_DISPATCH when
a matching nonce is seen.

Ignore-AOSP-First: security fix

Bug: 171495100
Test: atest DeviceOwnerTest#testRemoteBugreportWithTwoUsers
Test: atest DeviceOwnerTest#testAdminActionBookkeeping
Test: atest BugreportManagerTest
Change-Id: I7649b4f22b74647d152d76bb46d5ca70bfa3617d
2022-03-22 12:28:36 +00:00
arangelov
a107680e22 Check the managed profile for PO
Fixes: 225938013
Test: manual
Test: CTS test to be added in a follow-up CL
Change-Id: Ic43bf774d89f89947f7377bae47b6dfbd1e62ea1
2022-03-21 19:44:23 +00:00
kholoud mohamed
14913d1d08 RESTRICT AUTOMERGE Fixed and reenabled failing DevicePolicyManagerTest
Also refactored DPMS to stop calling DPM#getString

Fixes: 225415867
Test: atest com.android.server.devicepolicy.DevicePolicyManagerTest
Change-Id: Id53bd4c6b3f57d8ac98a31d28eaa27cb98547852
2022-03-21 15:16:46 +00:00
Ayush Sharma
4fb297e3c8 Fix deadlock in DPMS
Dont hold lock while calling in to NetworkPolicyManagerService in
removeAdminArtifacts
Bug: 223382458
Test: atest com.android.server.devicepolicy.DevicePolicyManagerTest#testForceRemoveActiveAdmin_nonShellCallerWithPermission
      atest com.android.server.devicepolicy.DevicePolicyManagerTest#testForceRemoveActiveAdmin_ShellCaller

Change-Id: I1e83201211678df203908a52759858fa7dd44e5b
2022-03-21 10:44:12 +00:00
Antoan Angelov
a443dccaad Merge "Add DevicePolicyManager#getPolicyManagedProfiles system api" into tm-dev 2022-03-20 20:08:50 +00:00
Kholoud Mohamed
a8e9aa390d Merge changes from topic "apiFeedback" into tm-dev
* changes:
  RESTRICT AUTOMERGE Refactor device policy resource APIs to a separate class
  RESTRICT AUTOMERGE move device policy resource APIs to a separate class
  RESTRICT AUTOMERGE hide device policy resources constants
2022-03-19 06:30:43 +00:00
kholoud mohamed
b7aedc6f3d RESTRICT AUTOMERGE Refactor device policy resource APIs to a separate class
Bug: 217388602
Bug: 218875965
Test: atest EnterpriseResourcesTests
Test: manual
Change-Id: I8af03136e67057d171e97cb5a43187aa6c7f4fe7
2022-03-19 00:22:17 +00:00
kholoud mohamed
6ed9faf5bd RESTRICT AUTOMERGE hide device policy resources constants
Bug: 218875965
Bug: 217388602
Test: atest EnterpriseResourcesTests
Change-Id: Iac71c0d5b451e8ec77c0ca0113e2248ef21cc412
2022-03-18 20:47:12 +00:00
Jonathan Scott
9bc9a8bdd1 Merge "Add setProfileOwnerOnOrganizationOwnedDevice COPE API." into tm-dev 2022-03-18 17:50:42 +00:00
arangelov
69bb632cb8 Add DevicePolicyManager#getPolicyManagedProfiles system api
That way the logic to get a managed profile can be
customizable by OEMs.

Fixes: 214473624
Test: manual
Test: CTS tests to be added in a follow-up CL
Change-Id: Id183e987d2cb04040db028b9913188267d1a9a84
2022-03-18 17:11:26 +00:00
Kholoud Mohamed
3d31e0b93b Merge changes from topic "resetAPIs" into tm-dev
* changes:
  RESTRICT AUTOMERGE add requiresAPI annotation for DPM#getString
  RESTRICT AUTOMERGE Expose getString APIs as public
2022-03-18 16:07:22 +00:00
Jonathan Scott
95826d61fb Merge "Add finalizeWorkProfileProvisioning." into tm-dev 2022-03-18 14:50:07 +00:00
Jonathan Scott
1355042efd Add finalizeWorkProfileProvisioning.
Test: atest android.devicepolicy.cts.DevicePolicyManagerTest
Bug: 210469972

Change-Id: I8dff5653ac7404c2571c1f2d708f239584208be1
2022-03-18 12:41:36 +00:00
Aleks Todorov
6a9ed66cdd Add setProfileOwnerOnOrganizationOwnedDevice COPE API.
Bug: 198774281
Test: atest cts/tests/devicepolicy/src/android/devicepolicy/cts/DevicePolicyManagerTest.java
Change-Id: I50d5f69709789912af63ebecc33aad4df17bbe5f
2022-03-18 11:22:08 +00:00
kholoud mohamed
1d0d9c9cfb RESTRICT AUTOMERGE Expose getString APIs as public
exposed getString APIs as public to make it consistent with the
getDrawable APIs.
Also changed resetStrings/Drawables API to take in a set instead of an
array.

Bug: 218875965
Test: atest EnterpriseResourcesTests
Change-Id: I042636233ea342af62a7e6569c90786d3ef249cb
2022-03-17 14:45:52 +00:00
Alex Johnston
b2eae22673 Merge "dump factory reset protection policy" into tm-dev 2022-03-17 10:27:07 +00:00
Felipe Leme
4504fe76a0 [automerge] Disable user switching when the device is factory resetting. 2p: 1573cdb1d4
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17224796

Bug: 225012970
Change-Id: Idaa27b7634c91843549e0f09a2c54ac3554811f0
2022-03-16 19:44:42 +00:00
Felipe Leme
1573cdb1d4 Disable user switching when the device is factory resetting.
On automotive, a factory reset request from the device admin can be
delayed as it would be a driving hazard, but the user should not be
switchable during this state.

Test: atest FrameworksMockingServicesTests:FactoryResetterTest
Test: manual verification using TestDpc

Fixes: 205874492
Bug: 225012970

Change-Id: I2b6cd7c56bf3714ccf79b9b092c8b67dd5817f0c
2022-03-16 12:44:03 -07:00
Sooraj Sasindran
ddf19a486a Merge "Use int array for included and excluded uids" am: fd8ac5ce94 am: 591578331e am: 1e24104474
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2019627

Change-Id: I36f4c5c08c0702d444cdbf3ff16fb226a7a189c5
2022-03-16 18:58:04 +00:00
Sooraj Sasindran
1e24104474 Merge "Use int array for included and excluded uids" am: fd8ac5ce94 am: 591578331e
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2019627

Change-Id: I649ea11cb08cba9fdeaac61179626e19337b0078
2022-03-16 18:46:32 +00:00
Sooraj Sasindran
39558844fa Use int array for included and excluded uids
Bug: 217365439
Test: presubmit
Change-Id: Ida507186aab1514e45c9531eec79ac78b19e247e
2022-03-16 07:18:40 +00:00
Alex Johnston
ca234fdd8c dump factory reset protection policy
Bug: 176109794
Test: Generate bug report and checked dumpsys
Change-Id: I08562763ce998b825830f8bcaba40b0f7fc5aaa3
2022-03-15 20:48:50 +00:00
kholoud mohamed
47020d16c3 Add API to check if device policy role qualification is bypassable
Bug: 220692690
Test: atest android.devicepolicy.cts.DevicePolicyManagerTest
Change-Id: I81b2f7848682d3d23dbd57ca100590d73d6dfd3e
2022-03-15 15:26:44 +00:00
Sooraj Sasindran
cbeda1b1c3 Merge "Allow a list of configs to be sent for enterprise slice" am: 78bc18e26b am: 92a2654e17
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2019626

Change-Id: I7cf7107fdcb6c94f9c22940a9aa680465025b390
2022-03-15 04:40:26 +00:00
Sooraj Sasindran
e9c9dda003 Allow a list of configs to be sent for enterprise slice
Allow a list of configs to be sent for enterprise slice
Allow device owner to set enterprise slice config
Allow enterprise apn to be configured by profile owner

Bug: 217365439
Bug: 222723840
Test: ran CTS tests
Merged-In: I82c159843d0806cbfc5eea602fbd0304e7ff04ac
Change-Id: I82c159843d0806cbfc5eea602fbd0304e7ff04ac
2022-03-11 05:38:59 +00:00