mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-04-30 18:56:23 +00:00
Prevent crash in CoreFileTransferService if Core's thread is busy and doesn't trigger notification fast enough
This commit is contained in:
parent
4a75315240
commit
ce1c3dad65
1 changed files with 13 additions and 2 deletions
|
|
@ -23,6 +23,7 @@ import android.Manifest
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
|
import androidx.annotation.AnyThread
|
||||||
import androidx.annotation.MainThread
|
import androidx.annotation.MainThread
|
||||||
import androidx.annotation.WorkerThread
|
import androidx.annotation.WorkerThread
|
||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
|
|
@ -92,6 +93,7 @@ class CoreFileTransferService : FileTransferService() {
|
||||||
.setOngoing(true)
|
.setOngoing(true)
|
||||||
.setProgress(0, 0, true)
|
.setProgress(0, 0, true)
|
||||||
.build()
|
.build()
|
||||||
|
postNotification()
|
||||||
|
|
||||||
coreContext.postOnCoreThread { core ->
|
coreContext.postOnCoreThread { core ->
|
||||||
val downloadingFilesCount = core.remainingDownloadFileCount
|
val downloadingFilesCount = core.remainingDownloadFileCount
|
||||||
|
|
@ -128,17 +130,26 @@ class CoreFileTransferService : FileTransferService() {
|
||||||
} else if (uploadingFilesCount > 0) {
|
} else if (uploadingFilesCount > 0) {
|
||||||
uploadText
|
uploadText
|
||||||
} else {
|
} else {
|
||||||
""
|
getString(R.string.notification_file_transfer_title)
|
||||||
}
|
}
|
||||||
|
|
||||||
mServiceNotification = builder.setContentText(message).build()
|
mServiceNotification = builder.setContentText(message).build()
|
||||||
|
postNotification()
|
||||||
|
}
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
|
private fun postNotification() {
|
||||||
val notificationsManager = NotificationManagerCompat.from(this)
|
val notificationsManager = NotificationManagerCompat.from(this)
|
||||||
if (ActivityCompat.checkSelfPermission(
|
if (ActivityCompat.checkSelfPermission(
|
||||||
this,
|
this,
|
||||||
Manifest.permission.POST_NOTIFICATIONS
|
Manifest.permission.POST_NOTIFICATIONS
|
||||||
) == PackageManager.PERMISSION_GRANTED
|
) == PackageManager.PERMISSION_GRANTED
|
||||||
) {
|
) {
|
||||||
|
if (mServiceNotification != null) {
|
||||||
notificationsManager.notify(SERVICE_NOTIF_ID, mServiceNotification)
|
notificationsManager.notify(SERVICE_NOTIF_ID, mServiceNotification)
|
||||||
|
} else {
|
||||||
|
Log.e("$TAG Notification content hasn't been computed yet!")
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.e("$TAG POST_NOTIFICATIONS permission wasn't granted!")
|
Log.e("$TAG POST_NOTIFICATIONS permission wasn't granted!")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue