Some Bits: Nelson's log

Android Scoped Storage, SyncThing, GPSLogger

I’m trying to synchronize data from Mendhak’s GPSLogger to other devices. I’m running the latest Android (11?) on a Pixel 3. GPSLogger supports a nice variety of sync options but none are quite right for me, so I thought I’d try using SyncThing on the data files on the phone instead. But I ran into a confusing permissions / security thing in Android where SyncThing couldn’t see GPSLogger’s data files. Here’s what’s going on.

First off, where are the files? The GPSLogger docs say they are in a folder with a name like /sdcard/Android/data/com.mendhak.gpslogger/files/. The first confusing this is that /sdcard prefix: apparently this is different on different devices. But the path from Android on down should be consistent.

If I access this files via the SolidExplorer Android file browser it shows up as a storage named “Internal Memory”, the default. (Presumably this could also be an SDcard or something). From there I can click Android and get three choices: data, media, and obb. Click data, search the giant list for com.mendhak.gpslogger, and there I am. Bottom line: GPSLogger stores its files in /sdcard/Android/data/com.mendhak.gpslogger under the root directory, at least on my phone. It’s just where the root is can be confusing.

If I plug in my phone and access it on my Windows machine as a USB drive, I can find my data with this path:
This PC\Pixel 3\Internal shared storage\Android\data\com.mendhak.gpslogger
Seems logically consistent; get to the root of the internal memory, then drill in on Android.

Unfortunately as of Android 11, ordinary apps can no longer access the data folder of other apps. This is presumably a security update, I guess the assumption is most of the time those files are private to the app and shouldn’t be visible. There’s an elaborate new system called “Scoped Storage” where apps can explicitly choose to share files but a lot of apps haven’t really caught up to that. It’s great that Android has a filesystem you can just access at all but over time they’ve complicated it.

There’s a couple of workarounds to the Android restrictions. A bunch of file explorer apps (including Solid) have hacked around it somehow to show you all the folders. Not sure how, I wonder if they’re using the opt-out procedure which is listed as “temporary”, a compatibly measure, and comes with other restrictions.

But this doesn’t help me with SyncThing; it doesn’t seem to support the workaround. All it shows me under “Android” is “media”, a sign that it’s stuck inside the scoped storage sandbox. Which is a little weird because I think it’s supposed to work thanks to including this patch. In particular there’s a “Use advanced Folder Picker: Select any folder on the device for syncing” that sounds like it should enable the workaround. It just doesn’t seem to work.

I also tried SyncThing-Fork, an experimental version. It has a little wheel next to the directory picker that gives you some “advanced” picker. It shows a data folder but that folder is empty. There’s so much drama getting Google Play Store approval I’m not sure it even can work. I briefly tried the FDroid version too (which is a bit more up to date) and it didn’t work there either. Anyway not thrilled at the idea of the fork, particularly if I have to install it via FDroid! So not pursuing that option further.

I finally gave up; the SyncThing app just can’t access that folder. Which is too bad. But fortunately there’s an easy other solution, which is just to get GPSLogger to write files to a different place instead. I chose to put them in /Documents/GPSLogger. Near as I can tell this directory is world-accessible. At least SyncThing can get at it, although IIRC I had to give it one-time permission to access it.

And so now I have SyncThing syncing GPSLogger’s files to my Linux server. Yay! Honestly it would have been a lot easier just to use SFTP or something from GPSLogger but I didn’t really want to set any of the GPSLogger options up. SyncThing seems to be working.