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.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.annotation.RequiresPermission;
|
import android.annotation.RequiresPermission;
|
||||||
|
import android.annotation.UserIdInt;
|
||||||
import android.annotation.WorkerThread;
|
import android.annotation.WorkerThread;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.ActivityManagerInternal;
|
import android.app.ActivityManagerInternal;
|
||||||
@@ -2842,20 +2843,18 @@ public class NotificationManagerService extends SystemService {
|
|||||||
record = mToastQueue.get(index);
|
record = mToastQueue.get(index);
|
||||||
record.update(duration);
|
record.update(duration);
|
||||||
} else {
|
} else {
|
||||||
// Limit the number of toasts that any given package except the android
|
// Limit the number of toasts that any given package can enqueue.
|
||||||
// package can enqueue. Prevents DOS attacks and deals with leaks.
|
// Prevents DOS attacks and deals with leaks.
|
||||||
if (!isSystemToast) {
|
int count = 0;
|
||||||
int count = 0;
|
final int N = mToastQueue.size();
|
||||||
final int N = mToastQueue.size();
|
for (int i = 0; i < N; i++) {
|
||||||
for (int i = 0; i < N; i++) {
|
final ToastRecord r = mToastQueue.get(i);
|
||||||
final ToastRecord r = mToastQueue.get(i);
|
if (r.pkg.equals(pkg)) {
|
||||||
if (r.pkg.equals(pkg)) {
|
count++;
|
||||||
count++;
|
if (count >= MAX_PACKAGE_NOTIFICATIONS) {
|
||||||
if (count >= MAX_PACKAGE_NOTIFICATIONS) {
|
Slog.e(TAG, "Package has already posted " + count
|
||||||
Slog.e(TAG, "Package has already posted " + count
|
+ " toasts. Not showing more. Package=" + pkg);
|
||||||
+ " toasts. Not showing more. Package=" + pkg);
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user