Do more to keep MessageRetrievalService alive

Closes #6456
This commit is contained in:
Moxie Marlinspike 2017-07-03 11:36:31 -07:00
parent fcbcffe9ba
commit 39b95ca4ed
3 changed files with 25 additions and 1 deletions

View File

@ -514,6 +514,13 @@
</intent-filter>
</receiver>
<receiver android:name=".service.BootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="org.thoughtcrime.securesms.RESTART"/>
</intent-filter>
</receiver>
<receiver android:name=".service.DirectoryRefreshListener">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />

View File

@ -0,0 +1,15 @@
package org.thoughtcrime.securesms.service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class BootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent messageRetrievalService = new Intent(context, MessageRetrievalService.class);
context.startService(messageRetrievalService);
}
}

View File

@ -87,6 +87,8 @@ public class MessageRetrievalService extends Service implements InjectableType,
if (retrievalThread != null) {
retrievalThread.stopThread();
}
sendBroadcast(new Intent("org.thoughtcrime.securesms.RESTART"));
}
@Override
@ -236,7 +238,7 @@ public class MessageRetrievalService extends Service implements InjectableType,
Log.w(TAG, "Exiting...");
}
public void stopThread() {
private void stopThread() {
stopThread.set(true);
}