diff options
author | Carlo Lobrano <c.lobrano@gmail.com> | 2016-08-08 15:47:18 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2016-08-10 09:39:27 +0200 |
commit | 60f4f9e57df90cf094fffb6896ffce8dba15d244 (patch) | |
tree | a611d459cc957f1c5bf3e16268d2d3b8ba082f9f /src/mm-iface-modem.c | |
parent | 3047522b2e494776d9aced64180e54c46e861de1 (diff) |
modem: support SIM hot swap
BaseModem
added reprobe property.
MMDevice
added logic to recreate the modem if it is set invalid and "to reprobe"
MMBroadbandModem
* added initialization step for SIM hot swap:
1. keep dedicated ports open to listen to modem's unsolicited
2. dedicated error management in case of initialization failure due to SIM missing
* added function to be called in order to act upon SIM insertion/removal:
1. close dedicated ports
2. set the modem to be reprobed
3. disable modem
* added SIM HOT SWAP boolean property
MMIfaceModem
* added initialization step for SIM hot swap, if supported by the plugin
* dedicated error management in case of initialization failure due to SIM missing
Diffstat (limited to 'src/mm-iface-modem.c')
-rw-r--r-- | src/mm-iface-modem.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c index 30fe20da..c942e7b1 100644 --- a/src/mm-iface-modem.c +++ b/src/mm-iface-modem.c @@ -3747,6 +3747,7 @@ typedef enum { INITIALIZATION_STEP_SUPPORTED_BANDS, INITIALIZATION_STEP_SUPPORTED_IP_FAMILIES, INITIALIZATION_STEP_POWER_STATE, + INITIALIZATION_STEP_SIM_HOT_SWAP, INITIALIZATION_STEP_UNLOCK_REQUIRED, INITIALIZATION_STEP_SIM, INITIALIZATION_STEP_OWN_NUMBERS, @@ -4203,6 +4204,27 @@ load_current_bands_ready (MMIfaceModem *self, interface_initialization_step (ctx); } +/*****************************************************************************/ +/* Setup SIM hot swap (Modem interface) */ +static void +setup_sim_hot_swap_ready (MMIfaceModem *self, + GAsyncResult *res, + InitializationContext *ctx) { + GError *error = NULL; + + MM_IFACE_MODEM_GET_INTERFACE (self)->setup_sim_hot_swap_finish (self, res, &error); + if (error) { + mm_warn ("Iface modem: SIM hot swap setup failed: '%s'", error->message); + g_error_free (error); + } else { + mm_dbg ("Iface modem: SIM hot swap setup succeded"); + } + + /* Go on to next step */ + ctx->step++; + interface_initialization_step (ctx); +} + static void interface_initialization_step (InitializationContext *ctx) { @@ -4544,6 +4566,18 @@ interface_initialization_step (InitializationContext *ctx) /* Fall down to next step */ ctx->step++; + case INITIALIZATION_STEP_SIM_HOT_SWAP: + if (MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->setup_sim_hot_swap && + MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->setup_sim_hot_swap_finish) { + MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->setup_sim_hot_swap ( + MM_IFACE_MODEM (ctx->self), + (GAsyncReadyCallback) setup_sim_hot_swap_ready, + ctx); + return; + } + /* Fall down to next step */ + ctx->step++; + case INITIALIZATION_STEP_UNLOCK_REQUIRED: /* Only check unlock required if we were previously not unlocked */ if (mm_gdbus_modem_get_unlock_required (ctx->skeleton) != MM_MODEM_LOCK_NONE) { @@ -4707,6 +4741,21 @@ interface_initialization_step (InitializationContext *ctx) ctx->self); if (ctx->fatal_error) { + if (g_error_matches (ctx->fatal_error, + MM_MOBILE_EQUIPMENT_ERROR, + MM_MOBILE_EQUIPMENT_ERROR_SIM_NOT_INSERTED)) { + 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) { + mm_iface_modem_update_failed_state (ctx->self, + MM_MODEM_STATE_FAILED_REASON_SIM_MISSING); + } + } g_simple_async_result_take_error (ctx->result, ctx->fatal_error); ctx->fatal_error = NULL; } else { @@ -5119,6 +5168,13 @@ iface_modem_init (gpointer g_iface) "List of bearers handled by the modem", MM_TYPE_BEARER_LIST, G_PARAM_READWRITE)); + g_object_interface_install_property + (g_iface, + g_param_spec_boolean (MM_IFACE_MODEM_SIM_HOT_SWAP_SUPPORTED, + "Sim Hot Swap Supported", + "Whether the modem supports sim hot swap or not.", + FALSE, + G_PARAM_READWRITE)); initialized = TRUE; } |