Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Librem5
debs
Geoclue 2.0
Commits
ba3ba94d
Commit
ba3ba94d
authored
Apr 19, 2021
by
Guido Gunther
Browse files
Fix 4G location
In the 4G case we need to set the towerType to not fall back to GeoIP location.
parent
13d04f45
Changes
4
Hide whitespace changes
Inline
Side-by-side
debian/patches/pureos/3g-Track-tower-type.patch
0 → 100644
View file @
ba3ba94d
From: =?utf-8?q?Guido_G=C3=BCnther?= <agx@sigxcpu.org>
Date: Mon, 19 Apr 2021 17:39:29 +0200
Subject: 3g: Track tower type
We want to distinguish 3G and LTE towers since that information
is needed e.g. in mozillas location API.
(cherry picked from commit aaa285adc7b2e01d59513f3e4497283446033b1b)
---
src/gclue-3g-tower.h | 7 +++++++
src/gclue-3g.c | 12 +++++++-----
src/gclue-marshal.list | 1 +
src/gclue-modem-manager.c | 5 ++++-
src/gclue-modem.c | 7 ++++---
5 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/src/gclue-3g-tower.h b/src/gclue-3g-tower.h
index 2bbcae4..6b9391e 100644
--- a/src/gclue-3g-tower.h
+++ b/src/gclue-3g-tower.h
@@ -24,6 +24,12 @@
G_BEGIN_DECLS
+typedef enum {
+ GCLUE_TOWER_TEC_UNKNOWN = 0,
+ GCLUE_TOWER_TEC_3G = 1,
+ GCLUE_TOWER_TEC_4G = 2,
+} GClueTowerTec;
+
typedef struct _GClue3GTower GClue3GTower;
struct _GClue3GTower {
@@ -31,6 +37,7 @@
struct _GClue3GTower {
guint mnc;
gulong lac;
gulong cell_id;
+ GClueTowerTec tec;
};
G_END_DECLS
diff --git a/src/gclue-3g.c b/src/gclue-3g.c
index 4473102..d69b090 100644
--- a/src/gclue-3g.c
+++ b/src/gclue-3g.c
@@ -248,11 +248,12 @@
gclue_3g_get_available_accuracy_level (GClueWebSource *web,
}
static void
-on_fix_3g (GClueModem *modem,
- guint mcc,
- guint mnc,
- gulong lac,
- gulong cell_id,
+on_fix_3g (GClueModem *modem,
+ guint mcc,
+ guint mnc,
+ gulong lac,
+ gulong cell_id,
+ GClueTowerTec tec,
gpointer user_data)
{
GClue3GPrivate *priv = GCLUE_3G (user_data)->priv;
@@ -263,6 +264,7 @@
on_fix_3g (GClueModem *modem,
priv->tower->mnc = mnc;
priv->tower->lac = lac;
priv->tower->cell_id = cell_id;
+ priv->tower->tec = tec;
gclue_web_source_refresh (GCLUE_WEB_SOURCE (user_data));
}
diff --git a/src/gclue-marshal.list b/src/gclue-marshal.list
index 06068f0..2311586 100644
--- a/src/gclue-marshal.list
+++ b/src/gclue-marshal.list
@@ -1,2 +1,3 @@
VOID:UINT,UINT,ULONG,ULONG
+VOID:UINT,UINT,ULONG,ULONG,ENUM
VOID:DOUBLE,DOUBLE
diff --git a/src/gclue-modem-manager.c b/src/gclue-modem-manager.c
index a752b13..7950afc 100644
--- a/src/gclue-modem-manager.c
+++ b/src/gclue-modem-manager.c
@@ -25,6 +25,7 @@
#include <libmm-glib.h>
#include "gclue-modem-manager.h"
#include "gclue-marshal.h"
+#include "gclue-3g-tower.h"
/**
* SECTION:gclue-modem-manager
@@ -306,6 +307,7 @@
on_get_3gpp_ready (GObject *source_object,
GError *error = NULL;
guint mcc, mnc;
gulong lac, cell_id;
+ GClueTowerTec tec = GCLUE_TOWER_TEC_3G;
location_3gpp = mm_modem_location_get_3gpp_finish (modem_location,
res,
@@ -332,6 +334,7 @@
on_get_3gpp_ready (GObject *source_object,
// https://ichnaea.readthedocs.io/en/latest/api/geolocate.html#cell-tower-fields
if (lac == 0x0 || lac == 0xFFFE) {
lac = mm_location_3gpp_get_tracking_area_code(location_3gpp);
+ tec = GCLUE_TOWER_TEC_4G;
}
cell_id = mm_location_3gpp_get_cell_id (location_3gpp);
@@ -343,7 +346,7 @@
on_get_3gpp_ready (GObject *source_object,
g_clear_object (&priv->location_3gpp);
priv->location_3gpp = location_3gpp;
- g_signal_emit (manager, signals[FIX_3G], 0, mcc, mnc, lac, cell_id);
+ g_signal_emit (manager, signals[FIX_3G], 0, mcc, mnc, lac, cell_id, tec);
}
static void
diff --git a/src/gclue-modem.c b/src/gclue-modem.c
index c9ea386..4ee8230 100644
--- a/src/gclue-modem.c
+++ b/src/gclue-modem.c
@@ -78,13 +78,14 @@
gclue_modem_default_init (GClueModemInterface *iface)
0,
NULL,
NULL,
- gclue_marshal_VOID__UINT_UINT_ULONG_ULONG,
+ gclue_marshal_VOID__UINT_UINT_ULONG_ULONG_ENUM,
G_TYPE_NONE,
- 4,
+ 5,
G_TYPE_UINT,
G_TYPE_UINT,
G_TYPE_ULONG,
- G_TYPE_ULONG);
+ G_TYPE_ULONG,
+ G_TYPE_INT);
g_signal_new ("fix-cdma",
GCLUE_TYPE_MODEM,
debian/patches/pureos/gclue-modem-manager-Untabify.patch
0 → 100644
View file @
ba3ba94d
From: =?utf-8?q?Guido_G=C3=BCnther?= <agx@sigxcpu.org>
Date: Mon, 19 Apr 2021 17:56:31 +0200
Subject: gclue-modem-manager: Untabify
Rest of the file uses spaces.
(cherry picked from commit b4cf6517bbb38bd88db147df35f2f656fbbd19d0)
---
src/gclue-modem-manager.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/gclue-modem-manager.c b/src/gclue-modem-manager.c
index 90ef682..a752b13 100644
--- a/src/gclue-modem-manager.c
+++ b/src/gclue-modem-manager.c
@@ -326,13 +326,13 @@
on_get_3gpp_ready (GObject *source_object,
mnc = mm_location_3gpp_get_mobile_network_code (location_3gpp);
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) {
- lac = mm_location_3gpp_get_tracking_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) {
+ lac = mm_location_3gpp_get_tracking_area_code(location_3gpp);
+ }
cell_id = mm_location_3gpp_get_cell_id (location_3gpp);
debian/patches/pureos/gclue-mozilla-Add-per-tower-radio-type.patch
0 → 100644
View file @
ba3ba94d
From: =?utf-8?q?Guido_G=C3=BCnther?= <agx@sigxcpu.org>
Date: Mon, 19 Apr 2021 17:44:07 +0200
Subject: gclue-mozilla: Add per tower radio type
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Mozilla's API has a per tower `radioType` field¹. Without that filled in
it will assume GSM and hence ignore the provided data in case of 4G with
a locationAreaCode > 65535² and just fallback to GeoIP.
This changes the request from
{"radioType":"gsm","cellTowers":[{"cellId":45622821,"mobileCountryCode":262,"mobileNetworkCode":3,"locationAreaCode":47260}]}
to
{"radioType":"gsm","cellTowers":[{"cellId":45622821,"mobileCountryCode":262,"mobileNetworkCode":3,"locationAreaCode":47260,"radioType":"lte"}]}
and the returned result then matches the cell tower data from ³.
1: https://ichnaea.readthedocs.io/en/latest/api/geolocate.html#cell-tower-fields
2: See https://developers.google.com/maps/documentation/geolocation/overview#calculating_cell_id
3: https://location.services.mozilla.com/downloads
Fixes 5d15b65e60df84f741b436c254dc5eb4dc8e966c
(cherry picked from commit 89c20a5b84ea48b7a3b4107bc2c893ff32f1909a)
---
src/gclue-mozilla.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/gclue-mozilla.c b/src/gclue-mozilla.c
index ffdb77c..30b2da2 100644
--- a/src/gclue-mozilla.c
+++ b/src/gclue-mozilla.c
@@ -164,6 +164,10 @@
gclue_mozilla_create_query (GList *bss_list, /* As in Access Points */
json_builder_add_int_value (builder, tower->mnc);
json_builder_set_member_name (builder, "locationAreaCode");
json_builder_add_int_value (builder, tower->lac);
+ if (tower->tec == GCLUE_TOWER_TEC_4G) {
+ json_builder_set_member_name (builder, "radioType");
+ json_builder_add_string_value (builder, "lte");
+ }
json_builder_end_object (builder);
debian/patches/series
View file @
ba3ba94d
...
...
@@ -6,4 +6,7 @@ fix-nowifi-query.patch
0006-client-info-Support-cgroup-v2.patch
pureos/Bump-mm-glib-dep-to-1.10.patch
pureos/0006-Use-tracking-area-code-TAC-as-the-LAC-when-in-LTE-mo.patch
pureos/gclue-modem-manager-Untabify.patch
pureos/3g-Track-tower-type.patch
pureos/gclue-mozilla-Add-per-tower-radio-type.patch
pureos/geoclue.conf-Add-phosh.patch
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment