Skip to content

Conversation

@OS-pedrogustavobilro
Copy link
Contributor

@OS-pedrogustavobilro OS-pedrogustavobilro commented Sep 30, 2025

Description

This PR provides a new option enableLocationManagerFallback for using Android Framework's LocationManager, if for some reason using the Fused Provider from GMS is not possible (e.g. device without Play Services).

Also using the LocationManager with enableLocationManagerFallback=true when there's no network (e.g. device in Airplane mode). Even though Fused Provider technically could work without network (it would just use GPS), the location settings check fails - in this situation we use LocationManager with just GPS provider.

This PR contains BREAKING CHANGE: The constructor for the controller and some of its methods have changed signature.
Clients will need to change how your application calls the library if you update to this version.

Context

https://outsystemsrd.atlassian.net/browse/RMET-2991

Type of changes

  • Fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Refactor (cosmetic changes)
  • Breaking change (change that would cause existing functionality to not work as expected)

Tests

Use the following application, either from .apk file or build from source code (downloads may take a few seconds to start) - It's the Location Sample App From OutSystems O11 but with code from this PR in the native library.

Testing with airplane mode

If you set the device to airplane mode, it will use the LocationManager fallback.

Depending on what device you're testing, you may get location timeouts. This is because there is only GPS to access, which may be slower or in some cases only return a location when there's actual movement.

  • Try setting a higher timeout value, and to check that cached locations are still returned, try increasing maximum age.
  • For emulators - If you use the extended controls (three vertical dots), you'll be able to set new GPS coordinates, which should help in triggering new location updates.
  • For physical devices
    • On a Pixel I was able to trigger this fairly often by shaking the phone quickly
    • On another device I was only able to trigger updates when walking outside, so that GPS would update

Testing without Play Services

You may test with an emulator and AOSP image (without Play Store). Other than that I saw a "Huawei P40" on sauce labs, but it didn't have Petal Maps installed, the only way I found to properly trigger a new location was via the Sauce Labs Tools to mock a different device location.

Checklist

  • Pull request title follows the format RNMT-XXXX <title>
  • Code follows code style of this project
  • CHANGELOG.md file is correctly updated
  • Changes require an update to the documentation
    • Documentation has been updated accordingly

This fallback is used if IONGLOCLocationOptions#useLocationManagerFallback is true, and when there is an error in checking location settings / google play services.

BREAKING CHANGE: The constructor and some methods of `IONGLOCController` have changed signatures. Updating the library will require changes to fix compilation errors.
@OS-pedrogustavobilro OS-pedrogustavobilro self-assigned this Sep 30, 2025
@alexgerardojacinto
Copy link
Collaborator

Tested on Pixel 9 Pro XL (Android 16), Pixel 7 (Android 16), and Pixel 3 XL (Android 12) and it works properly. Using a timeout of 5 seconds I sometimes get a timeout, which is expected, but it still works most of the time - I'm able to get the location, both with GetLocation and WatchPosition.

@OS-pedrogustavobilro OS-pedrogustavobilro merged commit e820114 into main Oct 2, 2025
1 of 5 checks passed
@OS-pedrogustavobilro OS-pedrogustavobilro deleted the feature/RMET-2991/fallback branch October 2, 2025 14:28
github-actions bot pushed a commit that referenced this pull request Oct 24, 2025
# 1.0.0 (2025-10-24)

