Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use AltitudeConverterCompat instead of custom solution. #1931

Merged
merged 1 commit into from
Sep 14, 2024

Conversation

dennisguse
Copy link
Member

Fixes #1920.

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

Aspects:

  • core library is still in alpha mode
  • data may still be bundled (not sure how big it is)

@dennisguse dennisguse added the maintenance Required maintenance work label Jun 18, 2024
@dennisguse dennisguse force-pushed the AltitudeConverterCompat#1920 branch from 46937a3 to 12a13a8 Compare June 20, 2024 16:15
@dennisguse
Copy link
Member Author

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 dennisguse requested a review from pstorch June 20, 2024 16:17
@dennisguse
Copy link
Member Author

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

@dennisguse dennisguse force-pushed the AltitudeConverterCompat#1920 branch from 12a13a8 to ad18eed Compare June 20, 2024 20:18
@pstorch
Copy link
Member

pstorch commented Jun 23, 2024

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

  • ID: de.dennisguse.opentracks.debug
  • Version: 5788 v4.12.4-debug

Device information

  • Brand: samsung
  • Device: y2s
  • Model: SM-G985F
  • Id: TP1A.220624.014
  • Product: y2seea

Firmware

  • SDK: 33
  • Release: 13
  • Incremental: G985FXXSKHXEA

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
Copy link
Member Author

@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.

@dennisguse
Copy link
Member Author

@pstorch I reported this: https://issuetracker.google.com/issues/195660815#comment21
Let's hope the library gets adjusted - adding async behavior to this would make the code even messier.

@dennisguse
Copy link
Member Author

@pstorch I added some <airquote>background</airquote> and it works in my emulator.
Not proud to have written this code...
Would you have some time to check this?

@pstorch
Copy link
Member

pstorch commented Sep 7, 2024

I'll give it a try.

@pstorch
Copy link
Member

pstorch commented Sep 7, 2024

The bug from last time is gone. I found another, but this is already in the main branch.

@dennisguse
Copy link
Member Author

@pstorch which one? :D

@pstorch
Copy link
Member

pstorch commented Sep 8, 2024

@pstorch which one? :D

The crash I reported here:
#1931 (comment)

@dennisguse dennisguse merged commit 2e7a3b7 into main Sep 14, 2024
3 of 5 checks passed
@dennisguse dennisguse deleted the AltitudeConverterCompat#1920 branch September 14, 2024 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Required maintenance work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use AltitudeConverterCompat?
2 participants