microg / GmsCore

Free implementation of Play Services
https://microg.org
Apache License 2.0
7.43k stars 1.6k forks source link

Cell towers, Location on new engine, low accuracy. #2391

Open kvak54 opened 3 weeks ago

kvak54 commented 3 weeks ago

Describe the bug microG with new location engine (v0.3.2) send only one cell tower on mozilla location server -> location low accuracy.

To Reproduce Steps to reproduce the behavior:

  1. Go to microG Settings
  2. Click on "Location"
  3. Enable only one point "Mobile network location" - "Request from Mozilla", other point - turn off. See screen1.
  4. Start logcat
  5. Request location in any app
  6. Grub logcat tag IchnaeaLocation an see request with only one cell tower and response with location low accuracy:

D IchnaeaLocation: GeolocateRequest(carrier=null, considerIp=false, homeMobileCountryCode=null, homeMobileNetworkCode=null, radioType=null, bluetoothBeacons=null, cellTowers=[CellTower(radioType=lte, mobileCountryCode=DELETED, mobileNetworkCode=DELETED, locationAreaCode=DELETED, cellId=DELETED, age=20, psc=null, signalStrength=-104, timingAdvance=null)], wifiAccessPoints=null, fallbacks=Fallback(lacf=true, ipf=false)) -> GeolocateResponse(location=ResponseLocation(lat=DELETED, lng=DELETED), accuracy=50000.0, fallback=lacf, error=null)

If you don't see geolocation request in logcat, you may force geolocation request. I do not know a guaranteed method to force geolocation request, but you may change network type in SIMs setting or insert other SIM and request location again.

Expected behavior microG with old location engine (v0.2.7) with MozillaNlpBackend send many towers on mozilla server -> location higher accuracy.

D/IchnaeaBackendService request: {"radioType":"gsm","cellTowers":[{"radioType":"gsm","mobileCountryCode":DELETED,"mobileNetworkCode":DELETED,"locationAreaCode":DELETED,"cellId":DELETED,"signalStrength":-77,"asu":18},{"radioType":"gsm","mobileCountryCode":DELETED,"mobileNetworkCode":DELETED,"locationAreaCode":DELETED,"cellId":DELETED,"signalStrength":-73,"asu":20},{"radioType":"gsm","mobileCountryCode":DELETED,"mobileNetworkCode":DELETED,"locationAreaCode":DELETED,"cellId":DELETED,"signalStrength":-77,"asu":18},{"radioType":"gsm","mobileCountryCode":DELETED,"mobileNetworkCode":DELETED,"locationAreaCode":DELETED,"cellId":DELETED,"signalStrength":-81,"asu":16},{"radioType":"gsm","mobileCountryCode":DELETED,"mobileNetworkCode":DELETED,"locationAreaCode":DELETED,"cellId":DELETED,"signalStrength":-53,"asu":30},{"radioType":"gsm","mobileCountryCode":DELETED,"mobileNetworkCode":DELETED,"locationAreaCode":DELETED,"cellId":DELETED,"signalStrength":-77,"asu":18}],"wifiAccessPoints":[],"fallbacks":{"lacf":true,"ipf":false}}

[D/IchnaeaBackendService] response: {"location": {"lat": DELETED, "lng": DELETED}, "accuracy": 1000.0, "fallback": "lacf"}

Screenshots screen1**

System Two devices:

  1. Android Version: 13, Custom ROM: LineageOS 20 Official
  2. Android Version: 14, Custom ROM: LineageOS 21 Official

Additional context microG pushed as priv-app with granted all required priv-app premissions throu xml (because LineageOS Official don't have location patch) and granted all premissions at runtime in selfcheck and system settings app. I read earlier that some devices by design can get only one tower, but the old version 0.2.7 of the microG get many towers on the same device. Maybe I need setup ROM setting?

kvak54 commented 3 weeks ago

upd. I was intercepting traffic, this is not a bug in the display in the logs. 1mitmproxy

operarulez commented 3 weeks ago

MLS is sunsetted.

https://github.com/mozilla/ichnaea/issues/2065

We need alternate sources such as OpenCellId, Apple Wi-Fi, Baidu, Déjà Vu.

mar-v-in commented 3 weeks ago

@kvak54 is this two different android versions on the same device model or different device models?

Many device models don't properly support getting information about neighboring cells or only limited details that are insufficient (i.e. the cell id is not included). On those devices we can only get cell id from the current active cell and if that is unknown to the backend (as in your case), it falls back to the cell's location area code which is very inaccurate

ale5000-git commented 3 weeks ago

With SatStat: https://f-droid.org/it/packages/com.vonglasow.michael.satstat/ you could see if an app on your device can really view neighboring cells or just the connected cell.

kvak54 commented 3 weeks ago

@kvak54 is this two different android versions on the same device model or different device models?

Different device models: Redmi 7A and Samsung Galaxy Tab S6 Lite (LTE) The third and other devices requires additional setup for verification.

Many device models don't properly support getting information about neighboring cells or only limited details that are insufficient (i.e. the cell id is not included). On those devices we can only get cell id from the current active cell and if that is unknown to the backend (as in your case), it falls back to the cell's location area code which is very inaccurate

I read about that earlier. On your test devices, does the app send multiple towers to the location server? On all my devices with microG 0.2.27 and MozillaNlpBackend i read log with send multiple towers to the location server but only one or no one with newer verion of microG.

kvak54 commented 3 weeks ago

@ale5000-git I use SatStat + My Location If you mean this: Screenshot_SatStat

I see two towers but only one in location request log.

mar-v-in commented 3 weeks ago

The request to Mozilla will always only include a single tower. This is by design, microG should be doing the calculation then locally based on the data (and cache it, so you should only see a request for each cell once). That said, reviewing the code I noticed this currently probably doesn't work, because none of my test devices actually provides neighbor cells, so I could never test it.

In your screenshot, you can see a lot of cells, however only one of them is usable for geolocation and that is the second (first lacks signal strength, it's probably the last cell you've been connected to, all the others lack the cell id)

unknownankit commented 3 hours ago

@kvak54 Under microG settings > Locations > (3-dots on top right) > Configure Service URL.

Try changing the default Mozilla URL to https://api.positon.xyz/?key=74600654-2aec-11ef-aa95-3b7218da6865

Source: Marvin's comment:- https://github.com/microg/GmsCore/issues/2237#issuecomment-2169193229

Also, keep the "Request from Mozilla" in both Network and Wifi location, "Request from Hotspot" under Wifi location and "Address resolver" Enabled.