Commit Graph

2308 Commits

Author SHA1 Message Date
Pavel Grafov
c291627ea9 Merge "Remove fossilized upgrade code." into tm-dev 2022-04-14 11:02:12 +00:00
Pavel Grafov
003768dede Remove fossilized upgrade code.
* Handling of device owners without component names.
* Migration of user restriction from UserManager to DPMS.
* Handling legacy owners format.
* Legacy tag TAG_DEVICE_INITIALIZER in owners.

This code can only be invoked on a device that is upgrading from
M or below straight into T+, so the device should have a lifespan
of 8 dessert releases. This is more than twice than any device
officially supports.

This change is needed to make further changes for the issue
simpler.

Bug: 218639412
Test: atest com.android.server.devicepolicy.OwnersTest
Test: atest com.android.server.devicepolicy.DevicePolicyManagerServiceMigrationTest
Change-Id: I142ac7f690ebb5fb7a94cc32306aeb4a6321e541
2022-04-13 14:55:30 +01:00
kholoud mohamed
06a85bdb26 Respect style when source is also set
Fixes: 214576716
Test: atest android.devicepolicy.cts.DevicePolicyResourcesTests
Change-Id: I82ac3fa837232c3a6d7d51c8c41e5e851aa2366d
2022-04-13 12:44:54 +00:00
Lee Shombert
529a49ee3d Helper classes for IpcDataCache clients
Bug: 227653108

This adds a helper class that can reduce much of the boilerplate in
code that uses IpcDataCache (or the internal-only variant,
PropertyInvalidatedCache).  See the changes to DevicePolicyManager for
example usage.

Two PropertyInvalidatedCaches APIs are exposed for testing.  The
method createPropertyName() is changed so that apis like "Foo" are
converted to "foo", not "_foo".

Unit tests for the new behavior are added to IpcDataCacheTest.

This was manually tested by dumping the cache info from builds with
and without this change.  Special attention is paid to the
DevicePolicyManager caches.  The same caches were found (as identified
by their key and api) and the caches were enabled/disabled the same.

In the course of testing, multiple instances of DevicePolicyManager
caches were observed.  Cache performance is better if the caches are
static; making them static will be addressed in b/228452829.

Test:
 * atest FrameworksCoreTests:IpcDataCacheTest
 * atest FrameworksCoreTests:PropertyInvalidatedCacheTests
 * 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
 * atest MixedDeviceOwnerTest#testIsDeviceOrganizationOwnedWithManagedProfile
 * atest MixedDeviceOwnerTest#testSetKeyguardDisabledFeatures
 * atest MixedManagedProfileOwnerTest#testIsDeviceOrganizationOwnedWithManagedProfile
 * atest MixedManagedProfileOwnerTest#testNetworkLoggingDelegate
 * atest MixedManagedProfileOwnerTest#testSetKeyguardDisabledFeatures
 * atest OrgOwnedProfileOwnerTest#testIsDeviceOrganizationOwnedWithManagedProfile
 * atest OrgOwnedProfileOwnerTest#testNetworkLoggingDelegate
 * atest OrgOwnedProfileOwnerTest#testSetKeyguardDisabledFeatures
 * atest android.devicepolicy.cts.DevicePolicyManagerTest
 * atest android.devicepolicy.cts.NetworkLoggingTest
 * atest com.android.cts.devicepolicy.DeviceOwnerTest#testAdminActionBookkeeping

Change-Id: I2f4fe4ed25db5fb3100334b9d2ce748ee928c10d
2022-04-11 07:27:16 -07:00
Eric Biggers
256a0b563f Merge changes Idc218e5f,I26c3fafc am: 7e3c5382cc am: fb4c1822a8 am: 4d4ababae0
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2052056

Change-Id: I6c0ee77edf164ecf5a285afe4dff7cec85e9d668
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-08 02:11:26 +00:00
Eric Biggers
4d4ababae0 Merge changes Idc218e5f,I26c3fafc am: 7e3c5382cc am: fb4c1822a8
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2052056

Change-Id: Ib029dddb2fd26fa33f231b7ae87c3a1fee737a55
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-08 01:36:12 +00:00
Eric Biggers
fb4c1822a8 Merge changes Idc218e5f,I26c3fafc am: 7e3c5382cc
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2052056

Change-Id: I92b1cfccfc0bb657d9d5e1958c5e3e2d4ffc3794
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-08 00:36:33 +00:00
Eric Biggers
234ee35c93 Drop FDE status checks from DevicePolicyManagerService
Since FDE (Full Disk Encryption) is no longer supported, there is no
need for DevicePolicyManagerService.getEncryptionStatus() to check for
FDE-specific encryption statuses.

There is more that needs to be cleaned up here, but this gets rid of the
dependency on some obsolete StorageManager methods.

Bug: 208476087
Test: atest DevicePolicyManagerTest
Change-Id: I26c3fafc1b134177324de929d3600fb2dd7f4d1d
2022-04-07 16:38:29 +00:00
Jonathan Scott
58bbfc4167 [automerge] [scv2] RESTRICT AUTOMERGE Add finalizeWorkProfileProvisioning. 2p: b157e658a7
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17567140

Bug: 210469972
Change-Id: I19e3b76e9289c9b0709c3c1584bbb93f008913f5
2022-04-05 12:55:43 +00:00
Jonathan Scott
b157e658a7 [scv2] RESTRICT AUTOMERGE Add finalizeWorkProfileProvisioning.
Test: atest android.devicepolicy.cts.DevicePolicyManagerTest
Bug: 210469972
Change-Id: I1ea926194992cbce26e2245fec0e563b3010a02f
2022-04-05 12:55:36 +00:00
kholoud mohamed
01962c62c4 send broadcast to explicit role holder component names
Bug: 220876709
Test: atest android.devicepolicy.cts.DevicePolicyManagementRoleHolderTest
Change-Id: I02489f83db0e3385c68648950f221bc1c04b143e
2022-04-01 18:19:22 +01:00
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 a4131c50d0)
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