Huawei: fix activitySampleProvider time and tests

This commit is contained in:
Me7c7
2025-09-07 15:36:24 +03:00
parent 5127d2a4f6
commit 37de59fa4b
2 changed files with 12 additions and 6 deletions
@@ -333,8 +333,14 @@ public class HuaweiSampleProvider extends AbstractSampleProvider<HuaweiActivityS
protected List<HuaweiActivitySample> getGBActivitySamples(int timestamp_from, int timestamp_to) {
List<HuaweiActivitySample> processedSamples = new ArrayList<>();
timestamp_from = adjustTimeSecToMinute(timestamp_from);
timestamp_to = adjustTimeSecToMinute(timestamp_to);
int adjustedTimestampFrom = adjustTimeSecToMinute(timestamp_from);
int adjustedTimestampTo = adjustTimeSecToMinute(timestamp_to);
timestamp_from = (adjustedTimestampFrom < timestamp_from)?adjustedTimestampFrom + 60:adjustedTimestampFrom;
timestamp_to = (adjustedTimestampTo > timestamp_to)?adjustedTimestampTo - 60:adjustedTimestampTo;
if(timestamp_from > timestamp_to)
return processedSamples;
for (int timestamp = timestamp_from; timestamp <= timestamp_to; timestamp += 60) {
processedSamples.add(createDummySample(timestamp));
@@ -349,9 +355,6 @@ public class HuaweiSampleProvider extends AbstractSampleProvider<HuaweiActivityS
@Override
protected List<HuaweiActivitySample> getGBActivitySamplesHighRes(int timestamp_from, int timestamp_to) {
timestamp_from = adjustTimeSecToMinute(timestamp_from);
timestamp_to = adjustTimeSecToMinute(timestamp_to);
List<HuaweiActivitySample> processedSamples = getRawOrderedActivitySamples(timestamp_from, timestamp_to);
addWorkoutSamples(processedSamples, timestamp_from, timestamp_to);
// Filter out the end markers before returning
@@ -202,7 +202,10 @@ public class SampleProviderTest extends TestBase {
samples = sampleProvider.getAllActivitySamples(100, 150);
assertEquals(1, samples.size());
assertEquals(100, samples.get(0).getTimestamp());
assertEquals(120, samples.get(0).getTimestamp()); //Time is adjusted to whole minute, so we have only one sample for requested interval.
samples = sampleProvider.getAllActivitySamples(100, 110);
assertEquals(0, samples.size()); // no samples, time is adjusted to minute but interval is not
samples = sampleProvider.getAllActivitySamplesHighRes(100, 115);
assertEquals(2, samples.size());