modem-helpers: port supported modes filtering to use object logging
This commit is contained in:
@@ -1019,7 +1019,7 @@ parent_load_supported_modes_ready (MMIfaceModem *self,
|
||||
}
|
||||
|
||||
/* Filter out those unsupported modes */
|
||||
filtered = mm_filter_supported_modes (all, combinations);
|
||||
filtered = mm_filter_supported_modes (all, combinations, self);
|
||||
g_array_unref (all);
|
||||
g_array_unref (combinations);
|
||||
|
||||
|
@@ -88,7 +88,7 @@ parent_load_supported_modes_ready (MMIfaceModem *self,
|
||||
g_array_append_val (combinations, mode);
|
||||
|
||||
/* Filter out those unsupported modes */
|
||||
filtered = mm_filter_supported_modes (all, combinations);
|
||||
filtered = mm_filter_supported_modes (all, combinations, self);
|
||||
g_array_unref (all);
|
||||
g_array_unref (combinations);
|
||||
|
||||
|
@@ -88,7 +88,7 @@ parent_load_supported_modes_ready (MMIfaceModem *self,
|
||||
g_array_append_val (combinations, mode);
|
||||
|
||||
/* Filter out those unsupported modes */
|
||||
filtered = mm_filter_supported_modes (all, combinations);
|
||||
filtered = mm_filter_supported_modes (all, combinations, self);
|
||||
g_array_unref (all);
|
||||
g_array_unref (combinations);
|
||||
|
||||
|
@@ -104,7 +104,7 @@ parent_load_supported_modes_ready (MMIfaceModem *self,
|
||||
g_array_append_val (combinations, mode);
|
||||
|
||||
/* Filter out those unsupported modes */
|
||||
filtered = mm_filter_supported_modes (all, combinations);
|
||||
filtered = mm_filter_supported_modes (all, combinations, self);
|
||||
g_array_unref (all);
|
||||
g_array_unref (combinations);
|
||||
|
||||
|
@@ -111,7 +111,7 @@ parent_load_supported_modes_ready (MMIfaceModem *self,
|
||||
g_array_append_val (combinations, mode);
|
||||
|
||||
/* Filter out those unsupported modes */
|
||||
filtered = mm_filter_supported_modes (all, combinations);
|
||||
filtered = mm_filter_supported_modes (all, combinations, self);
|
||||
g_array_unref (all);
|
||||
g_array_unref (combinations);
|
||||
|
||||
|
@@ -589,7 +589,7 @@ parent_load_supported_modes_ready (MMIfaceModem *self,
|
||||
}
|
||||
|
||||
/* Filter out those unsupported modes */
|
||||
filtered = mm_filter_supported_modes (all, combinations);
|
||||
filtered = mm_filter_supported_modes (all, combinations, self);
|
||||
g_array_unref (all);
|
||||
g_array_unref (combinations);
|
||||
|
||||
|
@@ -850,7 +850,7 @@ parent_load_supported_modes_ready (MMIfaceModem *self,
|
||||
g_array_append_val (combinations, mode);
|
||||
|
||||
/* Filter out those unsupported modes */
|
||||
filtered = mm_filter_supported_modes (all, combinations);
|
||||
filtered = mm_filter_supported_modes (all, combinations, self);
|
||||
g_array_unref (all);
|
||||
g_array_unref (combinations);
|
||||
|
||||
|
@@ -102,7 +102,7 @@ load_supported_modes_ready (MMIfaceModem *self,
|
||||
|
||||
/* Filter out those unsupported modes */
|
||||
combinations = mm_telit_build_modes_list();
|
||||
filtered = mm_filter_supported_modes (all, combinations);
|
||||
filtered = mm_filter_supported_modes (all, combinations, self);
|
||||
g_array_unref (all);
|
||||
g_array_unref (combinations);
|
||||
|
||||
|
@@ -1241,7 +1241,7 @@ parent_load_supported_modes_ready (MMIfaceModem *self,
|
||||
|
||||
/* Filter out those unsupported modes */
|
||||
combinations = mm_telit_build_modes_list();
|
||||
filtered = mm_filter_supported_modes (all, combinations);
|
||||
filtered = mm_filter_supported_modes (all, combinations, self);
|
||||
g_array_unref (all);
|
||||
g_array_unref (combinations);
|
||||
|
||||
|
@@ -690,7 +690,7 @@ load_supported_modes_finish (MMIfaceModem *self,
|
||||
if (!(combinations = mm_ublox_parse_urat_test_response (response, error)))
|
||||
return FALSE;
|
||||
|
||||
if (!(combinations = mm_ublox_filter_supported_modes (mm_iface_modem_get_model (self), combinations, error)))
|
||||
if (!(combinations = mm_ublox_filter_supported_modes (mm_iface_modem_get_model (self), combinations, self, error)))
|
||||
return FALSE;
|
||||
|
||||
/* Decide and store which combination to apply when ANY requested */
|
||||
|
@@ -980,6 +980,7 @@ supported_modes_per_model (const gchar *model)
|
||||
GArray *
|
||||
mm_ublox_filter_supported_modes (const gchar *model,
|
||||
GArray *combinations,
|
||||
gpointer logger,
|
||||
GError **error)
|
||||
{
|
||||
MMModemModeCombination mode;
|
||||
@@ -1002,7 +1003,7 @@ mm_ublox_filter_supported_modes (const gchar *model,
|
||||
|
||||
all = g_array_sized_new (FALSE, FALSE, sizeof (MMModemModeCombination), 1);
|
||||
g_array_append_val (all, mode);
|
||||
filtered = mm_filter_supported_modes (all, combinations);
|
||||
filtered = mm_filter_supported_modes (all, combinations, logger);
|
||||
g_array_unref (all);
|
||||
g_array_unref (combinations);
|
||||
|
||||
|
@@ -115,6 +115,7 @@ gboolean mm_ublox_get_support_config (const gchar *model,
|
||||
|
||||
GArray *mm_ublox_filter_supported_modes (const gchar *model,
|
||||
GArray *combinations,
|
||||
gpointer logger,
|
||||
GError **error);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@@ -294,7 +294,7 @@ compare_combinations (const gchar *response,
|
||||
g_assert_no_error (error);
|
||||
g_assert (combinations);
|
||||
|
||||
combinations = mm_ublox_filter_supported_modes (model, combinations, &error);
|
||||
combinations = mm_ublox_filter_supported_modes (model, combinations, NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (combinations);
|
||||
|
||||
|
@@ -176,7 +176,7 @@ supported_ms_classes_query_ready (MMBaseModem *self,
|
||||
g_array_append_val (combinations, mode);
|
||||
|
||||
/* Filter out those unsupported modes */
|
||||
filtered = mm_filter_supported_modes (all, combinations);
|
||||
filtered = mm_filter_supported_modes (all, combinations, self);
|
||||
g_array_unref (all);
|
||||
g_array_unref (combinations);
|
||||
|
||||
|
@@ -90,7 +90,7 @@ parent_load_supported_modes_ready (MMIfaceModem *self,
|
||||
g_array_append_val (combinations, mode);
|
||||
|
||||
/* Filter out those unsupported modes */
|
||||
filtered = mm_filter_supported_modes (all, combinations);
|
||||
filtered = mm_filter_supported_modes (all, combinations, self);
|
||||
g_array_unref (all);
|
||||
g_array_unref (combinations);
|
||||
|
||||
|
@@ -172,6 +172,7 @@ static const MMModemMode xmm_modes[] = {
|
||||
|
||||
gboolean
|
||||
mm_xmm_parse_xact_test_response (const gchar *response,
|
||||
gpointer logger,
|
||||
GArray **modes_out,
|
||||
GArray **bands_out,
|
||||
GError **error)
|
||||
@@ -318,7 +319,7 @@ mm_xmm_parse_xact_test_response (const gchar *response,
|
||||
all_modes = g_array_sized_new (FALSE, FALSE, sizeof (MMModemModeCombination), 1);
|
||||
g_array_append_val (all_modes, all);
|
||||
|
||||
filtered = mm_filter_supported_modes (all_modes, modes);
|
||||
filtered = mm_filter_supported_modes (all_modes, modes, logger);
|
||||
if (!filtered || filtered->len == 0) {
|
||||
inner_error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
|
||||
"Empty supported mode list after frequency band filtering");
|
||||
|
@@ -21,6 +21,7 @@
|
||||
|
||||
/* AT+XACT=? response parser */
|
||||
gboolean mm_xmm_parse_xact_test_response (const gchar *response,
|
||||
gpointer logger,
|
||||
GArray **modes_out,
|
||||
GArray **bands_out,
|
||||
GError **error);
|
||||
|
@@ -154,6 +154,7 @@ xact_test_ready (MMBaseModem *self,
|
||||
response = mm_base_modem_at_command_finish (self, res, &error);
|
||||
if (!response ||
|
||||
!mm_xmm_parse_xact_test_response (response,
|
||||
self,
|
||||
&priv->supported_modes,
|
||||
&priv->supported_bands,
|
||||
&error))
|
||||
|
@@ -45,7 +45,7 @@ validate_xact_test_response (const gchar *response,
|
||||
gboolean ret;
|
||||
guint i;
|
||||
|
||||
ret = mm_xmm_parse_xact_test_response (response, &modes, &bands, &error);
|
||||
ret = mm_xmm_parse_xact_test_response (response, NULL, &modes, &bands, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (ret);
|
||||
|
||||
|
@@ -303,7 +303,7 @@ parent_load_supported_modes_ready (MMIfaceModem *self,
|
||||
}
|
||||
|
||||
/* Filter out those unsupported modes */
|
||||
filtered = mm_filter_supported_modes (all, combinations);
|
||||
filtered = mm_filter_supported_modes (all, combinations, self);
|
||||
g_array_unref (all);
|
||||
g_array_unref (combinations);
|
||||
|
||||
|
@@ -418,7 +418,8 @@ mm_new_iso8601_time (guint year,
|
||||
|
||||
GArray *
|
||||
mm_filter_supported_modes (const GArray *all,
|
||||
const GArray *supported_combinations)
|
||||
const GArray *supported_combinations,
|
||||
gpointer log_object)
|
||||
{
|
||||
MMModemModeCombination all_item;
|
||||
guint i;
|
||||
@@ -429,6 +430,9 @@ mm_filter_supported_modes (const GArray *all,
|
||||
g_return_val_if_fail (all->len == 1, NULL);
|
||||
g_return_val_if_fail (supported_combinations != NULL, NULL);
|
||||
|
||||
mm_obj_dbg (log_object, "filtering %u supported mode combinations with %u modes",
|
||||
supported_combinations->len, all->len);
|
||||
|
||||
all_item = g_array_index (all, MMModemModeCombination, 0);
|
||||
g_return_val_if_fail (all_item.allowed != MM_MODEM_MODE_NONE, NULL);
|
||||
|
||||
@@ -450,14 +454,17 @@ mm_filter_supported_modes (const GArray *all,
|
||||
}
|
||||
|
||||
if (filtered_combinations->len == 0)
|
||||
mm_warn ("All supported mode combinations were filtered out.");
|
||||
mm_obj_warn (log_object, "all supported mode combinations were filtered out");
|
||||
|
||||
/* Add default entry with the generic mask including all items */
|
||||
if (!all_item_added) {
|
||||
mm_dbg ("Adding an explicit item with all supported modes allowed");
|
||||
mm_obj_dbg (log_object, "adding an explicit item with all supported modes allowed");
|
||||
g_array_append_val (filtered_combinations, all_item);
|
||||
}
|
||||
|
||||
mm_obj_dbg (log_object, "device supports %u different mode combinations",
|
||||
filtered_combinations->len);
|
||||
|
||||
return filtered_combinations;
|
||||
}
|
||||
|
||||
|
@@ -84,7 +84,8 @@ gchar *mm_new_iso8601_time (guint year,
|
||||
gint offset_minutes);
|
||||
|
||||
GArray *mm_filter_supported_modes (const GArray *all,
|
||||
const GArray *supported_combinations);
|
||||
const GArray *supported_combinations,
|
||||
gpointer log_object);
|
||||
|
||||
GArray *mm_filter_supported_capabilities (MMModemCapability all,
|
||||
const GArray *supported_combinations);
|
||||
|
@@ -1624,7 +1624,7 @@ mm_shared_qmi_load_supported_modes (MMIfaceModem *self,
|
||||
}
|
||||
|
||||
/* Filter out unsupported modes */
|
||||
filtered = mm_filter_supported_modes (all, combinations);
|
||||
filtered = mm_filter_supported_modes (all, combinations, self);
|
||||
g_array_unref (all);
|
||||
g_array_unref (combinations);
|
||||
|
||||
|
@@ -3423,7 +3423,7 @@ test_supported_mode_filter (void *f, gpointer d)
|
||||
|
||||
/* Only 2G supported */
|
||||
all = build_mode_all (MM_MODEM_MODE_2G);
|
||||
filtered = mm_filter_supported_modes (all, combinations);
|
||||
filtered = mm_filter_supported_modes (all, combinations, NULL);
|
||||
g_assert_cmpuint (filtered->len, ==, 1);
|
||||
g_assert (find_mode_combination (filtered, MM_MODEM_MODE_2G, MM_MODEM_MODE_NONE));
|
||||
g_array_unref (filtered);
|
||||
@@ -3431,7 +3431,7 @@ test_supported_mode_filter (void *f, gpointer d)
|
||||
|
||||
/* Only 3G supported */
|
||||
all = build_mode_all (MM_MODEM_MODE_3G);
|
||||
filtered = mm_filter_supported_modes (all, combinations);
|
||||
filtered = mm_filter_supported_modes (all, combinations, NULL);
|
||||
g_assert_cmpuint (filtered->len, ==, 1);
|
||||
g_assert (find_mode_combination (filtered, MM_MODEM_MODE_3G, MM_MODEM_MODE_NONE));
|
||||
g_array_unref (filtered);
|
||||
@@ -3439,7 +3439,7 @@ test_supported_mode_filter (void *f, gpointer d)
|
||||
|
||||
/* 2G and 3G supported */
|
||||
all = build_mode_all (MM_MODEM_MODE_2G | MM_MODEM_MODE_3G);
|
||||
filtered = mm_filter_supported_modes (all, combinations);
|
||||
filtered = mm_filter_supported_modes (all, combinations, NULL);
|
||||
g_assert_cmpuint (filtered->len, ==, 3);
|
||||
g_assert (find_mode_combination (filtered, MM_MODEM_MODE_2G, MM_MODEM_MODE_NONE));
|
||||
g_assert (find_mode_combination (filtered, MM_MODEM_MODE_3G, MM_MODEM_MODE_NONE));
|
||||
@@ -3449,7 +3449,7 @@ test_supported_mode_filter (void *f, gpointer d)
|
||||
|
||||
/* 3G and 4G supported */
|
||||
all = build_mode_all (MM_MODEM_MODE_3G | MM_MODEM_MODE_4G);
|
||||
filtered = mm_filter_supported_modes (all, combinations);
|
||||
filtered = mm_filter_supported_modes (all, combinations, NULL);
|
||||
g_assert_cmpuint (filtered->len, ==, 3);
|
||||
g_assert (find_mode_combination (filtered, MM_MODEM_MODE_3G, MM_MODEM_MODE_NONE));
|
||||
g_assert (find_mode_combination (filtered, MM_MODEM_MODE_4G, MM_MODEM_MODE_NONE));
|
||||
@@ -3459,7 +3459,7 @@ test_supported_mode_filter (void *f, gpointer d)
|
||||
|
||||
/* 2G, 3G and 4G supported */
|
||||
all = build_mode_all (MM_MODEM_MODE_2G | MM_MODEM_MODE_3G | MM_MODEM_MODE_4G);
|
||||
filtered = mm_filter_supported_modes (all, combinations);
|
||||
filtered = mm_filter_supported_modes (all, combinations, NULL);
|
||||
g_assert_cmpuint (filtered->len, ==, 6);
|
||||
g_assert (find_mode_combination (filtered, MM_MODEM_MODE_2G, MM_MODEM_MODE_NONE));
|
||||
g_assert (find_mode_combination (filtered, MM_MODEM_MODE_3G, MM_MODEM_MODE_NONE));
|
||||
|
Reference in New Issue
Block a user