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

Provide different geo intent targets for [fixed position | trip origin | trip destination | add bookmark ] instead of the "Use Geo-Intent For" menu #24

Open
chambm opened this issue Sep 12, 2024 · 10 comments

Comments

@chambm
Copy link

chambm commented Sep 12, 2024

The idea of letting OsmAnd provide the mapping interface is great. But to make it convenient to use Mock my GPS from OsmAnd, we should be able to specify the purpose of sending the geo intent without opening the Mock my GPS UI. It should send the intent, have it take effect (change location), and then go back to the map. I shouldn't really have to see the Mock my GPS UI, or at least there should be an option for it.

So the feature request has three parts:

  • Provide different geo intent targets for [fixed position | trip origin | trip destination | add bookmark] instead of the "Use Geo-Intent For" menu shown after sending to the single target Mock my GPS has right now
  • When sending fixed position intent, make the new position take effect immediately
  • When sending the trip destination intent, start the trip immediately
    The "take immediate effect" part of the last two features could be an option in the Mock my GPS preferences.

A bonus convenience option would be to have consecutive "trip destination" intents, without intervening "trip origin" intents, change the "trip origin" to the current location automatically. For example:
User sends trip origin intent of 42,42
User sends trip destination intent of 44,44; trip starts automatically and holds at destination
User sends trip destination intent of 43,43; trip starts automatically from 44,44 to 43,43

@warren-bank
Copy link
Owner

dumb question.. were you reading the conversation going on this afternoon.. or just reading our minds? 😃

I'm planning on adding support for the presence of extras in the Intent.. and allow them to conditionally either:

  1. skipping the UI dialog to choose the "purpose" for the location (ex: fixed position, trip origin, etc..)
    • which would still show UI
  2. skipping all UI and silently control the running Service
    • set a fixed position
    • start/update the destination and duration for a "trip"
      • using the currently mocked position as the trip origin
        • whether that be a fixed position, or the current position along a partial trip's path

Having said that.. most 3rd party software that supports sharing geo-Intents won't allow you to configure additional custom extras. But for somebody inventive, it wouldn't be too hard to write an app that intercepts, modifies, and resends. Or, as you mentioned earlier, such Intents could be started from either the command-line or pre-configured with an app like Bookmarks.

@warren-bank
Copy link
Owner

I'm going to work on it this afternoon.. and will get back to you with the finer details after they've all been ironed out.

@chambm
Copy link
Author

chambm commented Sep 12, 2024

Sounds good, thanks for the quick reply!

Isn't it possible to show the [fixed position | trip origin | trip destination | add bookmark] options as associated activities (I'm not sure of the term) that show up when you press "geo:" in OsmAnd? That would maximize compatibility (at the cost of spamming the "Open with" menu: so can adding the extra intents/activities be optional?).

Basically instead of:

Open with

Google Earth              Maps               Mock my GPS               OsmAnd

Just once                                        Always

we would see

Open with

Google Earth             Maps           Mock my GPS (fixed position)         Mock my GPS (trip origin) 
Mock my GPS (trip destination)          Mock my GPS (add bookmark)           OsmAnd

Just once                                        Always

Then I could even set "trip destination" as the default and, with the smart behavior described above (immediately starting a new trip to that destination, using the current mocked position as the trip origin), it would be super convenient to just move around from place to place from OsmAnd.

@warren-bank
Copy link
Owner

I just released an updated version that includes support for extras in the Intent.

To address your suggestion..

  • I really don't like the idea of (as you say: spamming) the Activity chooser by adding a standalone Activity for every possible permutation of extras
  • plus.. that doesn't solve the problem of needing to specify a trip duration (in seconds) when providing the coordinates for a new trip destination
  • I think a better idea.. which is something I'm considering doing this evening for the hell of it.. is to write a standalone app that:
    • has all the same geo-Intent filters
    • can be preconfigured to add any combination of the new extras
    • when an implicit Intent is received:
      • add the extras
      • add the package/class to make an explicit Intent that will be sent directly to Mock-my-Location
      • start the modified Intent
      • finish (without displaying any UI)

