Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -5771,6 +5771,7 @@ package android.app { method public String addAutomaticZenRule(android.app.AutomaticZenRule); method public boolean areBubblesAllowed(); method public boolean areNotificationsEnabled(); method public boolean areNotificationsPaused(); method public boolean canNotifyAsPackage(String); method public void cancel(int); method public void cancel(String, int); core/java/android/app/INotificationManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -94,6 +94,7 @@ interface INotificationManager boolean areChannelsBypassingDnd(); int getAppsBypassingDndCount(int uid); ParceledListSlice getNotificationChannelsBypassingDnd(String pkg, int userId); boolean isPackagePaused(String pkg); // TODO: Remove this when callers have been migrated to the equivalent // INotificationListener method. Loading core/java/android/app/NotificationManager.java +16 −0 Original line number Diff line number Diff line Loading @@ -1093,6 +1093,22 @@ public class NotificationManager { } } /** * Returns whether notifications from this package are temporarily hidden. This * could be done because the package was marked as distracting to the user via * {@code PackageManager#setDistractingPackageRestrictions(String[], int)} or because the * package is {@code PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle, * PersistableBundle, SuspendDialogInfo) suspended}. */ public boolean areNotificationsPaused() { INotificationManager service = getService(); try { return service.isPackagePaused(mContext.getPackageName()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Checks the ability to modify notification do not disturb policy for the calling package. * Loading services/core/java/com/android/server/notification/NotificationManagerService.java +19 −0 Original line number Diff line number Diff line Loading @@ -121,6 +121,7 @@ import android.content.pm.ApplicationInfo; import android.content.pm.IPackageManager; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManagerInternal; import android.content.pm.ParceledListSlice; import android.content.pm.UserInfo; import android.content.res.Resources; Loading Loading @@ -3854,6 +3855,24 @@ public class NotificationManagerService extends SystemService { return mLockScreenAllowSecureNotifications; } @Override public boolean isPackagePaused(String pkg) { Preconditions.checkNotNull(pkg); checkCallerIsSameApp(pkg); boolean isPaused; 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, boolean assistantAllowed) { ManagedServiceInfo info; Loading Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -5771,6 +5771,7 @@ package android.app { method public String addAutomaticZenRule(android.app.AutomaticZenRule); method public boolean areBubblesAllowed(); method public boolean areNotificationsEnabled(); method public boolean areNotificationsPaused(); method public boolean canNotifyAsPackage(String); method public void cancel(int); method public void cancel(String, int);
core/java/android/app/INotificationManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -94,6 +94,7 @@ interface INotificationManager boolean areChannelsBypassingDnd(); int getAppsBypassingDndCount(int uid); ParceledListSlice getNotificationChannelsBypassingDnd(String pkg, int userId); boolean isPackagePaused(String pkg); // TODO: Remove this when callers have been migrated to the equivalent // INotificationListener method. Loading
core/java/android/app/NotificationManager.java +16 −0 Original line number Diff line number Diff line Loading @@ -1093,6 +1093,22 @@ public class NotificationManager { } } /** * Returns whether notifications from this package are temporarily hidden. This * could be done because the package was marked as distracting to the user via * {@code PackageManager#setDistractingPackageRestrictions(String[], int)} or because the * package is {@code PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle, * PersistableBundle, SuspendDialogInfo) suspended}. */ public boolean areNotificationsPaused() { INotificationManager service = getService(); try { return service.isPackagePaused(mContext.getPackageName()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Checks the ability to modify notification do not disturb policy for the calling package. * Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +19 −0 Original line number Diff line number Diff line Loading @@ -121,6 +121,7 @@ import android.content.pm.ApplicationInfo; import android.content.pm.IPackageManager; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManagerInternal; import android.content.pm.ParceledListSlice; import android.content.pm.UserInfo; import android.content.res.Resources; Loading Loading @@ -3854,6 +3855,24 @@ public class NotificationManagerService extends SystemService { return mLockScreenAllowSecureNotifications; } @Override public boolean isPackagePaused(String pkg) { Preconditions.checkNotNull(pkg); checkCallerIsSameApp(pkg); boolean isPaused; 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, boolean assistantAllowed) { ManagedServiceInfo info; Loading