Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace proprietary Google Fused location library with open source microG library #901

Closed
5 tasks done
CoelacanthusHex opened this issue Apr 7, 2024 · 21 comments
Closed
5 tasks done
Assignees
Labels
Dependency issue Issue is upstream Idea Ideas can become new feature or improvement Wontfix This will not be worked on
Milestone

Comments

@CoelacanthusHex
Copy link

Describe your idea

Now fused location feature is only enabled in Google Play flavor. But it can be implemented with open source projects and services completely. To use this feature, we must include a library and a runtime application. Both of them can be implemented with OSS easily. For the former, just replace https://github.com/breezy-weather/breezy-weather/blob/main/app/build.gradle.kts#L217 with OSS implementation https://github.com/microg/GmsCore/tree/master/play-services-location, which is compatible with gms API by API but completely open source, even doesn't use non-free network service. Some open source projects in F-droid have started to use microG to implemented these useful feature in easy and open source way, such as Fennec, which uses microG to implement FIDO feature. For the latter, just use microG to replace Google's GMS.

Other details

No response

Acknowledgements

  • I have searched the existing issues and this is a new ticket, NOT a duplicate or related to another open or closed issue.
  • I have written a short but informative title.
  • My idea is not related to a question covered in the Frequently Asked Questions document, or a feature described in the Homepage document.
  • I have updated the app to version 5.1.8 or later.
  • I understand that this app is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, so I may not get a positive reply to my request, if any at all.
@CoelacanthusHex CoelacanthusHex added Idea Ideas can become new feature or improvement Needs review Issue that need to be analyzed (reproduced for a bug, take a decision for an idea, etc) labels Apr 7, 2024
@papjul
Copy link
Collaborator

papjul commented Apr 7, 2024

doesn't use non-free network service

How is that possible? If the server-side is also open source, it's not Google's, it's an alternative service, right?

@papjul papjul added the Needs more info Further information is requested label Apr 7, 2024
@CoelacanthusHex
Copy link
Author

doesn't use non-free network service

How is that possible? If the server-side is also open source, it's not Google's, it's an alternative service, right?

Yes. And there is a local database as well, which records WiFi and Cell when GPS works and use it to determine location later.

@papjul
Copy link
Collaborator

papjul commented Apr 8, 2024

So, we can't replace it or users expecting Google's accuracy won't have it anymore?

Additionally I don't plan on bundling a 2 GB local database, requesting additional permissions nearby wifi and bluetooth and more, it's overkill.

@CoelacanthusHex
Copy link
Author

So, we can't replace it or users expecting Google's accuracy won't have it anymore?

With open source network service, the accuracy is worse than Google's. With local database, it could be much better than Google's where you have reached.

Additionally I don't plan on bundling a 2 GB local database, requesting additional permissions nearby wifi and bluetooth and more, it's overkill.

No. There is no additional database when build. microG just collect data and build database on user's devices locally when they use the device. And Breezy Weather needn't any additional permission: Breezy Weather request location from microG application installed on the same device. microG will do all the thing, Breezy Weather just need call a API.

@papjul
Copy link
Collaborator

papjul commented Apr 8, 2024

So, that's a completely different location provider? It needs a separate entry in Settings > Location > Location service, then.

If the user needs to install microG Services, it's the same thing as if they need to install Google Play Services. It won't work on devices without it.

I will leave this open to contributions.

@papjul papjul changed the title Fused location can be implemented with OSS easily microG location service Apr 8, 2024
@papjul papjul added New source Requests about a new source option Open to contributions This issue is open to the community for implementation and removed Idea Ideas can become new feature or improvement labels Apr 8, 2024
@CoelacanthusHex
Copy link
Author

So, that's a completely different location provider?

Yes.

It needs a separate entry in Settings > Location > Location service, then.

There is a problem: it uses the same API as GMS. From the caller side, the application calls microG the same way as it calls GMS. In fact, if you set the source to GMS Fused Location and install microG, it will work just like GMS was installed. So separate entry is impossible and useless.

In my opinion, I want to push this source into Standard and F-Droid flavors. Because this source can be used without proprietary Google GMS service or library, it should be included in Standard flavor. Because microG's Fused Location implementation uses all libre services and code, it should be included in F-Droid flavor.

