[PATCH 3/3] qmi: just one InvalidCommand error is enough to avoid all DMS UIM commands
Aleksander Morgado
aleksander at aleksander.es
Sat Jan 30 20:14:25 PST 2016
The MMBroadbandModemQmi will not create a MMSimQmi until the unlock status has
been checked, and therefore this means that when the SIM object is being created
we already know whether the modem supports DMS UIM commands or not, so avoid
further fallbacks in the SIM object.
---
src/mm-broadband-modem-qmi.c | 16 +++----
src/mm-sim-qmi.c | 109 ++++++++++++++++++++++++-------------------
src/mm-sim-qmi.h | 15 +++---
3 files changed, 77 insertions(+), 63 deletions(-)
diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c
index bd6e2a8..775e1f7 100644
--- a/src/mm-broadband-modem-qmi.c
+++ b/src/mm-broadband-modem-qmi.c
@@ -90,8 +90,8 @@ struct _MMBroadbandModemQmiPrivate {
guint signal_info_indication_id;
#endif /* WITH_NEWEST_QMI_COMMANDS */
- /* New devices may not support the legacy DMS UIM Get PIN status */
- gboolean dms_uim_get_pin_status_supported;
+ /* New devices may not support the legacy DMS UIM commands */
+ gboolean dms_uim_deprecated;
/* 3GPP/CDMA registration helpers */
gchar *current_operator_id;
@@ -1753,7 +1753,7 @@ dms_uim_get_pin_status_ready (QmiClientDms *client,
g_error_free (error);
qmi_message_dms_uim_get_pin_status_output_unref (output);
/* Flag that the command is unsupported, and try with the new way */
- ctx->self->priv->dms_uim_get_pin_status_supported = FALSE;
+ ctx->self->priv->dms_uim_deprecated = TRUE;
ctx->step++;
load_unlock_required_context_step (ctx);
return;
@@ -1833,7 +1833,7 @@ load_unlock_required_context_step (LoadUnlockRequiredContext *ctx)
/* Go on to next step */
case LOAD_UNLOCK_REQUIRED_STEP_DMS:
- if (ctx->self->priv->dms_uim_get_pin_status_supported) {
+ if (!ctx->self->priv->dms_uim_deprecated) {
/* Failure to get DMS client is hard really */
client = peek_qmi_client (ctx->self, QMI_SERVICE_DMS, &error);
if (!client) {
@@ -1998,7 +1998,7 @@ unlock_retries_dms_uim_get_pin_status_ready (QmiClientDms *client,
QMI_PROTOCOL_ERROR_INVALID_QMI_COMMAND)) {
g_error_free (error);
/* Flag that the command is unsupported, and try with the new way */
- self->priv->dms_uim_get_pin_status_supported = FALSE;
+ self->priv->dms_uim_deprecated = TRUE;
uim_load_unlock_retries (self, task);
return;
}
@@ -2070,7 +2070,7 @@ modem_load_unlock_retries (MMIfaceModem *_self,
task = g_task_new (self, NULL, callback, user_data);
mm_dbg ("loading unlock retries...");
- if (self->priv->dms_uim_get_pin_status_supported)
+ if (!self->priv->dms_uim_deprecated)
dms_uim_load_unlock_retries (MM_BROADBAND_MODEM_QMI (self), task);
else
uim_load_unlock_retries (MM_BROADBAND_MODEM_QMI (self), task);
@@ -3292,6 +3292,7 @@ create_sim (MMIfaceModem *self,
{
/* New QMI SIM */
mm_sim_qmi_new (MM_BASE_MODEM (self),
+ MM_BROADBAND_MODEM_QMI (self)->priv->dms_uim_deprecated,
NULL, /* cancellable */
callback,
user_data);
@@ -11322,9 +11323,6 @@ mm_broadband_modem_qmi_init (MMBroadbandModemQmi *self)
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
MM_TYPE_BROADBAND_MODEM_QMI,
MMBroadbandModemQmiPrivate);
-
- /* Initially we always try to use the legacy command */
- self->priv->dms_uim_get_pin_status_supported = TRUE;
}
static void
diff --git a/src/mm-sim-qmi.c b/src/mm-sim-qmi.c
index ea9f2a7..d8e1c82 100644
--- a/src/mm-sim-qmi.c
+++ b/src/mm-sim-qmi.c
@@ -30,6 +30,14 @@
G_DEFINE_TYPE (MMSimQmi, mm_sim_qmi, MM_TYPE_BASE_SIM)
+enum {
+ PROP_0,
+ PROP_DMS_UIM_DEPRECATED,
+ PROP_LAST
+};
+
+static GParamSpec *properties[PROP_LAST];
+
struct _MMSimQmiPrivate {
gboolean dms_uim_deprecated;
};
@@ -481,17 +489,6 @@ dms_uim_verify_pin_ready (QmiClientDms *client,
g_prefix_error (&error, "QMI operation failed: ");
g_task_return_error (task, error);
} else if (!qmi_message_dms_uim_verify_pin_output_get_result (output, &error)) {
- /* DMS UIM deprecated? */
- if (g_error_matches (error,
- QMI_PROTOCOL_ERROR,
- QMI_PROTOCOL_ERROR_INVALID_QMI_COMMAND)) {
- g_error_free (error);
- qmi_message_dms_uim_verify_pin_output_unref (output);
- /* Flag as deprecated and try with UIM */
- self->priv->dms_uim_deprecated = TRUE;
- uim_verify_pin (self, task);
- return;
- }
g_prefix_error (&error, "Couldn't verify PIN: ");
g_task_return_error (task, pin_qmi_error_to_mobile_equipment_error (error));
} else
@@ -654,17 +651,6 @@ dms_uim_unblock_pin_ready (QmiClientDms *client,
g_prefix_error (&error, "QMI operation failed: ");
g_task_return_error (task, error);
} else if (!qmi_message_dms_uim_unblock_pin_output_get_result (output, &error)) {
- /* DMS UIM deprecated? */
- if (g_error_matches (error,
- QMI_PROTOCOL_ERROR,
- QMI_PROTOCOL_ERROR_INVALID_QMI_COMMAND)) {
- g_error_free (error);
- qmi_message_dms_uim_unblock_pin_output_unref (output);
- /* Flag as deprecated and try with UIM */
- self->priv->dms_uim_deprecated = TRUE;
- uim_unblock_pin (self, task);
- return;
- }
g_prefix_error (&error, "Couldn't unblock PIN: ");
g_task_return_error (task, pin_qmi_error_to_mobile_equipment_error (error));
} else
@@ -835,17 +821,6 @@ dms_uim_change_pin_ready (QmiClientDms *client,
g_prefix_error (&error, "QMI operation failed: ");
g_task_return_error (task, error);
} else if (!qmi_message_dms_uim_change_pin_output_get_result (output, &error)) {
- /* DMS UIM deprecated? */
- if (g_error_matches (error,
- QMI_PROTOCOL_ERROR,
- QMI_PROTOCOL_ERROR_INVALID_QMI_COMMAND)) {
- g_error_free (error);
- qmi_message_dms_uim_change_pin_output_unref (output);
- /* Flag as deprecated and try with UIM */
- self->priv->dms_uim_deprecated = TRUE;
- uim_change_pin (self, task);
- return;
- }
g_prefix_error (&error, "Couldn't change PIN: ");
g_task_return_error (task, pin_qmi_error_to_mobile_equipment_error (error));
} else
@@ -1015,17 +990,6 @@ dms_uim_set_pin_protection_ready (QmiClientDms *client,
g_prefix_error (&error, "QMI operation failed: ");
g_task_return_error (task, error);
} else if (!qmi_message_dms_uim_set_pin_protection_output_get_result (output, &error)) {
- /* DMS UIM deprecated? */
- if (g_error_matches (error,
- QMI_PROTOCOL_ERROR,
- QMI_PROTOCOL_ERROR_INVALID_QMI_COMMAND)) {
- g_error_free (error);
- qmi_message_dms_uim_set_pin_protection_output_unref (output);
- /* Flag as deprecated and try with UIM */
- self->priv->dms_uim_deprecated = TRUE;
- uim_enable_pin (self, task);
- return;
- }
g_prefix_error (&error, "Couldn't enable PIN: ");
g_task_return_error (task, pin_qmi_error_to_mobile_equipment_error (error));
} else
@@ -1120,10 +1084,11 @@ mm_sim_qmi_new_finish (GAsyncResult *res,
}
void
-mm_sim_qmi_new (MMBaseModem *modem,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+mm_sim_qmi_new (MMBaseModem *modem,
+ gboolean dms_uim_deprecated,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
g_async_initable_new_async (MM_TYPE_SIM_QMI,
G_PRIORITY_DEFAULT,
@@ -1131,6 +1096,7 @@ mm_sim_qmi_new (MMBaseModem *modem,
callback,
user_data,
MM_BASE_SIM_MODEM, modem,
+ MM_SIM_QMI_DMS_UIM_DEPRECATED, dms_uim_deprecated,
NULL);
}
@@ -1144,6 +1110,42 @@ mm_sim_qmi_init (MMSimQmi *self)
}
static void
+set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ MMSimQmi *self = MM_SIM_QMI (object);
+
+ switch (prop_id) {
+ case PROP_DMS_UIM_DEPRECATED:
+ self->priv->dms_uim_deprecated = g_value_get_boolean (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ MMSimQmi *self = MM_SIM_QMI (object);
+
+ switch (prop_id) {
+ case PROP_DMS_UIM_DEPRECATED:
+ g_value_set_boolean (value, self->priv->dms_uim_deprecated);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
mm_sim_qmi_class_init (MMSimQmiClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -1151,6 +1153,9 @@ mm_sim_qmi_class_init (MMSimQmiClass *klass)
g_type_class_add_private (object_class, sizeof (MMSimQmiPrivate));
+ object_class->get_property = get_property;
+ object_class->set_property = set_property;
+
base_sim_class->load_sim_identifier = load_sim_identifier;
base_sim_class->load_sim_identifier_finish = load_sim_identifier_finish;
base_sim_class->load_imsi = load_imsi;
@@ -1167,4 +1172,12 @@ mm_sim_qmi_class_init (MMSimQmiClass *klass)
base_sim_class->change_pin_finish = change_pin_finish;
base_sim_class->enable_pin = enable_pin;
base_sim_class->enable_pin_finish = enable_pin_finish;
+
+ properties[PROP_DMS_UIM_DEPRECATED] =
+ g_param_spec_boolean (MM_SIM_QMI_DMS_UIM_DEPRECATED,
+ "DMS UIM deprecated",
+ "Whether DMS UIM commands should be skipped",
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+ g_object_class_install_property (object_class, PROP_DMS_UIM_DEPRECATED, properties[PROP_DMS_UIM_DEPRECATED]);
}
diff --git a/src/mm-sim-qmi.h b/src/mm-sim-qmi.h
index c0b7621..2095444 100644
--- a/src/mm-sim-qmi.h
+++ b/src/mm-sim-qmi.h
@@ -32,6 +32,8 @@ typedef struct _MMSimQmi MMSimQmi;
typedef struct _MMSimQmiClass MMSimQmiClass;
typedef struct _MMSimQmiPrivate MMSimQmiPrivate;
+#define MM_SIM_QMI_DMS_UIM_DEPRECATED "dms-uim-deprecated"
+
struct _MMSimQmi {
MMBaseSim parent;
MMSimQmiPrivate *priv;
@@ -43,11 +45,12 @@ struct _MMSimQmiClass {
GType mm_sim_qmi_get_type (void);
-void mm_sim_qmi_new (MMBaseModem *modem,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-MMBaseSim *mm_sim_qmi_new_finish (GAsyncResult *res,
- GError **error);
+void mm_sim_qmi_new (MMBaseModem *modem,
+ gboolean dms_uim_deprecated,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+MMBaseSim *mm_sim_qmi_new_finish (GAsyncResult *res,
+ GError **error);
#endif /* MM_SIM_QMI_H */
--
2.7.0
More information about the ModemManager-devel
mailing list