[android] Google Play Location API returns bogus location in the first 1-2 seconds #2149

Closed
opened 2022-02-19 12:32:31 +00:00 by rtsisyk · 0 comments
Owner

A test case:

  1. Open the app
  2. Wait until precise location is acquired from hardware GPS.
  3. Ensure that no other apps are using location.
  4. Lock the screen.
  5. Unlock the screen.
  6. Open the app.
  7. The app will show a previous location for 1-2 seconds, then jump to a location far away for 1-5 seconds, and then start jump back to the proper location.

Explanation:

  1. The app disables all location services when going into the background, i.e. then the user switches to another app or locks the screen.
  2. Android disables hardware GPS almost immediately if there are no active apps using it.
  3. On the next run, the app starts location services again.
  4. Google Play Location API returns network location instantly. This location can be 10-700 meters away from the real location. The accuracy depends on situation. In cities, the accuracy of the first location is about ~10 meters. In a forest, it can be up to 700 meters inaccurate.
  5. The app blindly trusts all results returned from Google Play Location API.
  6. HW GPS catches up and starts returning proper location 1-2 seconds.

This issue reproduces both on the new (#2023 #2087) and previous implementation.

Below is logcat after resuming the app:

2022-02-13 13:28:12.796 main: D/LocationHelper: onLocationChanged, location = Location[fused 55.852561,37.312428 hAcc=699.999 et=+2d2h41m23s327ms alt=192.40202601485817 vAcc
=14.377255 {Bundle[EMPTY_PARCEL]}]
2022-02-13 13:28:15.722 main: D/LocationHelper: onLocationChanged, location = Location[fused 55.846022,37.311573 hAcc=48.0 et=+2d2h41m27s412ms alt=192.40202601485817 vAcc=13
.479849 vel=0.37648338 sAcc=0.6590801 bear=68.0 bAcc=180.0 {Bundle[EMPTY_PARCEL]}]
2022-02-13 13:28:18.683 main: D/LocationHelper: onLocationChanged, location = Location[fused 55.846000,37.311548 hAcc=49.736 et=+2d2h41m30s417ms alt=192.4040892666825 vAcc=1
3.44495 vel=0.09437784 sAcc=0.67334217 bear=87.855286 bAcc=180.0 {Bundle[EMPTY_PARCEL]}]
2022-02-13 13:28:20.678 main: D/LocationHelper: onLocationChanged, location = Location[fused 55.845981,37.311509 hAcc=39.525 et=+2d2h41m32s409ms alt=192.4040892666825 vAcc=1
3.43119 vel=0.22056967 sAcc=0.21031955 bear=138.34778 {Bundle[EMPTY_PARCEL]}]
2022-02-13 13:28:22.099 main: D/LocationHelper: onLocationChanged, location = Location[fused 55.845975,37.311519 hAcc=29.39 et=+2d2h41m33s832ms alt=192.34425516820477 vAcc=1
3.362372 vel=0.42359042 sAcc=0.20136186 bear=138.66772 {Bundle[EMPTY_PARCEL]}]

Please note, the first location has provider="fused" and location hAcc=699.999 of the first returned result.

See also #2034

A test case: 1. Open the app 2. Wait until precise location is acquired from **hardware** GPS. 2. Ensure that no other apps are using location. 3. Lock the screen. 4. Unlock the screen. 5. Open the app. 6. The app will show a previous location for 1-2 seconds, then jump to a location **far away** for 1-5 seconds, and then start jump back to the proper location. Explanation: 1. The app disables all location services when going into the background, i.e. then the user switches to another app or locks the screen. 2. Android disables hardware GPS almost immediately if there are no active apps using it. 3. On the next run, the app starts location services again. 4. Google Play Location API returns network location instantly. This location can be **10-700 meters** away from the real location. The accuracy depends on situation. In cities, the accuracy of the first location is about ~10 meters. In a forest, it can be up to 700 meters inaccurate. 5. [**The app blindly trusts all results returned from Google Play Location API.**](https://github.com/organicmaps/organicmaps/blob/d02453b52f760459c41dc4dd825cacdb744a8e5f/android/src/com/mapswithme/util/LocationUtils.java#L89-L92) 6. HW GPS catches up and starts returning proper location 1-2 seconds. This issue reproduces both on the new (#2023 #2087) and previous implementation. Below is logcat after resuming the app: ``` 2022-02-13 13:28:12.796 main: D/LocationHelper: onLocationChanged, location = Location[fused 55.852561,37.312428 hAcc=699.999 et=+2d2h41m23s327ms alt=192.40202601485817 vAcc =14.377255 {Bundle[EMPTY_PARCEL]}] 2022-02-13 13:28:15.722 main: D/LocationHelper: onLocationChanged, location = Location[fused 55.846022,37.311573 hAcc=48.0 et=+2d2h41m27s412ms alt=192.40202601485817 vAcc=13 .479849 vel=0.37648338 sAcc=0.6590801 bear=68.0 bAcc=180.0 {Bundle[EMPTY_PARCEL]}] 2022-02-13 13:28:18.683 main: D/LocationHelper: onLocationChanged, location = Location[fused 55.846000,37.311548 hAcc=49.736 et=+2d2h41m30s417ms alt=192.4040892666825 vAcc=1 3.44495 vel=0.09437784 sAcc=0.67334217 bear=87.855286 bAcc=180.0 {Bundle[EMPTY_PARCEL]}] 2022-02-13 13:28:20.678 main: D/LocationHelper: onLocationChanged, location = Location[fused 55.845981,37.311509 hAcc=39.525 et=+2d2h41m32s409ms alt=192.4040892666825 vAcc=1 3.43119 vel=0.22056967 sAcc=0.21031955 bear=138.34778 {Bundle[EMPTY_PARCEL]}] 2022-02-13 13:28:22.099 main: D/LocationHelper: onLocationChanged, location = Location[fused 55.845975,37.311519 hAcc=29.39 et=+2d2h41m33s832ms alt=192.34425516820477 vAcc=1 3.362372 vel=0.42359042 sAcc=0.20136186 bear=138.66772 {Bundle[EMPTY_PARCEL]}] ``` Please note, the first location has `provider="fused"` and location `hAcc=699.999` of the first returned result. See also #2034
This repo is archived. You cannot comment on issues.
No labels
Accessibility
Accessibility
Address
Address
Android
Android
Android Auto
Android Auto
Android Automotive (AAOS)
Android Automotive (AAOS)
API
API
AppGallery
AppGallery
AppStore
AppStore
Battery and Performance
Battery and Performance
Blocker
Blocker
Bookmarks and Tracks
Bookmarks and Tracks
Borders
Borders
Bug
Bug
Build
Build
CarPlay
CarPlay
Classificator
Classificator
Community
Community
Core
Core
CrashReports
CrashReports
Cycling
Cycling
Desktop
Desktop
DevEx
DevEx
DevOps
DevOps
dev_sandbox
dev_sandbox
Directions
Directions
Documentation
Documentation
Downloader
Downloader
Drape
Drape
Driving
Driving
Duplicate
Duplicate
Editor
Editor
Elevation
Elevation
Enhancement
Enhancement
Epic
Epic
External Map Datasets
External Map Datasets
F-Droid
F-Droid
Fonts
Fonts
Frequently User Reported
Frequently User Reported
Fund
Fund
Generator
Generator
Good first issue
Good first issue
Google Play
Google Play
GPS
GPS
GSoC
GSoC
iCloud
iCloud
Icons
Icons
iOS
iOS
Legal
Legal
Linux Desktop
Linux Desktop
Linux packaging
Linux packaging
Linux Phone
Linux Phone
Mac OS
Mac OS
Map Data
Map Data
Metro
Metro
Navigation
Navigation
Need Feedback
Need Feedback
Night Mode
Night Mode
NLnet 2024-06-281
NLnet 2024-06-281
No Feature Parity
No Feature Parity
Opening Hours
Opening Hours
Outdoors
Outdoors
POI Info
POI Info
Privacy
Privacy
Public Transport
Public Transport
Raw Idea
Raw Idea
Refactoring
Refactoring
Regional
Regional
Regression
Regression
Releases
Releases
RoboTest
RoboTest
Route Planning
Route Planning
Routing
Routing
Ruler
Ruler
Search
Search
Security
Security
Styles
Styles
Tests
Tests
Track Recording
Track Recording
Translations
Translations
TTS
TTS
UI
UI
UX
UX
Walk Navigation
Walk Navigation
Watches
Watches
Web
Web
Wikipedia
Wikipedia
Windows
Windows
Won't fix
Won't fix
World Map
World Map
No milestone
No project
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: organicmaps/organicmaps-tmp#2149
No description provided.