base-sim: skip loading SIM properties based on SIM type
If the reported eSIM doesn't have profiles, there is no point in trying to load properties like ICCID, IMSI or operator name/id. If the reported SIM is a physical SIM, there is no point in trying to load properties like EID or eSIM status.
This commit is contained in:
@@ -73,6 +73,18 @@ struct _MMBaseSimPrivate {
|
||||
|
||||
static guint signals[SIGNAL_LAST] = { 0 };
|
||||
|
||||
/*****************************************************************************/
|
||||
/* SIM type helpers */
|
||||
|
||||
#define IS_PSIM(self) \
|
||||
(mm_gdbus_sim_get_sim_type (MM_GDBUS_SIM (self)) == MM_SIM_TYPE_PHYSICAL)
|
||||
|
||||
#define IS_ESIM(self) \
|
||||
(mm_gdbus_sim_get_sim_type (MM_GDBUS_SIM (self)) == MM_SIM_TYPE_ESIM)
|
||||
|
||||
#define IS_ESIM_WITHOUT_PROFILES(self) \
|
||||
(IS_ESIM (self) && (mm_gdbus_sim_get_esim_status (MM_GDBUS_SIM (self)) == MM_SIM_ESIM_STATUS_NO_PROFILES))
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void
|
||||
@@ -2250,15 +2262,15 @@ static void interface_initialization_step (GTask *task);
|
||||
typedef enum {
|
||||
INITIALIZATION_STEP_FIRST,
|
||||
INITIALIZATION_STEP_WAIT_READY,
|
||||
INITIALIZATION_STEP_SIM_TYPE,
|
||||
INITIALIZATION_STEP_ESIM_STATUS,
|
||||
INITIALIZATION_STEP_SIM_IDENTIFIER,
|
||||
INITIALIZATION_STEP_IMSI,
|
||||
INITIALIZATION_STEP_EID,
|
||||
INITIALIZATION_STEP_OPERATOR_ID,
|
||||
INITIALIZATION_STEP_OPERATOR_NAME,
|
||||
INITIALIZATION_STEP_EMERGENCY_NUMBERS,
|
||||
INITIALIZATION_STEP_PREFERRED_NETWORKS,
|
||||
INITIALIZATION_STEP_SIM_TYPE,
|
||||
INITIALIZATION_STEP_ESIM_STATUS,
|
||||
INITIALIZATION_STEP_EID,
|
||||
INITIALIZATION_STEP_REMOVABILITY,
|
||||
INITIALIZATION_STEP_LAST
|
||||
} InitializationStep;
|
||||
@@ -2346,8 +2358,7 @@ initable_init_finish (GAsyncInitable *initable,
|
||||
}
|
||||
|
||||
UINT_REPLY_READY_FN (removability, "removability")
|
||||
UINT_REPLY_READY_FN (esim_status, "esim status")
|
||||
UINT_REPLY_READY_FN (sim_type, "sim type")
|
||||
STR_REPLY_READY_FN (eid, "EID")
|
||||
|
||||
static void
|
||||
init_load_preferred_networks_ready (MMBaseSim *self,
|
||||
@@ -2402,7 +2413,6 @@ init_load_emergency_numbers_ready (MMBaseSim *self,
|
||||
|
||||
STR_REPLY_READY_FN (operator_name, "operator name")
|
||||
STR_REPLY_READY_FN (operator_identifier, "operator identifier")
|
||||
STR_REPLY_READY_FN (eid, "EID")
|
||||
STR_REPLY_READY_FN (imsi, "IMSI")
|
||||
|
||||
static void
|
||||
@@ -2441,6 +2451,9 @@ init_load_sim_identifier_ready (MMBaseSim *self,
|
||||
interface_initialization_step (task);
|
||||
}
|
||||
|
||||
UINT_REPLY_READY_FN (esim_status, "esim status")
|
||||
UINT_REPLY_READY_FN (sim_type, "sim type")
|
||||
|
||||
static void
|
||||
init_wait_sim_ready (MMBaseSim *self,
|
||||
GAsyncResult *res,
|
||||
@@ -2489,97 +2502,6 @@ interface_initialization_step (GTask *task)
|
||||
ctx->step++;
|
||||
/* Fall through */
|
||||
|
||||
case INITIALIZATION_STEP_SIM_IDENTIFIER:
|
||||
if (mm_gdbus_sim_get_sim_identifier (MM_GDBUS_SIM (self)) == NULL &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_sim_identifier &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_sim_identifier_finish) {
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_sim_identifier (
|
||||
self,
|
||||
(GAsyncReadyCallback)init_load_sim_identifier_ready,
|
||||
task);
|
||||
return;
|
||||
}
|
||||
ctx->step++;
|
||||
/* Fall through */
|
||||
|
||||
case INITIALIZATION_STEP_IMSI:
|
||||
if (mm_gdbus_sim_get_imsi (MM_GDBUS_SIM (self)) == NULL &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_imsi &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_imsi_finish) {
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_imsi (
|
||||
self,
|
||||
(GAsyncReadyCallback)init_load_imsi_ready,
|
||||
task);
|
||||
return;
|
||||
}
|
||||
ctx->step++;
|
||||
/* Fall through */
|
||||
|
||||
case INITIALIZATION_STEP_EID:
|
||||
if (mm_gdbus_sim_get_eid (MM_GDBUS_SIM (self)) == NULL &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_eid &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_eid_finish) {
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_eid (
|
||||
self,
|
||||
(GAsyncReadyCallback)init_load_eid_ready,
|
||||
task);
|
||||
return;
|
||||
}
|
||||
ctx->step++;
|
||||
/* Fall through */
|
||||
|
||||
case INITIALIZATION_STEP_OPERATOR_ID:
|
||||
if (mm_gdbus_sim_get_operator_identifier (MM_GDBUS_SIM (self)) == NULL &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_operator_identifier &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_operator_identifier_finish) {
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_operator_identifier (
|
||||
self,
|
||||
(GAsyncReadyCallback)init_load_operator_identifier_ready,
|
||||
task);
|
||||
return;
|
||||
}
|
||||
ctx->step++;
|
||||
/* Fall through */
|
||||
|
||||
case INITIALIZATION_STEP_OPERATOR_NAME:
|
||||
if (mm_gdbus_sim_get_operator_name (MM_GDBUS_SIM (self)) == NULL &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_operator_name &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_operator_name_finish) {
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_operator_name (
|
||||
self,
|
||||
(GAsyncReadyCallback)init_load_operator_name_ready,
|
||||
task);
|
||||
return;
|
||||
}
|
||||
ctx->step++;
|
||||
/* Fall through */
|
||||
|
||||
case INITIALIZATION_STEP_EMERGENCY_NUMBERS:
|
||||
if (mm_gdbus_sim_get_emergency_numbers (MM_GDBUS_SIM (self)) == NULL &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_emergency_numbers &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_emergency_numbers_finish) {
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_emergency_numbers (
|
||||
self,
|
||||
(GAsyncReadyCallback)init_load_emergency_numbers_ready,
|
||||
task);
|
||||
return;
|
||||
}
|
||||
ctx->step++;
|
||||
/* Fall through */
|
||||
|
||||
case INITIALIZATION_STEP_PREFERRED_NETWORKS:
|
||||
if (mm_gdbus_sim_get_preferred_networks (MM_GDBUS_SIM (self)) == NULL &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_preferred_networks &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_preferred_networks_finish) {
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_preferred_networks (
|
||||
self,
|
||||
(GAsyncReadyCallback)init_load_preferred_networks_ready,
|
||||
task);
|
||||
return;
|
||||
}
|
||||
ctx->step++;
|
||||
/* Fall through */
|
||||
|
||||
case INITIALIZATION_STEP_SIM_TYPE:
|
||||
if (mm_gdbus_sim_get_sim_type (MM_GDBUS_SIM (self)) == MM_SIM_TYPE_UNKNOWN &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_sim_type &&
|
||||
@@ -2594,9 +2516,12 @@ interface_initialization_step (GTask *task)
|
||||
/* Fall through */
|
||||
|
||||
case INITIALIZATION_STEP_ESIM_STATUS:
|
||||
if (mm_gdbus_sim_get_esim_status (MM_GDBUS_SIM (self)) == MM_SIM_ESIM_STATUS_UNKNOWN &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_esim_status &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_esim_status_finish) {
|
||||
/* Don't load eSIM status if the SIM is known to be a physical SIM */
|
||||
if (IS_PSIM (self))
|
||||
mm_obj_dbg (self, "not loading eSIM status in physical SIM");
|
||||
else if (mm_gdbus_sim_get_esim_status (MM_GDBUS_SIM (self)) == MM_SIM_ESIM_STATUS_UNKNOWN &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_esim_status &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_esim_status_finish) {
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_esim_status (
|
||||
self,
|
||||
(GAsyncReadyCallback)init_load_esim_status_ready,
|
||||
@@ -2606,7 +2531,134 @@ interface_initialization_step (GTask *task)
|
||||
ctx->step++;
|
||||
/* Fall through */
|
||||
|
||||
case INITIALIZATION_STEP_SIM_IDENTIFIER:
|
||||
/* Don't load SIM ICCID if the SIM is known to be an eSIM without
|
||||
* profiles; otherwise (if physical SIM, or if eSIM with profile, or if
|
||||
* SIM type unknown) try to load it. */
|
||||
if (IS_ESIM_WITHOUT_PROFILES (self))
|
||||
mm_obj_dbg (self, "not loading SIM identifier in eSIM without profiles");
|
||||
else if (mm_gdbus_sim_get_sim_identifier (MM_GDBUS_SIM (self)) == NULL &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_sim_identifier &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_sim_identifier_finish) {
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_sim_identifier (
|
||||
self,
|
||||
(GAsyncReadyCallback)init_load_sim_identifier_ready,
|
||||
task);
|
||||
return;
|
||||
}
|
||||
ctx->step++;
|
||||
/* Fall through */
|
||||
|
||||
case INITIALIZATION_STEP_IMSI:
|
||||
/* Don't load SIM IMSI if the SIM is known to be an eSIM without
|
||||
* profiles; otherwise (if physical SIM, or if eSIM with profile, or if
|
||||
* SIM type unknown) try to load it. */
|
||||
if (IS_ESIM_WITHOUT_PROFILES (self))
|
||||
mm_obj_dbg (self, "not loading IMSI in eSIM without profiles");
|
||||
else if (mm_gdbus_sim_get_imsi (MM_GDBUS_SIM (self)) == NULL &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_imsi &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_imsi_finish) {
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_imsi (
|
||||
self,
|
||||
(GAsyncReadyCallback)init_load_imsi_ready,
|
||||
task);
|
||||
return;
|
||||
}
|
||||
ctx->step++;
|
||||
/* Fall through */
|
||||
|
||||
case INITIALIZATION_STEP_OPERATOR_ID:
|
||||
/* Don't load operator ID if the SIM is known to be an eSIM without
|
||||
* profiles; otherwise (if physical SIM, or if eSIM with profile, or if
|
||||
* SIM type unknown) try to load it. */
|
||||
if (IS_ESIM_WITHOUT_PROFILES (self))
|
||||
mm_obj_dbg (self, "not loading operator ID in eSIM without profiles");
|
||||
else if (mm_gdbus_sim_get_operator_identifier (MM_GDBUS_SIM (self)) == NULL &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_operator_identifier &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_operator_identifier_finish) {
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_operator_identifier (
|
||||
self,
|
||||
(GAsyncReadyCallback)init_load_operator_identifier_ready,
|
||||
task);
|
||||
return;
|
||||
}
|
||||
ctx->step++;
|
||||
/* Fall through */
|
||||
|
||||
case INITIALIZATION_STEP_OPERATOR_NAME:
|
||||
/* Don't load operator name if the SIM is known to be an eSIM without
|
||||
* profiles; otherwise (if physical SIM, or if eSIM with profile, or if
|
||||
* SIM type unknown) try to load it. */
|
||||
if (IS_ESIM_WITHOUT_PROFILES (self))
|
||||
mm_obj_dbg (self, "not loading operator name in eSIM without profiles");
|
||||
else if (mm_gdbus_sim_get_operator_name (MM_GDBUS_SIM (self)) == NULL &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_operator_name &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_operator_name_finish) {
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_operator_name (
|
||||
self,
|
||||
(GAsyncReadyCallback)init_load_operator_name_ready,
|
||||
task);
|
||||
return;
|
||||
}
|
||||
ctx->step++;
|
||||
/* Fall through */
|
||||
|
||||
case INITIALIZATION_STEP_EMERGENCY_NUMBERS:
|
||||
/* Don't load emergency numbers if the SIM is known to be an eSIM without
|
||||
* profiles; otherwise (if physical SIM, or if eSIM with profile, or if
|
||||
* SIM type unknown) try to load it. */
|
||||
if (IS_ESIM_WITHOUT_PROFILES (self))
|
||||
mm_obj_dbg (self, "not loading emergency numbers in eSIM without profiles");
|
||||
else if (mm_gdbus_sim_get_emergency_numbers (MM_GDBUS_SIM (self)) == NULL &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_emergency_numbers &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_emergency_numbers_finish) {
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_emergency_numbers (
|
||||
self,
|
||||
(GAsyncReadyCallback)init_load_emergency_numbers_ready,
|
||||
task);
|
||||
return;
|
||||
}
|
||||
ctx->step++;
|
||||
/* Fall through */
|
||||
|
||||
case INITIALIZATION_STEP_PREFERRED_NETWORKS:
|
||||
/* Don't load preferred networks if the SIM is known to be an eSIM without
|
||||
* profiles; otherwise (if physical SIM, or if eSIM with profile, or if
|
||||
* SIM type unknown) try to load it. */
|
||||
if (IS_ESIM_WITHOUT_PROFILES (self))
|
||||
mm_obj_dbg (self, "not loading preferred networks in eSIM without profiles");
|
||||
else if (mm_gdbus_sim_get_preferred_networks (MM_GDBUS_SIM (self)) == NULL &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_preferred_networks &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_preferred_networks_finish) {
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_preferred_networks (
|
||||
self,
|
||||
(GAsyncReadyCallback)init_load_preferred_networks_ready,
|
||||
task);
|
||||
return;
|
||||
}
|
||||
ctx->step++;
|
||||
/* Fall through */
|
||||
|
||||
case INITIALIZATION_STEP_EID:
|
||||
/* Don't load EID if the SIM is known to be a physical SIM; otherwise
|
||||
* (if eSIM with or without profiles) try to load it. */
|
||||
if (IS_PSIM (self))
|
||||
mm_obj_dbg (self, "not loading EID in physical SIM");
|
||||
else if (mm_gdbus_sim_get_eid (MM_GDBUS_SIM (self)) == NULL &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_eid &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_eid_finish) {
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_eid (
|
||||
self,
|
||||
(GAsyncReadyCallback)init_load_eid_ready,
|
||||
task);
|
||||
return;
|
||||
}
|
||||
ctx->step++;
|
||||
/* Fall through */
|
||||
|
||||
case INITIALIZATION_STEP_REMOVABILITY:
|
||||
/* Although not very common, there are removable eSIMs, so always try to
|
||||
* load it, regardless of SIM type. */
|
||||
if (mm_gdbus_sim_get_removability (MM_GDBUS_SIM (self)) == MM_SIM_REMOVABILITY_UNKNOWN &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_removability &&
|
||||
MM_BASE_SIM_GET_CLASS (self)->load_removability_finish) {
|
||||
|
Reference in New Issue
Block a user