BasicAirData / GPSLogger

A GPS logger for Android mobile devices
http://www.basicairdata.eu/projects/android/android-gps-logger/
GNU General Public License v3.0
401 stars 126 forks source link

Move EGM Binary Geoid Height File into FilesDir #24

Closed GrazianoCapelli closed 7 years ago

GrazianoCapelli commented 7 years ago

For historical reasons, the EGM Binary Geoid Height File is saved into /GPSLogger/AppData/.

Would be nice to move it into the FilesDir, that is a private folder and is not normally accessed by the user. The file will be downloaded in the new folder when the user enables the EGM correction for the first time. In case the file already exists in /GPSLogger/AppData/, we have to copy it into the new folder.

In that way will be possible in the future to clear and remove the "/AppData" subfolder on Shutdown.

GrazianoCapelli commented 7 years ago

I tried to copy the file on startup (I left the commented-out code, added on commit 4fc4432). This was the simplest solution in order to move the file into the new location, but sadly the operation freezes the app execution for too much time (on my phone more or less a couple of seconds). It is a one-time operation, but 2 seconds of freeze are unacceptable.

I'll try to implement the enhancement in another way. One possible solution is to insert it into EGM class itself (in LoadEGM96Grid, that runs in a runnable).

JLJu commented 7 years ago

Well, to say it straight. Two seconds may be acceptable for a one-time operation.

GrazianoCapelli commented 7 years ago

I've choosen a better approach that doesn't freeze the app (commit 9128f0a): The EGM loader first looks for EGM Grid File in both /GPSLogger/AppData and FilesDir and loads the grid.

If the file is present in FilesDir, it loads this file. If the file is present in /GPSLogger/AppData, it loads the grid and then it copies the file into FilesDir using a background thread. When the copy is finished, it delete the old one. If the file is present in both folders, it simply delete the shared one (/GPSLogger/AppData).

The new downloads of EGM file are directly put into FilesDir.

Thanks to this improvement: