1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2025-01-13 11:17:33 +01:00

Pebble: Display a failure if we cannot map a notification id back to a Phone number when replying to an SMS

This commit is contained in:
Andreas Shimokawa 2015-12-31 01:43:00 +01:00
parent 890016d652
commit d358ed81d2

View File

@ -18,6 +18,7 @@ import java.util.Random;
import java.util.SimpleTimeZone; import java.util.SimpleTimeZone;
import java.util.UUID; import java.util.UUID;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppInfo; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppInfo;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppManagement; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppManagement;
@ -1579,6 +1580,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
icon_id = PebbleIconID.RESULT_MUTE; icon_id = PebbleIconID.RESULT_MUTE;
break; break;
case 0x05: case 0x05:
boolean failed = true;
byte attribute_count = buf.get(); byte attribute_count = buf.get();
if (attribute_count > 0) { if (attribute_count > 0) {
byte attribute = buf.get(); byte attribute = buf.get();
@ -1587,16 +1589,18 @@ public class PebbleProtocol extends GBDeviceProtocol {
if (length > 64) length = 64; if (length > 64) length = 64;
byte[] reply = new byte[length]; byte[] reply = new byte[length];
buf.get(reply); buf.get(reply);
devEvtNotificationControl.event = GBDeviceEventNotificationControl.Event.REPLY; // 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
devEvtNotificationControl.reply = new String(reply); String phoneNumber = GBApplication.getIDSenderLookup().lookup(id);
caption = "SENT"; if (phoneNumber != null) {
icon_id = PebbleIconID.RESULT_SENT; devEvtNotificationControl.event = GBDeviceEventNotificationControl.Event.REPLY;
} else { devEvtNotificationControl.reply = new String(reply);
devEvtNotificationControl = null; // error caption = "SENT";
caption = "FAILED"; icon_id = PebbleIconID.RESULT_SENT;
icon_id = PebbleIconID.RESULT_FAILED; failed = false;
}
} }
} else { }
if (failed) {
caption = "FAILED"; caption = "FAILED";
icon_id = PebbleIconID.RESULT_FAILED; icon_id = PebbleIconID.RESULT_FAILED;
devEvtNotificationControl = null; // error devEvtNotificationControl = null; // error