Skip to content

Commit

Permalink
Periodically wake the WebSocket, when GCM is disabled
Browse files Browse the repository at this point in the history
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 signalapp#6644
// FREEBIE
  • Loading branch information
Dimitris Papavasiliou committed Apr 10, 2018
1 parent ca471b1 commit c1970a7
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -50,6 +51,7 @@ public class MessageRetrievalService extends Service implements InjectableType,
private int activeActivities = 0;
private List<Intent> pushPending = new LinkedList<>();
private MessageRetrievalThread retrievalThread = null;
private WebSocketAlarm webSocketAlarm = null;

public static SignalServiceMessagePipe pipe = null;

Expand All @@ -66,6 +68,10 @@ public void onCreate() {
retrievalThread = new MessageRetrievalThread();
retrievalThread.start();

if (TextSecurePreferences.isGcmDisabled(this)) {
webSocketAlarm = new WebSocketAlarm(this);
}

setForegroundIfNecessary();
}

Expand All @@ -87,6 +93,10 @@ public void onDestroy() {
retrievalThread.stopThread();
}

if (webSocketAlarm != null) {
webSocketAlarm.disable();
}

sendBroadcast(new Intent("org.thoughtcrime.securesms.RESTART"));
}

Expand Down

0 comments on commit c1970a7

Please sign in to comment.