From f4d1168056ab2cb45989110c01be5eb2a39e3711 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Thu, 9 Jul 2020 15:58:16 -0400 Subject: [PATCH] Fix multiuser access to setNotificationPolicy Fixes an issue where the call would fail if called from a secondary user when the app wasn't installed on the primary user Test: install an app on secondary user only and ensure that it can change the dnd policy Bug: 148620301 Change-Id: Ibb45685f48017e9a42a98eb20b879d8fb1588137 --- .../server/notification/NotificationManagerService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index e2be1932a08dc..88964e055a18e 100755 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -4674,10 +4674,11 @@ public class NotificationManagerService extends SystemService { @Override public void setNotificationPolicy(String pkg, Policy policy) { enforcePolicyAccess(pkg, "setNotificationPolicy"); + int callingUid = Binder.getCallingUid(); final long identity = Binder.clearCallingIdentity(); try { final ApplicationInfo applicationInfo = mPackageManager.getApplicationInfo(pkg, - 0, UserHandle.getUserId(MY_UID)); + 0, UserHandle.getUserId(callingUid)); Policy currPolicy = mZenModeHelper.getNotificationPolicy(); if (applicationInfo.targetSdkVersion < Build.VERSION_CODES.P) {