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.
This commit is contained in:
@@ -1500,6 +1500,7 @@ static void interface_initialization_step (GTask *task);
|
|||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
INITIALIZATION_STEP_FIRST,
|
INITIALIZATION_STEP_FIRST,
|
||||||
|
INITIALIZATION_STEP_WAIT_READY,
|
||||||
INITIALIZATION_STEP_SIM_IDENTIFIER,
|
INITIALIZATION_STEP_SIM_IDENTIFIER,
|
||||||
INITIALIZATION_STEP_IMSI,
|
INITIALIZATION_STEP_IMSI,
|
||||||
INITIALIZATION_STEP_OPERATOR_ID,
|
INITIALIZATION_STEP_OPERATOR_ID,
|
||||||
@@ -1633,6 +1634,23 @@ STR_REPLY_READY_FN (imsi, "IMSI")
|
|||||||
STR_REPLY_READY_FN (operator_identifier, "operator identifier")
|
STR_REPLY_READY_FN (operator_identifier, "operator identifier")
|
||||||
STR_REPLY_READY_FN (operator_name, "operator name")
|
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
|
static void
|
||||||
interface_initialization_step (GTask *task)
|
interface_initialization_step (GTask *task)
|
||||||
{
|
{
|
||||||
@@ -1652,6 +1670,18 @@ interface_initialization_step (GTask *task)
|
|||||||
ctx->step++;
|
ctx->step++;
|
||||||
/* Fall through */
|
/* 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:
|
case INITIALIZATION_STEP_SIM_IDENTIFIER:
|
||||||
/* SIM ID is meant to be loaded only once during the whole
|
/* SIM ID is meant to be loaded only once during the whole
|
||||||
* lifetime of the modem. Therefore, if we already have them loaded,
|
* lifetime of the modem. Therefore, if we already have them loaded,
|
||||||
|
@@ -52,6 +52,14 @@ struct _MMBaseSim {
|
|||||||
struct _MMBaseSimClass {
|
struct _MMBaseSimClass {
|
||||||
MmGdbusSimSkeletonClass parent;
|
MmGdbusSimSkeletonClass parent;
|
||||||
|
|
||||||
|
/* Wait SIM ready (async) */
|
||||||
|
void (* wait_sim_ready) (MMBaseSim *self,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data);
|
||||||
|
gboolean (* wait_sim_ready_finish) (MMBaseSim *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
/* Load SIM identifier (async) */
|
/* Load SIM identifier (async) */
|
||||||
void (* load_sim_identifier) (MMBaseSim *self,
|
void (* load_sim_identifier) (MMBaseSim *self,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
|
Reference in New Issue
Block a user