diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-broadband-modem.c | 24 | ||||
-rw-r--r-- | src/mm-iface-modem.c | 31 | ||||
-rw-r--r-- | src/mm-iface-modem.h | 2 |
3 files changed, 47 insertions, 10 deletions
diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c index c0c74410..99011b6c 100644 --- a/src/mm-broadband-modem.c +++ b/src/mm-broadband-modem.c @@ -8423,13 +8423,26 @@ iface_modem_initialize_ready (MMBroadbandModem *self, /* If the modem interface fails to get initialized, we will move the modem * to a FAILED state. Note that in this case we still export the interface. */ if (!mm_iface_modem_initialize_finish (MM_IFACE_MODEM (self), result, &error)) { + MMModemStateFailedReason failed_reason = MM_MODEM_STATE_FAILED_REASON_UNKNOWN; + /* Report the new FAILED state */ mm_warn ("Modem couldn't be initialized: %s", error->message); + + if (g_error_matches (error, + MM_MOBILE_EQUIPMENT_ERROR, + MM_MOBILE_EQUIPMENT_ERROR_SIM_NOT_INSERTED)) + failed_reason = MM_MODEM_STATE_FAILED_REASON_SIM_MISSING; + else if (g_error_matches (error, + MM_MOBILE_EQUIPMENT_ERROR, + MM_MOBILE_EQUIPMENT_ERROR_SIM_FAILURE) || + g_error_matches (error, + MM_MOBILE_EQUIPMENT_ERROR, + MM_MOBILE_EQUIPMENT_ERROR_SIM_WRONG)) + failed_reason = MM_MODEM_STATE_FAILED_REASON_SIM_MISSING; + g_error_free (error); - mm_iface_modem_update_state (MM_IFACE_MODEM (self), - MM_MODEM_STATE_FAILED, - MM_MODEM_STATE_CHANGE_REASON_UNKNOWN); + mm_iface_modem_update_failed_state (MM_IFACE_MODEM (self), failed_reason); /* Jump to the firmware step. We allow firmware switching even in failed * state */ @@ -8474,9 +8487,8 @@ iface_modem_initialize_ready (MMBroadbandModem *self, g_error_free (error); \ \ /* Report the new FAILED state */ \ - mm_iface_modem_update_state (MM_IFACE_MODEM (self), \ - MM_MODEM_STATE_FAILED, \ - MM_MODEM_STATE_CHANGE_REASON_UNKNOWN); \ + mm_iface_modem_update_failed_state (MM_IFACE_MODEM (self), \ + MM_MODEM_STATE_FAILED_REASON_UNKNOWN); \ \ /* Just jump to the last step */ \ ctx->step = INITIALIZE_STEP_LAST; \ diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c index f02b0bdc..0775add1 100644 --- a/src/mm-iface-modem.c +++ b/src/mm-iface-modem.c @@ -1145,10 +1145,11 @@ bearer_list_count_connected (MMBearer *bearer, (*count)++; } -void -mm_iface_modem_update_state (MMIfaceModem *self, - MMModemState new_state, - MMModemStateChangeReason reason) +static void +__iface_modem_update_state_internal (MMIfaceModem *self, + MMModemState new_state, + MMModemStateChangeReason reason, + MMModemStateFailedReason failed_reason) { MMModemState old_state = MM_MODEM_STATE_UNKNOWN; MmGdbusModem *skeleton = NULL; @@ -1207,6 +1208,10 @@ mm_iface_modem_update_state (MMIfaceModem *self, /* Signal status change */ if (skeleton) { + /* Set failure reason */ + if (failed_reason != mm_gdbus_modem_get_state_failed_reason (skeleton)) + mm_gdbus_modem_set_state_failed_reason (skeleton, failed_reason); + /* Flush current change before signaling the state change, * so that clients get the proper state already in the * state-changed callback */ @@ -1239,6 +1244,23 @@ mm_iface_modem_update_state (MMIfaceModem *self, g_object_unref (bearer_list); } +void +mm_iface_modem_update_state (MMIfaceModem *self, + MMModemState new_state, + MMModemStateChangeReason reason) +{ + g_assert (new_state != MM_MODEM_STATE_FAILED); + + __iface_modem_update_state_internal (self, new_state, reason, MM_MODEM_STATE_FAILED_REASON_NONE); +} + +void +mm_iface_modem_update_failed_state (MMIfaceModem *self, + MMModemStateFailedReason failed_reason) +{ + __iface_modem_update_state_internal (self, MM_MODEM_STATE_FAILED, MM_MODEM_STATE_CHANGE_REASON_FAILURE, failed_reason); +} + /*****************************************************************************/ typedef struct { @@ -4092,6 +4114,7 @@ mm_iface_modem_initialize (MMIfaceModem *self, mm_gdbus_modem_set_supported_bands (skeleton, mm_common_build_bands_unknown ()); mm_gdbus_modem_set_bands (skeleton, mm_common_build_bands_unknown ()); mm_gdbus_modem_set_power_state (skeleton, MM_MODEM_POWER_STATE_UNKNOWN); + mm_gdbus_modem_set_state_failed_reason (skeleton, MM_MODEM_STATE_FAILED_REASON_NONE); /* Bind our State property */ g_object_bind_property (self, MM_IFACE_MODEM_STATE, diff --git a/src/mm-iface-modem.h b/src/mm-iface-modem.h index 451c3f7e..ba9282fe 100644 --- a/src/mm-iface-modem.h +++ b/src/mm-iface-modem.h @@ -397,6 +397,8 @@ void mm_iface_modem_update_subsystem_state (MMIfaceModem *self, void mm_iface_modem_update_state (MMIfaceModem *self, MMModemState new_state, MMModemStateChangeReason reason); +void mm_iface_modem_update_failed_state (MMIfaceModem *self, + MMModemStateFailedReason failed_reason); /* Allow reporting new access tech */ void mm_iface_modem_update_access_technologies (MMIfaceModem *self, |