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

Commit 68454aa0 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android Git Automerger
Browse files

am 1b20abd3: am 20bf46af: am b0878223: am 6800a801: Merge "frameworks/base:...

am 1b20abd3: am 20bf46af: am b0878223: am 6800a801: Merge "frameworks/base: Cap the number of toasts that a package can post."

* commit '1b20abd3':
  frameworks/base: Cap the number of toasts that a package can post.
parents b4913b87 1b20abd3
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -469,6 +469,24 @@ public class NotificationManagerService extends INotificationManager.Stub
                    record = mToastQueue.get(index);
                    record.update(duration);
                } else {
                    // Limit the number of toasts that any given package except the android
                    // package can enqueue.  Prevents DOS attacks and deals with leaks.
                    if (!"android".equals(pkg)) {
                        int count = 0;
                        final int N = mToastQueue.size();
                        for (int i=0; i<N; i++) {
                             final ToastRecord r = mToastQueue.get(i);
                             if (r.pkg.equals(pkg)) {
                                 count++;
                                 if (count >= MAX_PACKAGE_NOTIFICATIONS) {
                                     Slog.e(TAG, "Package has already posted " + count
                                            + " toasts. Not showing more. Package=" + pkg);
                                     return;
                                 }
                             }
                        }
                    }

                    record = new ToastRecord(callingPid, pkg, callback, duration);
                    mToastQueue.add(record);
                    index = mToastQueue.size() - 1;