mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Huawei: fix activitySampleProvider time and tests
This commit is contained in:
+8
-5
@@ -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
|
||||
|
||||
+4
-1
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user