diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2020-08-01 09:59:24 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2020-08-28 14:59:06 +0000 |
commit | b2979c63eb2d724512c7a96c071f3d4b422e79cb (patch) | |
tree | 4f10087feda351343b56a992364dc45b934e2c9d /src/mm-base-sim.c | |
parent | 18084f89394491d4a363a90354000c55af1490c8 (diff) |
base-sim: allow explicit wait for SIM readiness during initialization
Before attempting to load any SIM property value, allow checking
whether the SIM is ready for operation or not.
This action is implicitly done by the "unlock required check" step
that is triggered before initializing the primary SIM card, but it
would not be done when initializing other available SIM cards.
Diffstat (limited to 'src/mm-base-sim.c')
-rw-r--r-- | src/mm-base-sim.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/mm-base-sim.c b/src/mm-base-sim.c index cc61a603..c9d24fbb 100644 --- a/src/mm-base-sim.c +++ b/src/mm-base-sim.c @@ -1500,6 +1500,7 @@ static void interface_initialization_step (GTask *task); typedef enum { INITIALIZATION_STEP_FIRST, + INITIALIZATION_STEP_WAIT_READY, INITIALIZATION_STEP_SIM_IDENTIFIER, INITIALIZATION_STEP_IMSI, INITIALIZATION_STEP_OPERATOR_ID, @@ -1634,6 +1635,23 @@ STR_REPLY_READY_FN (operator_identifier, "operator identifier") STR_REPLY_READY_FN (operator_name, "operator name") static void +init_wait_sim_ready (MMBaseSim *self, + GAsyncResult *res, + GTask *task) +{ + InitAsyncContext *ctx; + g_autoptr(GError) error = NULL; + + if (!MM_BASE_SIM_GET_CLASS (self)->wait_sim_ready_finish (self, res, &error)) + mm_obj_warn (self, "couldn't wait for SIM to be ready: %s", error->message); + + /* Go on to next step */ + ctx = g_task_get_task_data (task); + ctx->step++; + interface_initialization_step (task); +} + +static void interface_initialization_step (GTask *task) { MMBaseSim *self; @@ -1652,6 +1670,18 @@ interface_initialization_step (GTask *task) ctx->step++; /* Fall through */ + case INITIALIZATION_STEP_WAIT_READY: + if (MM_BASE_SIM_GET_CLASS (self)->wait_sim_ready && + MM_BASE_SIM_GET_CLASS (self)->wait_sim_ready_finish) { + MM_BASE_SIM_GET_CLASS (self)->wait_sim_ready ( + self, + (GAsyncReadyCallback)init_wait_sim_ready, + task); + return; + } + ctx->step++; + /* Fall through */ + case INITIALIZATION_STEP_SIM_IDENTIFIER: /* SIM ID is meant to be loaded only once during the whole * lifetime of the modem. Therefore, if we already have them loaded, |