From 670300166260da56b57b77fab9b6aa872e53ad34 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Fri, 28 Feb 2020 16:17:52 -0500 Subject: [PATCH] Fix crash & history text - Fix crash on first boot when something is snoozed - Add placeholder text for notifications that don't have any text (e.g. use custom layouts without a backup) Test: manual Fixes: 150327744 Fixes: 149767075 Change-Id: I5e6beb3d68b9974fa950f5e4cb7ea9dc01c34fc7 --- core/res/res/values/strings.xml | 2 ++ core/res/res/values/symbols.xml | 3 +++ .../notification/NotificationManagerService.java | 15 ++++++++++----- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index df1f46f10967a..64f93696b0252 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -4918,6 +4918,8 @@ You set the importance of these notifications. This is important because of the people involved. + Custom app notification + Allow %1$s to create a new User with %2$s (a User with this account already exists) ? diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index e1d261840950b..2fb0370f7fc77 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -3905,4 +3905,7 @@ + + + diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index e6fa610386455..c40f1b65573dc 100755 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -570,17 +570,17 @@ public class NotificationManagerService extends SystemService { public StatusBarNotification[] getArray(int count, boolean includeSnoozed) { if (count == 0) count = mBufferSize; - final StatusBarNotification[] a - = new StatusBarNotification[Math.min(count, mBuffer.size())]; + List a = new ArrayList(); Iterator> iter = descendingIterator(); int i=0; while (iter.hasNext() && i < count) { Pair pair = iter.next(); if (pair.second != REASON_SNOOZED || includeSnoozed) { - a[i++] = pair.first; + i++; + a.add(pair.first); } } - return a; + return a.toArray(new StatusBarNotification[a.size()]); } } @@ -2697,8 +2697,13 @@ public class NotificationManagerService extends SystemService { CharSequence title = null; if (n.extras != null) { title = n.extras.getCharSequence(Notification.EXTRA_TITLE); + if (title == null) { + title = n.extras.getCharSequence(Notification.EXTRA_TITLE_BIG); + } } - return title == null? null : String.valueOf(title); + return title == null ? getContext().getResources().getString( + com.android.internal.R.string.notification_history_title_placeholder) + : String.valueOf(title); } /**