mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Huawei: fix HR in the sample provider
This commit is contained in:
+21
-4
@@ -19,6 +19,9 @@ package nodomain.freeyourgadget.gadgetbridge.devices.huawei;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -44,9 +47,12 @@ import nodomain.freeyourgadget.gadgetbridge.entities.HuaweiWorkoutSummarySampleD
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huawei.HuaweiSupportProvider;
|
||||
|
||||
public class HuaweiSampleProvider extends AbstractSampleProvider<HuaweiActivitySample> {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(HuaweiSampleProvider.class);
|
||||
|
||||
/*
|
||||
* We save all data by saving a marker at the begin and end. We do not actively use these for
|
||||
* showing the data at the moment, but the samples are still saved as such, to keep the table
|
||||
@@ -274,6 +280,9 @@ public class HuaweiSampleProvider extends AbstractSampleProvider<HuaweiActivityS
|
||||
List<HuaweiActivitySample> samples = qb.build().list();
|
||||
for (HuaweiActivitySample sample : samples) {
|
||||
sample.setProvider(this);
|
||||
if(sample.getHeartRate() != ActivitySample.NOT_MEASURED) {
|
||||
sample.setHeartRate(sample.getHeartRate() & 0xFF);
|
||||
}
|
||||
}
|
||||
detachFromSession();
|
||||
return samples;
|
||||
@@ -498,8 +507,12 @@ public class HuaweiSampleProvider extends AbstractSampleProvider<HuaweiActivityS
|
||||
// Skip the processed sample that are before this workout sample
|
||||
while (workoutSamples.get(i).getTimestamp() > processedSamples.get(currentIndex).getTimestamp()) {
|
||||
if (inWorkout) {
|
||||
processedSamples.get(currentIndex).setHeartRate(lastHr);
|
||||
processedSamples.get(currentIndex).setRawIntensity(0);
|
||||
// In the DB we have samples where timestamp > otherTimestamp and where otherTimestamp > timestamp.
|
||||
// Do not overwrite this sample
|
||||
if(workoutSamples.get(i).getTimestamp() > processedSamples.get(currentIndex).getOtherTimestamp() || processedSamples.get(currentIndex).getHeartRate() == ActivitySample.NOT_MEASURED) {
|
||||
processedSamples.get(currentIndex).setHeartRate(lastHr);
|
||||
processedSamples.get(currentIndex).setRawIntensity(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Reset
|
||||
@@ -537,8 +550,12 @@ public class HuaweiSampleProvider extends AbstractSampleProvider<HuaweiActivityS
|
||||
// and intensity - see #4126 for the reasoning
|
||||
while (currentIndex < processedSamples.size() && workoutSamples.get(i).getTimestamp() > processedSamples.get(currentIndex).getTimestamp()) {
|
||||
if (inWorkout) {
|
||||
processedSamples.get(currentIndex).setHeartRate(ActivitySample.NOT_MEASURED);
|
||||
processedSamples.get(currentIndex).setRawIntensity(0);
|
||||
// In the DB we have samples where timestamp > otherTimestamp and where otherTimestamp > timestamp.
|
||||
// Do not clear this sample
|
||||
if(workoutSamples.get(i).getTimestamp() > processedSamples.get(currentIndex).getOtherTimestamp() || processedSamples.get(currentIndex).getHeartRate() == ActivitySample.NOT_MEASURED) {
|
||||
processedSamples.get(currentIndex).setHeartRate(ActivitySample.NOT_MEASURED);
|
||||
processedSamples.get(currentIndex).setRawIntensity(0);
|
||||
}
|
||||
}
|
||||
|
||||
currentIndex += 1;
|
||||
|
||||
Reference in New Issue
Block a user