mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-25 19:36:50 +01:00
Pebble: ack the messages that go to the webview and do not destroy it on disconnect.
This commit is contained in:
parent
53dbc54041
commit
a545c56680
@ -84,6 +84,7 @@ class PebbleIoThread extends GBDeviceIoThread {
|
||||
private void sendAppMessageJS(GBDeviceEventAppMessage appMessage) {
|
||||
// WebViewSingleton.runJavascriptInterface(gbDevice, appMessage.appUUID);
|
||||
WebViewSingleton.appMessage(appMessage.message);
|
||||
write(mPebbleProtocol.encodeApplicationMessageAck(appMessage.appUUID, (byte) appMessage.id));
|
||||
}
|
||||
|
||||
PebbleIoThread(PebbleSupport pebbleSupport, GBDevice gbDevice, GBDeviceProtocol gbDeviceProtocol, BluetoothAdapter btAdapter, Context context) {
|
||||
|
@ -105,10 +105,11 @@ public class WebViewSingleton {
|
||||
}
|
||||
}
|
||||
|
||||
public static void appMessage(final String message) {
|
||||
public static void appMessage(String message) {
|
||||
|
||||
if (instance == null)
|
||||
return;
|
||||
|
||||
final String appMessage = jsInterface.parseIncomingAppMessage(message);
|
||||
LOG.debug("to WEBVIEW: " + appMessage);
|
||||
|
||||
@ -119,7 +120,8 @@ public class WebViewSingleton {
|
||||
instance.evaluateJavascript("Pebble.evaluate('appmessage',[" + appMessage + "]);", new ValueCallback<String>() {
|
||||
@Override
|
||||
public void onReceiveValue(String s) {
|
||||
LOG.debug("Callback from showConfiguration", s);
|
||||
//TODO: the message should be acked here instead of in PebbleIoThread
|
||||
LOG.debug("Callback from appmessage", s);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@ -141,9 +143,9 @@ public class WebViewSingleton {
|
||||
instance.loadUrl("about:blank");
|
||||
instance.freeMemory();
|
||||
instance.pauseTimers();
|
||||
instance.destroy();
|
||||
instance = null;
|
||||
contextWrapper = null;
|
||||
// instance.destroy();
|
||||
// instance = null;
|
||||
// contextWrapper = null;
|
||||
jsInterface = null;
|
||||
}
|
||||
}
|
||||
@ -258,6 +260,13 @@ public class WebViewSingleton {
|
||||
}
|
||||
jsAppMessage.put("payload", outgoing);
|
||||
|
||||
//ack message to pebble
|
||||
|
||||
/*
|
||||
sendBytesAck = new GBDeviceEventSendBytes();
|
||||
sendBytesAck.encodedBytes = encodeApplicationMessageAck(uuid, last_id);
|
||||
*/
|
||||
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user