From 06f7d06097094b77074f1e7a60a2682cd2af7af5 Mon Sep 17 00:00:00 2001 From: Wentao Wang Date: Mon, 19 Jun 2023 09:39:04 +0000 Subject: [PATCH] Expose getDeviceOwnerComponent to SystemServer. This is needed for newly proposed Retail Demo role. Security approved for design: go/retail-demo-role-fr BUG: 274132354 Test: manual Change-Id: Ibadfad8baa25df9eb79a1cf0ac4167c58471d056 --- .../android/app/admin/DevicePolicyManagerInternal.java | 10 ++++++++++ .../devicepolicy/DevicePolicyManagerService.java | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/core/java/android/app/admin/DevicePolicyManagerInternal.java b/core/java/android/app/admin/DevicePolicyManagerInternal.java index 0e78275fa30b2..8dd50f0c42e87 100644 --- a/core/java/android/app/admin/DevicePolicyManagerInternal.java +++ b/core/java/android/app/admin/DevicePolicyManagerInternal.java @@ -249,6 +249,16 @@ public abstract class DevicePolicyManagerInternal { @Nullable public abstract ComponentName getProfileOwnerAsUser(@UserIdInt int userId); + /** + * Returns the device owner component for the device, or {@code null} if there is not one. + * + * @deprecated added temporarily to support Android Role permission granting. + * Please contact Android Enterprise Device Policy team before calling this function. + */ + @Deprecated + @Nullable + public abstract ComponentName getDeviceOwnerComponent(boolean callingUserOnly); + /** * Returns the user id of the device owner, or {@link UserHandle#USER_NULL} if there is not one. */ diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 417fc3949f2cd..fe913b9807cf3 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -16228,6 +16228,11 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { return DevicePolicyManagerService.this.getProfileOwnerAsUser(userId); } + @Override + public ComponentName getDeviceOwnerComponent(boolean callingUserOnly) { + return DevicePolicyManagerService.this.getDeviceOwnerComponent(callingUserOnly); + } + @Override public int getDeviceOwnerUserId() { return DevicePolicyManagerService.this.getDeviceOwnerUserId();