[RFC PATCH] iface-modem: allow reset and factory reset operation in every state

Dan Williams dcbw at redhat.com
Tue Aug 27 14:32:44 PDT 2013


On Tue, 2013-08-27 at 12:21 -0700, Ben Chan wrote:
> ---
> Hi Dan and Aleksander,
> 
> Is there a reason that we'd like to disallow modem reset/factory reset when the modem is in FAILED state (e.g. SIM missing). It seems like modems should always allow resetting themselves regardless whether the SIM is missing or locked.

I think the only reason is that many modems implement simple command
interpreters (Sierra is the best example here, though ZTE is similar)
where about the only commands allowed are ATI and +CPIN.  Also there's
an argument to be made that if your phone or data card is locked, then
somebody shouldn't just be able to plug it in and wipe it.  That
argument is somewhat tenuous though, since somebody with physical access
to your card can simply remove it and use their own SIM (unless of
course the device is provider-locked).

(it also may be a left-over from before we had a FAILED state?)

So I'm fine with this, since:

1) it's already PolicyKit authenticated if PK is enabled at build time
2) the modem will give you an error if it doesn't allow the command
anyway, which will be returned to the client

Aleksander, thoughts?

Dan

> Thanks,
> Ben
> 
> 
>  src/mm-iface-modem.c | 50 +++++++++++---------------------------------------
>  1 file changed, 11 insertions(+), 39 deletions(-)
> 
> diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c
> index 3a12a6a..c599050 100644
> --- a/src/mm-iface-modem.c
> +++ b/src/mm-iface-modem.c
> @@ -1626,7 +1626,6 @@ handle_reset_auth_ready (MMBaseModem *self,
>                           GAsyncResult *res,
>                           HandleResetContext *ctx)
>  {
> -    MMModemState modem_state;
>      GError *error = NULL;
>  
>      if (!mm_base_modem_authorize_finish (self, res, &error)) {
> @@ -1646,20 +1645,6 @@ handle_reset_auth_ready (MMBaseModem *self,
>          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),
>                                                  (GAsyncReadyCallback)handle_reset_ready,
>                                                  ctx);
> @@ -1725,7 +1710,6 @@ handle_factory_reset_auth_ready (MMBaseModem *self,
>                                   GAsyncResult *res,
>                                   HandleFactoryResetContext *ctx)
>  {
> -    MMModemState modem_state;
>      GError *error = NULL;
>  
>      if (!mm_base_modem_authorize_finish (self, res, &error)) {
> @@ -1746,21 +1730,6 @@ handle_factory_reset_auth_ready (MMBaseModem *self,
>          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),
>                                                          ctx->code,
>                                                          (GAsyncReadyCallback)handle_factory_reset_ready,
> @@ -4441,6 +4410,17 @@ interface_initialization_step (InitializationContext *ctx)
>                            "handle-set-current-capabilities",
>                            G_CALLBACK (handle_set_current_capabilities),
>                            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) {
>              g_simple_async_result_take_error (ctx->result, ctx->fatal_error);
> @@ -4473,14 +4453,6 @@ interface_initialization_step (InitializationContext *ctx)
>                                G_CALLBACK (handle_set_power_state),
>                                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,
>                                "handle-set-current-bands",
>                                G_CALLBACK (handle_set_current_bands),
>                                ctx->self);




More information about the ModemManager-devel mailing list