api,modem-3gpp: new 'InitialEpsBearerSettings' property

This property shows the settings stored in the device to be used
during the initial LTE attach procedure.
This commit is contained in:
Aleksander Morgado
2018-12-06 07:55:58 +01:00
committed by Dan Williams
parent 9c3ac2fb60
commit 8281b5048b
9 changed files with 408 additions and 158 deletions

View File

@@ -368,8 +368,29 @@ print_modem_info (void)
mmcli_output_pco_list (pco_list); mmcli_output_pco_list (pco_list);
if (mm_modem_get_current_capabilities (ctx->modem) & (MM_MODEM_CAPABILITY_LTE | MM_MODEM_CAPABILITY_LTE_ADVANCED)) { if (mm_modem_get_current_capabilities (ctx->modem) & (MM_MODEM_CAPABILITY_LTE | MM_MODEM_CAPABILITY_LTE_ADVANCED)) {
MMBearerProperties *properties = NULL;
const gchar *apn = NULL;
gchar *ip_family_str = NULL;
const gchar *user = NULL;
const gchar *password = NULL;
mmcli_output_string (MMC_F_3GPP_EPS_UE_MODE, eps_ue_mode); mmcli_output_string (MMC_F_3GPP_EPS_UE_MODE, eps_ue_mode);
mmcli_output_string (MMC_F_3GPP_EPS_INITIAL_BEARER_PATH, g_strcmp0 (initial_eps_bearer_path, "/") != 0 ? initial_eps_bearer_path : NULL); mmcli_output_string (MMC_F_3GPP_EPS_INITIAL_BEARER_PATH, g_strcmp0 (initial_eps_bearer_path, "/") != 0 ? initial_eps_bearer_path : NULL);
if (ctx->modem_3gpp) {
properties = mm_modem_3gpp_peek_initial_eps_bearer_settings (ctx->modem_3gpp);
if (properties) {
apn = mm_bearer_properties_get_apn (properties);
ip_family_str = (properties ? mm_bearer_ip_family_build_string_from_mask (mm_bearer_properties_get_ip_type (properties)) : NULL);
user = mm_bearer_properties_get_user (properties);
password = mm_bearer_properties_get_password (properties);
}
}
mmcli_output_string (MMC_F_3GPP_EPS_BEARER_SETTINGS_APN, apn);
mmcli_output_string_take (MMC_F_3GPP_EPS_BEARER_SETTINGS_IP_TYPE, ip_family_str);
mmcli_output_string (MMC_F_3GPP_EPS_BEARER_SETTINGS_USER, user);
mmcli_output_string (MMC_F_3GPP_EPS_BEARER_SETTINGS_PASSWORD, password);
} }
g_free (facility_locks); g_free (facility_locks);

View File

