Repository navigation
Android: fill WorkoutSummary from Health Connect workout keys - #535
Open
ChandraChaan wants to merge 1 commit into
Open
ChandraChaan wants to merge 1 commit into
ChandraChaan wants to merge 1 commit into
Conversation
On Android, HealthDataPoint.workoutSummary was always null because the Kotlin reader sends workoutActivityType, totalDistance, totalEnergyBurned and totalSteps, while WorkoutSummary only read the snake_case keys that iOS sends. Fall back to the camelCase keys so the summary is filled on both platforms. Fixes carp-dk#492
iarata
added a commit
that referenced
this pull request
Nov 11, 2026
…alth Connect workout keys HealthDataPoint.workoutSummary was null for every Android workout: WorkoutSummary read only the snake_case keys that iOS sends, while Android sends the camelCase keys of WorkoutHealthValue. The PR reads the snake_case key first and falls back to the camelCase one, so on Android the workouts of reads, pages, reads by UUID and changes all get a summary: the workout's type name, as in workoutActivityType, and its totals, 0 for a missing one as on iOS. iOS sends both sets of keys, so its summaries do not change. It merges as is. Adapted: the new tests are formatted to the repo's 120 columns, and the iOS precedence test uses the reply of 14.0.0's iOS code (the RUNNING name, and both the whole-number summary totals and the workout value's). WorkoutSummary.toString had no ', ' after the workout type; the Android test checks it.
Author
|
Hi maintainers, a gentle ping on this one when you have a moment. It fixes #492: on Android |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #492.
Problem
On Android,
HealthDataPoint.workoutSummaryis alwaysnullforWORKOUTrecords. The Kotlin reader (handleWorkoutDatainHealthDataReader.kt) sendsworkoutActivityType,totalDistance,totalEnergyBurnedandtotalSteps, butWorkoutSummary.fromHealthDataPointand the check inHealthDataPoint.fromHealthDataPointonly look for the snake_case keys (workout_type,total_distance, ...) that the iOS reader sends.Fix
WorkoutSummary.fromHealthDataPointreads the snake_case keys first and falls back to the camelCase ones, so iOS behaves exactly as before.HealthDataPoint.fromHealthDataPointalso builds a summary whenworkoutActivityTypeis present, which every Android workout has.I fixed this on the Dart side rather than adding snake_case keys in Kotlin, so it also works without a native rebuild and can be covered by unit tests. Happy to move it into
HealthDataReader.ktinstead if you prefer to keep the key mapping native.Tests
Added four cases to
test/unit/health_value_parsing_test.dart:The two Android cases fail on
mainand pass with this change. Note thatflutter teston currentmainalready has 49 failing tests from thedevice_info_plusmocking issue addressed in #523; this change adds no new failures.