diff --git a/build.gradle b/build.gradle index dce2b1a10..979460547 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ project.ext { // AndroidX annotationVersion = "1.4.0" appcompatVersion = "1.5.1" - coreVersion = "1.8.0" + coreVersion = "1.9.0" fragmentVersion = "1.5.5" mediaVersion = "1.6.0" media3Version = "1.1.1" diff --git a/core/build.gradle b/core/build.gradle index 6683db189..ed4236e5b 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -10,7 +10,7 @@ android { lint { disable "InvalidPeriodicWorkRequestInterval", "ObsoleteLintCustomCheck", "DefaultLocale", "UnusedAttribute", "ParcelClassLoader", "CheckResult", "TrustAllX509TrustManager", - "StaticFieldLeak", "IconDensities", "IconDuplicates" + "StaticFieldLeak", "IconDensities", "IconDuplicates", "UnsafeOptInUsageError" } defaultConfig { diff --git a/core/src/main/AndroidManifest.xml b/core/src/main/AndroidManifest.xml index 99fd3de05..fc673ef5f 100644 --- a/core/src/main/AndroidManifest.xml +++ b/core/src/main/AndroidManifest.xml @@ -10,6 +10,7 @@ + { Log.d(TAG, "Loading notification icon"); notificationBuilder.loadIcon(); if (!Thread.currentThread().isInterrupted()) { - notificationManager.notify(R.id.notification_playing, notificationBuilder.build()); + if (ContextCompat.checkSelfPermission(getApplicationContext(), + Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED) { + notificationManager.notify(R.id.notification_playing, notificationBuilder.build()); + } updateMediaSessionMetadata(playable); } }); @@ -1779,7 +1794,10 @@ public class PlaybackService extends MediaBrowserServiceCompat { notificationBuilder.updatePosition(getCurrentPosition(), getCurrentPlaybackSpeed()); NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); - notificationManager.notify(R.id.notification_playing, notificationBuilder.build()); + if (ContextCompat.checkSelfPermission(getApplicationContext(), + Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED) { + notificationManager.notify(R.id.notification_playing, notificationBuilder.build()); + } } skipEndingIfNecessary(); }); diff --git a/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java b/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java index 86730b58c..3ee7c2b54 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java @@ -1,15 +1,18 @@ package de.danoeh.antennapod.core.sync; +import android.Manifest; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageManager; import android.os.Build; import android.util.Log; import androidx.annotation.NonNull; import androidx.core.app.NotificationCompat; +import androidx.core.content.ContextCompat; import androidx.core.util.Pair; import androidx.work.BackoffPolicy; import androidx.work.Constraints; @@ -329,7 +332,10 @@ public class SyncService extends Worker { .build(); NotificationManager nm = (NotificationManager) getApplicationContext() .getSystemService(Context.NOTIFICATION_SERVICE); - nm.notify(R.id.notification_gpodnet_sync_error, notification); + if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.POST_NOTIFICATIONS) + == PackageManager.PERMISSION_GRANTED) { + nm.notify(R.id.notification_gpodnet_sync_error, notification); + } } private static OneTimeWorkRequest.Builder getWorkRequest() {