@@ -127,6 +127,10 @@ static FieldInfo field_infos[] = {
[MMC_F_3GPP_PCO] = { "modem.3gpp.pco", "pco", MMC_S_MODEM_3GPP, }, [MMC_F_3GPP_PCO] = { "modem.3gpp.pco", "pco", MMC_S_MODEM_3GPP, },
[MMC_F_3GPP_EPS_UE_MODE] = { "modem.3gpp.eps.ue-mode-operation", "ue mode of operation", MMC_S_MODEM_3GPP_EPS, }, [MMC_F_3GPP_EPS_UE_MODE] = { "modem.3gpp.eps.ue-mode-operation", "ue mode of operation", MMC_S_MODEM_3GPP_EPS, },
[MMC_F_3GPP_EPS_INITIAL_BEARER_PATH] = { "modem.3gpp.eps.initial-bearer.dbus-path", "initial bearer dbus path", MMC_S_MODEM_3GPP_EPS, }, [MMC_F_3GPP_EPS_INITIAL_BEARER_PATH] = { "modem.3gpp.eps.initial-bearer.dbus-path", "initial bearer dbus path", MMC_S_MODEM_3GPP_EPS, },
[MMC_F_3GPP_EPS_BEARER_SETTINGS_APN] = { "modem.3gpp.eps.initial-bearer.settings.apn", "initial bearer apn", MMC_S_MODEM_3GPP_EPS, },
[MMC_F_3GPP_EPS_BEARER_SETTINGS_IP_TYPE] = { "modem.3gpp.eps.initial-bearer.settings.ip-type", "initial bearer ip type", MMC_S_MODEM_3GPP_EPS, },
[MMC_F_3GPP_EPS_BEARER_SETTINGS_USER] = { "modem.3gpp.eps.initial-bearer.settings.user", "initial bearer user", MMC_S_MODEM_3GPP_EPS, },
[MMC_F_3GPP_EPS_BEARER_SETTINGS_PASSWORD] = { "modem.3gpp.eps.initial-bearer.settings.password", "initial bearer password", MMC_S_MODEM_3GPP_EPS, },
[MMC_F_3GPP_SCAN_NETWORKS] = { "modem.3gpp.scan-networks", "networks", MMC_S_MODEM_3GPP_SCAN, }, [MMC_F_3GPP_SCAN_NETWORKS] = { "modem.3gpp.scan-networks", "networks", MMC_S_MODEM_3GPP_SCAN, },
[MMC_F_3GPP_USSD_STATUS] = { "modem.3gpp.ussd.status", "status", MMC_S_MODEM_3GPP_USSD, }, [MMC_F_3GPP_USSD_STATUS] = { "modem.3gpp.ussd.status", "status", MMC_S_MODEM_3GPP_USSD, },
[MMC_F_3GPP_USSD_NETWORK_REQUEST] = { "modem.3gpp.ussd.network-request", "network request", MMC_S_MODEM_3GPP_USSD, }, [MMC_F_3GPP_USSD_NETWORK_REQUEST] = { "modem.3gpp.ussd.network-request", "network request", MMC_S_MODEM_3GPP_USSD, },

View File

@@ -129,6 +129,10 @@ typedef enum {
/* 3GPP EPS section */ /* 3GPP EPS section */
MMC_F_3GPP_EPS_UE_MODE, MMC_F_3GPP_EPS_UE_MODE,
MMC_F_3GPP_EPS_INITIAL_BEARER_PATH, MMC_F_3GPP_EPS_INITIAL_BEARER_PATH,
MMC_F_3GPP_EPS_BEARER_SETTINGS_APN,
MMC_F_3GPP_EPS_BEARER_SETTINGS_IP_TYPE,
MMC_F_3GPP_EPS_BEARER_SETTINGS_USER,
MMC_F_3GPP_EPS_BEARER_SETTINGS_PASSWORD,
/* 3GPP scan section */ /* 3GPP scan section */
MMC_F_3GPP_SCAN_NETWORKS, MMC_F_3GPP_SCAN_NETWORKS,
/* USSD section */ /* USSD section */

View File

@@ -284,6 +284,8 @@ mm_modem_3gpp_dup_initial_eps_bearer_path
mm_modem_3gpp_get_initial_eps_bearer mm_modem_3gpp_get_initial_eps_bearer
mm_modem_3gpp_get_initial_eps_bearer_finish mm_modem_3gpp_get_initial_eps_bearer_finish
mm_modem_3gpp_get_initial_eps_bearer_sync mm_modem_3gpp_get_initial_eps_bearer_sync
mm_modem_3gpp_get_initial_eps_bearer_settings
mm_modem_3gpp_peek_initial_eps_bearer_settings
<SUBSECTION Methods> <SUBSECTION Methods>
mm_modem_3gpp_register mm_modem_3gpp_register
mm_modem_3gpp_register_finish mm_modem_3gpp_register_finish
@@ -1770,6 +1772,8 @@ mm_gdbus_modem3gpp_get_pco
mm_gdbus_modem3gpp_dup_pco mm_gdbus_modem3gpp_dup_pco
mm_gdbus_modem3gpp_get_initial_eps_bearer mm_gdbus_modem3gpp_get_initial_eps_bearer
mm_gdbus_modem3gpp_dup_initial_eps_bearer mm_gdbus_modem3gpp_dup_initial_eps_bearer
mm_gdbus_modem3gpp_get_initial_eps_bearer_settings
mm_gdbus_modem3gpp_dup_initial_eps_bearer_settings
<SUBSECTION Methods> <SUBSECTION Methods>
mm_gdbus_modem3gpp_call_register mm_gdbus_modem3gpp_call_register
mm_gdbus_modem3gpp_call_register_finish mm_gdbus_modem3gpp_call_register_finish
@@ -1795,6 +1799,7 @@ mm_gdbus_modem3gpp_set_subscription_state
mm_gdbus_modem3gpp_set_eps_ue_mode_operation mm_gdbus_modem3gpp_set_eps_ue_mode_operation
mm_gdbus_modem3gpp_set_pco mm_gdbus_modem3gpp_set_pco
mm_gdbus_modem3gpp_set_initial_eps_bearer mm_gdbus_modem3gpp_set_initial_eps_bearer
mm_gdbus_modem3gpp_set_initial_eps_bearer_settings
<SUBSECTION Standard> <SUBSECTION Standard>
MM_GDBUS_IS_MODEM3GPP MM_GDBUS_IS_MODEM3GPP
MM_GDBUS_MODEM3GPP MM_GDBUS_MODEM3GPP

View File

@@ -182,5 +182,18 @@
--> -->
<property name="InitialEpsBearer" type="o" access="read" /> <property name="InitialEpsBearer" type="o" access="read" />
<!--
InitialEpsBearerSettings:
List of properties requested by the device for the initial EPS bearer during
LTE network attach procedure.
The network may decide to use different settings during the actual device attach
procedure, e.g. if the device is roaming or no explicit settings were requested,
so the properties shown in the #org.freedesktop.ModemManager1.Modem.Modem3gpp.InitialEpsBearer:InitialEpsBearer
may be totally different.
-->
<property name="InitialEpsBearerSettings" type="a{sv}" access="read" />
</interface> </interface>
</node> </node>

View File

@@ -43,6 +43,13 @@
G_DEFINE_TYPE (MMModem3gpp, mm_modem_3gpp, MM_GDBUS_TYPE_MODEM3GPP_PROXY) G_DEFINE_TYPE (MMModem3gpp, mm_modem_3gpp, MM_GDBUS_TYPE_MODEM3GPP_PROXY)
struct _MMModem3gppPrivate {
/* Properties */
GMutex initial_eps_bearer_settings_mutex;
guint initial_eps_bearer_settings_id;
MMBearerProperties *initial_eps_bearer_settings;
};
/*****************************************************************************/ /*****************************************************************************/
/** /**
@@ -567,6 +574,117 @@ mm_modem_3gpp_network_get_access_technology (const MMModem3gppNetwork *network)
/*****************************************************************************/ /*****************************************************************************/
static void
initial_eps_bearer_settings_updated (MMModem3gpp *self,
GParamSpec *pspec)
{
g_mutex_lock (&self->priv->initial_eps_bearer_settings_mutex);
{
GVariant *dictionary;
g_clear_object (&self->priv->initial_eps_bearer_settings);
dictionary = mm_gdbus_modem3gpp_get_initial_eps_bearer_settings (MM_GDBUS_MODEM3GPP (self));
if (dictionary) {
GError *error = NULL;
self->priv->initial_eps_bearer_settings = mm_bearer_properties_new_from_dictionary (dictionary, &error);
if (error) {
g_warning ("Invalid bearer properties received: %s", error->message);
g_error_free (error);
}
}
}
g_mutex_unlock (&self->priv->initial_eps_bearer_settings_mutex);
}
static void
ensure_internal_initial_eps_bearer_settings (MMModem3gpp *self,
MMBearerProperties **dup)
{
g_mutex_lock (&self->priv->initial_eps_bearer_settings_mutex);
{
/* If this is the first time ever asking for the object, setup the
* update listener and the initial object, if any. */
if (!self->priv->initial_eps_bearer_settings_id) {
GVariant *dictionary;
dictionary = mm_gdbus_modem3gpp_dup_initial_eps_bearer_settings (MM_GDBUS_MODEM3GPP (self));
if (dictionary) {
GError *error = NULL;
self->priv->initial_eps_bearer_settings = mm_bearer_properties_new_from_dictionary (dictionary, &error);
if (error) {
g_warning ("Invalid initial bearer properties: %s", error->message);
g_error_free (error);
}
g_variant_unref (dictionary);
}
/* No need to clear this signal connection when freeing self */
self->priv->initial_eps_bearer_settings_id =
g_signal_connect (self,
"notify::initial-eps-bearer-properties",
G_CALLBACK (initial_eps_bearer_settings_updated),
NULL);
}
if (dup && self->priv->initial_eps_bearer_settings)
*dup = g_object_ref (self->priv->initial_eps_bearer_settings);
}
g_mutex_unlock (&self->priv->initial_eps_bearer_settings_mutex);
}
/**
* mm_modem_3gpp_get_initial_eps_bearer_settings:
* @self: A #MMModem3gpp.
*
* Gets a #MMBearerProperties object specifying the settings configured in
* the device to use when attaching to the LTE network.
*
* <warning>The values reported by @self are not updated when the values in the
* interface change. Instead, the client is expected to call
* mm_modem_3gpp_get_initial_eps_bearer_settings() again to get a new #MMBearerProperties with the
* new values.</warning>
*
* Returns: (transfer full): A #MMBearerProperties that must be freed with g_object_unref() or %NULL if unknown.
*/
MMBearerProperties *
mm_modem_3gpp_get_initial_eps_bearer_settings (MMModem3gpp *self)
{
MMBearerProperties *props = NULL;
g_return_val_if_fail (MM_IS_MODEM_3GPP (self), NULL);
ensure_internal_initial_eps_bearer_settings (self, &props);
return props;
}
/**
* mm_modem_3gpp_peek_initial_eps_bearer_settings:
* @self: A #MMModem3gpp.
*
* Gets a #MMBearerProperties object specifying the settings configured in
* the device to use when attaching to the LTE network.
*
* <warning>The returned value is only valid until the property changes so
* it is only safe to use this function on the thread where
* @self was constructed. Use mm_modem_3gpp_get_initial_eps_bearer_settings() if on another
* thread.</warning>
*
* Returns: (transfer none): A #MMBearerProperties. Do not free the returned value, it belongs to @self.
*/
MMBearerProperties *
mm_modem_3gpp_peek_initial_eps_bearer_settings (MMModem3gpp *self)
{
g_return_val_if_fail (MM_IS_MODEM_3GPP (self), NULL);
ensure_internal_initial_eps_bearer_settings (self, NULL);
return self->priv->initial_eps_bearer_settings;
}
/*****************************************************************************/
static GList * static GList *
create_networks_list (GVariant *variant) create_networks_list (GVariant *variant)
{ {
@@ -914,9 +1032,38 @@ mm_modem_3gpp_get_initial_eps_bearer_sync (MMModem3gpp *self,
static void static void
mm_modem_3gpp_init (MMModem3gpp *self) mm_modem_3gpp_init (MMModem3gpp *self)
{ {
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, MM_TYPE_MODEM_3GPP, MMModem3gppPrivate);
g_mutex_init (&self->priv->initial_eps_bearer_settings_mutex);
}
static void
finalize (GObject *object)
{
MMModem3gpp *self = MM_MODEM_3GPP (object);
g_mutex_clear (&self->priv->initial_eps_bearer_settings_mutex);
G_OBJECT_CLASS (mm_modem_3gpp_parent_class)->finalize (object);
}
static void
dispose (GObject *object)
{
MMModem3gpp *self = MM_MODEM_3GPP (object);
g_clear_object (&self->priv->initial_eps_bearer_settings);
G_OBJECT_CLASS (mm_modem_3gpp_parent_class)->dispose (object);
} }
static void static void
mm_modem_3gpp_class_init (MMModem3gppClass *modem_class) mm_modem_3gpp_class_init (MMModem3gppClass *modem_class)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (modem_class);
g_type_class_add_private (object_class, sizeof (MMModem3gppPrivate));
/* Virtual methods */
object_class->dispose = dispose;
object_class->finalize = finalize;
} }

View File

@@ -44,6 +44,7 @@ G_BEGIN_DECLS
typedef struct _MMModem3gpp MMModem3gpp; typedef struct _MMModem3gpp MMModem3gpp;
typedef struct _MMModem3gppClass MMModem3gppClass; typedef struct _MMModem3gppClass MMModem3gppClass;
typedef struct _MMModem3gppPrivate MMModem3gppPrivate;
/** /**
* MMModem3gpp: * MMModem3gpp:
@@ -54,7 +55,7 @@ typedef struct _MMModem3gppClass MMModem3gppClass;
struct _MMModem3gpp { struct _MMModem3gpp {
/*< private >*/ /*< private >*/
MmGdbusModem3gppProxy parent; MmGdbusModem3gppProxy parent;
gpointer unused; MMModem3gppPrivate *priv;
}; };
struct _MMModem3gppClass { struct _MMModem3gppClass {
@@ -87,6 +88,9 @@ GList *mm_modem_3gpp_get_pco (MMModem3gpp *self);
const gchar *mm_modem_3gpp_get_initial_eps_bearer_path (MMModem3gpp *self); const gchar *mm_modem_3gpp_get_initial_eps_bearer_path (MMModem3gpp *self);
gchar *mm_modem_3gpp_dup_initial_eps_bearer_path (MMModem3gpp *self); gchar *mm_modem_3gpp_dup_initial_eps_bearer_path (MMModem3gpp *self);
MMBearerProperties *mm_modem_3gpp_get_initial_eps_bearer_settings (MMModem3gpp *self);
MMBearerProperties *mm_modem_3gpp_peek_initial_eps_bearer_settings (MMModem3gpp *self);
void mm_modem_3gpp_register (MMModem3gpp *self, void mm_modem_3gpp_register (MMModem3gpp *self,
const gchar *network_id, const gchar *network_id,
GCancellable *cancellable, GCancellable *cancellable,

View File

@@ -2049,6 +2049,7 @@ typedef enum {
INITIALIZATION_STEP_IMEI, INITIALIZATION_STEP_IMEI,
INITIALIZATION_STEP_ENABLED_FACILITY_LOCKS, INITIALIZATION_STEP_ENABLED_FACILITY_LOCKS,
INITIALIZATION_STEP_EPS_UE_MODE_OPERATION, INITIALIZATION_STEP_EPS_UE_MODE_OPERATION,
INITIALIZATION_STEP_EPS_INITIAL_BEARER_SETTINGS,
INITIALIZATION_STEP_LAST INITIALIZATION_STEP_LAST
} InitializationStep; } InitializationStep;
@@ -2080,6 +2081,36 @@ sim_pin_lock_enabled_cb (MMBaseSim *self,
mm_gdbus_modem3gpp_set_enabled_facility_locks (skeleton, facilities); mm_gdbus_modem3gpp_set_enabled_facility_locks (skeleton, facilities);
} }
static void
load_initial_eps_bearer_settings_ready (MMIfaceModem3gpp *self,
GAsyncResult *res,
GTask *task)
{
InitializationContext *ctx;
MMBearerProperties *config;
GError *error = NULL;
ctx = g_task_get_task_data (task);
config = MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->load_initial_eps_bearer_settings_finish (self, res, &error);
if (!config) {
mm_warn ("couldn't load initial EPS bearer settings: '%s'", error->message);
g_error_free (error);
} else {
GVariant *dictionary;
dictionary = mm_bearer_properties_get_dictionary (config);
mm_gdbus_modem3gpp_set_initial_eps_bearer_settings (ctx->skeleton, dictionary);
g_object_unref (config);
if (dictionary)
g_variant_unref (dictionary);
}
/* Go on to next step */
ctx->step++;
interface_initialization_step (task);
}
static void static void
load_eps_ue_mode_operation_ready (MMIfaceModem3gpp *self, load_eps_ue_mode_operation_ready (MMIfaceModem3gpp *self,
GAsyncResult *res, GAsyncResult *res,
@@ -2228,6 +2259,19 @@ interface_initialization_step (GTask *task)
/* Fall down to next step */ /* Fall down to next step */
ctx->step++; ctx->step++;
case INITIALIZATION_STEP_EPS_INITIAL_BEARER_SETTINGS:
if (MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->load_initial_eps_bearer_settings &&
MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->load_initial_eps_bearer_settings_finish) {
MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->load_initial_eps_bearer_settings (
self,
(GAsyncReadyCallback)load_initial_eps_bearer_settings_ready,
task);
return;
}
/* Fall down to next step */
ctx->step++;
case INITIALIZATION_STEP_LAST: case INITIALIZATION_STEP_LAST:
/* We are done without errors! */ /* We are done without errors! */

View File

@@ -155,6 +155,14 @@ struct _MMIfaceModem3gpp {
GAsyncResult *res, GAsyncResult *res,
GError **error); GError **error);
/* Asynchronous initial default EPS bearer settings loading */
void (*load_initial_eps_bearer_settings) (MMIfaceModem3gpp *self,
GAsyncReadyCallback callback,
gpointer user_data);
MMBearerProperties * (*load_initial_eps_bearer_settings_finish) (MMIfaceModem3gpp *self,
GAsyncResult *res,
GError **error);
/* Create initial default EPS bearer object */ /* Create initial default EPS bearer object */
MMBaseBearer * (*create_initial_eps_bearer) (MMIfaceModem3gpp *self, MMBaseBearer * (*create_initial_eps_bearer) (MMIfaceModem3gpp *self,
MMBearerProperties *properties); MMBearerProperties *properties);