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

Pebble JS: add transactionId metadata to the appmessage.

Removes the errors in Pebble-Casio-WV58DE as reported in #482
This commit is contained in:
Daniele Gobbetti 2018-02-28 21:56:46 +01:00
parent 1e0d7550d9
commit d88badaf4d
2 changed files with 6 additions and 3 deletions

View File

@ -124,7 +124,7 @@ class PebbleIoThread extends GBDeviceIoThread {
jsEvent = "appmessage";
}
final String appMessage = PebbleUtils.parseIncomingAppMessage(message.message, message.appUUID);
final String appMessage = PebbleUtils.parseIncomingAppMessage(message.message, message.appUUID, message.id);
LOG.debug("to WEBVIEW: event: " + jsEvent + " message: " + appMessage);
WebViewSingleton.invokeWebview(new WebViewSingleton.WebViewRunnable() {
@Override

View File

@ -130,14 +130,14 @@ public class PebbleUtils {
return null;
}
public static String parseIncomingAppMessage(String msg, UUID uuid) {
public static String parseIncomingAppMessage(String msg, UUID uuid, int transactionId) {
JSONObject jsAppMessage = new JSONObject();
JSONObject knownKeys = PebbleUtils.getAppConfigurationKeys(uuid);
SparseArray<String> appKeysMap = new SparseArray<>();
if (knownKeys == null || msg == null) {
return "{}";
msg = "[]";
}
String inKey, outKey;
@ -169,6 +169,9 @@ public class PebbleUtils {
}
}
jsAppMessage.put("payload", outgoing);
JSONObject data = new JSONObject();
data.put("transactionId", transactionId);
jsAppMessage.put("data", data);
} catch (Exception e) {
LOG.warn("Unable to parse incoming app message", e);