OpenTracksApp / OpenTracks

OpenTracks is a sport tracking application that completely respects your privacy.
https://OpenTracksApp.com
Apache License 2.0
952 stars 184 forks source link

Use AltitudeConverterCompat instead of custom solution. #1931

Open dennisguse opened 2 weeks ago

dennisguse commented 2 weeks ago

Fixes #1920.

Implements fallback to EGM2008 up until API33 using Android's core library.

Aspects:

dennisguse commented 1 week ago

Android core location does include the data into the APK (assets/database/geoid-height-map-v0.db). This file is about 80Kb and opened using Android ROOM (i.e., an SQLite database).

This will reduce the APK size by ~17MB.

dennisguse commented 1 week ago

@gdt if you have time, it would be great if you could try this out :)

pstorch commented 1 week ago

Haven't used OpenTracks for some time. I checked out this branch and went for a walk
I started the recording. The notification indicated that it's running, but when I click on it, OpenTracks shows no running recording.

I tried to start it again and got this error:

App information

Device information

Firmware

Cause of error

Exception in thread "main": java.lang.IllegalStateException: Cannot access database on the main thread since it may potentially lock the UI for a long period of time.
    at androidx.room.RoomDatabase.assertNotMainThread(RoomDatabase.java:469)
    at androidx.room.RoomDatabase.query(RoomDatabase.java:525)
    at androidx.room.util.DBUtil.query(DBUtil.java:86)
    at androidx.core.location.altitude.impl.db.MapParamsDao_Impl.getCurrent(MapParamsDao_Impl.java:29)
    at androidx.core.location.altitude.impl.GeoidHeightMap.getParams(GeoidHeightMap.java:93)
    at androidx.core.location.altitude.impl.AltitudeConverter.addMslAltitudeToLocation(AltitudeConverter.java:199)
    at androidx.core.location.altitude.AltitudeConverterCompat.addMslAltitudeToLocation(AltitudeConverterCompat.java:86)
    at de.dennisguse.opentracks.services.handlers.AltitudeCorrectionManager.correctAltitude(AltitudeCorrectionManager.java:29)
    at de.dennisguse.opentracks.services.TrackRecordingManager.getDataForUI(TrackRecordingManager.java:128)
    at de.dennisguse.opentracks.services.TrackRecordingService.updateRecordingDataWhileRecording(TrackRecordingService.java:307)
    at de.dennisguse.opentracks.services.TrackRecordingService.-$$Nest$mupdateRecordingDataWhileRecording(Unknown Source:0)
    at de.dennisguse.opentracks.services.TrackRecordingService$1.run(TrackRecordingService.java:76)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:226)
    at android.os.Looper.loop(Looper.java:313)
    at android.app.ActivityThread.main(ActivityThread.java:8762)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
dennisguse commented 1 week ago

@pstorch I just realized that I was using the SDK34 emulator all the time and there the fallback isn't used.... Need to check how to get this done :) PS main thread is okay in this case.