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

also behave as a UnifiedNlp provider #13

Open
khimaros opened this issue Feb 3, 2023 · 9 comments
Open

also behave as a UnifiedNlp provider #13

khimaros opened this issue Feb 3, 2023 · 9 comments

Comments

@khimaros
Copy link

khimaros commented Feb 3, 2023

it would be great if this also behaved as a UnifiedNlp provider, as GMS/FCM apps will often use this instead of direct network or GPS access. this causes location to jump around unless all Nlp providers are disabled.

@warren-bank
Copy link
Owner

warren-bank commented Feb 4, 2023

Hi. Interesting request. I'll be the first to admit that I needed to do a little Googling and reading.. to get a basic understanding of what this would mean.

  • the official XDA thread as well as this blog post both give a nice overview of what UnifiedNlp is.. what it does.. why it exists.
    To summarize (my understanding)..

    • the Android ROM that comes OEM on nearly all phones includes Google Play Services, which contains Google's Location Service
    • when installing a deGoogled ROM (ex: LineageOS), none of this is present.. and there's a need for an open-source privacy-minded replacement
  • this open issue on github for the UnifiedNlp project draws a clear distinction between its location data plugins (ex: mobile towers, wifi APs, ...) and mock locations. Mocked location data is not currently supported as a data source.

Unrelated to Google Location Service vs. UnifiedNlp.. both of which derive location data from sources that cannot be mocked.. and would otherwise interfere with location mocking.. and, hence, should be disabled when attempting to mock location (ie: by choosing either "device only" sources, or possibly also "high accuracy" sources).. I did notice that the LocationManager API has 2x other location providers that neither this app (nor FakeTraveler) currently mock.. and I would assume we could (and should):

I'll need to play around with this a little.. and see if it's a good idea (or not).

@warren-bank
Copy link
Owner

@warren-bank
Copy link
Owner

correction..
regarding the UnifiedNlp issue (mentioned above)..
I think I read it too quickly and got its feature request a bit backwards..
the request was for the UnifiedNlp to be used as the source for mock location data on non-rooted devices..
rather than the other way around..
so, idk.. ??
TBD.. I need to do some more reading..

@warren-bank
Copy link
Owner

notes (to self):

@khimaros
Copy link
Author

khimaros commented Feb 4, 2023

wow, thank you for the thorough reply!

I was indeed referring to using mock locations as a source (provider) for UnifiedNlp requests.

as far as I know there is no technical limitation on using mock data for in a UnifiedNlp provider.

@warren-bank
Copy link
Owner

I have LineageOS on a few devices that I occasionally use to test app compatability with various versions of Android,
but I've never played around with microG or UnifiedNlp.. so you'll be able to answer this better than me:

  • in UnifiedNlp.. you have multiple plugins that each provide its own best guess for the current location.
  • hypothetically, what would happen if there was a plugin that was giving wildly different location data?
    • plugin A (using cellular towers) says: you're in Massachusetts w/ accuracy of 1 mile
    • plugin B (using wifi APs) says: you're in Massachusetts w/ accuracy of 200 ft
    • plugin C (mock data) says: you're in Bora Bora w/ accuracy of 1 meter
  • I'm kind of envisioning a classic Star Trek evil robot saying: "does not compute" repeatedly..
    steam coming out from its ears.. and then it blowing up

@warren-bank
Copy link
Owner

warren-bank commented Feb 5, 2023

when in doubt.. read the code!

interestingly.. this could work:

  • the updateLocation() method obtains location data from all plugins..
    and conditionally determines whether or not to use it
  • here is the Java code for v1.6.8.. which is the most recently release.. from Jan 16, 2017
  • here is the Kotlin code for the most recent commit.. from Aug 1, 2022
  • both implementations use the same conditional logic:
    • is the location data provided by a plugin newer than the last used location data

specifically.. albeit a bit hacky:

  • a "mock" provider could guarantee that its location data always takes priority over all other plugins by also mocking the timestamp
  • if every "mock" location data update includes: timestamp = now() + offset
    • where: offset = 30 seconds
    • then:
      • mocked location data updates are properly ordered
      • all other location data plugins are ignored because they are older than the mocked data
      • once the "mock" provider is disabled, the other plugins can regain top priority after only a 30 second delay

@warren-bank
Copy link
Owner

The release for v2.2.0 adds a 2nd app, which is a backend provider plugin for UnifiedNlp. This plugin requires that Mock my GPS be installed and started, otherwise it doesn't do anything.

Strictly speaking, on a system that has UnifiedNlp working.. Mock my GPS doesn't need to be set as the default app to mock location data in Developer Options; so long as it's running, it will pass its mock location data to UnifiedNlp.

I've only confirmed with the debugger that binding to all of the services is working correctly. However, I don't have UnifiedNlp installed as a system app.. so I'm only about 95% sure that it will work. It would be great if you could test it for me.. and report back with any observations.. good or bad.

@khimaros
Copy link
Author

khimaros commented Feb 6, 2023

awesome work! I will test and let you know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants