aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-08-31 16:52:59 +0200
committerAleksander Morgado <aleksander@lanedo.com>2012-08-31 17:44:45 +0200
commit04ce8b567cca9f3ab125f59af3bd8bfed554adce (patch)
tree66d399cca353189df6b1adc7feb88a87a6fd989f
parent61d41978c1b217870f399aa38df9af110ca977b1 (diff)
broadband-modem-qmi: use System Selection Preference when available
Get/Set Technology Preference was introduced in NAS 1.0, so should be always available (even if we thought it was introduced in NAS 1.7, that's not true). But the newer System Selection Preference behaves better as it allows more features like 'preferred' modes; so use it when available (NAS >= 1.1).
-rw-r--r--src/mm-broadband-modem-qmi.c66
-rw-r--r--src/mm-modem-helpers-qmi.c4
-rw-r--r--src/mm-modem-helpers-qmi.h4
3 files changed, 10 insertions, 64 deletions
diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c
index 17e22fb9..3a718572 100644
--- a/src/mm-broadband-modem-qmi.c
+++ b/src/mm-broadband-modem-qmi.c
@@ -56,11 +56,6 @@ struct _MMBroadbandModemQmiPrivate {
gchar *meid;
gchar *esn;
- /* Allowed mode related */
-#if defined WITH_NEWEST_QMI_COMMANDS
- gboolean has_mode_preference_in_system_selection_preference;
-#endif /* WITH_NEWEST_QMI_COMMANDS */
-
/* 3GPP and CDMA share unsolicited events setup/enable/disable/cleanup */
gboolean unsolicited_events_enabled;
gboolean unsolicited_events_setup;
@@ -1589,9 +1584,7 @@ typedef struct {
MMBroadbandModemQmi *self;
QmiClientNas *client;
GSimpleAsyncResult *result;
-#if defined WITH_NEWEST_QMI_COMMANDS
gboolean run_get_system_selection_preference;
-#endif /* WITH_NEWEST_QMI_COMMANDS */
gboolean run_get_technology_preference;
} LoadAllowedModesContext;
@@ -1686,8 +1679,6 @@ get_technology_preference_ready (QmiClientNas *client,
load_allowed_modes_context_complete_and_free (ctx);
}
-#if defined WITH_NEWEST_QMI_COMMANDS
-
static void
allowed_modes_get_system_selection_preference_ready (QmiClientNas *client,
GAsyncResult *res,
@@ -1709,9 +1700,6 @@ allowed_modes_get_system_selection_preference_ready (QmiClientNas *client,
output,
&mode_preference_mask,
NULL)) {
- /* Assuming here that Get System Selection Preference reports *always* all
- * optional fields that the current message version supports */
- ctx->self->priv->has_mode_preference_in_system_selection_preference = FALSE;
mm_dbg ("Mode preference not reported in system selection preference");
} else {
MMModemMode allowed;
@@ -1731,8 +1719,8 @@ allowed_modes_get_system_selection_preference_ready (QmiClientNas *client,
result->allowed = allowed;
result->preferred = MM_MODEM_MODE_NONE;
- if (mode_preference_mask & QMI_NAS_RAT_MODE_PREFERENCE_GSM &&
- mode_preference_mask & QMI_NAS_RAT_MODE_PREFERENCE_UMTS &&
+ if ((mode_preference_mask & QMI_NAS_RAT_MODE_PREFERENCE_GSM) &&
+ (mode_preference_mask & QMI_NAS_RAT_MODE_PREFERENCE_UMTS) &&
qmi_message_nas_get_system_selection_preference_output_get_gsm_wcdma_acquisition_order_preference (
output,
&gsm_or_wcdma,
@@ -1759,12 +1747,9 @@ allowed_modes_get_system_selection_preference_ready (QmiClientNas *client,
load_allowed_modes_context_complete_and_free (ctx);
}
-#endif /* WITH_NEWEST_QMI_COMMANDS */
-
static void
load_allowed_modes_context_step (LoadAllowedModesContext *ctx)
{
-#if defined WITH_NEWEST_QMI_COMMANDS
if (ctx->run_get_system_selection_preference) {
qmi_client_nas_get_system_selection_preference (
ctx->client,
@@ -1775,7 +1760,6 @@ load_allowed_modes_context_step (LoadAllowedModesContext *ctx)
ctx);
return;
}
-#endif /* WITH_NEWEST_QMI_COMMANDS */
if (ctx->run_get_technology_preference) {
qmi_client_nas_get_technology_preference (
@@ -1817,17 +1801,11 @@ load_allowed_modes (MMIfaceModem *self,
user_data,
load_allowed_modes);
-#if defined WITH_NEWEST_QMI_COMMANDS
- /* System selection preference introduced in NAS 1.1
- * TODO: Not sure when the System Selection Preference got the
- * 'Mode Preference' TLV, so we'll need to handle the fallback. */
- ctx->run_get_system_selection_preference =
- (qmi_client_check_version (client, 1, 1) &&
- ctx->self->priv->has_mode_preference_in_system_selection_preference);
-#endif /* WITH_NEWEST_QMI_COMMANDS */
+ /* System selection preference introduced in NAS 1.1 */
+ ctx->run_get_system_selection_preference = qmi_client_check_version (client, 1, 1);
- /* Technology preference introduced in NAS 1.7 */
- ctx->run_get_technology_preference = qmi_client_check_version (client, 1, 7);
+ /* Technology preference introduced in NAS 1.0, so always available */
+ ctx->run_get_technology_preference = TRUE;
load_allowed_modes_context_step (ctx);
}
@@ -1841,9 +1819,7 @@ typedef struct {
GSimpleAsyncResult *result;
MMModemMode allowed;
MMModemMode preferred;
-#if defined WITH_NEWEST_QMI_COMMANDS
gboolean run_set_system_selection_preference;
-#endif /* WITH_NEWEST_QMI_COMMANDS */
gboolean run_set_technology_preference;
} SetAllowedModesContext;
@@ -1894,8 +1870,6 @@ set_technology_preference_ready (QmiClientNas *client,
set_allowed_modes_context_step (ctx);
}
-#if defined WITH_NEWEST_QMI_COMMANDS
-
static void
allowed_modes_set_system_selection_preference_ready (QmiClientNas *client,
GAsyncResult *res,
@@ -1909,10 +1883,6 @@ allowed_modes_set_system_selection_preference_ready (QmiClientNas *client,
mm_dbg ("QMI operation failed: %s", error->message);
g_error_free (error);
} else if (!qmi_message_nas_set_system_selection_preference_output_get_result (output, &error)) {
- if (g_error_matches (error,
- QMI_PROTOCOL_ERROR,
- QMI_PROTOCOL_ERROR_DEVICE_UNSUPPORTED))
- ctx->self->priv->has_mode_preference_in_system_selection_preference = FALSE;
mm_dbg ("Couldn't set system selection preference: %s", error->message);
g_error_free (error);
qmi_message_nas_set_system_selection_preference_output_unref (output);
@@ -1929,12 +1899,9 @@ allowed_modes_set_system_selection_preference_ready (QmiClientNas *client,
set_allowed_modes_context_step (ctx);
}
-#endif /* WITH_NEWEST_QMI_COMMANDS */
-
static void
set_allowed_modes_context_step (SetAllowedModesContext *ctx)
{
-#if defined WITH_NEWEST_QMI_COMMANDS
if (ctx->run_set_system_selection_preference) {
QmiMessageNasSetSystemSelectionPreferenceInput *input;
QmiNasRatModePreference pref;
@@ -1978,7 +1945,6 @@ set_allowed_modes_context_step (SetAllowedModesContext *ctx)
qmi_message_nas_set_system_selection_preference_input_unref (input);
return;
}
-#endif /* WITH_NEWEST_QMI_COMMANDS */
if (ctx->run_set_technology_preference) {
QmiMessageNasSetTechnologyPreferenceInput *input;
@@ -2056,17 +2022,11 @@ set_allowed_modes (MMIfaceModem *self,
ctx->allowed = allowed;
ctx->preferred = preferred;
-#if defined WITH_NEWEST_QMI_COMMANDS
- /* System selection preference introduced in NAS 1.1
- * TODO: Not sure when the System Selection Preference got the
- * 'Mode Preference' TLV, so we'll need to handle the fallback. */
- ctx->run_set_system_selection_preference =
- (qmi_client_check_version (client, 1, 1) &&
- ctx->self->priv->has_mode_preference_in_system_selection_preference);
-#endif /* WITH_NEWEST_QMI_COMMANDS */
+ /* System selection preference introduced in NAS 1.1 */
+ ctx->run_set_system_selection_preference = qmi_client_check_version (client, 1, 1);
- /* Technology preference introduced in NAS 1.7 */
- ctx->run_set_technology_preference = qmi_client_check_version (client, 1, 7);
+ /* Technology preference introduced in NAS 1.0, so always available */
+ ctx->run_set_technology_preference = TRUE;
set_allowed_modes_context_step (ctx);
}
@@ -4740,12 +4700,6 @@ mm_broadband_modem_qmi_init (MMBroadbandModemQmi *self)
self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self),
MM_TYPE_BROADBAND_MODEM_QMI,
MMBroadbandModemQmiPrivate);
-
-#if defined WITH_NEWEST_QMI_COMMANDS
- /* Some initial defaults for when we need to gather info about
- * supported commands/TLVs */
- self->priv->has_mode_preference_in_system_selection_preference = TRUE;
-#endif /* WITH_NEWEST_QMI_COMMANDS */
}
static void
diff --git a/src/mm-modem-helpers-qmi.c b/src/mm-modem-helpers-qmi.c
index 3c42dcbc..c170dba6 100644
--- a/src/mm-modem-helpers-qmi.c
+++ b/src/mm-modem-helpers-qmi.c
@@ -572,8 +572,6 @@ mm_modem_mode_to_qmi_radio_technology_preference (MMModemMode mode,
/*****************************************************************************/
-#if defined WITH_NEWEST_QMI_COMMANDS
-
MMModemMode
mm_modem_mode_from_qmi_rat_mode_preference (QmiNasRatModePreference qmi)
{
@@ -674,8 +672,6 @@ mm_modem_mode_to_qmi_gsm_wcdma_acquisition_order_preference (MMModemMode mode)
return MM_MODEM_MODE_NONE;
}
-#endif /* WITH_NEWEST_QMI_COMMANDS */
-
/*****************************************************************************/
MMModem3gppRegistrationState
diff --git a/src/mm-modem-helpers-qmi.h b/src/mm-modem-helpers-qmi.h
index 54c41bd1..4a69653b 100644
--- a/src/mm-modem-helpers-qmi.h
+++ b/src/mm-modem-helpers-qmi.h
@@ -47,8 +47,6 @@ MMModemMode mm_modem_mode_from_qmi_radio_technology_preference (QmiNasRadioTechn
QmiNasRadioTechnologyPreference mm_modem_mode_to_qmi_radio_technology_preference (MMModemMode mode,
gboolean is_cdma);
-#if defined WITH_NEWEST_QMI_COMMANDS
-
MMModemMode mm_modem_mode_from_qmi_rat_mode_preference (QmiNasRatModePreference qmi);
QmiNasRatModePreference mm_modem_mode_to_qmi_rat_mode_preference (MMModemMode mode,
gboolean is_cdma,
@@ -57,8 +55,6 @@ QmiNasRatModePreference mm_modem_mode_to_qmi_rat_mode_preference (MMModemMode mo
MMModemMode mm_modem_mode_from_qmi_gsm_wcdma_acquisition_order_preference (QmiNasGsmWcdmaAcquisitionOrderPreference qmi);
QmiNasGsmWcdmaAcquisitionOrderPreference mm_modem_mode_to_qmi_gsm_wcdma_acquisition_order_preference (MMModemMode mode);
-#endif /* WITH_NEWEST_QMI_COMMANDS */
-
GArray *mm_modem_bands_from_qmi_rf_band_information_array (GArray *info_array);
MMModem3gppRegistrationState mm_modem_3gpp_registration_state_from_qmi_registration_state (QmiNasAttachState attach_state,