1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-25 18:15:49 +01:00

Pebble: fix nasty crash when appmessage id is > 127

This is a regression since Gadgetbridge 0.22.0

Potentially fixes the following:

- #868
- #876
- #884

NOTE:

Java has no unisgned, java has no unsigned, java has no unsigned.
Java has no unisgned, java has no unsigned, java has no unsigned.
Java has no unisgned, java has no unsigned, java has no unsigned.
This commit is contained in:
Andreas Shimokawa 2017-11-14 22:28:54 +01:00
parent 97fda2434d
commit 7ffcc44378

View File

@ -1986,7 +1986,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
}
}
idLookup[last_id] = ext_id;
idLookup[last_id & 0xff] = ext_id;
return buf.array();
}
@ -2633,14 +2633,14 @@ public class PebbleProtocol extends GBDeviceProtocol {
LOG.info("got APPLICATIONMESSAGE/LAUNCHER (EP " + endpoint + ") NACK");
}
GBDeviceEventAppMessage evtAppMessage = null;
if (endpoint == ENDPOINT_APPLICATIONMESSAGE && idLookup[last_id] != null) {
if (endpoint == ENDPOINT_APPLICATIONMESSAGE && idLookup[last_id & 0xff] != null) {
evtAppMessage = new GBDeviceEventAppMessage();
if (pebbleCmd == APPLICATIONMESSAGE_ACK) {
evtAppMessage.type = GBDeviceEventAppMessage.TYPE_ACK;
} else {
evtAppMessage.type = GBDeviceEventAppMessage.TYPE_NACK;
}
evtAppMessage.id = idLookup[last_id];
evtAppMessage.id = idLookup[last_id & 0xff];
evtAppMessage.appUUID = currentRunningApp;
}
devEvts = new GBDeviceEvent[]{evtAppMessage};