Do not show incoming call notification when we will decline it with busy reason right after
This commit is contained in:
parent
a78089204e
commit
9572da70d4
2 changed files with 34 additions and 23 deletions
|
@ -136,29 +136,9 @@ class CoreContext(val context: Context, coreConfig: Config) {
|
|||
) {
|
||||
Log.i("[Context] Call state changed [$state]")
|
||||
if (state == Call.State.IncomingReceived || state == Call.State.IncomingEarlyMedia) {
|
||||
if (!corePreferences.useTelecomManager) { // Can't use the following call with Telecom Manager API as it will "fake" GSM calls
|
||||
var gsmCallActive = false
|
||||
if (::phoneStateListener.isInitialized) {
|
||||
gsmCallActive = phoneStateListener.isInCall()
|
||||
}
|
||||
|
||||
if (gsmCallActive) {
|
||||
Log.w("[Context] Refusing the call with reason busy because a GSM call is active")
|
||||
call.decline(Reason.Busy)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if (TelecomHelper.exists()) {
|
||||
if (!TelecomHelper.get().isIncomingCallPermitted() ||
|
||||
TelecomHelper.get().isInManagedCall()
|
||||
) {
|
||||
Log.w("[Context] Refusing the call with reason busy because Telecom Manager will reject the call")
|
||||
call.decline(Reason.Busy)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
Log.e("[Context] Telecom Manager singleton wasn't created!")
|
||||
}
|
||||
if (declineCallDueToGsmActiveCall()) {
|
||||
call.decline(Reason.Busy)
|
||||
return
|
||||
}
|
||||
|
||||
// Starting SDK 24 (Android 7.0) we rely on the fullscreen intent of the call incoming notification
|
||||
|
@ -437,6 +417,32 @@ class CoreContext(val context: Context, coreConfig: Config) {
|
|||
}
|
||||
}
|
||||
|
||||
fun declineCallDueToGsmActiveCall(): Boolean {
|
||||
if (!corePreferences.useTelecomManager) { // Can't use the following call with Telecom Manager API as it will "fake" GSM calls
|
||||
var gsmCallActive = false
|
||||
if (::phoneStateListener.isInitialized) {
|
||||
gsmCallActive = phoneStateListener.isInCall()
|
||||
}
|
||||
|
||||
if (gsmCallActive) {
|
||||
Log.w("[Context] Refusing the call with reason busy because a GSM call is active")
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
if (TelecomHelper.exists()) {
|
||||
if (!TelecomHelper.get().isIncomingCallPermitted() ||
|
||||
TelecomHelper.get().isInManagedCall()
|
||||
) {
|
||||
Log.w("[Context] Refusing the call with reason busy because Telecom Manager will reject the call")
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
Log.e("[Context] Telecom Manager singleton wasn't created!")
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun answerCallVideoUpdateRequest(call: Call, accept: Boolean) {
|
||||
val params = core.createCallParams(call)
|
||||
|
||||
|
|
|
@ -414,6 +414,11 @@ class NotificationsManager(private val context: Context) {
|
|||
}
|
||||
|
||||
private fun displayIncomingCallNotification(call: Call, useAsForeground: Boolean = false) {
|
||||
if (coreContext.declineCallDueToGsmActiveCall()) {
|
||||
Log.w("[Notifications Manager] Call will be declined, do not show incoming call notification")
|
||||
return
|
||||
}
|
||||
|
||||
val address = LinphoneUtils.getDisplayableAddress(call.remoteAddress)
|
||||
val notifiable = getNotifiableForCall(call)
|
||||
|
||||
|
|
Loading…
Reference in a new issue