diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index ab5238f1ddbf7..4a6150f6ece47 100755 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -3084,8 +3084,23 @@ public class NotificationManagerService extends SystemService { synchronized (mToastQueue) { int uid = Binder.getCallingUid(); + int userId = UserHandle.getUserId(uid); if (enable) { mToastRateLimitingDisabledUids.remove(uid); + try { + String[] packages = mPackageManager.getPackagesForUid(uid); + if (packages == null) { + Slog.e(TAG, "setToastRateLimitingEnabled method haven't found any " + + "packages for the given uid: " + uid + ", toast rate " + + "limiter not reset for that uid."); + return; + } + for (String pkg : packages) { + mToastRateLimiter.clear(userId, pkg); + } + } catch (RemoteException e) { + Slog.e(TAG, "Failed to reset toast rate limiter for given uid", e); + } } else { mToastRateLimitingDisabledUids.add(uid); }