summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <pwithnall@endlessos.org>2020-11-18 15:38:08 +0000
committerZeeshan Ali <zeeshanak@gnome.org>2020-12-23 12:37:40 +0100
commit77ac07782856c73e26ffb58f7a819860b970fb7c (patch)
tree21a1e3b093f39b0791fc184ab166b004bcf5e8c2
parentc02e7943d22e5c0720a2165301db9a358d71e782 (diff)
downloadgeoclue-77ac07782856c73e26ffb58f7a819860b970fb7c.tar.gz
gclue-mozilla: Don’t submit a single BSS entry in a query
The MLS documentation says: > All of the fields are optional, but in order to get a Bluetooth or > WiFi based position estimate at least two networks need to be provided > and include a macAddress. The two networks minimum is a mandatory > privacy restriction for Bluetooth and WiFi based location services. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
-rw-r--r--src/gclue-mozilla.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/gclue-mozilla.c b/src/gclue-mozilla.c
index 665cefc..ffdb77c 100644
--- a/src/gclue-mozilla.c
+++ b/src/gclue-mozilla.c
@@ -124,13 +124,28 @@ gclue_mozilla_create_query (GList *bss_list, /* As in Access Points */
char *data;
gsize data_len;
const char *uri;
+ guint n_non_ignored_bsss;
+ GList *iter;
builder = json_builder_new ();
json_builder_begin_object (builder);
/* We send pure geoip query using empty object if both bss_list and
* tower are NULL.
+ *
+ * If the list of non-ignored BSSs is <2, don’t bother submitting the
+ * BSS list as MLS will only do a geoip lookup anyway.
+ * See https://ichnaea.readthedocs.io/en/latest/api/geolocate.html#field-definition
*/
+ n_non_ignored_bsss = 0;
+ for (iter = bss_list; iter != NULL; iter = iter->next) {
+ WPABSS *bss = WPA_BSS (iter->data);
+
+ if (gclue_mozilla_should_ignore_bss (bss))
+ continue;
+
+ n_non_ignored_bsss++;
+ }
if (tower != NULL) {
json_builder_set_member_name (builder, "radioType");
@@ -155,9 +170,7 @@ gclue_mozilla_create_query (GList *bss_list, /* As in Access Points */
json_builder_end_array (builder);
}
- if (bss_list != NULL) {
- GList *iter;
-
+ if (n_non_ignored_bsss >= 2) {
json_builder_set_member_name (builder, "wifiAccessPoints");
json_builder_begin_array (builder);