1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-28 04:46:51 +01:00

Pebble: add method to stop the background JS engine without disposing the webview

This commit is contained in:
Daniele Gobbetti 2017-10-23 20:47:30 +02:00
parent 83038a47ca
commit e028b4d223
2 changed files with 13 additions and 1 deletions

View File

@ -518,7 +518,7 @@ class PebbleIoThread extends GBDeviceIoThread {
LOG.info("got GBDeviceEventAppManagement START event for uuid: " + appMgmt.uuid);
if (prefs.getBoolean("pebble_enable_background_javascript", false)) {
if (mPebbleProtocol.hasAppMessageHandler(appMgmt.uuid)) {
WebViewSingleton.disposeWebView();
WebViewSingleton.stopJavascriptInterface();
} else {
WebViewSingleton.runJavascriptInterface(gbDevice, appMgmt.uuid);
}

View File

@ -197,6 +197,18 @@ public class WebViewSingleton {
});
}
public static void stopJavascriptInterface() {
new Handler(webViewSingleton.mainLooper).post(new Runnable() {
@Override
public void run() {
if (webViewSingleton.instance != null) {
webViewSingleton.instance.removeJavascriptInterface("GBjs");
webViewSingleton.instance.loadUrl("about:blank");
}
}
});
}
public static void disposeWebView() {
if (internetHelperBound) {
LOG.debug("WEBVIEW: will unbind the internet helper");