@warren-bank
Copy link
Owner

warren-bank commented Sep 13, 2024

I'll need to change which commit this tag is associated with..
because I've added this helper utility ("Mock Silently") to the repo in a subsequent commit,
and it doesn't change either of the other pre-existing apps.. so no need for a new tag w/ rebuild.

at the moment, I haven't translated its strings yet..
but I added the APK for its english-only build to the v2.4.0 release.

I tested it out a bit.. and it works great.

update: replaced the english-only APK for one with all (51x) language translations, and updated the tag to reference the most-recent commit.

@warren-bank
Copy link
Owner

warren-bank commented Sep 13, 2024

so, just to recap..

using this utility app:

  1. open "Mock Silently" to configure the values for custom extras,
    for example:
    • purpose = trip destination
    • trip_duration_seconds = 60
  2. close

your use-case was to:

  1. open "Mock my GPS"
    • start the location mock service
  2. open "OsmAnd+"
  3. click a location on the map and share it via an implicit geo-Intent
    • the first time you do this, choose to always open with "Mock Silently"
    • subsequently, there won't be any UI and you'll stay in "OsmAnd+"
  4. repeat step 3..

@chambm
Copy link
Author

chambm commented Sep 13, 2024

Awesome, thanks for the lightning fast solution! From my testing, it works great as long as the mocking is turned on. If it's stopped, then the UI is still shown. Can "automatic start" be added as a boolean extra that Mock Silently would presumably always set to true?

This standalone utility makes me (giddily) wonder whether it can run on the non-owner profile and send intents to the Mock my GPS service running on the owner profile? Does it just need a user id (0) to make that work?

@chambm
Copy link
Author

chambm commented Sep 13, 2024

Is this work profile stuff applicable to the arbitrary user profiles available on a Samsung Galaxy Tab?
https://developer.android.com/work/managed-profiles#java

If a device has a work profile, there are implications for apps running on the device, no matter which profile the app is running under:

By default, most intents do not cross from one profile to the other. If an app running on profile fires an intent, there is no handler for the intent on that profile, and the intent is not allowed to cross to the other profile due to profile restrictions, the request fails and the app may shut down unexpectedly.

Does this mean all that needs to be done is somehow configure Mock my GPS to allow cross-profile geo intents?

@warren-bank
Copy link
Owner

warren-bank commented Sep 13, 2024

From my testing, it works great as long as the mocking is turned on. If it's stopped, then the UI is still shown. Can "automatic start" be added as a boolean extra that Mock Silently would presumably always set to true?

Yes. I like this idea. I could add a new (boolean) extra "force_start" which would only apply when "purpose" = 1 (fixed position). It couldn't be applied to start a trip when provided a new destination, because a trip also requires an origin.

I'll update both "Mock my GPS" to accept this new extra, as well as "Mock Silently" to support setting its value. I think I'll also update the PreferenceActivity in "Mock Silently" to conditionally show/hide extras based on the value chosen for "purpose".. to reduce confusion.

If a device has a work profile, there are implications..

Though I don't have any 1st-hand experience with this, the documentation that you linked to clearly says:

  • On a device with a work profile, there are restrictions on whether intents can cross from one profile to another. In most cases, when an intent is fired off, it is handled on the same profile where it is fired.
  • The profile admin can choose which intents are allowed to cross from one profile to another.

So, depending on your use-case.. if you plan on firing a geo-Intent from one profile and plan on it being handled by an app running in another.. then you need to configure your profiles to allow this. I'm not sure what level of granularity is available for this configuration.. but you would need to learn more about it.

@warren-bank
Copy link
Owner

a new version has been released that includes support for the force_start extra..
in both "Mock my GPS" and "Mock Silently".

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