Nullcheck channels when reading importance. (#2971)

Fixes #2970
This commit is contained in:
Levi Bard 2022-12-02 19:46:02 +01:00 committed by GitHub
parent 588307f7a1
commit 83862569e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -473,7 +473,7 @@ public class NotificationHelper {
if (notificationManager.areNotificationsEnabled()) {
for (NotificationChannel channel : notificationManager.getNotificationChannels()) {
if (channel.getImportance() > NotificationManager.IMPORTANCE_NONE) {
if (channel != null && channel.getImportance() > NotificationManager.IMPORTANCE_NONE) {
Log.d(TAG, "NotificationsEnabled");
return true;
}
@ -546,7 +546,7 @@ public class NotificationHelper {
return false;
}
NotificationChannel channel = notificationManager.getNotificationChannel(channelId);
return channel.getImportance() > NotificationManager.IMPORTANCE_NONE;
return channel != null && channel.getImportance() > NotificationManager.IMPORTANCE_NONE;
}
switch (type) {