diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2018-08-04 17:27:53 +0200 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2018-08-08 18:42:47 +0000 |
commit | 59a5af9771b942ea6878e2f428635daae624f229 (patch) | |
tree | 4fbc8eaef0d9e114da66c8010bd7670536d86d90 | |
parent | 518d62e731534cb4834a10e86f32ee31300de98b (diff) | |
download | ModemManager-59a5af9771b942ea6878e2f428635daae624f229.tar.gz |
iface-modem: reload current bands after setting
Setting bands is a very device-specific operation. Sometimes the
device requires specific band combinations, or sometimes the 'any'
specific logic doesn't apply to all supported bands (e.g. may apply
only to the currently selected modes, as in XMM based devices).
So, don't assume that if the set command succeeds we have set all
expected bands. Instead, do an explicit loading of the current bands
after the set operation, same thing as we do when setting modes.
-rw-r--r-- | src/mm-iface-modem.c | 90 |
1 files changed, 66 insertions, 24 deletions
diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c index 11bdf1f60..03a680ddd 100644 --- a/src/mm-iface-modem.c +++ b/src/mm-iface-modem.c @@ -2221,40 +2221,82 @@ mm_iface_modem_set_current_bands_finish (MMIfaceModem *self, } static void +set_current_bands_complete_with_defaults (GTask *task) +{ + SetCurrentBandsContext *ctx; + + ctx = g_task_get_task_data (task); + + /* Never show just 'any' in the interface */ + if (ctx->bands_array->len == 1 && g_array_index (ctx->bands_array, MMModemBand, 0) == MM_MODEM_BAND_ANY) { + GArray *supported_bands; + + supported_bands = (mm_common_bands_variant_to_garray (mm_gdbus_modem_get_supported_bands (ctx->skeleton))); + mm_common_bands_garray_sort (supported_bands); + mm_gdbus_modem_set_current_bands (ctx->skeleton, mm_common_bands_garray_to_variant (supported_bands)); + g_array_unref (supported_bands); + } else { + mm_common_bands_garray_sort (ctx->bands_array); + mm_gdbus_modem_set_current_bands (ctx->skeleton, mm_common_bands_garray_to_variant (ctx->bands_array)); + } + + g_task_return_boolean (task, TRUE); + g_object_unref (task); +} + +static void +after_set_load_current_bands_ready (MMIfaceModem *self, + GAsyncResult *res, + GTask *task) +{ + GError *error = NULL; + GArray *current_bands; + SetCurrentBandsContext *ctx; + + ctx = g_task_get_task_data (task); + + current_bands = MM_IFACE_MODEM_GET_INTERFACE (self)->load_current_bands_finish (self, res, &error); + if (!current_bands) { + /* Errors when getting bands won't be critical */ + mm_warn ("couldn't load current bands: '%s'", error->message); + g_error_free (error); + /* Default to the ones we requested */ + set_current_bands_complete_with_defaults (task); + return; + } + + mm_common_bands_garray_sort (current_bands); + mm_gdbus_modem_set_current_bands (ctx->skeleton, mm_common_bands_garray_to_variant (current_bands)); + g_array_unref (current_bands); + + g_task_return_boolean (task, TRUE); + g_object_unref (task); +} + +static void set_current_bands_ready (MMIfaceModem *self, GAsyncResult *res, GTask *task) { GError *error = NULL; - if (!MM_IFACE_MODEM_GET_INTERFACE (self)->set_current_bands_finish (self, res, &error)) + if (!MM_IFACE_MODEM_GET_INTERFACE (self)->set_current_bands_finish (self, res, &error)) { g_task_return_error (task, error); - else { - SetCurrentBandsContext *ctx; - - ctx = g_task_get_task_data (task); - - /* Never show just 'any' in the interface */ - if (ctx->bands_array->len == 1 && - g_array_index (ctx->bands_array, MMModemBand, 0) == MM_MODEM_BAND_ANY) { - GArray *supported_bands; - - supported_bands = (mm_common_bands_variant_to_garray ( - mm_gdbus_modem_get_supported_bands (ctx->skeleton))); - mm_common_bands_garray_sort (supported_bands); - mm_gdbus_modem_set_current_bands (ctx->skeleton, - mm_common_bands_garray_to_variant (supported_bands)); - g_array_unref (supported_bands); - } else { - mm_common_bands_garray_sort (ctx->bands_array); - mm_gdbus_modem_set_current_bands (ctx->skeleton, - mm_common_bands_garray_to_variant (ctx->bands_array)); - } + g_object_unref (task); + return; + } - g_task_return_boolean (task, TRUE); + if (MM_IFACE_MODEM_GET_INTERFACE (self)->load_current_bands && + MM_IFACE_MODEM_GET_INTERFACE (self)->load_current_bands_finish) { + MM_IFACE_MODEM_GET_INTERFACE (self)->load_current_bands ( + self, + (GAsyncReadyCallback)after_set_load_current_bands_ready, + task); + return; } - g_object_unref (task); + /* Default to the ones we requested */ + set_current_bands_complete_with_defaults (task); } static gboolean |