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

Commit 69fccd62 authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "Check permission of package, not caller." into nyc-dev

parents 6bb61e25 0867b3af
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);
        }