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

Commit ad7f37d4 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Check distraction flags in addition to suspension state" into qt-qpr1-dev

parents f5fa3cf7 fc2dcf5d
Loading
Loading
Loading
Loading
+15 −17
Original line number Original line Diff line number Diff line
@@ -2266,7 +2266,7 @@ public class NotificationManagerService extends SystemService {
            final int callingUid = Binder.getCallingUid();
            final int callingUid = Binder.getCallingUid();
            final boolean isSystemToast = isCallerSystemOrPhone()
            final boolean isSystemToast = isCallerSystemOrPhone()
                    || PackageManagerService.PLATFORM_PACKAGE_NAME.equals(pkg);
                    || PackageManagerService.PLATFORM_PACKAGE_NAME.equals(pkg);
            final boolean isPackageSuspended = isPackageSuspendedForUser(pkg, callingUid);
            final boolean isPackageSuspended = isPackagePaused(pkg);
            final boolean notificationsDisabledForPackage = !areNotificationsEnabledForPackage(pkg,
            final boolean notificationsDisabledForPackage = !areNotificationsEnabledForPackage(pkg,
                    callingUid);
                    callingUid);


@@ -4120,17 +4120,7 @@ public class NotificationManagerService extends SystemService {
            Preconditions.checkNotNull(pkg);
            Preconditions.checkNotNull(pkg);
            checkCallerIsSameApp(pkg);
            checkCallerIsSameApp(pkg);


            boolean isPaused;
            return isPackagePausedOrSuspended(pkg, Binder.getCallingUid());

            final PackageManagerInternal pmi = LocalServices.getService(
                    PackageManagerInternal.class);
            int flags = pmi.getDistractingPackageRestrictions(
                    pkg, Binder.getCallingUserHandle().getIdentifier());
            isPaused = ((flags & PackageManager.RESTRICTION_HIDE_NOTIFICATIONS) != 0);

            isPaused |= isPackageSuspendedForUser(pkg, Binder.getCallingUid());

            return isPaused;
        }
        }


        private void verifyPrivilegedListener(INotificationListener token, UserHandle user,
        private void verifyPrivilegedListener(INotificationListener token, UserHandle user,
@@ -5352,11 +5342,18 @@ public class NotificationManagerService extends SystemService {
    }
    }


    @GuardedBy("mNotificationLock")
    @GuardedBy("mNotificationLock")
    private boolean isPackageSuspendedLocked(NotificationRecord r) {
    boolean isPackagePausedOrSuspended(String pkg, int uid) {
        final String pkg = r.sbn.getPackageName();
        boolean isPaused;
        final int callingUid = r.sbn.getUid();

        final PackageManagerInternal pmi = LocalServices.getService(
                PackageManagerInternal.class);
        int flags = pmi.getDistractingPackageRestrictions(
                pkg, Binder.getCallingUserHandle().getIdentifier());
        isPaused = ((flags & PackageManager.RESTRICTION_HIDE_NOTIFICATIONS) != 0);


        return isPackageSuspendedForUser(pkg, callingUid);
        isPaused |= isPackageSuspendedForUser(pkg, uid);

        return isPaused;
    }
    }


    protected class PostNotificationRunnable implements Runnable {
    protected class PostNotificationRunnable implements Runnable {
@@ -5389,7 +5386,8 @@ public class NotificationManagerService extends SystemService {
                        return;
                        return;
                    }
                    }


                    final boolean isPackageSuspended = isPackageSuspendedLocked(r);
                    final boolean isPackageSuspended =
                            isPackagePausedOrSuspended(r.sbn.getPackageName(), r.getUid());
                    r.setHidden(isPackageSuspended);
                    r.setHidden(isPackageSuspended);
                    if (isPackageSuspended) {
                    if (isPackageSuspended) {
                        mUsageStats.registerSuspendedByAdmin(r);
                        mUsageStats.registerSuspendedByAdmin(r);