modem-helpers: port supported modes filtering to use object logging
This commit is contained in:
+10
-3
@@ -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);
|
||||
|
||||
+1
-1
@@ -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