* feat!: Fallback for no network or Play Services ([#7](#7)) ([e820114](e820114)), closes [IONGLOCLocationOptions#useLocationManagerFallback](https://github.com/IONGLOCLocationOptions/issues/useLocationManagerFallback)

### Bug Fixes

* fix subtitle in README.md ([afc0bb4](afc0bb4))
* fix subtitles in README.md ([148471a](148471a))
* fix subtitles in README.md ([d778351](d778351))
* fix typo in yml file ([765b75d](765b75d))
* fixing typo in README ([7b5fa41](7b5fa41))
* LICENSE file directory in publish-module.gradle file ([3340682](3340682))
* publish library under `io.ionic.libs` instead of `com.capacitorjs` ([1bf7cd8](1bf7cd8))
* Publishing Migration To Central Portal ([#6](#6)) ([60228ff](60228ff))

### Features

* add publish-android workflow to publish Android lib in Maven ([7d33cbe](7d33cbe))
* bring full implementation of library from outsystems-geolocation repo ([0b1362c](0b1362c))
* set workflow_dispatch to manual trigger, avoiding the GitHub action to run when pushing to a branch ([8a1b7be](8a1b7be))
* use semantic-release for library ([53f775e](53f775e))

### BREAKING CHANGES

* The constructor and some methods of `IONGLOCController` have changed signatures. Updating the library will require changes to fix compilation errors.

* refactor: Rename new fallback attribute

References: https://outsystemsrd.atlassian.net/browse/RMET-2991

* refactor: Extract code to separate methods

* fix: Improve `getCurrentLocation` fallback and fix fallback condition

References: https://outsystemsrd.atlassian.net/browse/RMET-2991

* chore: update Gradle, AGP, and Android SDK

* fix: Fallback Quality based on network connectivity

* fix: Use maximumAge in addWatch fallback

* fix: Improve use of providers in fallback

References: https://outsystemsrd.atlassian.net/browse/RMET-2991

* refactor: Extract methods and classes to separate files

References: https://outsystemsrd.atlassian.net/browse/RMET-2991

* chore: Return specific error on no network+location

* docs: Document the IONGLOCLocationOptions properties

* chore: Prepare to release 2.0.0

1.0.0->2.0.0 because it includes breaking changes

References: https://outsystemsrd.atlassian.net/browse/RMET-2991

* chore: remove outdate doc

References: https://outsystemsrd.atlassian.net/browse/RMET-2991

* chore: remove irrelevant portion of PR template

References: https://outsystemsrd.atlassian.net/browse/RMET-2991

* refactor: minor changes from PR comments

References: https://outsystemsrd.atlassian.net/browse/RMET-2991
@github-actions
Copy link

🎉 This PR is included in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

alexgerardojacinto pushed a commit that referenced this pull request Oct 24, 2025
# 1.0.0 (2025-10-24)

* feat!: Fallback for no network or Play Services ([#7](#7)) ([e820114](e820114)), closes [IONGLOCLocationOptions#useLocationManagerFallback](https://github.com/IONGLOCLocationOptions/issues/useLocationManagerFallback)

### Bug Fixes

* fix subtitle in README.md ([afc0bb4](afc0bb4))
* fix subtitles in README.md ([148471a](148471a))
* fix subtitles in README.md ([d778351](d778351))
* fix typo in yml file ([765b75d](765b75d))
* fixing typo in README ([7b5fa41](7b5fa41))
* LICENSE file directory in publish-module.gradle file ([3340682](3340682))
* publish library under `io.ionic.libs` instead of `com.capacitorjs` ([1bf7cd8](1bf7cd8))
* Publishing Migration To Central Portal ([#6](#6)) ([60228ff](60228ff))

### Features

* add publish-android workflow to publish Android lib in Maven ([7d33cbe](7d33cbe))
* bring full implementation of library from outsystems-geolocation repo ([0b1362c](0b1362c))
* set workflow_dispatch to manual trigger, avoiding the GitHub action to run when pushing to a branch ([8a1b7be](8a1b7be))
* use semantic-release for library ([53f775e](53f775e))

### BREAKING CHANGES

* The constructor and some methods of `IONGLOCController` have changed signatures. Updating the library will require changes to fix compilation errors.

* refactor: Rename new fallback attribute

References: https://outsystemsrd.atlassian.net/browse/RMET-2991

* refactor: Extract code to separate methods

* fix: Improve `getCurrentLocation` fallback and fix fallback condition

References: https://outsystemsrd.atlassian.net/browse/RMET-2991

* chore: update Gradle, AGP, and Android SDK

* fix: Fallback Quality based on network connectivity

* fix: Use maximumAge in addWatch fallback

* fix: Improve use of providers in fallback

References: https://outsystemsrd.atlassian.net/browse/RMET-2991

* refactor: Extract methods and classes to separate files

References: https://outsystemsrd.atlassian.net/browse/RMET-2991

* chore: Return specific error on no network+location

* docs: Document the IONGLOCLocationOptions properties

* chore: Prepare to release 2.0.0

1.0.0->2.0.0 because it includes breaking changes

References: https://outsystemsrd.atlassian.net/browse/RMET-2991

* chore: remove outdate doc

References: https://outsystemsrd.atlassian.net/browse/RMET-2991

* chore: remove irrelevant portion of PR template

References: https://outsystemsrd.atlassian.net/browse/RMET-2991

* refactor: minor changes from PR comments

References: https://outsystemsrd.atlassian.net/browse/RMET-2991
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants