mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-05 09:47:01 +01:00
Xiaomi: Ignore activity files without timestamp and version
Some watches will send a sequence of zeroes, which would make activity fetch become stuck, as the file does not exist.
This commit is contained in:
parent
09bcb782da
commit
0e9c709a59
@ -845,6 +845,10 @@ public class XiaomiHealthService extends AbstractXiaomiService {
|
|||||||
while (buf.position() < buf.limit()) {
|
while (buf.position() < buf.limit()) {
|
||||||
final XiaomiActivityFileId fileId = XiaomiActivityFileId.from(buf);
|
final XiaomiActivityFileId fileId = XiaomiActivityFileId.from(buf);
|
||||||
LOG.debug("Got activity to fetch: {}", fileId);
|
LOG.debug("Got activity to fetch: {}", fileId);
|
||||||
|
if (fileId.getTimestamp().getTime() == 0 && fileId.getVersion() == 0) {
|
||||||
|
LOG.warn("Skipping invalid file with no timestamp and version");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
fileIds.add(fileId);
|
fileIds.add(fileId);
|
||||||
}
|
}
|
||||||
activityFetcher.fetch(fileIds);
|
activityFetcher.fetch(fileIds);
|
||||||
|
@ -18,6 +18,7 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.xiaomi.activity;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@ -80,4 +81,10 @@ public class XiaomiActivityFileIdTest {
|
|||||||
|
|
||||||
assertArrayEquals(bytes, bufEncode.array());
|
assertArrayEquals(bytes, bufEncode.array());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testZero() {
|
||||||
|
final XiaomiActivityFileId fileId = XiaomiActivityFileId.from(new byte[]{0, 0, 0, 0, 0, 0, 0});
|
||||||
|
assertTrue(fileId.getTimestamp().getTime() == 0 && fileId.getVersion() == 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user