Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0867b3af authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Check permission of package, not caller.

Bug: 27923662
Change-Id: I86fd9ed2e8971bde216f53b6d1a5933e8188a425
parent 1d0ca4b2
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -1852,11 +1852,17 @@ public class NotificationManagerService extends SystemService {
        }

        private boolean checkPolicyAccess(String pkg) {
            try {
                int uid = getContext().getPackageManager().getPackageUidAsUser(
                        pkg, UserHandle.getCallingUserId());
                if (PackageManager.PERMISSION_GRANTED == ActivityManager.checkComponentPermission(
                    android.Manifest.permission.MANAGE_NOTIFICATIONS, Binder.getCallingUid(),
                        android.Manifest.permission.MANAGE_NOTIFICATIONS, uid,
                        -1, true)) {
                    return true;
                }
            } catch (NameNotFoundException e) {
                return false;
            }
            return checkPackagePolicyAccess(pkg) || mListeners.isComponentEnabledForPackage(pkg);
        }