From 0f83346d65fe6ac5453eab135c3cb179e24baaa1 Mon Sep 17 00:00:00 2001 From: MrYoranimo Date: Mon, 4 Dec 2023 22:03:59 +0100 Subject: [PATCH] Xiaomi: check if binary parser result is null The activity parser may return null pointers in case the version of the data structure is not supported. Not checking for null here may result in the activity fetching task may never complete and cause further communication with the device to grind to a halt. --- .../devices/xiaomi/activity/impl/WorkoutSummaryParser.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/activity/impl/WorkoutSummaryParser.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/activity/impl/WorkoutSummaryParser.java index e59869215..6b9dff69d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/activity/impl/WorkoutSummaryParser.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/activity/impl/WorkoutSummaryParser.java @@ -60,6 +60,11 @@ public class WorkoutSummaryParser extends XiaomiActivityParser implements Activi return false; } + // parseBinaryData may return null in case the version is not supported + if (summary == null) { + return false; + } + summary.setSummaryData(null); // remove json before saving to database try (DBHandler dbHandler = GBApplication.acquireDB()) {