From 9077db3c0d147120f74b914087327a4088d61961 Mon Sep 17 00:00:00 2001 From: Bernardo Rufino Date: Fri, 23 Oct 2020 10:00:57 +0100 Subject: [PATCH] Update trampoline toast message It was saying "will be blocked" when it was in fact already being blocked. Test: W/ targetSdk 30, verify trampoline toast says "will be blocked". Test: W/ targetSdk 'S', verify trampoline toast says "blocked". Bug: 167676448 Fixes: 171296995 Change-Id: Ie6ac8b7b5dac08c828f25582c7ef841b2bb1f9e6 --- .../NotificationManagerService.java | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index 4d6b760fc56f5..c2313dbbe05e6 100755 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -10077,24 +10077,27 @@ public class NotificationManagerService extends SystemService { @Override public boolean isActivityStartAllowed(int uid, String packageName) { - boolean block = CompatChanges.isChangeEnabled(NOTIFICATION_TRAMPOLINE_BLOCK, uid); - if (block || mPackagesShown.add(packageName)) { - mUiHandler.post(() -> - Toast.makeText(getUiContext(), - "Indirect activity start from " - + packageName + ". " - + "This will be blocked in S.\n" - + "See go/s-trampolines.", - Toast.LENGTH_LONG).show()); - } - String message = + String toastMessage = "Indirect activity start from " + packageName; + String logcatMessage = "Indirect notification activity start (trampoline) from " + packageName; - if (block) { - Slog.e(TAG, message + " blocked"); + + if (CompatChanges.isChangeEnabled(NOTIFICATION_TRAMPOLINE_BLOCK, uid)) { + toast(toastMessage + " blocked."); + Slog.e(TAG, logcatMessage + " blocked"); return false; + } else { + if (mPackagesShown.add(packageName)) { + toast(toastMessage + ". This will be blocked in S."); + } + Slog.w(TAG, logcatMessage + ", this should be avoided for performance reasons"); + return true; } - Slog.w(TAG, message + ", this should be avoided for performance reasons"); - return true; + } + + private void toast(String message) { + mUiHandler.post(() -> + Toast.makeText(getUiContext(), message + "\nSee go/s-trampolines.", + Toast.LENGTH_LONG).show()); } } }