From 406f9ab90ddd32d6162cda5dae4e8f19a545bddf Mon Sep 17 00:00:00 2001 From: Daniele Gobbetti Date: Tue, 2 Jun 2015 17:29:02 +0200 Subject: [PATCH] Do not allocate the buffer if there's no data available. Perhaps could fix the "data in the future" issue --- .../freeyourgadget/gadgetbridge/miband/MiBandSupport.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/miband/MiBandSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/miband/MiBandSupport.java index eaa3ccd0..c2f2dda9 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/miband/MiBandSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/miband/MiBandSupport.java @@ -462,8 +462,10 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport { LOG.info("data to read until next header: "+ dataUntilNextHeader +" len: " + (dataUntilNextHeader / 3) + " minute(s)"); LOG.info("TIMESTAMP: " + DateFormat.getDateTimeInstance().format(timestamp.getTime()).toString() + " magic byte: " + dataUntilNextHeader); - this.activityDataRemainingBytes = this.activityDataUntilNextHeader = dataUntilNextHeader; - this.activityDataTimestampProgress = this.activityDataTimestampToAck = timestamp; + if (dataUntilNextHeader > 0 ) { //tentative fix for data in the future + this.activityDataRemainingBytes = this.activityDataUntilNextHeader = dataUntilNextHeader; + this.activityDataTimestampProgress = this.activityDataTimestampToAck = timestamp; + } } else { bufferActivityData(value);