Fix crash on clicking dismissed notifications

Read the channelid from the notification vs RankingMap
for historical notifications

Test: manual
Fixes: 142531668
Change-Id: Ia7b48e6bcee3995286eea2e2f5f3b6bc4cff98e2
This commit is contained in:
Julia Reynolds
2019-10-11 13:06:55 -04:00
parent ce37679e3a
commit d80ddbd82b

View File

@@ -79,6 +79,9 @@ public class NotificationStation extends SettingsPreferenceFragment {
private static class HistoricalNotificationInfo { private static class HistoricalNotificationInfo {
public String key; public String key;
public NotificationChannel channel; public NotificationChannel channel;
// Historical notifications don't have Ranking information. for most fields that's ok
// but we need channel id to launch settings.
public String channelId;
public String pkg; public String pkg;
public Drawable pkgicon; public Drawable pkgicon;
public CharSequence pkgname; public CharSequence pkgname;
@@ -416,6 +419,7 @@ public class NotificationStation extends SettingsPreferenceFragment {
info.timestamp = sbn.getPostTime(); info.timestamp = sbn.getPostTime();
info.priority = n.priority; info.priority = n.priority;
info.key = sbn.getKey(); info.key = sbn.getKey();
info.channelId = sbn.getNotification().getChannelId();
info.active = active; info.active = active;
info.notificationExtra = generateExtraText(sbn, info); info.notificationExtra = generateExtraText(sbn, info);
@@ -724,7 +728,8 @@ public class NotificationStation extends SettingsPreferenceFragment {
public void performClick() { public void performClick() {
Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS) Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
.putExtra(EXTRA_APP_PACKAGE, mInfo.pkg) .putExtra(EXTRA_APP_PACKAGE, mInfo.pkg)
.putExtra(EXTRA_CHANNEL_ID, mInfo.channel.getId()); .putExtra(EXTRA_CHANNEL_ID,
mInfo.channel != null ? mInfo.channel.getId() : mInfo.channelId);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getContext().startActivity(intent); getContext().startActivity(intent);
} }