mattermoran / map_launcher

Flutter plugin for launching maps
MIT License
259 stars 117 forks source link

Change in Android app detection #152

Closed tjeffree closed 10 months ago

tjeffree commented 1 year ago

This change avoids the use of packageManager.getInstalledApplications() and instead relies on testing intents.

From what I could find the safest method was to simply test the intents. It's mentioned in a various places but isn't exactly explicit:

https://developer.android.com/training/package-visibility/use-cases https://developer.android.com/guide/components/intents-common

This may or may not make a difference in Google's review process but figured it was worth sharing just in case.

tjeffree commented 10 months ago

Just want to leave a note here to mention our app passed review on the Play Store using this fork.

mattermoran commented 10 months ago

Oh great, I'm gonna shelve my idea of a big rewrite and just gonna merge all prs and make a release this weekend :)

mattermoran commented 10 months ago

@tjeffree hey. looks like there are some merge conflicts. You think you could get that fixed? Cheers!

tjeffree commented 10 months ago

I'll have a go

tjeffree commented 10 months ago

Ok that's those resolved. I haven't retested all the apps but did check the new ones: Sygic Truck, Flitsmeister and Truckmeister.

mattermoran commented 10 months ago

Cheers, I'll make sure to double test before releasing!

mattermoran commented 10 months ago

Interesting. I'm doing some tests and looks like some maps are simply not showing with this method. Here's the list of missing ones:

Trying to figure out why that is hmm

mattermoran commented 10 months ago

Seems like some maps might have different types of intents. What about something like context.packageManager.getPackageInfo(map.packageName, 0)? That does not seem to be using sensitive permissions afaik.

tjeffree commented 10 months ago

@mattermoran Just installed Osmand to see what was up with that one. I originally got the URL schemes from the iOS side I think.

Looks like the Android version doesn't support osmandmaps://, however it does support geo:// the same as a few of the others. Can you try changing them to geo:// and see if they show up?

mattermoran commented 8 months ago

I decided to go with this as it seems to be working fine and not using any special permissions

private fun getInstalledMaps(): List<MapModel> {
    return maps.filter { map ->
        context.packageManager?.getLaunchIntentForPackage(map.packageName) != null
    }
}