From cf40dae93b0579e476a8acb198263928c2debf29 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 10bd6452f..015fbcb12 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 @@ -106,6 +106,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.AlarmUtils; import nodomain.freeyourgadget.gadgetbridge.util.EmojiConverter; import nodomain.freeyourgadget.gadgetbridge.util.FileUtils; 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; @@ -134,6 +135,8 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport { private boolean realtimeStep = false; private int realtimeHRMInterval = 30*60; + private final LimitedQueue/*Long*/ mNotificationReplyAction = new LimitedQueue(16); + /// Maximum amount of characters to store in receiveHistory public static final int MAX_RECEIVE_HISTORY_CHARS = 100000; // Local Intents - for app manager communication @@ -445,6 +448,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": { @@ -675,6 +685,11 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport { @Override public void onNotification(NotificationSpec notificationSpec) { + for (int i=0;i