Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 56c69be8 authored by Quallenauge's avatar Quallenauge Committed by Jacob Mueller
Browse files

Wifi: Use bss->age identifier for wifi scan results

This value will be used as "timestamp" and Google Play Services
uses this value for identifying sane wifi scan items.

The current timestamp (tsf=) has a different meaning, which causes
the Google Location Resolver to ignore all wifi scan entries and
therefore no location can be resolved.

This solution is already done on batched result parsing, but
missing on the traditional scans.

Change-Id: I36a1aeb666379e6a010298f09161e971012db83f
parent db1422a3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -279,7 +279,7 @@ public class WifiNative {
     * MASK=<N> see wpa_supplicant/src/common/wpa_ctrl.h for details
     */
    public String scanResults(int sid) {
        return doStringCommandWithoutLogging("BSS RANGE=" + sid + "- MASK=0x21987");
        return doStringCommandWithoutLogging("BSS RANGE=" + sid + "- MASK=0x21B87");
    }

    /**
+12 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 The CyanogenMod Project
 * Copyright (C) 2010 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
@@ -1916,6 +1917,7 @@ public class WifiStateMachine extends StateMachine {
    private static final String FLAGS_STR = "flags=";
    private static final String SSID_STR = "ssid=";
    private static final String DELIMITER_STR = "====";
    private static final String AGE_STR = "age=";
    private static final String END_STR = "####";

    /**
@@ -1987,6 +1989,8 @@ public class WifiStateMachine extends StateMachine {
            final int bssidStrLen = BSSID_STR.length();
            final int flagLen = FLAGS_STR.length();

            final long now = SystemClock.elapsedRealtime();

            for (String line : lines) {
                if (line.startsWith(BSSID_STR)) {
                    bssid = new String(line.getBytes(), bssidStrLen, line.length() - bssidStrLen);
@@ -2012,6 +2016,14 @@ public class WifiStateMachine extends StateMachine {
                    } catch (NumberFormatException e) {
                        tsf = 0;
                    }
                } else if (line.startsWith(AGE_STR)) {
                    try {
                        tsf = now - Long.parseLong(line.substring(AGE_STR.length()));
                        tsf *= 1000; // Convert mS -> uS
                    } catch (NumberFormatException e) {
                        loge("Invalid timestamp: " + line);
                        tsf = 0;
                    }
                } else if (line.startsWith(FLAGS_STR)) {
                    flags = new String(line.getBytes(), flagLen, line.length() - flagLen);
                } else if (line.startsWith(SSID_STR)) {