1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2025-01-05 19:15:32 +00:00

record-store: Don't crash on unexpected call state changes

It has been reported that the BM818 sometimes unexpectedly
changes the call state from "active" back to "ringing-in"
(as reported by ModemManager) shortly after accepting an incoming call.

ModemManager[734]: <info>  [modem1/call1] user request to accept call
ModemManager[734]: <info>  [modem1/call1] call is accepted
ModemManager[734]: <info>  [modem1/call1] call state changed: ringing-in -> active (accepted)
ModemManager[734]: <info>  [modem1/call1] call state changed: active -> ringing-in (unknown)

This leads to a failed assertion and program termination.
Instead of crashing raising a critical warning is more appropriate
and may allow the user to pick up the call after all.

Closes: #547
This commit is contained in:
Evangelos Ribeiro Tzaras 2023-01-18 18:41:15 +01:00
parent c0140b4109
commit 0e6d5d9745

View file

@ -71,6 +71,22 @@ state_to_record_state (CuiCallState call_state)
}
static const char *
record_state_to_string (CallsCallRecordState state)
{
switch (state) {
case STARTED:
return "started";
case ANSWERED:
return "answered";
case ENDED:
return "ended";
default:
return "unknown";
}
}
struct _CallsRecordStore {
GtkApplicationWindow parent_instance;
@ -528,8 +544,9 @@ state_changed_cb (CallsRecordStore *self,
g_object_get_data (call_obj, "calls-call-record");
CallsCallRecordState new_rec_state, old_rec_state;
g_debug ("Call state changed from %d to %d",
old_state, new_state);
g_debug ("Call state changed from %s (%d) to %s (%d)",
cui_call_state_to_string (old_state), old_state,
cui_call_state_to_string (new_state), new_state);
/* Check whether the call is recorded */
if (!record) {
@ -561,8 +578,7 @@ state_changed_cb (CallsRecordStore *self,
case STARTED:
default:
g_assert_not_reached ();
break;
goto critical_exit;
}
break;
@ -575,16 +591,23 @@ state_changed_cb (CallsRecordStore *self,
case STARTED:
case ANSWERED:
default:
g_assert_not_reached ();
break;
goto critical_exit;
}
break;
case ENDED:
default:
g_assert_not_reached ();
break;
goto critical_exit;
}
return;
critical_exit:
/* XXX Modem's may be buggy; let's print as much information as possible */
g_critical ("Unexpected state change occurred!\n"
"From %s (%s) to %s (%s)",
cui_call_state_to_string (old_state), record_state_to_string (old_rec_state),
cui_call_state_to_string (new_state), record_state_to_string (new_rec_state));
}