summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Julia Reynolds <juliacr@google.com> 2018-10-11 09:21:11 -0400
committer Julia Reynolds <juliacr@google.com> 2018-10-11 09:24:52 -0400
commitbba26b18ec1ba45f6c312cdae05f7ec0dfef1663 (patch)
tree13f6920a93951058b51b6f74c56f83aef8ece5f6
parent803a52498b022303e725de72f9eb96b16cb3a898 (diff)
Post channel error toasts as android
Since we're using system_server's context, our calling identity needs to match Test: test app that posts a notification to a non-existant channel Fixes: 117519040 Change-Id: I599d2a2c3f086bceef9f4b5c50f4cc7c55bdb207
-rw-r--r--services/core/java/com/android/server/notification/NotificationManagerService.java18
1 files changed, 10 insertions, 8 deletions
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index f9d49d7ce0d1..506cc441c868 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -4282,14 +4282,16 @@ public class NotificationManagerService extends SystemService {
}
private void doChannelWarningToast(CharSequence toastText) {
- final int defaultWarningEnabled = Build.IS_DEBUGGABLE ? 1 : 0;
- final boolean warningEnabled = Settings.Global.getInt(getContext().getContentResolver(),
- Settings.Global.SHOW_NOTIFICATION_CHANNEL_WARNINGS, defaultWarningEnabled) != 0;
- if (warningEnabled) {
- Toast toast = Toast.makeText(getContext(), mHandler.getLooper(), toastText,
- Toast.LENGTH_SHORT);
- toast.show();
- }
+ Binder.withCleanCallingIdentity(() -> {
+ final int defaultWarningEnabled = Build.IS_DEBUGGABLE ? 1 : 0;
+ final boolean warningEnabled = Settings.Global.getInt(getContext().getContentResolver(),
+ Settings.Global.SHOW_NOTIFICATION_CHANNEL_WARNINGS, defaultWarningEnabled) != 0;
+ if (warningEnabled) {
+ Toast toast = Toast.makeText(getContext(), mHandler.getLooper(), toastText,
+ Toast.LENGTH_SHORT);
+ toast.show();
+ }
+ });
}
@VisibleForTesting