Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()))
Expand Down