option: disable preferred networks management in custom SIM object

It's been observed that running CPOL? would completely break the AT
port of the modules like the GIO225.

Fully disable this feature in the whole option and option-hso plugins,
by creating a new custom SIM object with the features disabled
completely, and setup as a new shared interface object.

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/404
This commit is contained in:
Aleksander Morgado
2021-07-27 00:10:02 +02:00
parent af0fba0585
commit 0d1952c489
7 changed files with 285 additions and 0 deletions
+4
View File
@@ -228,6 +228,10 @@ if WITH_SHARED_OPTION
pkglib_LTLIBRARIES += libmm-shared-option.la
libmm_shared_option_la_SOURCES = \
option/mm-shared.c \
option/mm-shared-option.h \
option/mm-shared-option.c \
option/mm-sim-option.c \
option/mm-sim-option.h \
option/mm-broadband-modem-option.c \
option/mm-broadband-modem-option.h \
$(NULL)
+10
View File
@@ -34,7 +34,9 @@
#include "mm-broadband-modem-hso.h"
#include "mm-broadband-bearer-hso.h"
#include "mm-bearer-list.h"
#include "mm-shared-option.h"
static void shared_option_init (MMSharedOption *iface);
static void iface_modem_init (MMIfaceModem *iface);
static void iface_modem_3gpp_init (MMIfaceModem3gpp *iface);
static void iface_modem_location_init (MMIfaceModemLocation *iface);
@@ -43,6 +45,7 @@ static MMIfaceModem3gpp *iface_modem_3gpp_parent;
static MMIfaceModemLocation *iface_modem_location_parent;
G_DEFINE_TYPE_EXTENDED (MMBroadbandModemHso, mm_broadband_modem_hso, MM_TYPE_BROADBAND_MODEM_OPTION, 0,
G_IMPLEMENT_INTERFACE (MM_TYPE_SHARED_OPTION, shared_option_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM, iface_modem_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_3GPP, iface_modem_3gpp_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_LOCATION, iface_modem_location_init));
@@ -728,9 +731,16 @@ mm_broadband_modem_hso_init (MMBroadbandModemHso *self)
self->priv->enabled_sources = MM_MODEM_LOCATION_SOURCE_NONE;
}
static void
shared_option_init (MMSharedOption *iface)
{
}
static void
iface_modem_init (MMIfaceModem *iface)
{
iface->create_sim = mm_shared_option_create_sim;
iface->create_sim_finish = mm_shared_option_create_sim_finish;
iface->create_bearer = modem_create_bearer;
iface->create_bearer_finish = modem_create_bearer_finish;
iface->load_unlock_retries = load_unlock_retries;
@@ -31,7 +31,9 @@
#include "mm-iface-modem-3gpp.h"
#include "mm-base-modem-at.h"
#include "mm-broadband-modem-option.h"
#include "mm-shared-option.h"
static void shared_option_init (MMSharedOption *iface);
static void iface_modem_init (MMIfaceModem *iface);
static void iface_modem_3gpp_init (MMIfaceModem3gpp *iface);
@@ -39,6 +41,7 @@ static MMIfaceModem *iface_modem_parent;
static MMIfaceModem3gpp *iface_modem_3gpp_parent;
G_DEFINE_TYPE_EXTENDED (MMBroadbandModemOption, mm_broadband_modem_option, MM_TYPE_BROADBAND_MODEM, 0,
G_IMPLEMENT_INTERFACE (MM_TYPE_SHARED_OPTION, shared_option_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM, iface_modem_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_3GPP, iface_modem_3gpp_init))
@@ -1179,11 +1182,18 @@ mm_broadband_modem_option_init (MMBroadbandModemOption *self)
G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
}
static void
shared_option_init (MMSharedOption *iface)
{
}
static void
iface_modem_init (MMIfaceModem *iface)
{
iface_modem_parent = g_type_interface_peek_parent (iface);
iface->create_sim = mm_shared_option_create_sim;
iface->create_sim_finish = mm_shared_option_create_sim_finish;
iface->modem_after_power_up = modem_after_power_up;
iface->modem_after_power_up_finish = modem_after_power_up_finish;
iface->load_access_technologies = load_access_technologies;
+77
View File
@@ -0,0 +1,77 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
*
* Copyright (C) 2021 Aleksander Morgado <aleksander@aleksander.es>
*/
#include <config.h>
#include <stdio.h>
#include <glib-object.h>
#include <gio/gio.h>
#define _LIBMM_INSIDE_MM
#include <libmm-glib.h>
#include "mm-log-object.h"
#include "mm-iface-modem.h"
#include "mm-sim-option.h"
#include "mm-shared-option.h"
/*****************************************************************************/
/* Create SIM (Modem inteface) */
MMBaseSim *
mm_shared_option_create_sim_finish (MMIfaceModem *self,
GAsyncResult *res,
GError **error)
{
return mm_sim_option_new_finish (res, error);
}
void
mm_shared_option_create_sim (MMIfaceModem *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
mm_sim_option_new (MM_BASE_MODEM (self),
NULL, /* cancellable */
callback,
user_data);
}
/*****************************************************************************/
static void
shared_option_init (gpointer g_iface)
{
}
GType
mm_shared_option_get_type (void)
{
static GType shared_option_type = 0;
if (!G_UNLIKELY (shared_option_type)) {
static const GTypeInfo info = {
sizeof (MMSharedOption), /* class_size */
shared_option_init, /* base_init */
NULL, /* base_finalize */
};
shared_option_type = g_type_register_static (G_TYPE_INTERFACE, "MMSharedOption", &info, 0);
g_type_interface_add_prerequisite (shared_option_type, MM_TYPE_IFACE_MODEM);
}
return shared_option_type;
}
+49
View File
@@ -0,0 +1,49 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
*
* Copyright (C) 2021 Aleksander Morgado <aleksander@aleksander.es>
*/
#ifndef MM_SHARED_OPTION_H
#define MM_SHARED_OPTION_H
#include <glib-object.h>
#include <gio/gio.h>
#define _LIBMM_INSIDE_MM
#include <libmm-glib.h>
#include "mm-broadband-modem.h"
#include "mm-iface-modem.h"
#include "mm-iface-modem-location.h"
#define MM_TYPE_SHARED_OPTION (mm_shared_option_get_type ())
#define MM_SHARED_OPTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_SHARED_OPTION, MMSharedOption))
#define MM_IS_SHARED_OPTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_SHARED_OPTION))
#define MM_SHARED_OPTION_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), MM_TYPE_SHARED_OPTION, MMSharedOption))
typedef struct _MMSharedOption MMSharedOption;
struct _MMSharedOption {
GTypeInterface g_iface;
};
GType mm_shared_option_get_type (void);
void mm_shared_option_create_sim (MMIfaceModem *self,
GAsyncReadyCallback callback,
gpointer user_data);
MMBaseSim *mm_shared_option_create_sim_finish (MMIfaceModem *self,
GAsyncResult *res,
GError **error);
#endif /* MM_SHARED_OPTION_H */
+84
View File
@@ -0,0 +1,84 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
*
* Copyright (C) 2021 Aleksander Morgado <aleksander@aleksander.es>
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include <ModemManager.h>
#define _LIBMM_INSIDE_MM
#include <libmm-glib.h>
#include "mm-sim-option.h"
G_DEFINE_TYPE (MMSimOption, mm_sim_option, MM_TYPE_BASE_SIM)
/*****************************************************************************/
MMBaseSim *
mm_sim_option_new_finish (GAsyncResult *res,
GError **error)
{
GObject *source;
GObject *sim;
source = g_async_result_get_source_object (res);
sim = g_async_initable_new_finish (G_ASYNC_INITABLE (source), res, error);
g_object_unref (source);
if (!sim)
return NULL;
/* Only export valid SIMs */
mm_base_sim_export (MM_BASE_SIM (sim));
return MM_BASE_SIM (sim);
}
void
mm_sim_option_new (MMBaseModem *modem,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_async_initable_new_async (MM_TYPE_SIM_OPTION,
G_PRIORITY_DEFAULT,
cancellable,
callback,
user_data,
MM_BASE_SIM_MODEM, modem,
"active", TRUE, /* by default always active */
NULL);
}
static void
mm_sim_option_init (MMSimOption *self)
{
}
static void
mm_sim_option_class_init (MMSimOptionClass *klass)
{
MMBaseSimClass *base_sim_class = MM_BASE_SIM_CLASS (klass);
/* Skip managing preferred networks, not supported by Option modems */
base_sim_class->load_preferred_networks = NULL;
base_sim_class->load_preferred_networks_finish = NULL;
base_sim_class->set_preferred_networks = NULL;
base_sim_class->set_preferred_networks_finish = NULL;
}
+51
View File
@@ -0,0 +1,51 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
*
* Copyright (C) 2021 Aleksander Morgado <aleksander@aleksander.es>
*/
#ifndef MM_SIM_OPTION_H
#define MM_SIM_OPTION_H
#include <glib.h>
#include <glib-object.h>
#include "mm-base-sim.h"
#define MM_TYPE_SIM_OPTION (mm_sim_option_get_type ())
#define MM_SIM_OPTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_SIM_OPTION, MMSimOption))
#define MM_SIM_OPTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_SIM_OPTION, MMSimOptionClass))
#define MM_IS_SIM_OPTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_SIM_OPTION))
#define MM_IS_SIM_OPTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_SIM_OPTION))
#define MM_SIM_OPTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_SIM_OPTION, MMSimOptionClass))
typedef struct _MMSimOption MMSimOption;
typedef struct _MMSimOptionClass MMSimOptionClass;
struct _MMSimOption {
MMBaseSim parent;
};
struct _MMSimOptionClass {
MMBaseSimClass parent;
};
GType mm_sim_option_get_type (void);
void mm_sim_option_new (MMBaseModem *modem,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
MMBaseSim *mm_sim_option_new_finish (GAsyncResult *res,
GError **error);
#endif /* MM_SIM_OPTION_H */