From 74fbadf55373995bac05a289d9334b79fcfffa47 Mon Sep 17 00:00:00 2001 From: Daniele Gobbetti Date: Thu, 13 Jun 2024 16:26:39 +0200 Subject: [PATCH] Pebble: fix webview crash (on android 14) Older android version also possibly impacted --- .../gadgetbridge/util/WebViewSingleton.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/WebViewSingleton.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/WebViewSingleton.java index d4b8e1b92..d776abeee 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/WebViewSingleton.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/WebViewSingleton.java @@ -124,6 +124,9 @@ public class WebViewSingleton { //Internet helper inbound (responses) handler private class IncomingHandler extends Handler { + public IncomingHandler(Looper looper) { + super(looper); + } private String getCharsetFromHeaders(String contentType) { if (contentType != null && contentType.toLowerCase().trim().contains("charset=")) { @@ -199,7 +202,15 @@ public class WebViewSingleton { Intent intent = new Intent(); intent.setComponent(new ComponentName(internetHelperPkg, internetHelperCls)); contextWrapper.getApplicationContext().bindService(intent, internetHelperConnection, Context.BIND_AUTO_CREATE); - internetHelperListener = new Messenger(new IncomingHandler()); + Thread thread = new Thread(new Runnable() { + @Override + public void run() { + Looper.prepare(); + internetHelperListener = new Messenger(new IncomingHandler(Looper.myLooper())); + Looper.loop(); + } + }); + thread.start(); internetHelperInstalled = true; } catch (PackageManager.NameNotFoundException e) {