diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lefun/LefunDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lefun/LefunDeviceSupport.java index c9b706fad..427622a87 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lefun/LefunDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lefun/LefunDeviceSupport.java @@ -40,6 +40,7 @@ import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; import nodomain.freeyourgadget.gadgetbridge.database.DBHelper; import nodomain.freeyourgadget.gadgetbridge.devices.lefun.LefunConstants; +import nodomain.freeyourgadget.gadgetbridge.devices.lefun.commands.FindPhoneCommand; import nodomain.freeyourgadget.gadgetbridge.devices.lefun.commands.GetActivityDataCommand; import nodomain.freeyourgadget.gadgetbridge.devices.lefun.commands.GetPpgDataCommand; import nodomain.freeyourgadget.gadgetbridge.devices.lefun.commands.GetSleepDataCommand; @@ -385,6 +386,8 @@ public class LefunDeviceSupport extends AbstractBTLEDeviceSupport { switch (commandId) { case LefunConstants.CMD_PPG_RESULT: return handleAsynchronousPpgResult(data); + case LefunConstants.CMD_FIND_PHONE: + return handleAntiLoss(data); } return false; } @@ -401,6 +404,19 @@ public class LefunDeviceSupport extends AbstractBTLEDeviceSupport { } } + private boolean handleAntiLoss(byte[] data) { + try { + FindPhoneCommand cmd = new FindPhoneCommand(); + cmd.deserialize(data); + // TODO: actually pop something that makes sound + GB.toast("Your device is trying to find your phone", Toast.LENGTH_LONG, GB.INFO); + return true; + } catch (IllegalArgumentException e) { + LOG.error("Failed to handle anti-loss", e); + return false; + } + } + public void completeInitialization() { gbDevice.setState(GBDevice.State.INITIALIZED); gbDevice.sendDeviceUpdateIntent(getContext());