From c204a8ce4ebbcfa88cbfe2a08098d2a527bc0b6a Mon Sep 17 00:00:00 2001 From: Ben Chan Date: Thu, 24 Jan 2013 00:43:08 -0800 Subject: iface-modem: rearrange initialization steps This patch rearranges the initialization steps in MMIfaceModem such that the following SIM related operations happen at the end of the initialization: - INITIALIZATION_STEP_UNLOCK_REQUIRED - INITIALIZATION_STEP_SIM - INITIALIZATION_STEP_OWN_NUMBERS The rationale of this change is that the SIM interface of some modems may require some time to initialize before it responds to SIM related AT commands. By rearranging the initialization steps to execute non-SIM related AT commands first, some of the latency for the SIM initialization can be absorbed. --- src/mm-iface-modem.c | 118 +++++++++++++++++++++++++-------------------------- 1 file changed, 59 insertions(+), 59 deletions(-) (limited to 'src') diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c index f6af878c..10144aac 100644 --- a/src/mm-iface-modem.c +++ b/src/mm-iface-modem.c @@ -3402,12 +3402,12 @@ typedef enum { INITIALIZATION_STEP_REVISION, INITIALIZATION_STEP_EQUIPMENT_ID, INITIALIZATION_STEP_DEVICE_ID, - INITIALIZATION_STEP_UNLOCK_REQUIRED, - INITIALIZATION_STEP_SIM, - INITIALIZATION_STEP_OWN_NUMBERS, INITIALIZATION_STEP_SUPPORTED_MODES, INITIALIZATION_STEP_SUPPORTED_BANDS, INITIALIZATION_STEP_POWER_STATE, + INITIALIZATION_STEP_UNLOCK_REQUIRED, + INITIALIZATION_STEP_SIM, + INITIALIZATION_STEP_OWN_NUMBERS, INITIALIZATION_STEP_LAST } InitializationStep; @@ -3873,62 +3873,6 @@ interface_initialization_step (InitializationContext *ctx) /* Fall down to next step */ ctx->step++; - case INITIALIZATION_STEP_UNLOCK_REQUIRED: - /* Only check unlock required if we were previously not unlocked */ - if (mm_gdbus_modem_get_unlock_required (ctx->skeleton) != MM_MODEM_LOCK_NONE) { - mm_iface_modem_update_lock_info (ctx->self, - MM_MODEM_LOCK_UNKNOWN, /* ask */ - (GAsyncReadyCallback)modem_update_lock_info_ready, - ctx); - return; - } - /* Fall down to next step */ - ctx->step++; - - case INITIALIZATION_STEP_SIM: - /* If the modem doesn't need any SIM, skip */ - if (MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->create_sim && - MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->create_sim_finish) { - MMSim *sim = NULL; - - g_object_get (ctx->self, - MM_IFACE_MODEM_SIM, &sim, - NULL); - if (!sim) { - MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->create_sim ( - MM_IFACE_MODEM (ctx->self), - (GAsyncReadyCallback)sim_new_ready, - ctx); - return; - } - - /* If already available the sim object, relaunch initialization. - * This will try to load any missing property value that couldn't be - * retrieved before due to having the SIM locked. */ - mm_sim_initialize (sim, - NULL, /* TODO: cancellable */ - (GAsyncReadyCallback)sim_reinit_ready, - ctx); - g_object_unref (sim); - return; - } - - case INITIALIZATION_STEP_OWN_NUMBERS: - /* Own numbers is meant to be loaded only once during the whole - * lifetime of the modem. Therefore, if we already have them loaded, - * don't try to load them again. */ - if (mm_gdbus_modem_get_own_numbers (ctx->skeleton) == NULL && - MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->load_own_numbers && - MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->load_own_numbers_finish) { - MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->load_own_numbers ( - ctx->self, - (GAsyncReadyCallback)load_own_numbers_ready, - ctx); - return; - } - /* Fall down to next step */ - ctx->step++; - case INITIALIZATION_STEP_SUPPORTED_MODES: g_assert (MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->load_supported_modes != NULL); g_assert (MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->load_supported_modes_finish != NULL); @@ -3996,6 +3940,62 @@ interface_initialization_step (InitializationContext *ctx) /* Fall down to next step */ ctx->step++; + case INITIALIZATION_STEP_UNLOCK_REQUIRED: + /* Only check unlock required if we were previously not unlocked */ + if (mm_gdbus_modem_get_unlock_required (ctx->skeleton) != MM_MODEM_LOCK_NONE) { + mm_iface_modem_update_lock_info (ctx->self, + MM_MODEM_LOCK_UNKNOWN, /* ask */ + (GAsyncReadyCallback)modem_update_lock_info_ready, + ctx); + return; + } + /* Fall down to next step */ + ctx->step++; + + case INITIALIZATION_STEP_SIM: + /* If the modem doesn't need any SIM, skip */ + if (MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->create_sim && + MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->create_sim_finish) { + MMSim *sim = NULL; + + g_object_get (ctx->self, + MM_IFACE_MODEM_SIM, &sim, + NULL); + if (!sim) { + MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->create_sim ( + MM_IFACE_MODEM (ctx->self), + (GAsyncReadyCallback)sim_new_ready, + ctx); + return; + } + + /* If already available the sim object, relaunch initialization. + * This will try to load any missing property value that couldn't be + * retrieved before due to having the SIM locked. */ + mm_sim_initialize (sim, + NULL, /* TODO: cancellable */ + (GAsyncReadyCallback)sim_reinit_ready, + ctx); + g_object_unref (sim); + return; + } + + case INITIALIZATION_STEP_OWN_NUMBERS: + /* Own numbers is meant to be loaded only once during the whole + * lifetime of the modem. Therefore, if we already have them loaded, + * don't try to load them again. */ + if (mm_gdbus_modem_get_own_numbers (ctx->skeleton) == NULL && + MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->load_own_numbers && + MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->load_own_numbers_finish) { + MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->load_own_numbers ( + ctx->self, + (GAsyncReadyCallback)load_own_numbers_ready, + ctx); + return; + } + /* Fall down to next step */ + ctx->step++; + case INITIALIZATION_STEP_LAST: if (ctx->fatal_error) { g_simple_async_result_take_error (ctx->result, ctx->fatal_error); -- cgit v1.2.3-70-g09d2