diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c index b480255..dee67df 100644 --- a/src/mm-broadband-modem.c +++ b/src/mm-broadband-modem.c @@ -9444,11 +9444,45 @@ enabling_started_ready (MMBroadbandModem *self, } static void +enabling_wait_for_final_state_ready2 (MMIfaceModem *self, + GAsyncResult *res, + EnablingContext *ctx) +{ + GError *error = NULL; + MMModemState state = MM_MODEM_STATE_UNKNOWN; + + ctx->previous_state = mm_iface_modem_wait_for_final_state_finish (self, res, &error); + if (error) { + g_simple_async_result_take_error (ctx->result, error); + enabling_context_complete_and_free (ctx); + return; + } + + g_object_get (self, + MM_IFACE_MODEM_STATE, &state, + NULL); + + if ((state < MM_MODEM_STATE_ENABLED) || (state > MM_MODEM_STATE_REGISTERED)) { + g_simple_async_result_take_error (ctx->result, + g_error_new_literal (MM_CORE_ERROR, + MM_CORE_ERROR_FAILED, + "waited longer, still not enabled")); + enabling_context_complete_and_free (ctx); + return; + } + + /* We're enabled now, go on */ + g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE); + enabling_context_complete_and_free (ctx); +} + +static void enabling_wait_for_final_state_ready (MMIfaceModem *self, GAsyncResult *res, EnablingContext *ctx) { GError *error = NULL; + MMModemState state = MM_MODEM_STATE_UNKNOWN; ctx->previous_state = mm_iface_modem_wait_for_final_state_finish (self, res, &error); if (error) { @@ -9457,6 +9491,20 @@ enabling_wait_for_final_state_ready (MMIfaceModem *self, return; } + g_object_get (self, + MM_IFACE_MODEM_STATE, &state, + NULL); + if (state == MM_MODEM_STATE_ENABLING) { + g_message ("######## parallel enables!"); + + mm_iface_modem_wait_for_final_state (MM_IFACE_MODEM (ctx->self), + MM_MODEM_STATE_UNKNOWN, /* just any */ + (GAsyncReadyCallback)enabling_wait_for_final_state_ready2, + ctx); + return; + } + + if (ctx->previous_state >= MM_MODEM_STATE_ENABLED) { /* Just return success, don't relaunch enabling */ g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);