From 205f691570535fe53e10d0f068a3dd901274d963 Mon Sep 17 00:00:00 2001 From: Evangelos Ribeiro Tzaras Date: Thu, 19 Jan 2023 11:46:48 +0100 Subject: [PATCH] mm-origin: Disable call waiting As Calls cannot deal with call waiting we should disable it entirely. This works around issues where call audio get's completely broken once the waiting call is disconnected on the BM818 modem shipped with the Librem 5. See https://source.puri.sm/Librem5/OS-issues/-/issues/311 --- plugins/provider/mm/calls-mm-origin.c | 59 +++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/plugins/provider/mm/calls-mm-origin.c b/plugins/provider/mm/calls-mm-origin.c index 35cfdb4..08af8dc 100644 --- a/plugins/provider/mm/calls-mm-origin.c +++ b/plugins/provider/mm/calls-mm-origin.c @@ -791,6 +791,60 @@ get_sim_ready_cb (MMModem *modem, } +static void +call_waiting_setup_cb (GObject *obj, + GAsyncResult *res, + gpointer user_data) +{ + g_autoptr (GError) error = NULL; + g_autoptr (CallsMMOrigin) self = NULL; + MMModemVoice *voice = MM_MODEM_VOICE (obj); + + g_assert (CALLS_IS_MM_ORIGIN (user_data)); + self = CALLS_MM_ORIGIN (user_data); + g_assert (voice == self->voice); + + if (!mm_modem_voice_call_waiting_setup_finish (voice, res, &error)) { + g_warning ("Could not disable call waiting: %s", error->message); + return; + } + + g_info ("Disabled call waiting on modem '%s'", self->name); +} + + +static void +call_waiting_query_cb (GObject *obj, + GAsyncResult *res, + gpointer user_data) +{ + g_autoptr (GError) error = NULL; + g_autoptr (CallsMMOrigin) self = NULL; + MMModemVoice *voice = MM_MODEM_VOICE (obj); + gboolean waiting; + + g_assert (CALLS_IS_MM_ORIGIN (user_data)); + self = CALLS_MM_ORIGIN (user_data); + g_assert (voice == self->voice); + + if (!mm_modem_voice_call_waiting_query_finish (voice, res, &waiting, &error)) { + g_warning ("Could not query call waiting status: %s", error->message); + return; + } + + g_debug ("Call waiting is %sabled", waiting ? "en" : "dis"); + if (waiting) { + g_info ("Disabling call waiting: Not implemented"); + + mm_modem_voice_call_waiting_setup (voice, + FALSE, + NULL, + call_waiting_setup_cb, + g_steal_pointer (&self)); + } +} + + static void constructed (GObject *object) { @@ -815,6 +869,11 @@ constructed (GObject *object) self->voice = mm_object_get_modem_voice (self->mm_obj); g_assert (self->voice != NULL); + mm_modem_voice_call_waiting_query (self->voice, + NULL, + call_waiting_query_cb, + g_object_ref (self)); + g_signal_connect (self->voice, "call-added", G_CALLBACK (call_added_cb), self); g_signal_connect (self->voice, "call-deleted",