From d358ed81d2295d0fa1c0dbe091242a9229e219ce Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Thu, 31 Dec 2015 01:43:00 +0100 Subject: [PATCH] Pebble: Display a failure if we cannot map a notification id back to a Phone number when replying to an SMS --- .../devices/pebble/PebbleProtocol.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java index 623e87b1..896be512 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java @@ -18,6 +18,7 @@ import java.util.Random; import java.util.SimpleTimeZone; import java.util.UUID; +import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppInfo; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppManagement; @@ -1579,6 +1580,7 @@ public class PebbleProtocol extends GBDeviceProtocol { icon_id = PebbleIconID.RESULT_MUTE; break; case 0x05: + boolean failed = true; byte attribute_count = buf.get(); if (attribute_count > 0) { byte attribute = buf.get(); @@ -1587,16 +1589,18 @@ public class PebbleProtocol extends GBDeviceProtocol { if (length > 64) length = 64; byte[] reply = new byte[length]; buf.get(reply); - devEvtNotificationControl.event = GBDeviceEventNotificationControl.Event.REPLY; - devEvtNotificationControl.reply = new String(reply); - caption = "SENT"; - icon_id = PebbleIconID.RESULT_SENT; - } else { - devEvtNotificationControl = null; // error - caption = "FAILED"; - icon_id = PebbleIconID.RESULT_FAILED; + // FIXME: this does not belong here, but we want at least check if there is no chance at all to send out the SMS later before we report success + String phoneNumber = GBApplication.getIDSenderLookup().lookup(id); + if (phoneNumber != null) { + devEvtNotificationControl.event = GBDeviceEventNotificationControl.Event.REPLY; + devEvtNotificationControl.reply = new String(reply); + caption = "SENT"; + icon_id = PebbleIconID.RESULT_SENT; + failed = false; + } } - } else { + } + if (failed) { caption = "FAILED"; icon_id = PebbleIconID.RESULT_FAILED; devEvtNotificationControl = null; // error