From ec902a9694969e1ea9f9298e11a193a30aade797 Mon Sep 17 00:00:00 2001 From: Felipe Leme Date: Wed, 6 Oct 2021 16:43:55 -0700 Subject: [PATCH] Do not set profile owner on guest users on headless system user. The guest user cannot have extra apps, hence the DPC app is not installed. We could try to bypass that restriction, but it could cause other issues down the road; besides, on phones the guest user is not managed neither and DPM doesn't provide an API to created managed guests. Test: manual verification using TestDpc Fixes: 202327386 Change-Id: I02f963bc84325dd73a18abb7103fc34d4960005d --- .../server/devicepolicy/DevicePolicyManagerService.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 14970ceb13d28..a3ff6da9782b8 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -10685,7 +10685,10 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } } - if (!mOwners.hasDeviceOwner() || !user.isFull() || user.isManagedProfile()) return; + if (!mOwners.hasDeviceOwner() || !user.isFull() || user.isManagedProfile() + || user.isGuest()) { + return; + } if (mInjector.userManagerIsHeadlessSystemUserMode()) { ComponentName admin = mOwners.getDeviceOwnerComponent();