mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-05-03 15:26:27 +00:00
Fixed foreground service notification lookup
This commit is contained in:
parent
63cb7d6630
commit
fe2a074d0b
1 changed files with 20 additions and 13 deletions
|
|
@ -105,6 +105,17 @@ class NotificationsManager @MainThread constructor(private val context: Context)
|
||||||
NotificationManagerCompat.from(context)
|
NotificationManagerCompat.from(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var inCallService: CoreInCallService? = null
|
||||||
|
private var keepAliveService: CoreKeepAliveThirdPartyAccountsService? = null
|
||||||
|
|
||||||
|
private val callNotificationsMap: HashMap<String, Notifiable> = HashMap()
|
||||||
|
private val chatNotificationsMap: HashMap<String, Notifiable> = HashMap()
|
||||||
|
private val previousChatNotifications: ArrayList<Int> = arrayListOf()
|
||||||
|
|
||||||
|
private val notificationsMap = HashMap<Int, Notification>()
|
||||||
|
|
||||||
|
private var currentlyDisplayedChatRoomId: String = ""
|
||||||
|
|
||||||
private val coreListener = object : CoreListenerStub() {
|
private val coreListener = object : CoreListenerStub() {
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
override fun onCallStateChanged(
|
override fun onCallStateChanged(
|
||||||
|
|
@ -355,15 +366,6 @@ class NotificationsManager @MainThread constructor(private val context: Context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var inCallService: CoreInCallService? = null
|
|
||||||
private var keepAliveService: CoreKeepAliveThirdPartyAccountsService? = null
|
|
||||||
|
|
||||||
private val callNotificationsMap: HashMap<String, Notifiable> = HashMap()
|
|
||||||
private val chatNotificationsMap: HashMap<String, Notifiable> = HashMap()
|
|
||||||
private val previousChatNotifications: ArrayList<Int> = arrayListOf()
|
|
||||||
|
|
||||||
private var currentlyDisplayedChatRoomId: String = ""
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
for (notification in notificationManager.activeNotifications) {
|
for (notification in notificationManager.activeNotifications) {
|
||||||
if (notification.tag.isNullOrEmpty()) {
|
if (notification.tag.isNullOrEmpty()) {
|
||||||
|
|
@ -613,8 +615,11 @@ class NotificationsManager @MainThread constructor(private val context: Context)
|
||||||
}
|
}
|
||||||
|
|
||||||
val notifiable = getNotifiableForCall(call)
|
val notifiable = getNotifiableForCall(call)
|
||||||
val notification = notificationManager.activeNotifications.find {
|
val notificationId = notifiable.notificationId
|
||||||
it.id == notifiable.notificationId
|
val notification = if (notificationsMap.containsKey(notificationId)) {
|
||||||
|
notificationsMap[notificationId]
|
||||||
|
} else {
|
||||||
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
if (notification == null) {
|
if (notification == null) {
|
||||||
|
|
@ -622,7 +627,7 @@ class NotificationsManager @MainThread constructor(private val context: Context)
|
||||||
stopInCallCallForegroundService()
|
stopInCallCallForegroundService()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Log.i("$TAG Found notification [${notification.id}] for current Call")
|
Log.i("$TAG Found notification [$notificationId] for current Call")
|
||||||
|
|
||||||
var mask = Compatibility.FOREGROUND_SERVICE_TYPE_PHONE_CALL
|
var mask = Compatibility.FOREGROUND_SERVICE_TYPE_PHONE_CALL
|
||||||
val callState = call.state
|
val callState = call.state
|
||||||
|
|
@ -664,7 +669,7 @@ class NotificationsManager @MainThread constructor(private val context: Context)
|
||||||
Compatibility.startServiceForeground(
|
Compatibility.startServiceForeground(
|
||||||
service,
|
service,
|
||||||
notifiable.notificationId,
|
notifiable.notificationId,
|
||||||
notification.notification,
|
notification,
|
||||||
mask
|
mask
|
||||||
)
|
)
|
||||||
currentInCallServiceNotificationId = notifiable.notificationId
|
currentInCallServiceNotificationId = notifiable.notificationId
|
||||||
|
|
@ -825,6 +830,7 @@ class NotificationsManager @MainThread constructor(private val context: Context)
|
||||||
)
|
)
|
||||||
try {
|
try {
|
||||||
notificationManager.notify(tag, id, notification)
|
notificationManager.notify(tag, id, notification)
|
||||||
|
notificationsMap[id] = notification
|
||||||
} catch (iae: IllegalArgumentException) {
|
} catch (iae: IllegalArgumentException) {
|
||||||
if (inCallService == null && tag == null) {
|
if (inCallService == null && tag == null) {
|
||||||
// We can't notify using CallStyle if there isn't a foreground service running
|
// We can't notify using CallStyle if there isn't a foreground service running
|
||||||
|
|
@ -848,6 +854,7 @@ class NotificationsManager @MainThread constructor(private val context: Context)
|
||||||
"$TAG Canceling notification with ID [$id] and ${if (tag == null) "without tag" else "with tag [$tag]"}"
|
"$TAG Canceling notification with ID [$id] and ${if (tag == null) "without tag" else "with tag [$tag]"}"
|
||||||
)
|
)
|
||||||
notificationManager.cancel(tag, id)
|
notificationManager.cancel(tag, id)
|
||||||
|
notificationsMap.remove(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue