From c1970a7eb66b2392e11ae9fc6cfce60ac8b1f308 Mon Sep 17 00:00:00 2001 From: Dimitris Papavasiliou Date: Tue, 10 Apr 2018 12:22:25 +0300 Subject: [PATCH] Periodically wake the WebSocket, when GCM is disabled Use the WebSocketAlarm, to periodically wake the WebSocket and with it, any threads that may be stuck in blocking wait, while the device is sleeping. Fixes #6644 // FREEBIE --- .../securesms/service/MessageRetrievalService.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/org/thoughtcrime/securesms/service/MessageRetrievalService.java b/src/org/thoughtcrime/securesms/service/MessageRetrievalService.java index c7b0a6c6d24..1e26616ae24 100644 --- a/src/org/thoughtcrime/securesms/service/MessageRetrievalService.java +++ b/src/org/thoughtcrime/securesms/service/MessageRetrievalService.java @@ -20,6 +20,7 @@ import org.whispersystems.libsignal.InvalidVersionException; import org.whispersystems.signalservice.api.SignalServiceMessagePipe; import org.whispersystems.signalservice.api.SignalServiceMessageReceiver; +import org.whispersystems.signalservice.api.WebSocketAlarm; import java.util.LinkedList; import java.util.List; @@ -50,6 +51,7 @@ public class MessageRetrievalService extends Service implements InjectableType, private int activeActivities = 0; private List pushPending = new LinkedList<>(); private MessageRetrievalThread retrievalThread = null; + private WebSocketAlarm webSocketAlarm = null; public static SignalServiceMessagePipe pipe = null; @@ -66,6 +68,10 @@ public void onCreate() { retrievalThread = new MessageRetrievalThread(); retrievalThread.start(); + if (TextSecurePreferences.isGcmDisabled(this)) { + webSocketAlarm = new WebSocketAlarm(this); + } + setForegroundIfNecessary(); } @@ -87,6 +93,10 @@ public void onDestroy() { retrievalThread.stopThread(); } + if (webSocketAlarm != null) { + webSocketAlarm.disable(); + } + sendBroadcast(new Intent("org.thoughtcrime.securesms.RESTART")); }