mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 03:18:06 +00:00
Prevent crash due to service being started as foreground if post_notifications permission isn't granted
This commit is contained in:
parent
0d8397b914
commit
915a847083
1 changed files with 33 additions and 17 deletions
|
|
@ -690,13 +690,21 @@ class NotificationsManager
|
|||
Log.i(
|
||||
"$TAG Service found, starting it as foreground using notification ID [$INCOMING_CALL_ID] with type PHONE_CALL"
|
||||
)
|
||||
Compatibility.startServiceForeground(
|
||||
service,
|
||||
INCOMING_CALL_ID,
|
||||
notification,
|
||||
Compatibility.FOREGROUND_SERVICE_TYPE_PHONE_CALL
|
||||
)
|
||||
currentInCallServiceNotificationId = INCOMING_CALL_ID
|
||||
if (ActivityCompat.checkSelfPermission(
|
||||
context,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
) == PackageManager.PERMISSION_GRANTED
|
||||
) {
|
||||
Compatibility.startServiceForeground(
|
||||
service,
|
||||
INCOMING_CALL_ID,
|
||||
notification,
|
||||
Compatibility.FOREGROUND_SERVICE_TYPE_PHONE_CALL
|
||||
)
|
||||
currentInCallServiceNotificationId = INCOMING_CALL_ID
|
||||
} else {
|
||||
Log.e("$TAG POST_NOTIFICATIONS permission isn't granted, don't start foreground service!")
|
||||
}
|
||||
} else {
|
||||
Log.w("$TAG Core Foreground Service hasn't started yet...")
|
||||
}
|
||||
|
|
@ -785,16 +793,24 @@ class NotificationsManager
|
|||
}
|
||||
}
|
||||
|
||||
Log.i(
|
||||
"$TAG Service found, starting it as foreground using notification ID [${notifiable.notificationId}] with type(s) [$mask]"
|
||||
)
|
||||
Compatibility.startServiceForeground(
|
||||
service,
|
||||
notifiable.notificationId,
|
||||
notification,
|
||||
mask
|
||||
)
|
||||
currentInCallServiceNotificationId = notifiable.notificationId
|
||||
if (ActivityCompat.checkSelfPermission(
|
||||
context,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
) == PackageManager.PERMISSION_GRANTED
|
||||
) {
|
||||
Log.i(
|
||||
"$TAG Service found, starting it as foreground using notification ID [${notifiable.notificationId}] with type(s) [$mask]"
|
||||
)
|
||||
Compatibility.startServiceForeground(
|
||||
service,
|
||||
notifiable.notificationId,
|
||||
notification,
|
||||
mask
|
||||
)
|
||||
currentInCallServiceNotificationId = notifiable.notificationId
|
||||
} else {
|
||||
Log.e("$TAG POST_NOTIFICATIONS permission isn't granted, don't start foreground service!")
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue