1
0
mirror of https://github.com/nextcloud/talk-android synced 2025-07-14 08:15:04 +01:00

add check that missed call notification is not shown accidentally

for example when call is hangup on mobile and immediately after on web, the loop in "checkIfCallIsActive" is still active and might trigger to send the "missed call" notification. Because of this, there is now another check if the "ongoing call" notification is still visible. It makes only sense to show the missed call notification, when the ongoing call notification is still visible.

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2022-11-14 15:32:43 +01:00 committed by Tim Krüger
parent 9c4b0a00c6
commit e121d32984
No known key found for this signature in database
GPG Key ID: FECE3A7222C52A4E

View File

@ -256,7 +256,7 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
sendNotification(pushMessage.timestamp.toInt(), notification) sendNotification(pushMessage.timestamp.toInt(), notification)
checkIfCallIsActive(signatureVerification, pushMessage) checkIfCallIsActive(signatureVerification)
} }
private fun initNcApiAndCredentials() { private fun initNcApiAndCredentials() {
@ -661,10 +661,7 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
notificationManager.cancel(notificationId) notificationManager.cancel(notificationId)
} }
private fun checkIfCallIsActive( private fun checkIfCallIsActive(signatureVerification: SignatureVerification) {
signatureVerification: SignatureVerification,
decryptedPushMessage: DecryptedPushMessage
) {
Log.d(TAG, "checkIfCallIsActive") Log.d(TAG, "checkIfCallIsActive")
var hasParticipantsInCall = true var hasParticipantsInCall = true
var inCallOnDifferentDevice = false var inCallOnDifferentDevice = false
@ -681,7 +678,7 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
ApiUtils.getUrlForCall( ApiUtils.getUrlForCall(
apiVersion, apiVersion,
signatureVerification.user!!.baseUrl, signatureVerification.user!!.baseUrl,
decryptedPushMessage.id pushMessage.id
) )
) )
.repeatWhen { completed -> .repeatWhen { completed ->
@ -708,18 +705,18 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
} }
if (inCallOnDifferentDevice) { if (inCallOnDifferentDevice) {
Log.d(TAG, "inCallOnDifferentDevice is true") Log.d(TAG, "inCallOnDifferentDevice is true")
removeNotification(decryptedPushMessage.timestamp.toInt()) removeNotification(pushMessage.timestamp.toInt())
} }
if (!hasParticipantsInCall) { if (!hasParticipantsInCall) {
showMissedCallNotification() showMissedCallNotification()
Log.d(TAG, "no participants in call") Log.d(TAG, "no participants in call")
removeNotification(decryptedPushMessage.timestamp.toInt()) removeNotification(pushMessage.timestamp.toInt())
} }
isCallNotificationVisible = NotificationUtils.isNotificationVisible( isCallNotificationVisible = NotificationUtils.isNotificationVisible(
context, context,
decryptedPushMessage.timestamp.toInt() pushMessage.timestamp.toInt()
) )
} }
@ -734,12 +731,18 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
showMissedCallNotification() showMissedCallNotification()
} }
removeNotification(decryptedPushMessage.timestamp.toInt()) removeNotification(pushMessage.timestamp.toInt())
} }
}) })
} }
fun showMissedCallNotification() { fun showMissedCallNotification() {
val isOngoingCallNotificationVisible = NotificationUtils.isNotificationVisible(
context,
pushMessage.timestamp.toInt()
)
if (isOngoingCallNotificationVisible) {
val apiVersion = ApiUtils.getConversationApiVersion( val apiVersion = ApiUtils.getConversationApiVersion(
signatureVerification.user, signatureVerification.user,
intArrayOf( intArrayOf(
@ -800,6 +803,7 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
} }
}) })
} }
}
private fun getIntentToOpenConversation(): PendingIntent? { private fun getIntentToOpenConversation(): PendingIntent? {
val bundle = Bundle() val bundle = Bundle()