mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-26 10:35:50 +01:00
Avoid NPE when fetching activity data:
java.lang.NullPointerException: Attempt to write to field 'int nodomain.freeyourgadget.gadgetbridge.miband.MiBandSupport$ActivityStruct.activityDataHolderProgress' on a null object reference at nodomain.freeyourgadget.gadgetbridge.miband.MiBandSupport.flushActivityDataHolder(MiBandSupport.java:748) at nodomain.freeyourgadget.gadgetbridge.miband.MiBandSupport.handleActivityNotif(MiBandSupport.java:689) at nodomain.freeyourgadget.gadgetbridge.miband.MiBandSupport.onCharacteristicChanged(MiBandSupport.java:583) at nodomain.freeyourgadget.gadgetbridge.btle.BtLEQueue$2.onCharacteristicChanged(BtLEQueue.java:369)
This commit is contained in:
parent
a1f60aab91
commit
716bbc7b78
@ -672,7 +672,6 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
||||
|
||||
if (activityStruct.activityDataRemainingBytes == 0) {
|
||||
sendAckDataTransfer(activityStruct.activityDataTimestampToAck, activityStruct.activityDataUntilNextHeader);
|
||||
flushActivityDataHolder();
|
||||
}
|
||||
}
|
||||
|
||||
@ -712,6 +711,11 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
|
||||
private void flushActivityDataHolder() {
|
||||
if (activityStruct == null) {
|
||||
LOG.debug("nothing to flush, struct is already null");
|
||||
return;
|
||||
}
|
||||
LOG.debug("flushing activity data holder");
|
||||
byte category, intensity, steps;
|
||||
|
||||
ActivityDatabaseHandler dbHandler = GBApplication.getActivityDatabaseHandler();
|
||||
@ -770,6 +774,10 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
||||
TransactionBuilder builder = performInitialized("send acknowledge");
|
||||
builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_CONTROL_POINT), ack);
|
||||
builder.queue(getQueue());
|
||||
|
||||
// flush to the DB after sending the ACK
|
||||
flushActivityDataHolder();
|
||||
|
||||
//The last data chunk sent by the miband has always length 0.
|
||||
//When we ack this chunk, the transfer is done.
|
||||
if(getDevice().isBusy() && bytesTransferred==0) {
|
||||
@ -781,6 +789,7 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
|
||||
private void handleActivityFetchFinish() {
|
||||
LOG.info("Fetching activity data has finished.");
|
||||
activityStruct = null;
|
||||
unsetBusy();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user