microg / microg/GmsCore

[io.homeassistant.companion.android] Home-Assistant cannot access location update result

Open
#1,616 16 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
14.6k
Forks
3.2k
Avg merge
12d 11h
Merged PRs (30d)
4

Description

Affected app
Name: Home-Assistant
Package id: io.homeassistant.companion.android

Describe the bug
Home-Assistant uses gms libraries to handle location updates coming via indent, but the gms library seems not to be able to parse microG's intents to extract the location information

To Reproduce
Steps to reproduce the behavior:

  1. Install Home-Assistant Companion App, connect to instance
  2. Enable the "Background Location" sensor in Companion App and further allow all location permission requests
  3. View in Home-Assistant that location never gets updated (see screenshot)

Expected behavior
Location should be sent to Home-Assistant instance after the intent was parsed correctly.

Screenshots
Screenshot of device_tracker / sensor in Home-Assistant web ui:
image

System
Android Version: 11
Custom ROM: LineageOS 18.1 with microg (18.1-20211021-microG-oneplus3)

microG
microG Core version: 0.2.22.212658
microG Self-Check results: All ticked

Additional context
I debugged the app in Android Studio and used logcat to determine the buggy code lines (hopefully the correct ones):

https://github.com/home-assistant/android/blob/ff20e4502b0f202d13323d4211c2c475c1d62bc8/app/src/full/java/io/homeassistant/companion/android/sensors/LocationSensorManager.kt#L445-L471

While debugging, I found out, that LocationResult.extractResult(intent) returns null and so subsequent ?. calls default to null. So I think, that LocationResult from gms cannot parse the intent given by microG.

See my issue report there: home-assistant/android#1833

Weird Good2Know
The author of the similar issue #1273 seems to have solved this issue by re-enabling the sensor, but further has problems with the geocoded location. On my device, geocoded location works just fine, but the real location does not even after re-installing the app and re-enabling the sensor multiple times.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the referenced LocationSensorManager.kt lines 445-471 and inspect how LocationResult.extractResult(intent) handles the microG location intent. Compare this with the related Home Assistant issue and reproduce using the listed Android 11, LineageOS 18.1 with microG setup. Done means the background location update is parsed and reaches the Home Assistant instance.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java, kotlin
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.