From 352b8ed53d69ef1ce4665c1dd76404451d3918a6 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 6 Mar 2025 08:29:56 -0600 Subject: broadband-modem-qmi: implement disabled 3GPP profiles Previously, a disabled profile would cause Profile Manager interface enabling to fail because get_profile_settings_ready() returned an error for disabled profiles. But 3GPP profile objects already have support for the enable/disabled setting, so just hook that up and stop returning an error for disabled ones. This allows successful initialization of the 3GPP Profile Manager on devices that contain disabled profiles. While we're at it, allow creating disabled profiles, and changing profiles back and forth from enabled<->disabled. Signed-off-by: Dan Williams --- src/mm-broadband-modem-qmi.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c index 996f91e2..ee6310a9 100644 --- a/src/mm-broadband-modem-qmi.c +++ b/src/mm-broadband-modem-qmi.c @@ -6582,12 +6582,17 @@ wds_profile_settings_to_3gpp_profile (MMBroadbandModemQmi *se QmiWdsPdpType pdp_type; QmiWdsAuthentication auth; QmiWdsApnTypeMask apn_type; + gboolean profile_disabled; profile = mm_3gpp_profile_new (); /* On 3GPP modems, the modem seems to force profile-index = pdp-context-number, * and so, we're just going to rely on the profile-index ourselves.*/ mm_3gpp_profile_set_profile_id (profile, (gint) profile_index); + mm_3gpp_profile_set_enabled (profile, TRUE); + + if (qmi_message_wds_get_profile_settings_output_get_apn_disabled_flag (output, &profile_disabled, NULL)) + mm_3gpp_profile_set_enabled (profile, !profile_disabled); if (qmi_message_wds_get_profile_settings_output_get_apn_name (output, &str, NULL)) mm_3gpp_profile_set_apn (profile, str); @@ -6627,7 +6632,6 @@ get_profile_settings_ready (QmiClientWds *client, MMBroadbandModemQmi *self; GError *error = NULL; gint profile_id; - gboolean profile_disabled = FALSE; MM3gppProfile *profile; g_autoptr(QmiMessageWdsGetProfileSettingsOutput) output = NULL; @@ -6642,15 +6646,6 @@ get_profile_settings_ready (QmiClientWds *client, return; } - /* just ignore the profile if it's disabled */ - qmi_message_wds_get_profile_settings_output_get_apn_disabled_flag (output, &profile_disabled, NULL); - if (profile_disabled) { - g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, - "Profile '%d' is internally disabled", profile_id); - g_object_unref (task); - return; - } - profile = wds_profile_settings_to_3gpp_profile (self, profile_id, output, &error); if (!profile) g_task_return_error (task, error); @@ -6850,6 +6845,7 @@ typedef struct { QmiWdsApnTypeMask qmi_apn_type; QmiWdsAuthentication qmi_auth; QmiWdsPdpType qmi_pdp_type; + gboolean apn_disabled_flag; } StoreProfileContext; static void @@ -6990,6 +6986,7 @@ store_profile_run (GTask *task) qmi_message_wds_create_profile_input_set_authentication (input, ctx->qmi_auth, NULL); qmi_message_wds_create_profile_input_set_username (input, ctx->user, NULL); qmi_message_wds_create_profile_input_set_password (input, ctx->password, NULL); + qmi_message_wds_create_profile_input_set_apn_disabled_flag (input, ctx->apn_disabled_flag, NULL); if (!self->priv->apn_type_not_supported) qmi_message_wds_create_profile_input_set_apn_type_mask (input, ctx->qmi_apn_type, NULL); @@ -7010,6 +7007,7 @@ store_profile_run (GTask *task) qmi_message_wds_modify_profile_input_set_authentication (input, ctx->qmi_auth, NULL); qmi_message_wds_modify_profile_input_set_username (input, ctx->user, NULL); qmi_message_wds_modify_profile_input_set_password (input, ctx->password, NULL); + qmi_message_wds_modify_profile_input_set_apn_disabled_flag (input, ctx->apn_disabled_flag, NULL); if (!self->priv->apn_type_not_supported) qmi_message_wds_modify_profile_input_set_apn_type_mask (input, ctx->qmi_apn_type, NULL); @@ -7083,6 +7081,8 @@ modem_3gpp_profile_manager_store_profile (MMIfaceModem3gppProfileManager *self, return; } + ctx->apn_disabled_flag = !mm_3gpp_profile_get_enabled (profile); + store_profile_run (task); } -- cgit v1.2.3-70-g09d2 From 4b0d3b7147a3fa8f669870e0a740a2b0121a475c Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 6 Mar 2025 08:32:36 -0600 Subject: broadband-modem-qmi: use correct profile index in error message Instead of using the loop index, use the actual profile index because they aren't always the same. Signed-off-by: Dan Williams --- src/mm-broadband-modem-qmi.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c index ee6310a9..16f2a088 100644 --- a/src/mm-broadband-modem-qmi.c +++ b/src/mm-broadband-modem-qmi.c @@ -6722,6 +6722,14 @@ modem_3gpp_profile_manager_list_profiles_finish (MMIfaceModem3gppProfileManager static void get_next_profile_settings (GTask *task); +static QmiMessageWdsGetProfileListOutputProfileListProfile * +get_current_qmi_profile_from_list (ListProfilesContext *ctx) +{ + return &g_array_index (ctx->qmi_profiles, + QmiMessageWdsGetProfileListOutputProfileListProfile, + ctx->i); +} + static void get_next_profile_settings_ready (MMIfaceModem3gppProfileManager *self, GAsyncResult *res, @@ -6735,7 +6743,12 @@ get_next_profile_settings_ready (MMIfaceModem3gppProfileManager *self, profile = modem_3gpp_profile_manager_get_profile_finish (self, res, &error); if (!profile) { - g_prefix_error (&error, "Couldn't load settings from profile index %u: ", ctx->i); + QmiMessageWdsGetProfileListOutputProfileListProfile *current; + + current = get_current_qmi_profile_from_list (ctx); + g_prefix_error (&error, + "Couldn't load settings from profile index %u: ", + current->profile_index); g_task_return_error (task, error); g_object_unref (task); return; @@ -6765,7 +6778,7 @@ get_next_profile_settings (GTask *task) return; } - current = &g_array_index (ctx->qmi_profiles, QmiMessageWdsGetProfileListOutputProfileListProfile, ctx->i); + current = get_current_qmi_profile_from_list (ctx); modem_3gpp_profile_manager_get_profile (MM_IFACE_MODEM_3GPP_PROFILE_MANAGER (self), current->profile_index, (GAsyncReadyCallback)get_next_profile_settings_ready, -- cgit v1.2.3-70-g09d2 From 4d2d01b2c6a0819d941a4ef2d257e5392af3e24f Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 6 Mar 2025 08:33:29 -0600 Subject: broadband-bearer,modem-helpers: don't use or match disabled profiles When matching profiles ignore disabled ones. When activating a specific profile index, return an error if that profile is marked as disabled. Signed-off-by: Dan Williams --- src/mm-broadband-bearer.c | 8 +++++++- src/mm-modem-helpers.c | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mm-broadband-bearer.c b/src/mm-broadband-bearer.c index 69bf699b..dfd9d489 100644 --- a/src/mm-broadband-bearer.c +++ b/src/mm-broadband-bearer.c @@ -634,7 +634,13 @@ select_profile_3gpp_get_profile_ready (MMIfaceModem3gppProfileManager *modem, profile = mm_iface_modem_3gpp_profile_manager_get_profile_finish (modem, res, &error); if (!profile) g_task_return_error (task, error); - else + else if (!mm_3gpp_profile_get_enabled (profile)) { + g_task_return_new_error (task, + MM_CORE_ERROR, + MM_CORE_ERROR_FAILED, + "Profile '%d' is internally disabled", + ctx->profile_id); + } else g_task_return_int (task, ctx->profile_id); g_object_unref (task); } diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c index 574ec7fc..fcb44ad2 100644 --- a/src/mm-modem-helpers.c +++ b/src/mm-modem-helpers.c @@ -1677,6 +1677,12 @@ mm_3gpp_profile_list_find_best (GList *profile_list, continue; } + /* Never select disabled profiles */ + if (!mm_3gpp_profile_get_enabled (iter_profile)) { + mm_obj_dbg (log_object, "skipping context at profile %d: disabled", iter_profile_id); + continue; + } + /* Always prefer an exact match; compare all supported fields except for profile id */ if (mm_3gpp_profile_cmp (iter_profile, requested, cmp_apn, cmp_flags)) { mm_obj_dbg (log_object, "found exact context at profile %d", iter_profile_id); -- cgit v1.2.3-70-g09d2