Garmin: fix laps with speed 0.0 for isPaceActivity=true

FIT file for testing:
https://github.com/ThomasKuehne/FIT-test-files/blob/main/Activity/2018/Activity_20180324_005_000_Swimming_Fr935_ae9c05519ca8c802f33a8ffd90b15915.fit

``
Error saving specific samplesjava.lang.IllegalArgumentException: Infinity is not a valid double value as per JSON specification. To override this behavior, use GsonBuilder.serializeSpecialFloatingPointValues() method.
  at com.google.gson.Gson.checkValidFloatingPoint(Gson.java:508)
  at com.google.gson.Gson$1.write(Gson.java:470)
  at com.google.gson.Gson$1.write(Gson.java:453)
  at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:73)
  at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$2.write(ReflectiveTypeAdapterFactory.java:251)
  at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:491)
  at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:73)
  at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:100)
  at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:64)
  at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:73)
  at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$2.write(ReflectiveTypeAdapterFactory.java:251)
  at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:491)
  at com.google.gson.TypeAdapter.toJsonTree(TypeAdapter.java:181)
  at com.google.gson.typeadapters.RuntimeTypeAdapterFactory$1.write(RuntimeTypeAdapterFactory.java:309)
  at com.google.gson.TypeAdapter$NullSafeTypeAdapter.write(TypeAdapter.java:304)
  at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:73)
  at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.write(MapTypeAdapterFactory.java:225)
  at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.write(MapTypeAdapterFactory.java:161)
  at com.google.gson.Gson.toJson(Gson.java:943)
  at com.google.gson.Gson.toJson(Gson.java:898)
  at com.google.gson.Gson.toJson(Gson.java:847)
  at com.google.gson.Gson.toJson(Gson.java:824)
  at nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryData.toJson(ActivitySummaryData.java:189)
  at nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryData.toString(ActivitySummaryData.java:185)
  at nodomain.freeyourgadget.gadgetbridge.devices.garmin.GarminWorkoutParser.updateSummary(GarminWorkoutParser.java:1080)
  at nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.FitImporter.persistWorkout(FitImporter.java:687)
``
This commit is contained in:
Thomas Kuehne
2026-04-29 18:22:53 +00:00
parent f0afd29d4a
commit 5bf6032e75
@@ -1,9 +1,36 @@
/* Copyright (C) 2024-2026 José Rebelo, Thomas Kuehne
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.activities.workouts.entries; package nodomain.freeyourgadget.gadgetbridge.activities.workouts.entries;
import androidx.annotation.Nullable;
import nodomain.freeyourgadget.gadgetbridge.activities.workouts.WorkoutValueFormatter; import nodomain.freeyourgadget.gadgetbridge.activities.workouts.WorkoutValueFormatter;
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries; import nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries;
public record ActivitySummaryValue(Object value, String unit) { public record ActivitySummaryValue(@Nullable Object value, String unit) {
public ActivitySummaryValue(@Nullable Object value, String unit) {
this.unit = unit;
if (value instanceof Number number) {
this.value = Double.isFinite(number.doubleValue()) ? value : null;
} else {
this.value = value;
}
}
public ActivitySummaryValue(final String value) { public ActivitySummaryValue(final String value) {
this(value, ActivitySummaryEntries.UNIT_STRING); this(value, ActivitySummaryEntries.UNIT_STRING);
} }