summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Bernardo Rufino <brufino@google.com> 2021-03-08 11:26:47 +0000
committer Bernardo Rufino <brufino@google.com> 2021-03-16 16:34:21 +0000
commit5c405a0ab558d40c197c29fa8a368d149d48d33a (patch)
treebfb3fe258bc375691b23ce092dd0d4ea71433bdc
parent11687fae2c34abce7a7b44166d7a14011c6c2c84 (diff)
Shorten trampoline toast text
Due to new toast UI constraints. So, instead of package name (which was less informative) we display the app label now with reduced messages: * targetSdk S+: https://screenshot.googleplex.com/3zYrPoNkNK2XabU * targetSdk < S: https://screenshot.googleplex.com/rpMsrkr2PRWMG3z Bug: 167676448 Test: Trigger trampoline w/ targetSdk S and < S, check toast fits. Change-Id: Ie03cfb9668c580018835919091acadce2fea4d75
-rwxr-xr-xservices/core/java/com/android/server/notification/NotificationManagerService.java26
1 files changed, 17 insertions, 9 deletions
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 6f39fea5dd95..079879fc0184 100755
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -134,7 +134,6 @@ import android.app.AlarmManager;
import android.app.AppGlobals;
import android.app.AppOpsManager;
import android.app.AutomaticZenRule;
-import android.app.BroadcastOptions;
import android.app.IActivityManager;
import android.app.INotificationManager;
import android.app.ITransientNotification;
@@ -10624,17 +10623,17 @@ public class NotificationManagerService extends SystemService {
return true;
}
}
- String toastMessage = "Indirect activity start from " + packageName;
String logcatMessage =
"Indirect notification activity start (trampoline) from " + packageName;
-
+ // Call to toast() method is posted to mHandler below to offload PM lookup from the
+ // activity start path
if (CompatChanges.isChangeEnabled(NOTIFICATION_TRAMPOLINE_BLOCK, uid)) {
- toast(toastMessage + " blocked.");
+ mHandler.post(() -> toast(packageName, uid, /* blocked */ true));
Slog.e(TAG, logcatMessage + " blocked");
return false;
} else {
if (mPackagesShown.add(packageName)) {
- toast(toastMessage + ". This will be blocked in S.");
+ mHandler.post(() -> toast(packageName, uid, /* blocked */ false));
}
Slog.w(TAG, logcatMessage + ", this should be avoided for performance reasons");
return true;
@@ -10650,10 +10649,19 @@ public class NotificationManagerService extends SystemService {
&& !CompatChanges.isChangeEnabled(NOTIFICATION_TRAMPOLINE_BLOCK, uid);
}
- private void toast(String message) {
- mUiHandler.post(() ->
- Toast.makeText(getUiContext(), message + "\nSee g.co/dev/trampolines.",
- Toast.LENGTH_LONG).show());
+ private void toast(String packageName, int uid, boolean blocked) {
+ final CharSequence label;
+ try {
+ label = mPackageManagerClient.getApplicationLabel(
+ mPackageManager.getApplicationInfo(packageName, 0,
+ UserHandle.getUserId(uid)));
+ } catch (RemoteException e) {
+ Slog.e(TAG, "Unexpected exception obtaining app label from PackageManager", e);
+ return;
+ }
+ mUiHandler.post(() -> Toast.makeText(getUiContext(),
+ label + " launch " + (blocked ? "blocked" : "will be blocked")
+ + "\ng.co/dev/trampolines", Toast.LENGTH_LONG).show());
}
}
}