mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02: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:
+1
-1
@@ -124,7 +124,7 @@ class PebbleIoThread extends GBDeviceIoThread {
|
|||||||
jsEvent = "appmessage";
|
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);
|
LOG.debug("to WEBVIEW: event: " + jsEvent + " message: " + appMessage);
|
||||||
WebViewSingleton.invokeWebview(new WebViewSingleton.WebViewRunnable() {
|
WebViewSingleton.invokeWebview(new WebViewSingleton.WebViewRunnable() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -130,14 +130,14 @@ public class PebbleUtils {
|
|||||||
return null;
|
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 jsAppMessage = new JSONObject();
|
||||||
|
|
||||||
JSONObject knownKeys = PebbleUtils.getAppConfigurationKeys(uuid);
|
JSONObject knownKeys = PebbleUtils.getAppConfigurationKeys(uuid);
|
||||||
SparseArray<String> appKeysMap = new SparseArray<>();
|
SparseArray<String> appKeysMap = new SparseArray<>();
|
||||||
|
|
||||||
if (knownKeys == null || msg == null) {
|
if (knownKeys == null || msg == null) {
|
||||||
return "{}";
|
msg = "[]";
|
||||||
}
|
}
|
||||||
|
|
||||||
String inKey, outKey;
|
String inKey, outKey;
|
||||||
@@ -169,6 +169,9 @@ public class PebbleUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
jsAppMessage.put("payload", outgoing);
|
jsAppMessage.put("payload", outgoing);
|
||||||
|
JSONObject data = new JSONObject();
|
||||||
|
data.put("transactionId", transactionId);
|
||||||
|
jsAppMessage.put("data", data);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.warn("Unable to parse incoming app message", e);
|
LOG.warn("Unable to parse incoming app message", e);
|
||||||
|
|||||||
Reference in New Issue
Block a user