Merge "Limit toasts posted by system" into rvc-dev am: 210deda3ef
Change-Id: I3e1f071cf1239a9b3f7b6b48bf173f562f6551b3
This commit is contained in:
@@ -107,6 +107,7 @@ import android.annotation.CallbackExecutor;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.RequiresPermission;
|
||||
import android.annotation.UserIdInt;
|
||||
import android.annotation.WorkerThread;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityManagerInternal;
|
||||
@@ -2842,20 +2843,18 @@ public class NotificationManagerService extends SystemService {
|
||||
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 (!isSystemToast) {
|
||||
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;
|
||||
}
|
||||
// Limit the number of toasts that any given package can enqueue.
|
||||
// Prevents DOS attacks and deals with leaks.
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user