iface-modem: never try to create a SIM in a CDMA-only modem

CDMA modems without LTE capabilities will usually not have a SIM, so just skip
loading a SIM object if so.

https://bugzilla.gnome.org/show_bug.cgi?id=696582
This commit is contained in:
Aleksander Morgado
2013-03-26 16:40:54 +01:00
committed by Dan Williams
parent 7f1bea5fbf
commit b377a62377
2 changed files with 7 additions and 51 deletions

View File

@@ -280,37 +280,7 @@ modem_create_sim_finish (MMIfaceModem *self,
GAsyncResult *res, GAsyncResult *res,
GError **error) GError **error)
{ {
MMSim *sim; return mm_sim_new_finish (res, error);
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
return NULL;
sim = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res));
return (sim ? g_object_ref (sim) : NULL);
}
static void
modem_create_sim_ready (GObject *source,
GAsyncResult *res,
GSimpleAsyncResult *simple)
{
MMSim *sim;
GError *error = NULL;
sim = mm_sim_new_finish (res, &error);
if (!sim)
g_simple_async_result_take_error (simple, error);
else {
mm_dbg ("New SIM created at DBus path '%s'",
mm_sim_get_path (sim));
g_simple_async_result_set_op_res_gpointer (
simple,
sim,
(GDestroyNotify)g_object_unref);
}
g_simple_async_result_complete (simple);
g_object_unref (simple);
} }
static void static void
@@ -318,27 +288,11 @@ modem_create_sim (MMIfaceModem *self,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
GSimpleAsyncResult *result;
result = g_simple_async_result_new (G_OBJECT (self),
callback,
user_data,
modem_create_sim);
/* CDMA-only modems don't need this */
if (mm_iface_modem_is_cdma_only (self)) {
mm_dbg ("Skipping SIM creation in CDMA-only modem...");
g_simple_async_result_set_op_res_gpointer (result, NULL, NULL);
g_simple_async_result_complete_in_idle (result);
g_object_unref (result);
return;
}
/* New generic SIM */ /* New generic SIM */
mm_sim_new (MM_BASE_MODEM (self), mm_sim_new (MM_BASE_MODEM (self),
NULL, /* cancellable */ NULL, /* cancellable */
(GAsyncReadyCallback)modem_create_sim_ready, callback,
result); user_data);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@@ -3961,8 +3961,10 @@ interface_initialization_step (InitializationContext *ctx)
ctx->step++; ctx->step++;
case INITIALIZATION_STEP_SIM: case INITIALIZATION_STEP_SIM:
/* If the modem doesn't need any SIM, skip */ /* If the modem doesn't need any SIM (not implemented by plugin, or not
if (MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->create_sim && * needed in CDMA-only modems) */
if (!mm_iface_modem_is_cdma_only (ctx->self) &&
MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->create_sim &&
MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->create_sim_finish) { MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->create_sim_finish) {
MMSim *sim = NULL; MMSim *sim = NULL;