If the user needs to install microG Services, it's the same thing as if they need to install Google Play Services. It won't work on devices without it.

I will leave this open to contributions.

@CoelacanthusHex
Copy link
Author

PS: microG and GMS are both service and library, and they can be combined in any combination:

  • compile with microG library and use with microG service
  • compile with GMS library and use with GMS service
  • compile with microG library and use with GMS service
  • compile with GMS library and use with microG service

@papjul
Copy link
Collaborator

papjul commented Apr 8, 2024

microG and GMS are both service and library, and they can be combined in any combination

That's much clearer now, thanks!

In my opinion, I want to push this source into Standard and F-Droid flavors.

But there are also users like me without any *Services that must still be able to use the current location without it failing.

So, at the moment, the idea is to replace the library of the gplay flavor and have someone with Google Play Services test it still works.

To use it in standard, we would need to add a condition "IF google play services are installed OR microG services are installed OR Huawei services are installed OR whatever services are installed THEN use Google Fused location" but that's not very flexible. I saw that there is an API to check the availability of Google Play Services, I believe microG would say true here? Maybe we could use that. Is there a documentation of that microG library so I can understand better what to expect?

I also don't think we can really qualify the Google Fused location as a "free network" because someone reversed engineered, spoofed Google signature and re-used the same API. It's still a non-free network in the way it was intended and for the majority of users who have Google Play Services and not microG. So adding it to standard why not since there would no longer be any proprietary lib bundled, but fdroid I would like to avoid as this is a no "non-free network" flavor. F-Droid users can still use the basic network location provider from Google Play Services if they wish to, but that's something we can't prevent.

@papjul papjul added Idea Ideas can become new feature or improvement and removed New source Requests about a new source option labels Apr 8, 2024
@papjul papjul changed the title microG location service [Gplay flavor] Replace proprietary Google Fused location with open source microG Apr 8, 2024
@CoelacanthusHex
Copy link
Author

microG and GMS are both service and library, and they can be combined in any combination

That's much clearer now, thanks!

In my opinion, I want to push this source into Standard and F-Droid flavors.

But there are also users like me without any *Services that must still be able to use the current location without it failing.

So, at the moment, the idea is to replace the library of the gplay flavor and have someone with Google Play Services test it still works.

To use it in standard, we would need to add a condition "IF google play services are installed OR microG services are installed OR Huawei services are installed OR whatever services are installed THEN use Google Fused location" but that's not very flexible. I saw that there is an API to check the availability of Google Play Services, I believe microG would say true here? Maybe we could use that. Is there a documentation of that microG library so I can understand better what to expect?

microG is designed to have the same behavior as GMS except non-privacy behaviors. There are few documents about microG for developers because it's the same as GMS in most cases. If you have any questions, @mar-v-in and @ale5000-git may give you some answers. And @relan has some experience using microG to replace GMS in Fennec (A full free Firefox build).

I also don't think we can really qualify the Google Fused location as a "free network" because someone reversed engineered, spoofed Google signature and re-used the same API. It's still a non-free network in the way it was intended and for the majority of users who have Google Play Services and not microG. So adding it to standard why not since there would no longer be any proprietary lib bundled, but fdroid I would like to avoid as this is a no "non-free network" flavor. F-Droid users can still use the basic network location provider from Google Play Services if they wish to, but that's something we can't prevent.

Ok, at least this source will have a place in Standard flavor. For the non-free network, @linsui from F-droid may have some opinions.

@linsui
Copy link

linsui commented Apr 8, 2024

In F-Droid flavor as long as the fused location is not used by default it's not considered as NonFreeNet.

@papjul papjul removed Open to contributions This issue is open to the community for implementation Needs more info Further information is requested Needs review Issue that need to be analyzed (reproduced for a bug, take a decision for an idea, etc) labels Apr 8, 2024
@papjul
Copy link
Collaborator

papjul commented Apr 8, 2024

WIP on https://github.com/breezy-weather/breezy-weather/tree/microg branch as a separate location source you can select from Settings > Location if interested

I don't have Google Play Services or microG so feel free to test

