diff --git a/app/src/main/java/org/linphone/core/CoreContext.kt b/app/src/main/java/org/linphone/core/CoreContext.kt index 4eaf53c46..3274f7ee7 100644 --- a/app/src/main/java/org/linphone/core/CoreContext.kt +++ b/app/src/main/java/org/linphone/core/CoreContext.kt @@ -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) diff --git a/app/src/main/java/org/linphone/notifications/NotificationsManager.kt b/app/src/main/java/org/linphone/notifications/NotificationsManager.kt index eea1fc8cf..f298958b0 100644 --- a/app/src/main/java/org/linphone/notifications/NotificationsManager.kt +++ b/app/src/main/java/org/linphone/notifications/NotificationsManager.kt @@ -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)