diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-05-21 20:55:52 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-05-21 20:55:52 +0200 |
commit | ac3926cfbf29c6e1ca62a66f318efad666d17a19 (patch) | |
tree | b4c5cef73f57974e29186304d2c60beceb6475eb /src | |
parent | 3a66fef2030be00615e47a725cdf375e96ad3093 (diff) |
make fcm receiver ignore messages when all accounts are disabled
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/de/pixart/messenger/services/EventReceiver.java | 2 | ||||
-rw-r--r-- | src/standardPush/java/de/pixart/messenger/services/PushMessageReceiver.java | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/main/java/de/pixart/messenger/services/EventReceiver.java b/src/main/java/de/pixart/messenger/services/EventReceiver.java index e4ec8cdb7..6200a40ce 100644 --- a/src/main/java/de/pixart/messenger/services/EventReceiver.java +++ b/src/main/java/de/pixart/messenger/services/EventReceiver.java @@ -32,7 +32,7 @@ public class EventReceiver extends BroadcastReceiver { } } - public boolean hasEnabledAccounts(Context context) { + public static boolean hasEnabledAccounts(Context context) { return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTING_ENABLED_ACCOUNTS, true); } diff --git a/src/standardPush/java/de/pixart/messenger/services/PushMessageReceiver.java b/src/standardPush/java/de/pixart/messenger/services/PushMessageReceiver.java index ffbb93425..d45ded454 100644 --- a/src/standardPush/java/de/pixart/messenger/services/PushMessageReceiver.java +++ b/src/standardPush/java/de/pixart/messenger/services/PushMessageReceiver.java @@ -1,13 +1,20 @@ package de.pixart.messenger.services; import android.content.Intent; +import android.util.Log; import java.util.Map; +import de.pixart.messenger.Config; + public class PushMessageReceiver extends FirebaseMessagingService { @Override public void onMessageReceived(RemoteMessage message) { + if (!EventReceiver.hasEnabledAccounts(this)) { + Log.d(Config.LOGTAG, "PushMessageReceiver ignored message because no accounts are enabled"); + return; + } Map<String, String> data = message.getData(); Intent intent = new Intent(this, XmppConnectionService.class); intent.setAction(XmppConnectionService.ACTION_FCM_MESSAGE_RECEIVED); |