summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShoji Keita <awaittrot@shjk.jp>2022-05-04 15:07:58 +0900
committerTeemu Ikonen <tpikonen@mailbox.org>2022-10-26 10:33:21 +0000
commit843118c5d3db2d9e76ddb515345107ea7b40d616 (patch)
tree4777b56e8800b791829de887ca1f1e807748f6e8
parenta55afb6e377d18d200fa0d5ee57797e86e7b85de (diff)
downloadgeoclue-843118c5d3db2d9e76ddb515345107ea7b40d616.tar.gz
modem: Get radio type from modem
-rw-r--r--src/gclue-3g-tower.h5
-rw-r--r--src/gclue-modem-manager.c44
2 files changed, 32 insertions, 17 deletions
diff --git a/src/gclue-3g-tower.h b/src/gclue-3g-tower.h
index 15d8c87..a40e1fe 100644
--- a/src/gclue-3g-tower.h
+++ b/src/gclue-3g-tower.h
@@ -26,8 +26,9 @@ G_BEGIN_DECLS
typedef enum {
GCLUE_TOWER_TEC_UNKNOWN = 0,
- GCLUE_TOWER_TEC_3G = 1,
- GCLUE_TOWER_TEC_4G = 2,
+ GCLUE_TOWER_TEC_2G = 1,
+ GCLUE_TOWER_TEC_3G = 2,
+ GCLUE_TOWER_TEC_4G = 3,
GCLUE_TOWER_TEC_NO_FIX = 99,
} GClueTowerTec;
diff --git a/src/gclue-modem-manager.c b/src/gclue-modem-manager.c
index 5c03d80..6ed889e 100644
--- a/src/gclue-modem-manager.c
+++ b/src/gclue-modem-manager.c
@@ -51,6 +51,7 @@ struct _GClueModemManagerPrivate {
GCancellable *cancellable;
MMModemLocationSource caps; /* Caps we set or are going to set */
+ GClueTowerTec tec;
guint time_threshold;
};
@@ -287,7 +288,8 @@ static gboolean
is_location_3gpp_same (GClueModemManager *manager,
const gchar *new_opc,
gulong new_lac,
- gulong new_cell_id)
+ gulong new_cell_id,
+ GClueTowerTec new_tec)
{
GClueModemManagerPrivate *priv = manager->priv;
const gchar *opc;
@@ -307,11 +309,10 @@ is_location_3gpp_same (GClueModemManager *manager,
#endif
lac = mm_location_3gpp_get_location_area_code (priv->location_3gpp);
- // Most likely this is an LTE connection and with the mozilla
- // services they use the tracking area code in place of the
- // location area code in this case.
+ // Use the tracking area code in place of the
+ // location area code for LTE.
// https://ichnaea.readthedocs.io/en/latest/api/geolocate.html#cell-tower-fields
- if (lac == 0x0 || lac == 0xFFFE) {
+ if (priv->tec == GCLUE_TOWER_TEC_4G) {
lac = mm_location_3gpp_get_tracking_area_code(priv->location_3gpp);
}
@@ -319,7 +320,8 @@ is_location_3gpp_same (GClueModemManager *manager,
return (g_strcmp0 (opc, new_opc) == 0 &&
lac == new_lac &&
- cell_id == new_cell_id);
+ cell_id == new_cell_id &&
+ priv->tec == new_tec);
}
static void clear_3gpp_location (GClueModemManager *manager)
@@ -342,10 +344,11 @@ on_get_3gpp_ready (GObject *source_object,
GClueModemManager *manager;
GClueModemManagerPrivate *priv;
MMModemLocation *modem_location = MM_MODEM_LOCATION (source_object);
+ MMModemAccessTechnology modem_access_tec;
g_autoptr(MMLocation3gpp) location_3gpp = NULL;
const gchar *opc;
gulong lac, cell_id;
- GClueTowerTec tec = GCLUE_TOWER_TEC_3G;
+ GClueTowerTec tec;
#if !MM_CHECK_VERSION(1, 18, 0)
g_autoptr(GError) error = NULL;
gchar opc_buf[GCLUE_3G_TOWER_OPERATOR_CODE_STR_LEN + 1];
@@ -386,24 +389,35 @@ on_get_3gpp_ready (GObject *source_object,
lac = mm_location_3gpp_get_location_area_code (location_3gpp);
- // Most likely this is an LTE connection and with the mozilla
- // services they use the tracking area code in place of the
- // location area code in this case.
- // https://ichnaea.readthedocs.io/en/latest/api/geolocate.html#cell-tower-fields
- if (lac == 0x0 || lac == 0xFFFE) {
+ cell_id = mm_location_3gpp_get_cell_id (location_3gpp);
+
+ modem_access_tec = mm_modem_get_access_technologies(priv->modem);
+
+ if (modem_access_tec == MM_MODEM_ACCESS_TECHNOLOGY_GSM ||
+ modem_access_tec == MM_MODEM_ACCESS_TECHNOLOGY_GPRS ||
+ modem_access_tec == MM_MODEM_ACCESS_TECHNOLOGY_EDGE) {
+ tec = GCLUE_TOWER_TEC_2G;
+ } else if (modem_access_tec == MM_MODEM_ACCESS_TECHNOLOGY_UMTS ||
+ modem_access_tec == MM_MODEM_ACCESS_TECHNOLOGY_HSDPA ||
+ modem_access_tec == MM_MODEM_ACCESS_TECHNOLOGY_HSUPA ||
+ modem_access_tec == MM_MODEM_ACCESS_TECHNOLOGY_HSPA ||
+ modem_access_tec == MM_MODEM_ACCESS_TECHNOLOGY_HSPA_PLUS) {
+ tec = GCLUE_TOWER_TEC_3G;
+ } else if (modem_access_tec == MM_MODEM_ACCESS_TECHNOLOGY_LTE) {
lac = mm_location_3gpp_get_tracking_area_code(location_3gpp);
tec = GCLUE_TOWER_TEC_4G;
+ } else {
+ tec = GCLUE_TOWER_TEC_UNKNOWN;
}
- cell_id = mm_location_3gpp_get_cell_id (location_3gpp);
-
- if (is_location_3gpp_same (manager, opc, lac, cell_id)) {
+ if (is_location_3gpp_same (manager, opc, lac, cell_id, tec)) {
g_debug ("New 3GPP location is same as last one");
return;
}
g_clear_object (&priv->location_3gpp);
priv->location_3gpp = g_steal_pointer (&location_3gpp);
priv->location_3gpp_ignore_previous = FALSE;
+ priv->tec = tec;
g_signal_emit (manager, signals[FIX_3G], 0, opc, lac, cell_id, tec);
}