mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Pebble: add method to stop the background JS engine without disposing the webview
This commit is contained in:
+1
-1
@@ -518,7 +518,7 @@ class PebbleIoThread extends GBDeviceIoThread {
|
|||||||
LOG.info("got GBDeviceEventAppManagement START event for uuid: " + appMgmt.uuid);
|
LOG.info("got GBDeviceEventAppManagement START event for uuid: " + appMgmt.uuid);
|
||||||
if (prefs.getBoolean("pebble_enable_background_javascript", false)) {
|
if (prefs.getBoolean("pebble_enable_background_javascript", false)) {
|
||||||
if (mPebbleProtocol.hasAppMessageHandler(appMgmt.uuid)) {
|
if (mPebbleProtocol.hasAppMessageHandler(appMgmt.uuid)) {
|
||||||
WebViewSingleton.disposeWebView();
|
WebViewSingleton.stopJavascriptInterface();
|
||||||
} else {
|
} else {
|
||||||
WebViewSingleton.runJavascriptInterface(gbDevice, appMgmt.uuid);
|
WebViewSingleton.runJavascriptInterface(gbDevice, appMgmt.uuid);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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() {
|
public static void disposeWebView() {
|
||||||
if (internetHelperBound) {
|
if (internetHelperBound) {
|
||||||
LOG.debug("WEBVIEW: will unbind the internet helper");
|
LOG.debug("WEBVIEW: will unbind the internet helper");
|
||||||
|
|||||||
Reference in New Issue
Block a user