diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-base-modem.c | 22 | ||||
-rw-r--r-- | src/mm-base-modem.h | 2 | ||||
-rw-r--r-- | src/mm-base-sim.c | 4 | ||||
-rw-r--r-- | src/mm-broadband-modem-mbim.c | 7 | ||||
-rw-r--r-- | src/mm-broadband-modem.c | 111 | ||||
-rw-r--r-- | src/mm-broadband-modem.h | 4 | ||||
-rw-r--r-- | src/mm-iface-modem.c | 36 | ||||
-rw-r--r-- | src/mm-iface-modem.h | 19 | ||||
-rw-r--r-- | src/mm-shared-qmi.c | 2 |
9 files changed, 98 insertions, 109 deletions
diff --git a/src/mm-base-modem.c b/src/mm-base-modem.c index 063cee6d..b8464414 100644 --- a/src/mm-base-modem.c +++ b/src/mm-base-modem.c @@ -1681,28 +1681,6 @@ mm_base_modem_get_product_id (MMBaseModem *self) /*****************************************************************************/ -static void -after_sim_switch_disable_ready (MMBaseModem *self, - GAsyncResult *res) -{ - g_autoptr(GError) error = NULL; - - mm_base_modem_disable_finish (self, res, &error); - if (error) - mm_obj_err (self, "failed to disable after SIM switch event: %s", error->message); - else - mm_base_modem_set_valid (self, FALSE); -} - -void -mm_base_modem_process_sim_event (MMBaseModem *self) -{ - mm_base_modem_set_reprobe (self, TRUE); - mm_base_modem_disable (self, (GAsyncReadyCallback) after_sim_switch_disable_ready, NULL); -} - -/*****************************************************************************/ - static gboolean base_modem_invalid_idle (MMBaseModem *self) { diff --git a/src/mm-base-modem.h b/src/mm-base-modem.h index 61e9e59a..e4254a0b 100644 --- a/src/mm-base-modem.h +++ b/src/mm-base-modem.h @@ -254,6 +254,4 @@ gboolean mm_base_modem_sync_finish (MMBaseModem *self, #endif -void mm_base_modem_process_sim_event (MMBaseModem *self); - #endif /* MM_BASE_MODEM_H */ diff --git a/src/mm-base-sim.c b/src/mm-base-sim.c index 22b54ba1..7d3f3cf4 100644 --- a/src/mm-base-sim.c +++ b/src/mm-base-sim.c @@ -98,7 +98,7 @@ reprobe_if_puk_discovered (MMBaseSim *self, MM_MOBILE_EQUIPMENT_ERROR, MM_MOBILE_EQUIPMENT_ERROR_SIM_PUK)) { mm_obj_dbg (self, "Discovered PUK lock, discarding old modem..."); - mm_base_modem_process_sim_event (self->priv->modem); + mm_iface_modem_process_sim_event (MM_IFACE_MODEM (self->priv->modem)); } } @@ -905,7 +905,7 @@ handle_send_puk_ready (MMBaseSim *self, if (sim_error) { mm_obj_info (self, "Received critical sim error. SIM might be permanently blocked. Reprobing..."); - mm_base_modem_process_sim_event (self->priv->modem); + mm_iface_modem_process_sim_event (MM_IFACE_MODEM (self->priv->modem)); } handle_send_puk_context_free (ctx); diff --git a/src/mm-broadband-modem-mbim.c b/src/mm-broadband-modem-mbim.c index 11f26efb..29b845b0 100644 --- a/src/mm-broadband-modem-mbim.c +++ b/src/mm-broadband-modem-mbim.c @@ -4712,7 +4712,7 @@ basic_connect_notification_subscriber_ready_status (MMBroadbandModemMbim *self, ready_state != MBIM_SUBSCRIBER_READY_STATE_NO_ESIM_PROFILE)) { /* eSIM profiles have been added or removed, re-probe to ensure correct interfaces are exposed */ mm_obj_dbg (self, "eSIM profile updates detected"); - mm_broadband_modem_sim_hot_swap_detected (MM_BROADBAND_MODEM (self)); + mm_iface_modem_process_sim_event (MM_IFACE_MODEM (self)); } if ((self->priv->last_ready_state != MBIM_SUBSCRIBER_READY_STATE_SIM_NOT_INSERTED && @@ -4721,7 +4721,7 @@ basic_connect_notification_subscriber_ready_status (MMBroadbandModemMbim *self, ready_state != MBIM_SUBSCRIBER_READY_STATE_SIM_NOT_INSERTED)) { /* SIM has been removed or reinserted, re-probe to ensure correct interfaces are exposed */ mm_obj_dbg (self, "SIM hot swap detected"); - mm_broadband_modem_sim_hot_swap_detected (MM_BROADBAND_MODEM (self)); + mm_iface_modem_process_sim_event (MM_IFACE_MODEM (self)); } self->priv->last_ready_state = ready_state; @@ -5227,11 +5227,10 @@ ms_basic_connect_extensions_notification_slot_info_status (MMBroadbandModemMbim return; } - if (self->priv->active_slot_index == slot_index + 1) { /* Major SIM event on the active slot, will request reprobing the * modem from scratch. */ - mm_base_modem_process_sim_event (MM_BASE_MODEM (self)); + mm_iface_modem_process_sim_event (MM_IFACE_MODEM (self)); } else { /* Modifies SIM object at the given slot based on the reported state, * when the slot is not the active one. */ diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c index f38e6b86..02fd0e2d 100644 --- a/src/mm-broadband-modem.c +++ b/src/mm-broadband-modem.c @@ -475,6 +475,37 @@ modem_create_sim (MMIfaceModem *self, } /*****************************************************************************/ +/* Helper to manage AT-based SIM hot swap ports context */ + +gboolean +mm_broadband_modem_sim_hot_swap_ports_context_init (MMBroadbandModem *self, + GError **error) +{ + PortsContext *ports; + + mm_obj_dbg (self, "creating serial ports context for SIM hot swap..."); + ports = ports_context_new (); + if (!ports_context_open (self, ports, FALSE, FALSE, FALSE, error)) { + ports_context_unref (ports); + return FALSE; + } + + g_assert (!self->priv->sim_hot_swap_ports_ctx); + self->priv->sim_hot_swap_ports_ctx = ports; + return TRUE; +} + +void +mm_broadband_modem_sim_hot_swap_ports_context_reset (MMBroadbandModem *self) +{ + if (self->priv->sim_hot_swap_ports_ctx) { + mm_obj_dbg (self, "releasing serial ports context for SIM hot swap"); + ports_context_unref (self->priv->sim_hot_swap_ports_ctx); + self->priv->sim_hot_swap_ports_ctx = NULL; + } +} + +/*****************************************************************************/ /* Capabilities loading (Modem interface) */ typedef struct { @@ -4156,7 +4187,7 @@ load_sim_identifier_ready (MMBaseSim *sim, if (g_strcmp0 (current_simid, cached_simid) != 0) { mm_obj_info (self, "sim identifier has changed: %s -> %s - possible SIM swap", cached_simid, current_simid); - mm_broadband_modem_sim_hot_swap_detected (self); + mm_iface_modem_process_sim_event (MM_IFACE_MODEM (self)); } g_task_return_boolean (task, TRUE); @@ -4208,7 +4239,7 @@ modem_check_for_sim_swap (MMIfaceModem *self, if (modem_state == MM_MODEM_STATE_FAILED) { mm_obj_info (self, "new SIM detected, handle as SIM hot-swap"); - mm_broadband_modem_sim_hot_swap_detected (MM_BROADBAND_MODEM (self)); + mm_iface_modem_process_sim_event (MM_IFACE_MODEM (self)); g_task_return_boolean (task, TRUE); } else { g_task_return_new_error (task, @@ -4230,7 +4261,7 @@ modem_check_for_sim_swap (MMIfaceModem *self, mm_obj_info (self, "detected ICCID change (%s -> %s), handle as SIM hot-swap", cached_simid ? cached_simid : "<none>", iccid); - mm_broadband_modem_sim_hot_swap_detected (MM_BROADBAND_MODEM (self)); + mm_iface_modem_process_sim_event (MM_IFACE_MODEM (self)); } else mm_obj_dbg (self, "ICCID not changed"); @@ -12268,7 +12299,6 @@ typedef enum { INITIALIZE_STEP_FALLBACK_LIMITED, INITIALIZE_STEP_IFACE_VOICE, INITIALIZE_STEP_IFACE_FIRMWARE, - INITIALIZE_STEP_SIM_HOT_SWAP, INITIALIZE_STEP_IFACE_SIMPLE, INITIALIZE_STEP_LAST, } InitializeStep; @@ -12625,37 +12655,6 @@ initialize_step (GTask *task) task); return; - case INITIALIZE_STEP_SIM_HOT_SWAP: - /* Create the SIM hot swap ports context only if not already done before - * (we may be re-running the initialization step after SIM-PIN unlock) */ - if (!ctx->self->priv->sim_hot_swap_ports_ctx) { - gboolean is_sim_hot_swap_supported = FALSE; - - g_object_get (ctx->self, - MM_IFACE_MODEM_SIM_HOT_SWAP_SUPPORTED, &is_sim_hot_swap_supported, - NULL); - - if (is_sim_hot_swap_supported) { - PortsContext *ports; - g_autoptr(GError) error = NULL; - - mm_obj_dbg (ctx->self, "creating ports context for SIM hot swap"); - ports = ports_context_new (); - if (!ports_context_open (ctx->self, ports, FALSE, FALSE, FALSE, &error)) { - mm_obj_warn (ctx->self, "couldn't open ports during modem SIM hot swap enabling: %s", - error ? error->message : "unknown reason"); - } else { - ctx->self->priv->sim_hot_swap_ports_ctx = ports_context_ref (ports); - } - - ports_context_unref (ports); - } - } else - mm_obj_dbg (ctx->self, "ports context for SIM hot swap already available"); - - ctx->step++; - /* fall through */ - case INITIALIZE_STEP_IFACE_SIMPLE: if (ctx->self->priv->modem_state != MM_MODEM_STATE_FAILED) mm_iface_modem_simple_initialize (MM_IFACE_MODEM_SIMPLE (ctx->self)); @@ -12664,16 +12663,9 @@ initialize_step (GTask *task) case INITIALIZE_STEP_LAST: if (ctx->self->priv->modem_state == MM_MODEM_STATE_FAILED) { - GError *error; + GError *error = NULL; - if (!ctx->self->priv->modem_dbus_skeleton) { - /* Error setting up ports. Abort without even exporting the - * Modem interface */ - error = g_error_new (MM_CORE_ERROR, - MM_CORE_ERROR_ABORTED, - "Modem is unusable, " - "cannot fully initialize"); - } else { + if (ctx->self->priv->modem_dbus_skeleton) { /* Fatal SIM, firmware, or modem failure :-( */ gboolean is_sim_hot_swap_supported = FALSE; MMModemStateFailedReason reason; @@ -12687,25 +12679,17 @@ initialize_step (GTask *task) if (reason == MM_MODEM_STATE_FAILED_REASON_SIM_MISSING) { if (!is_sim_hot_swap_supported) { mm_obj_dbg (ctx->self, "SIM is missing, but this modem does not support SIM hot swap."); - } else if (!ctx->self->priv->sim_hot_swap_ports_ctx) { - mm_obj_err (ctx->self, "SIM is missing and SIM hot swap is configured, but ports are not opened."); } else { mm_obj_dbg (ctx->self, "SIM is missing, but SIM hot swap is enabled; waiting for SIM..."); error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_WRONG_STATE, "Modem is unusable due to SIM missing, " "cannot fully initialize, waiting for SIM insertion."); - goto sim_hot_swap_enabled; } } - error = g_error_new (MM_CORE_ERROR, - MM_CORE_ERROR_WRONG_STATE, - "Modem is unusable, " - "cannot fully initialize"); -sim_hot_swap_enabled: - /* Ensure we only leave the Modem and Firmware interfaces - * around. A failure could be caused by firmware issues, which + /* Ensure we only leave the Modem, Voice and Firmware interfaces + * around. A failure could be caused by firmware issues, which * a firmware update, switch, or provisioning could fix. We also * leave the Voice interface around so that we can attempt * emergency voice calls. @@ -12721,6 +12705,11 @@ sim_hot_swap_enabled: mm_iface_modem_simple_shutdown (MM_IFACE_MODEM_SIMPLE (ctx->self)); } + if (!error) + error = g_error_new (MM_CORE_ERROR, + MM_CORE_ERROR_ABORTED, + "Modem is unusable, cannot fully initialize"); + g_task_return_error (task, error); g_object_unref (task); return; @@ -12873,20 +12862,6 @@ mm_broadband_modem_create_device_identifier (MMBroadbandModem *self, /*****************************************************************************/ -void -mm_broadband_modem_sim_hot_swap_detected (MMBroadbandModem *self) -{ - if (self->priv->sim_hot_swap_ports_ctx) { - mm_obj_dbg (self, "releasing SIM hot swap ports context"); - ports_context_unref (self->priv->sim_hot_swap_ports_ctx); - self->priv->sim_hot_swap_ports_ctx = NULL; - } - - mm_base_modem_process_sim_event (MM_BASE_MODEM (self)); -} - -/*****************************************************************************/ - MMBroadbandModem * mm_broadband_modem_new (const gchar *device, const gchar **drivers, diff --git a/src/mm-broadband-modem.h b/src/mm-broadband-modem.h index 2ba05799..bb4e1f66 100644 --- a/src/mm-broadband-modem.h +++ b/src/mm-broadband-modem.h @@ -122,6 +122,8 @@ void mm_broadband_modem_unlock_sms_storages (MMBroadbandModem *self, gboolean mem1, gboolean mem2); /* Helper to update SIM hot swap */ -void mm_broadband_modem_sim_hot_swap_detected (MMBroadbandModem *self); +gboolean mm_broadband_modem_sim_hot_swap_ports_context_init (MMBroadbandModem *self, + GError **error); +void mm_broadband_modem_sim_hot_swap_ports_context_reset (MMBroadbandModem *self); #endif /* MM_BROADBAND_MODEM_H */ diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c index 517288e6..d019fd4b 100644 --- a/src/mm-iface-modem.c +++ b/src/mm-iface-modem.c @@ -209,6 +209,8 @@ mm_iface_modem_check_for_sim_swap (MMIfaceModem *self, g_object_unref (task); } +/*****************************************************************************/ + static void sim_slot_free (MMBaseSim *sim) { @@ -277,6 +279,34 @@ mm_iface_modem_modify_sim (MMIfaceModem *self, /*****************************************************************************/ +static void +after_sim_event_disable_ready (MMBaseModem *self, + GAsyncResult *res) +{ + g_autoptr(GError) error = NULL; + + mm_base_modem_disable_finish (self, res, &error); + if (error) + mm_obj_err (self, "failed to disable after SIM switch event: %s", error->message); + + /* set invalid either way, so that it's reprobed */ + mm_base_modem_set_valid (self, FALSE); +} + +void +mm_iface_modem_process_sim_event (MMIfaceModem *self) +{ + if (MM_IFACE_MODEM_GET_INTERFACE (self)->cleanup_sim_hot_swap) + MM_IFACE_MODEM_GET_INTERFACE (self)->cleanup_sim_hot_swap (self); + + mm_base_modem_set_reprobe (MM_BASE_MODEM (self), TRUE); + mm_base_modem_disable (MM_BASE_MODEM (self), + (GAsyncReadyCallback) after_sim_event_disable_ready, + NULL); +} + +/*****************************************************************************/ + void mm_iface_modem_bind_simple_status (MMIfaceModem *self, MMSimpleStatus *status) @@ -1234,7 +1264,7 @@ set_primary_sim_slot_ready (MMIfaceModem *self, /* Notify about the SIM swap, which will disable and reprobe the device. * There is no need to update the PrimarySimSlot property, as this value will be * reloaded automatically during the reprobe. */ - mm_base_modem_process_sim_event (MM_BASE_MODEM (self)); + mm_iface_modem_process_sim_event (self); } mm_gdbus_modem_complete_set_primary_sim_slot (ctx->skeleton, ctx->invocation); @@ -6109,6 +6139,10 @@ mm_iface_modem_shutdown (MMIfaceModem *self) /* Remove running restart initialization idle, if any */ restart_initialize_idle_disable (self); + /* Cleanup SIM hot swap, if any */ + if (MM_IFACE_MODEM_GET_INTERFACE (self)->cleanup_sim_hot_swap) + MM_IFACE_MODEM_GET_INTERFACE (self)->cleanup_sim_hot_swap (self); + /* Remove SIM object */ g_object_set (self, MM_IFACE_MODEM_SIM, NULL, diff --git a/src/mm-iface-modem.h b/src/mm-iface-modem.h index bb79084c..43034dda 100644 --- a/src/mm-iface-modem.h +++ b/src/mm-iface-modem.h @@ -376,14 +376,14 @@ struct _MMIfaceModem { /* Create new bearer list object */ MMBearerList * (* create_bearer_list) (MMIfaceModem *self); - /* Setup SIM hot swap */ - void (*setup_sim_hot_swap) (MMIfaceModem *self, - GAsyncReadyCallback callback, - gpointer user_data); - - gboolean (*setup_sim_hot_swap_finish) (MMIfaceModem *self, - GAsyncResult *res, - GError **error); + /* Setup/cleanup SIM hot swap */ + void (* setup_sim_hot_swap) (MMIfaceModem *self, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* setup_sim_hot_swap_finish) (MMIfaceModem *self, + GAsyncResult *res, + GError **error); + void (* cleanup_sim_hot_swap) (MMIfaceModem *self); /* Load carrier config */ void (* load_carrier_config) (MMIfaceModem *self, @@ -609,4 +609,7 @@ void mm_iface_modem_modify_sim (MMIfaceModem *self, guint slot_index, MMBaseSim *new_sim); +void mm_iface_modem_process_sim_event (MMIfaceModem *self); + + #endif /* MM_IFACE_MODEM_H */ diff --git a/src/mm-shared-qmi.c b/src/mm-shared-qmi.c index 162c6227..0141d939 100644 --- a/src/mm-shared-qmi.c +++ b/src/mm-shared-qmi.c @@ -3817,7 +3817,7 @@ uim_slot_status_indication_cb (QmiClientUim *client, * active slot's status changed */ if (!slot_array_status_equal (priv->slots_status, new_slots_status, TRUE)) { mm_obj_dbg (self, "An active slot had a status change, will reprobe the modem"); - mm_base_modem_process_sim_event (MM_BASE_MODEM (self)); + mm_iface_modem_process_sim_event (MM_IFACE_MODEM (self)); return; } |