Merge pull request #4279 from kiwix/Fixes#4278

Fixed: Application crashes on `FetchDownloadNotificationManager.getCancelNotification` method.
This commit is contained in:
Kelson 2025-04-10 09:21:00 +02:00 committed by GitHub
commit 563e06e302
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -73,6 +73,8 @@ class FetchDownloadNotificationManager @Inject constructor(
val context: Context,
private val downloadRoomDao: DownloadRoomDao
) : DefaultFetchNotificationManager(context) {
private val notificationBuilderLock = Any()
private val downloadNotificationManager: NotificationManager by lazy {
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
}
@ -258,6 +260,7 @@ class FetchDownloadNotificationManager @Inject constructor(
download: Download,
notificationBuilder: Builder
): Notification {
synchronized(notificationBuilderLock) {
val downloadTitle = getDownloadNotificationTitle(download)
val notificationTitle =
runBlocking(Dispatchers.IO) {
@ -287,6 +290,7 @@ class FetchDownloadNotificationManager @Inject constructor(
)
.build()
}
}
private fun getActionPendingIntent(
fetch: Fetch,