iface-modem: allow reset and factory reset operation in every state
This commit is contained in:

committed by
Aleksander Morgado

parent
387c97d81f
commit
60e1ac6919
@@ -1626,7 +1626,6 @@ handle_reset_auth_ready (MMBaseModem *self,
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
HandleResetContext *ctx)
|
HandleResetContext *ctx)
|
||||||
{
|
{
|
||||||
MMModemState modem_state;
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
if (!mm_base_modem_authorize_finish (self, res, &error)) {
|
if (!mm_base_modem_authorize_finish (self, res, &error)) {
|
||||||
@@ -1646,20 +1645,6 @@ handle_reset_auth_ready (MMBaseModem *self,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
modem_state = MM_MODEM_STATE_UNKNOWN;
|
|
||||||
g_object_get (self,
|
|
||||||
MM_IFACE_MODEM_STATE, &modem_state,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
if (modem_state < MM_MODEM_STATE_DISABLED) {
|
|
||||||
g_dbus_method_invocation_return_error (ctx->invocation,
|
|
||||||
MM_CORE_ERROR,
|
|
||||||
MM_CORE_ERROR_WRONG_STATE,
|
|
||||||
"Cannot reset modem: not initialized/unlocked yet");
|
|
||||||
handle_reset_context_free (ctx);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
MM_IFACE_MODEM_GET_INTERFACE (self)->reset (MM_IFACE_MODEM (self),
|
MM_IFACE_MODEM_GET_INTERFACE (self)->reset (MM_IFACE_MODEM (self),
|
||||||
(GAsyncReadyCallback)handle_reset_ready,
|
(GAsyncReadyCallback)handle_reset_ready,
|
||||||
ctx);
|
ctx);
|
||||||
@@ -1725,7 +1710,6 @@ handle_factory_reset_auth_ready (MMBaseModem *self,
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
HandleFactoryResetContext *ctx)
|
HandleFactoryResetContext *ctx)
|
||||||
{
|
{
|
||||||
MMModemState modem_state;
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
if (!mm_base_modem_authorize_finish (self, res, &error)) {
|
if (!mm_base_modem_authorize_finish (self, res, &error)) {
|
||||||
@@ -1746,21 +1730,6 @@ handle_factory_reset_auth_ready (MMBaseModem *self,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
modem_state = MM_MODEM_STATE_UNKNOWN;
|
|
||||||
g_object_get (self,
|
|
||||||
MM_IFACE_MODEM_STATE, &modem_state,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
if (modem_state < MM_MODEM_STATE_DISABLED) {
|
|
||||||
g_dbus_method_invocation_return_error (ctx->invocation,
|
|
||||||
MM_CORE_ERROR,
|
|
||||||
MM_CORE_ERROR_WRONG_STATE,
|
|
||||||
"Cannot reset the modem to factory defaults: "
|
|
||||||
"not initialized/unlocked yet");
|
|
||||||
handle_factory_reset_context_free (ctx);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
MM_IFACE_MODEM_GET_INTERFACE (self)->factory_reset (MM_IFACE_MODEM (self),
|
MM_IFACE_MODEM_GET_INTERFACE (self)->factory_reset (MM_IFACE_MODEM (self),
|
||||||
ctx->code,
|
ctx->code,
|
||||||
(GAsyncReadyCallback)handle_factory_reset_ready,
|
(GAsyncReadyCallback)handle_factory_reset_ready,
|
||||||
@@ -4441,6 +4410,17 @@ interface_initialization_step (InitializationContext *ctx)
|
|||||||
"handle-set-current-capabilities",
|
"handle-set-current-capabilities",
|
||||||
G_CALLBACK (handle_set_current_capabilities),
|
G_CALLBACK (handle_set_current_capabilities),
|
||||||
ctx->self);
|
ctx->self);
|
||||||
|
/* Allow the reset and factory reset operation in FAILED state to rescue the modem.
|
||||||
|
* Also, for a modem that doesn't support SIM hot swapping, a reset is needed to
|
||||||
|
* force the modem to detect the newly inserted SIM. */
|
||||||
|
g_signal_connect (ctx->skeleton,
|
||||||
|
"handle-reset",
|
||||||
|
G_CALLBACK (handle_reset),
|
||||||
|
ctx->self);
|
||||||
|
g_signal_connect (ctx->skeleton,
|
||||||
|
"handle-factory-reset",
|
||||||
|
G_CALLBACK (handle_factory_reset),
|
||||||
|
ctx->self);
|
||||||
|
|
||||||
if (ctx->fatal_error) {
|
if (ctx->fatal_error) {
|
||||||
g_simple_async_result_take_error (ctx->result, ctx->fatal_error);
|
g_simple_async_result_take_error (ctx->result, ctx->fatal_error);
|
||||||
@@ -4472,14 +4452,6 @@ interface_initialization_step (InitializationContext *ctx)
|
|||||||
"handle-set-power-state",
|
"handle-set-power-state",
|
||||||
G_CALLBACK (handle_set_power_state),
|
G_CALLBACK (handle_set_power_state),
|
||||||
ctx->self);
|
ctx->self);
|
||||||
g_signal_connect (ctx->skeleton,
|
|
||||||
"handle-reset",
|
|
||||||
G_CALLBACK (handle_reset),
|
|
||||||
ctx->self);
|
|
||||||
g_signal_connect (ctx->skeleton,
|
|
||||||
"handle-factory-reset",
|
|
||||||
G_CALLBACK (handle_factory_reset),
|
|
||||||
ctx->self);
|
|
||||||
g_signal_connect (ctx->skeleton,
|
g_signal_connect (ctx->skeleton,
|
||||||
"handle-set-current-bands",
|
"handle-set-current-bands",
|
||||||
G_CALLBACK (handle_set_current_bands),
|
G_CALLBACK (handle_set_current_bands),
|
||||||
|
Reference in New Issue
Block a user