From 774fb4efc3797f591888bd38cc1a1f501d914d46 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Fri, 10 Jun 2022 11:40:53 +0100 Subject: [PATCH] Bangle.js fix message REPLY option --- .../devices/banglejs/BangleJSDeviceSupport.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSDeviceSupport.java index ad2ed8014..f99c22ac8 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSDeviceSupport.java @@ -90,6 +90,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEDeviceSuppo import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; import nodomain.freeyourgadget.gadgetbridge.util.AlarmUtils; import nodomain.freeyourgadget.gadgetbridge.util.GB; +import nodomain.freeyourgadget.gadgetbridge.util.LimitedQueue; import nodomain.freeyourgadget.gadgetbridge.util.Prefs; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_ALLOW_HIGH_MTU; @@ -114,6 +115,8 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport { private boolean realtimeStep = false; private int realtimeHRMInterval = 30*60; + private final LimitedQueue/*Long*/ mNotificationReplyAction = new LimitedQueue(16); + // Local Intents - for app manager communication public static final String BANGLEJS_COMMAND_TX = "banglejs_command_tx"; public static final String BANGLEJS_COMMAND_RX = "banglejs_command_rx"; @@ -376,6 +379,13 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport { deviceEvtNotificationControl.phoneNumber = json.getString("tel"); if (json.has("msg")) deviceEvtNotificationControl.reply = json.getString("msg"); + /* REPLY responses don't use the ID from the event (MUTE/etc seem to), but instead + * they use a handle that was provided in an action list on the onNotification.. event */ + if (deviceEvtNotificationControl.event == GBDeviceEventNotificationControl.Event.REPLY) { + Long foundHandle = (Long)mNotificationReplyAction.lookup((int)deviceEvtNotificationControl.handle); + if (foundHandle!=null) + deviceEvtNotificationControl.handle = foundHandle; + } evaluateGBDeviceEvent(deviceEvtNotificationControl); } break; case "act": { @@ -573,6 +583,11 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport { @Override public void onNotification(NotificationSpec notificationSpec) { + for (int i=0;i