abrensch / brouter

configurable OSM offline router with elevation awareness, Java + Android
MIT License
503 stars 120 forks source link

A10 unable to access SD-Card #384

Closed mello7tre closed 2 years ago

mello7tre commented 2 years ago

Hi, reading https://github.com/abrensch/brouter/blob/master/misc/readmes/readme_Android11.txt, seems that only for A11 access to other application folders is forbidden:

since Android 11 BRouter app uses only its local storage on 
.../Android/media/btools.routingapp/

That means it can't access the folders from other apps like OsmAnd, OruxMaps or Locus.

but looking at https://github.com/abrensch/brouter/blob/15e84c81ea23408abde8605bd57a87a777003ce2/brouter-routing-app/src/main/java/btools/routingapp/BRouterView.java#L224-L227

seem that starting from A10 Brouter is unable to access to AdditionalMaptoolDir cause canAccessSdCard is false.

And i can confirm that using A10 with version 1.6.3, even if i properly configured additional_maptool_dir, BRouter is unable to find OSMand waypoints. And in debug file brouterapp.txt i do not even find messages that suggest that BRouter is executing that part of code. I have only this line:

using basedir: /storage/emulated/0/Android/media/btools.routingapp
zod commented 2 years ago

It seems the documentation is wrong here. The BRouter 1.6.3 Release from Google Play targets API30 (Android 11) but this also changes handling of scoped storage on Android 10. When installing BRouter on Android 10 there seems to be no way to enable legacy storage.

The mentioned code-fragment only sets canAccessSdCard to false if it's running on Android 10 and external storage isn't provided as legacy storage.

mello7tre commented 2 years ago

I installed BRouter from Google Play (Aurora Store, since my phone is DeGoogled) and was a first install. Service interface (triggering BRouter from OsmAnd is working fine), but for very very long routing (unable to end in 60sec) would be useful to calculate it directly in BRouter without any time limit, directly accessing OsmAnd waypoints; currently i need to manually copy waypoints.gpx to import folder.

But if we change code with Build.VERSION.SDK_INT >= Build.VERSION_CODES.R, A10 would be still able to access OsmAnd storage ?

Like as been done for #379 with 7b460d25d36338aaae9774bd3757cba42900601c

abrensch commented 2 years ago

but for very very long routing (unable to end in 60sec) would be useful to calculate it directly in BRouter without any time limit

there's another workaround for that situation:

after you got the 60s timeout, starting the brouter-app you should see a "<repeat ..>" dummy-profile. Selecting that repeats the last requests with the same profile, waypoints and nogos. After doing that, try again in OsmAnd (with the exact same destination) and that should do a "fast recalculation" that finishes < 60s

mello7tre commented 2 years ago

Thanks for the info, no mention of this in the readme, can be really useful.

zod commented 2 years ago

But if we change code with Build.VERSION.SDK_INT >= Build.VERSION_CODES.R, A10 would be still able to access OsmAnd storage ?

No, Google Play BRouter 1.6.3 targets API30/Android 11/Q and therefore access to legacy storage is only possible if upgrading from an older BRouter installation, not for a new installation. The relevant part of the check is Environment.isExternalStorageLegacy which determines if legacy access is possible. This call is only available since API29/Android 10/Q, therefore we need to check the android version before calling it.

There is a BRouter 1.6.3 build which targets API19 which allows access to legacy storage on all android versions.

Thanks for the info, no mention of this in the readme, can be really useful.

There is ongoing work on the documentation. Current draft version is at https://zod.github.io/brouter/users/android_quickstart.html#routing-via-service-interface

mello7tre commented 2 years ago

Thanks for the fast and detailed answer. I think that <repeat:…> trick should be enough for me. And now i better understand what happen. I consider the issue resolved and close it