mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-29 05:16:51 +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) {
|
private void sendAppMessageJS(GBDeviceEventAppMessage appMessage) {
|
||||||
// WebViewSingleton.runJavascriptInterface(gbDevice, appMessage.appUUID);
|
// WebViewSingleton.runJavascriptInterface(gbDevice, appMessage.appUUID);
|
||||||
WebViewSingleton.appMessage(appMessage.message);
|
WebViewSingleton.appMessage(appMessage.message);
|
||||||
|
write(mPebbleProtocol.encodeApplicationMessageAck(appMessage.appUUID, (byte) appMessage.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
PebbleIoThread(PebbleSupport pebbleSupport, GBDevice gbDevice, GBDeviceProtocol gbDeviceProtocol, BluetoothAdapter btAdapter, Context context) {
|
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)
|
if (instance == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
final String appMessage = jsInterface.parseIncomingAppMessage(message);
|
final String appMessage = jsInterface.parseIncomingAppMessage(message);
|
||||||
LOG.debug("to WEBVIEW: " + appMessage);
|
LOG.debug("to WEBVIEW: " + appMessage);
|
||||||
|
|
||||||
@ -119,7 +120,8 @@ public class WebViewSingleton {
|
|||||||
instance.evaluateJavascript("Pebble.evaluate('appmessage',[" + appMessage + "]);", new ValueCallback<String>() {
|
instance.evaluateJavascript("Pebble.evaluate('appmessage',[" + appMessage + "]);", new ValueCallback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceiveValue(String s) {
|
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 {
|
} else {
|
||||||
@ -141,9 +143,9 @@ public class WebViewSingleton {
|
|||||||
instance.loadUrl("about:blank");
|
instance.loadUrl("about:blank");
|
||||||
instance.freeMemory();
|
instance.freeMemory();
|
||||||
instance.pauseTimers();
|
instance.pauseTimers();
|
||||||
instance.destroy();
|
// instance.destroy();
|
||||||
instance = null;
|
// instance = null;
|
||||||
contextWrapper = null;
|
// contextWrapper = null;
|
||||||
jsInterface = null;
|
jsInterface = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -258,6 +260,13 @@ public class WebViewSingleton {
|
|||||||
}
|
}
|
||||||
jsAppMessage.put("payload", outgoing);
|
jsAppMessage.put("payload", outgoing);
|
||||||
|
|
||||||
|
//ack message to pebble
|
||||||
|
|
||||||
|
/*
|
||||||
|
sendBytesAck = new GBDeviceEventSendBytes();
|
||||||
|
sendBytesAck.encodedBytes = encodeApplicationMessageAck(uuid, last_id);
|
||||||
|
*/
|
||||||
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user