From 1408242781e5584dcf678ef4b35976551b9da98e Mon Sep 17 00:00:00 2001 From: Rubin Xu Date: Wed, 19 Apr 2023 13:45:16 +0100 Subject: [PATCH] Headless: fix system update notification Allow the OTA client from the main user to send OTA information back to the framework. Bug: 262854379 Test: GtsDevicePolicyTestCases:PendingSystemUpdateTest Change-Id: I607e0515dee1bd8ba9d9a68940c13c1a6d147196 --- .../devicepolicy/DevicePolicyManagerService.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 7e5d5aae06e4c..ac5a5bab3d11f 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -16549,11 +16549,13 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { hasCallingOrSelfPermission(permission.NOTIFY_PENDING_SYSTEM_UPDATE), "Only the system update service can broadcast update information"); - if (UserHandle.getCallingUserId() != UserHandle.USER_SYSTEM) { - Slogf.w(LOG_TAG, "Only the system update service in the system user can broadcast " - + "update information."); - return; - } + mInjector.binderWithCleanCallingIdentity(() -> { + if (!mUserManager.getUserInfo(UserHandle.getCallingUserId()).isMain()) { + Slogf.w(LOG_TAG, "Only the system update service in the main user can broadcast " + + "update information."); + return; + } + }); if (!mOwners.saveSystemUpdateInfo(info)) { // Pending system update hasn't changed, don't send duplicate notification.