aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2022-05-20 14:41:48 +0200
committerAleksander Morgado <aleksander@aleksander.es>2022-05-20 15:36:43 +0200
commit4140758fdf5417d742d971a138d40833cdc18847 (patch)
tree326a77a959fe847274c5ebfca7eb31f207b97d15 /src
parent0c67d93eddd897eab7b8b4eee3fa244d83cde9ee (diff)
base-modem: if ABORTED during initialization, modem not exported
Commit b497de325 introduced a change by which some common errors (e.g. SIM missing) would be reported as MM_CORE_ERROR_ABORTED. This had the undesired effect of making the MMBaseModem object not flag as valid the modem, because the returned error wasn't MM_CORE_ERROR_WRONG_STATE. We now change this logic so that only ABORTED makes the modem object not flagged as valid, and we'll do that only if the Modem interface isn't exposed in DBus. Fixes b497de325
Diffstat (limited to 'src')
-rw-r--r--src/mm-base-modem.c30
-rw-r--r--src/mm-broadband-modem.c32
2 files changed, 20 insertions, 42 deletions
diff --git a/src/mm-base-modem.c b/src/mm-base-modem.c
index b8464414..13fe14dd 100644
--- a/src/mm-base-modem.c
+++ b/src/mm-base-modem.c
@@ -1233,29 +1233,21 @@ static void
initialize_ready (MMBaseModem *self,
GAsyncResult *res)
{
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
- if (mm_base_modem_initialize_finish (self, res, &error)) {
+ if (!mm_base_modem_initialize_finish (self, res, &error)) {
+ if (g_error_matches (error, MM_CORE_ERROR, MM_CORE_ERROR_ABORTED)) {
+ /* FATAL error, won't even be exported in DBus */
+ mm_obj_err (self, "fatal error initializing: %s", error->message);
+ } else {
+ /* non-fatal error */
+ mm_obj_warn (self, "error initializing: %s", error->message);
+ mm_base_modem_set_valid (self, TRUE);
+ }
+ } else {
mm_obj_dbg (self, "modem initialized");
mm_base_modem_set_valid (self, TRUE);
- return;
}
-
- /* Wrong state is returned when modem is found locked */
- if (g_error_matches (error, MM_CORE_ERROR, MM_CORE_ERROR_WRONG_STATE)) {
- /* Even with initialization errors, we do set the state to valid, so
- * that the modem gets exported and the failure notified to the user.
- */
- mm_obj_dbg (self, "couldn't finish initialization in the current state: '%s'", error->message);
- g_error_free (error);
- mm_base_modem_set_valid (self, TRUE);
- return;
- }
-
- /* Really fatal, we cannot even export the failed modem (e.g. error before
- * even trying to enable the Modem interface */
- mm_obj_warn (self, "couldn't initialize: '%s'", error->message);
- g_error_free (error);
}
static inline void
diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c
index 02fd0e2d..0cef006e 100644
--- a/src/mm-broadband-modem.c
+++ b/src/mm-broadband-modem.c
@@ -12665,28 +12665,19 @@ initialize_step (GTask *task)
if (ctx->self->priv->modem_state == MM_MODEM_STATE_FAILED) {
GError *error = NULL;
- if (ctx->self->priv->modem_dbus_skeleton) {
+ if (!ctx->self->priv->modem_dbus_skeleton) {
+ /* ABORTED here specifies an extremely fatal error that will make the modem
+ * not even exported in DBus */
+ error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_ABORTED,
+ "Fatal error: modem is unusable");
+ } else {
/* Fatal SIM, firmware, or modem failure :-( */
- gboolean is_sim_hot_swap_supported = FALSE;
MMModemStateFailedReason reason;
reason = mm_gdbus_modem_get_state_failed_reason (MM_GDBUS_MODEM (ctx->self->priv->modem_dbus_skeleton));
-
- g_object_get (ctx->self,
- MM_IFACE_MODEM_SIM_HOT_SWAP_SUPPORTED, &is_sim_hot_swap_supported,
- NULL);
-
- 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 {
- 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.");
- }
- }
+ error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_WRONG_STATE,
+ "Modem in failed state: %s",
+ mm_modem_state_failed_reason_get_string (reason));
/* Ensure we only leave the Modem, Voice and Firmware interfaces
* around. A failure could be caused by firmware issues, which
@@ -12705,11 +12696,6 @@ initialize_step (GTask *task)
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;