hangup call notification after 1 minute

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2021-10-15 00:08:19 +02:00
parent 3bc4c0c983
commit ec40ca9b66
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B

View File

@ -64,6 +64,7 @@ import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_FROM_NOTIFICATION_START_CA
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_USER_ENTITY
import com.nextcloud.talk.utils.preferences.AppPreferences
import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder
import io.reactivex.Observable
import io.reactivex.Observer
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
@ -78,6 +79,7 @@ import java.net.CookieManager
import java.security.InvalidKeyException
import java.security.NoSuchAlgorithmException
import java.security.PrivateKey
import java.util.concurrent.TimeUnit
import javax.crypto.Cipher
import javax.crypto.NoSuchPaddingException
import javax.inject.Inject
@ -308,7 +310,7 @@ class MagicFirebaseMessagingService : FirebaseMessagingService() {
val ncApi = retrofit!!.newBuilder()
.client(okHttpClient!!.newBuilder().cookieJar(JavaNetCookieJar(CookieManager())).build()).build()
.create(NcApi::class.java)
var hasParticipantsInCall = false
var hasParticipantsInCall = true
var inCallOnDifferentDevice = false
val apiVersion = ApiUtils.getConversationApiVersion(
@ -324,8 +326,10 @@ class MagicFirebaseMessagingService : FirebaseMessagingService() {
decryptedPushMessage.id
)
)
.takeWhile {
isServiceInForeground
.repeatWhen { completed ->
completed.zipWith(Observable.range(1, 12), { _, i -> i })
.flatMap { Observable.timer(5, TimeUnit.SECONDS) }
.takeWhile { isServiceInForeground && hasParticipantsInCall && !inCallOnDifferentDevice }
}
.subscribeOn(Schedulers.io())
.subscribe(object : Observer<ParticipantsOverall> {
@ -343,23 +347,17 @@ class MagicFirebaseMessagingService : FirebaseMessagingService() {
}
}
}
if (!hasParticipantsInCall || inCallOnDifferentDevice) {
Log.d(TAG, "no participants in call OR inCallOnDifferentDevice")
stopForeground(true)
handler.removeCallbacksAndMessages(null)
} else if (isServiceInForeground) {
handler.postDelayed(
{
checkIfCallIsActive(signatureVerification, decryptedPushMessage)
},
5000
)
}
}
override fun onError(e: Throwable) {}
override fun onComplete() {
stopForeground(true)
handler.removeCallbacksAndMessages(null)
}
})
}