From 4bac64f5f65776d0b0f7160d6e61e749dbe6f464 Mon Sep 17 00:00:00 2001 From: Konrad Kollnig <5175206+kasnder@users.noreply.github.com> Date: Fri, 21 Aug 2026 23:19:37 +0200 Subject: [PATCH] Bound the update check's network calls with timeouts checkUpdate() runs synchronously on the command handler thread inside the 30s command wakelock, twice a day (house-holding, sideloaded installs). The HttpsURLConnection had no connect/read timeouts, so a hung network could stall the command queue for the OS default timeout and hold a wakelock meanwhile. Give it 10s bounds on both. --- app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java b/app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java index 9790afb6..a9caf05f 100644 --- a/app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java +++ b/app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java @@ -139,6 +139,10 @@ public class ServiceSinkhole extends VpnService { // the 3s handover-retry sleep) with margin. private static final long WAKELOCK_TIMEOUT_MS = 30_000L; + // Bounds the update check's network calls so a hung connection cannot stall + // the command handler thread (and its wakelock) for the OS default timeout. + private static final int UPDATE_CHECK_TIMEOUT_MS = 10_000; + private boolean registeredUser = false; private boolean registeredIdleState = false; private boolean registeredApState = false; @@ -816,6 +820,8 @@ private void checkUpdate() { try { URL url = new URL(BuildConfig.GITHUB_LATEST_API); urlConnection = (HttpsURLConnection) url.openConnection(); + urlConnection.setConnectTimeout(UPDATE_CHECK_TIMEOUT_MS); + urlConnection.setReadTimeout(UPDATE_CHECK_TIMEOUT_MS); urlConnection.setRequestProperty("Accept-Encoding", "gzip"); BufferedReader br; if ("gzip".equals(urlConnection.getContentEncoding()))