iface-modem: always sort supported and current bands before exposing them

This commit is contained in:
Aleksander Morgado
2016-08-11 14:03:45 +02:00
parent ca1b9cb686
commit 292914cf65
3 changed files with 14 additions and 2 deletions

View File

@@ -655,6 +655,12 @@ mm_common_bands_garray_cmp (GArray *a, GArray *b)
return !different;
}
void
mm_common_bands_garray_sort (GArray *array)
{
g_array_sort (array, (GCompareFunc) cmp_band);
}
GArray *
mm_common_mode_combinations_variant_to_garray (GVariant *variant)
{

View File

@@ -100,7 +100,8 @@ GVariant *mm_common_bands_garray_to_variant (GArray *array);
GVariant *mm_common_build_bands_any (void);
GVariant *mm_common_build_bands_unknown (void);
gboolean mm_common_bands_garray_cmp (GArray *a, GArray *b);
gboolean mm_common_bands_garray_cmp (GArray *a, GArray *b);
void mm_common_bands_garray_sort (GArray *array);
GArray *mm_common_mode_combinations_variant_to_garray (GVariant *variant);
MMModemModeCombination *mm_common_mode_combinations_variant_to_array (GVariant *variant,

View File

@@ -2188,12 +2188,15 @@ set_current_bands_ready (MMIfaceModem *self,
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
} 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_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
}
@@ -3992,6 +3995,7 @@ load_supported_bands_ready (MMIfaceModem *self,
bands_array = MM_IFACE_MODEM_GET_INTERFACE (self)->load_supported_bands_finish (self, res, &error);
if (bands_array) {
mm_common_bands_garray_sort (bands_array);
mm_gdbus_modem_set_supported_bands (ctx->skeleton,
mm_common_bands_garray_to_variant (bands_array));
g_array_unref (bands_array);
@@ -4193,6 +4197,7 @@ load_current_bands_ready (MMIfaceModem *self,
g_array_unref (supported_bands);
if (filtered_bands) {
mm_common_bands_garray_sort (filtered_bands);
mm_gdbus_modem_set_current_bands (ctx->skeleton,
mm_common_bands_garray_to_variant (filtered_bands));
g_array_unref (filtered_bands);