diff --git a/src/gplay/java/org/thoughtcrime/securesms/notifications/FcmReceiveService.java b/src/gplay/java/org/thoughtcrime/securesms/notifications/FcmReceiveService.java
index 999b762f72..2411b1416f 100644
--- a/src/gplay/java/org/thoughtcrime/securesms/notifications/FcmReceiveService.java
+++ b/src/gplay/java/org/thoughtcrime/securesms/notifications/FcmReceiveService.java
@@ -18,19 +18,16 @@
import org.thoughtcrime.securesms.ApplicationContext;
import org.thoughtcrime.securesms.BuildConfig;
import org.thoughtcrime.securesms.R;
-import org.thoughtcrime.securesms.service.GenericForegroundService;
+import org.thoughtcrime.securesms.service.FetchForegroundService;
import org.thoughtcrime.securesms.service.NotificationController;
import org.thoughtcrime.securesms.util.Util;
public class FcmReceiveService extends FirebaseMessagingService {
private static final String TAG = FcmReceiveService.class.getSimpleName();
private static final Object INIT_LOCK = new Object();
- private static final Object NOTIFICATION_CONTROLLER_LOCK = new Object();
-
private static boolean initialized;
private static volatile boolean triedRegistering;
private static volatile String prefixedToken;
- private static NotificationController notificationController;
public static void register(Context context) {
if (Build.VERSION.SDK_INT < 19) {
@@ -101,23 +98,13 @@ public static String getToken() {
@Override
public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
Log.i(TAG, "FCM push notification received");
- synchronized (NOTIFICATION_CONTROLLER_LOCK) {
- notificationController = GenericForegroundService.startForegroundTask(this, getString(R.string.connectivity_updating));
- if (!ApplicationContext.dcAccounts.backgroundFetch(19)) { // we should complete within 20 seconds
- notificationController.close();
- notificationController = null;
- }
+ FetchForegroundService.start(this);
+ if (!ApplicationContext.dcAccounts.backgroundFetch(19)) { // we should complete within 20 seconds
+ FetchForegroundService.stop(this);
}
Log.i(TAG, "background fetch done");
}
- public static void backgroundFetchDone() {
- synchronized (NOTIFICATION_CONTROLLER_LOCK) {
- notificationController.close();
- notificationController = null;
- }
- }
-
@Override
public void onDeletedMessages() {
Log.i(TAG, "FCM push notifications dropped");
diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index ec201402cc..486980fcdc 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -380,6 +380,10 @@
android:name=".service.GenericForegroundService"
android:foregroundServiceType="dataSync" />
+
+
= Build.VERSION_CODES.O) {
CHANNEL_CREATED.set(true);
NotificationChannel channel = new NotificationChannel(NotificationCenter.CH_GENERIC,