@CoelacanthusHex
Copy link
Author

CoelacanthusHex commented Apr 9, 2024

WIP on microg branch as a separate location source you can select from Settings > Location if interested

I don't have Google Play Services or microG so feel free to test

I can confirm that the Fused Location works well with microG 0.3.1.

Tested-by: Coelacanthus CoelacanthusHex@gmail.com

@CoelacanthusHex
Copy link
Author

WIP on microg branch as a separate location source you can select from Settings > Location if interested

I don't have Google Play Services or microG so feel free to test

@Cryolitia and @KunoiSayami confirmed it works with GMS.

@Cryolitia
Copy link

Cryolitia commented Apr 9, 2024

Confirmed it works with GMS on Sony Xperia 1 IV, firmware version 64.2.A.2.112.

Tested-by: Cryolitia Cryolitia@gmail.com

@papjul
Copy link
Collaborator

papjul commented Apr 9, 2024

Currently, the Google Fused Location uses both Fused + Android framework in parallel, so if Fused fails, you still have data.

So, I removed Android framework calls to keep only the efficient Fused.

You can download the debug artifact from: https://github.com/breezy-weather/breezy-weather/pull/914/checks

Please test it that way:

  1. Tap the back button to exit the (empty) location list
  2. Tap the Settings icon
  3. Go to Location settings
  4. Choose "Google Fused" as the location service
  5. Go back to location list
  6. Add your current location

If it works, let me know! If it doesn't work, please export the crash log from Settings > Debug

Thanks!

@papjul papjul added the Needs more info Further information is requested label Apr 9, 2024
@papjul papjul changed the title [Gplay flavor] Replace proprietary Google Fused location with open source microG Replace proprietary Google Fused location library with open source microG library Apr 9, 2024
@papjul papjul added this to the v5.1.x milestone Apr 9, 2024
@Cod3dDOT
Copy link

Cod3dDOT commented Apr 10, 2024

As far as I can tell, microg does not support the recommended way to get the current location (getCurrentLocation).

See microg FusedLocationProviderClientImpl

The app currently uses requestLocationUpdates, which is supported, but intended for tracking rather than locating.

@CoelacanthusHex
Copy link
Author

CoelacanthusHex commented Apr 10, 2024

As far as I can tell, microg does not support the recommended way to get the current location (getCurrentLocation).

See microg FusedLocationProviderClientImpl

The app currently uses requestLocationUpdates, which is supported, but intended for tracking rather than locating.

I think it's not a problem in current way: it only affect users use BW with microG service, it doesn't affect users use BW compiled with microG but with GMS service.

Of course, it's better to let upstream support other methods.

@CoelacanthusHex
Copy link
Author

If it works, let me know! If it doesn't work, please export the crash log from Settings > Debug

I can confirm it works well with microG 0.3.1.

@papjul
Copy link
Collaborator

papjul commented Apr 10, 2024

We have another important bug that makes it a no-go for now: see microg/GmsCore#2309

We will keep the Google Play lib on gplay flavor for now, but we will implement Google Fused as a separate entry from Android source

@papjul
Copy link
Collaborator

papjul commented Apr 11, 2024

There is a 3rd option that I randomly found and is barely used in any other app (because Android framework documentation for location services is nearly inexistant): Fused provider is natively supported on Android >= 12 and QUALITY_BALANCED_POWER_ACCURACY is available on all versions through a Compat class.

Basically, this means we can decide to not depend on any library, and use the native Android functions, but this will only supports Android >= 12 (previous versions will just use the regular Android source, both network and GPS). Given all Android versions < 12 are EoL, I think it's an acceptable trade-off to get rid of a dependency and a flavor.

WIP on nativefused branch

@papjul
Copy link
Collaborator

papjul commented Apr 13, 2024

This branch was tested on different phones successfully. This makes this request obsolete as we no longer depend on any library

@papjul papjul closed this as not planned Won't fix, can't repro, duplicate, stale Apr 13, 2024
@papjul papjul added this to the V5.2.0 milestone Apr 13, 2024
@papjul papjul added the Wontfix This will not be worked on label Apr 13, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Dependency issue Issue is upstream Idea Ideas can become new feature or improvement Wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

5 participants