From 0ca35ad935bcfa61c64a676a0831dfd907952b35 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Tue, 19 Dec 2023 00:15:53 +0100 Subject: [PATCH] Xiaomi: Handle find phone messages without `system` properly After find phone is stopped, watch sends a `Command` message back without `system` set, and because of missing hasSystem() check, we'd wrongly go to condition that sets findPhoneEvent.event to START. --- .../xiaomi/services/XiaomiSystemService.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/services/XiaomiSystemService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/services/XiaomiSystemService.java index 5b3b153b4..ca75467c3 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/services/XiaomiSystemService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/services/XiaomiSystemService.java @@ -159,13 +159,15 @@ public class XiaomiSystemService extends AbstractXiaomiService implements Xiaomi return; case CMD_FIND_PHONE: LOG.debug("Got find phone: {}", cmd.getSystem().getFindDevice()); - final GBDeviceEventFindPhone findPhoneEvent = new GBDeviceEventFindPhone(); - if (cmd.getSystem().getFindDevice() == 0) { - findPhoneEvent.event = GBDeviceEventFindPhone.Event.START; - } else { - findPhoneEvent.event = GBDeviceEventFindPhone.Event.STOP; + if (cmd.hasSystem()) { + final GBDeviceEventFindPhone findPhoneEvent = new GBDeviceEventFindPhone(); + if (cmd.getSystem().getFindDevice() == 0) { + findPhoneEvent.event = GBDeviceEventFindPhone.Event.START; + } else { + findPhoneEvent.event = GBDeviceEventFindPhone.Event.STOP; + } + getSupport().evaluateGBDeviceEvent(findPhoneEvent); } - getSupport().evaluateGBDeviceEvent(findPhoneEvent); return; case CMD_DISPLAY_ITEMS_GET: handleDisplayItems(cmd.getSystem().getDisplayItems());