modem-helpers-qmi: better handle no supported modes
Dell Snapdragon X62 before FCC Unlock reports no radio interfaces from QMI and no device capabilities from MBIM. Instead of asserting in mm_filter_supported_modes() when called from mm_supported_modes_from_qmi_supported_modes_context() gracefully handle the lack of supported modes. Signed-off-by: Dan Williams <dan@ioncontrol.co>
This commit is contained in:
@@ -2541,13 +2541,22 @@ mm_supported_capabilities_from_qmi_supported_capabilities_context (MMQmiSupporte
|
||||
/* Utility to build list of supported modes */
|
||||
|
||||
GArray *
|
||||
mm_supported_modes_from_qmi_supported_modes_context (MMQmiSupportedModesContext *ctx,
|
||||
gpointer log_object)
|
||||
mm_supported_modes_from_qmi_supported_modes_context (MMQmiSupportedModesContext *ctx,
|
||||
gpointer log_object,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GArray) combinations = NULL;
|
||||
g_autoptr(GArray) all = NULL;
|
||||
MMModemModeCombination mode;
|
||||
|
||||
if (ctx->all == MM_MODEM_MODE_NONE) {
|
||||
g_set_error (error,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_FAILED,
|
||||
"No supported modes reported");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Start with a mode including ALL */
|
||||
mode.allowed = ctx->all;
|
||||
mode.preferred = MM_MODEM_MODE_NONE;
|
||||
|
||||
@@ -217,8 +217,9 @@ typedef struct {
|
||||
MMModemCapability current_capabilities;
|
||||
} MMQmiSupportedModesContext;
|
||||
|
||||
GArray *mm_supported_modes_from_qmi_supported_modes_context (MMQmiSupportedModesContext *ctx,
|
||||
gpointer log_object);
|
||||
GArray *mm_supported_modes_from_qmi_supported_modes_context (MMQmiSupportedModesContext *ctx,
|
||||
gpointer log_object,
|
||||
GError **error);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* QMI unique id manipulation */
|
||||
|
||||
+6
-2
@@ -1728,6 +1728,7 @@ mm_shared_qmi_load_supported_modes (MMIfaceModem *self,
|
||||
MMQmiSupportedModesContext ctx = { 0 };
|
||||
guint i;
|
||||
GArray *combinations;
|
||||
GError *error = NULL;
|
||||
|
||||
task = g_task_new (self, NULL, callback, user_data);
|
||||
|
||||
@@ -1753,8 +1754,11 @@ mm_shared_qmi_load_supported_modes (MMIfaceModem *self,
|
||||
ctx.current_capabilities = priv->current_capabilities;
|
||||
ctx.multimode = priv->multimode;
|
||||
|
||||
combinations = mm_supported_modes_from_qmi_supported_modes_context (&ctx, self);
|
||||
g_task_return_pointer (task, combinations, (GDestroyNotify) g_array_unref);
|
||||
combinations = mm_supported_modes_from_qmi_supported_modes_context (&ctx, self, &error);
|
||||
if (error)
|
||||
g_task_return_error (task, error);
|
||||
else
|
||||
g_task_return_pointer (task, combinations, (GDestroyNotify) g_array_unref);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
|
||||
@@ -72,14 +72,22 @@ test_supported_modes_expected (MMQmiSupportedModesContext *ctx,
|
||||
g_autoptr(GArray) built = NULL;
|
||||
g_autofree gchar *expected_str = NULL;
|
||||
g_autofree gchar *built_str = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
built = mm_supported_modes_from_qmi_supported_modes_context (ctx, NULL);
|
||||
built = mm_supported_modes_from_qmi_supported_modes_context (ctx, NULL, &error);
|
||||
if (built == NULL) {
|
||||
g_assert_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED);
|
||||
g_assert_cmpint (n_expected_modes, ==, 0);
|
||||
} else {
|
||||
g_assert_no_error (error);
|
||||
g_assert_cmpint (n_expected_modes, >, 0);
|
||||
|
||||
expected_str = mm_common_build_mode_combinations_string (expected_modes, n_expected_modes);
|
||||
built_str = mm_common_build_mode_combinations_string ((MMModemModeCombination *)built->data, built->len);
|
||||
expected_str = mm_common_build_mode_combinations_string (expected_modes, n_expected_modes);
|
||||
built_str = mm_common_build_mode_combinations_string ((MMModemModeCombination *)built->data, built->len);
|
||||
|
||||
/* compare strings, so that the error shows the string values as well */
|
||||
g_assert_cmpstr (built_str, ==, expected_str);
|
||||
/* compare strings, so that the error shows the string values as well */
|
||||
g_assert_cmpstr (built_str, ==, expected_str);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -1332,6 +1340,20 @@ test_supported_modes_generic_nr5g_lte_evdo (void)
|
||||
G_N_ELEMENTS (expected_modes));
|
||||
}
|
||||
|
||||
static void
|
||||
test_supported_modes_generic_none (void)
|
||||
{
|
||||
MMQmiSupportedModesContext ctx;
|
||||
|
||||
/* Dell Snapdragon X62 before FCC unlock reports no supported radio interfaces */
|
||||
ctx.multimode = FALSE;
|
||||
ctx.all = MM_MODEM_MODE_NONE;
|
||||
|
||||
test_supported_modes_expected (&ctx,
|
||||
NULL,
|
||||
0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* System Info processor helper */
|
||||
|
||||
@@ -1970,6 +1992,8 @@ int main (int argc, char **argv)
|
||||
g_test_add_func ("/MM/qmi/supported-capabilities/generic/nr5g-lte-evdo", test_supported_capabilities_generic_nr5g_lte_evdo);
|
||||
g_test_add_func ("/MM/qmi/supported-modes/generic/nr5g-lte-evdo", test_supported_modes_generic_nr5g_lte_evdo);
|
||||
|
||||
g_test_add_func ("/MM/qmi/supported-modes/generic/none", test_supported_modes_generic_none);
|
||||
|
||||
g_test_add_func ("/MM/qmi/registration-state-from-system-info/2g/searching", test_registration_state_from_qmi_system_info_2g_searching);
|
||||
g_test_add_func ("/MM/qmi/registration-state-from-system-info/2g/idle", test_registration_state_from_qmi_system_info_2g_idle);
|
||||
g_test_add_func ("/MM/qmi/registration-state-from-system-info/2g/cs-home", test_registration_state_from_qmi_system_info_2g_cs_home);
|
||||
|
||||
Reference in New Issue
Block a user