diff options
Diffstat (limited to '')
4 files changed, 16 insertions, 55 deletions
diff --git a/src/standardPush/AndroidManifest.xml b/src/standardPush/AndroidManifest.xml index 08aafe900..a54f8bee1 100644 --- a/src/standardPush/AndroidManifest.xml +++ b/src/standardPush/AndroidManifest.xml @@ -1,8 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" package="de.pixart.messenger"> - <application> + <application tools:ignore="GoogleAppIndexingWarning"> <meta-data android:name="firebase_analytics_collection_deactivated" @@ -16,7 +17,7 @@ android:exported="true" android:permission="android.permission.CHANGE_CONFIGURATION"> <intent-filter> - <action android:name="eu.siacs.conversations.RENEW_INSTANCE_ID" /> + <action android:name="de.pixart.messenger.RENEW_INSTANCE_ID" /> </intent-filter> </receiver> @@ -27,11 +28,5 @@ <action android:name="com.google.firebase.MESSAGING_EVENT" /> </intent-filter> </service> - - <service android:name=".services.InstanceIdService"> - <intent-filter> - <action android:name="com.google.firebase.INSTANCE_ID_EVENT" /> - </intent-filter> - </service> </application> </manifest> diff --git a/src/standardPush/java/de/pixart/messenger/services/InstanceIdService.java b/src/standardPush/java/de/pixart/messenger/services/InstanceIdService.java deleted file mode 100644 index 9a3309be4..000000000 --- a/src/standardPush/java/de/pixart/messenger/services/InstanceIdService.java +++ /dev/null @@ -1,29 +0,0 @@ -package de.pixart.messenger.services; - -import android.content.Intent; -import android.support.v4.content.ContextCompat; -import android.util.Log; - -import com.google.firebase.iid.FirebaseInstanceIdService; - -import de.pixart.messenger.Config; -import de.pixart.messenger.utils.Compatibility; - -public class InstanceIdService extends FirebaseInstanceIdService { - - @Override - public void onTokenRefresh() { - final Intent intent = new Intent(this, XmppConnectionService.class); - intent.setAction(XmppConnectionService.ACTION_FCM_TOKEN_REFRESH); - try { - if (Compatibility.runsAndTargetsTwentySix(this)) { - intent.putExtra(EventReceiver.EXTRA_NEEDS_FOREGROUND_SERVICE, true); - ContextCompat.startForegroundService(this, intent); - } else { - startService(intent); - } - } catch (IllegalStateException e) { - Log.e(Config.LOGTAG, "InstanceIdService is not allowed to start service"); - } - } -}
\ No newline at end of file diff --git a/src/standardPush/java/de/pixart/messenger/services/MaintenanceReceiver.java b/src/standardPush/java/de/pixart/messenger/services/MaintenanceReceiver.java index 5706a487a..31ed95a88 100644 --- a/src/standardPush/java/de/pixart/messenger/services/MaintenanceReceiver.java +++ b/src/standardPush/java/de/pixart/messenger/services/MaintenanceReceiver.java @@ -3,7 +3,6 @@ package de.pixart.messenger.services; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; -import android.support.v4.content.ContextCompat; import android.util.Log; import com.google.firebase.iid.FirebaseInstanceId; @@ -17,7 +16,7 @@ public class MaintenanceReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Log.d(Config.LOGTAG, "received intent in maintenance receiver"); - if ("eu.siacs.conversations.RENEW_INSTANCE_ID".equals(intent.getAction())) { + if ("de.pixart.messenger.RENEW_INSTANCE_ID".equals(intent.getAction())) { renewInstanceToken(context); } @@ -29,12 +28,7 @@ public class MaintenanceReceiver extends BroadcastReceiver { FirebaseInstanceId.getInstance().deleteInstanceId(); final Intent intent = new Intent(context, XmppConnectionService.class); intent.setAction(XmppConnectionService.ACTION_FCM_TOKEN_REFRESH); - if (Compatibility.runsAndTargetsTwentySix(context)) { - intent.putExtra(EventReceiver.EXTRA_NEEDS_FOREGROUND_SERVICE, true); - ContextCompat.startForegroundService(context, intent); - } else { - context.startService(intent); - } + Compatibility.startService(context, intent); } catch (IOException e) { Log.d(Config.LOGTAG, "unable to renew instance token", e); } diff --git a/src/standardPush/java/de/pixart/messenger/services/PushMessageReceiver.java b/src/standardPush/java/de/pixart/messenger/services/PushMessageReceiver.java index f07167f8d..c6d9b96be 100644 --- a/src/standardPush/java/de/pixart/messenger/services/PushMessageReceiver.java +++ b/src/standardPush/java/de/pixart/messenger/services/PushMessageReceiver.java @@ -1,7 +1,6 @@ package de.pixart.messenger.services; import android.content.Intent; -import android.support.v4.content.ContextCompat; import android.util.Log; import com.google.firebase.messaging.FirebaseMessagingService; @@ -24,15 +23,17 @@ public class PushMessageReceiver extends FirebaseMessagingService { final Intent intent = new Intent(this, XmppConnectionService.class); intent.setAction(XmppConnectionService.ACTION_FCM_MESSAGE_RECEIVED); intent.putExtra("account", data.get("account")); - try { - if (Compatibility.runsAndTargetsTwentySix(this)) { - intent.putExtra(EventReceiver.EXTRA_NEEDS_FOREGROUND_SERVICE, true); - ContextCompat.startForegroundService(this, intent); - } else { - startService(intent); - } - } catch (IllegalStateException e) { - Log.e(Config.LOGTAG, "PushMessageReceiver is not allowed to start service"); + Compatibility.startService(this, intent); + } + + @Override + public void onNewToken(String token) { + if (!EventReceiver.hasEnabledAccounts(this)) { + Log.d(Config.LOGTAG, "PushMessageReceiver ignored new token because no accounts are enabled"); + return; } + final Intent intent = new Intent(this, XmppConnectionService.class); + intent.setAction(XmppConnectionService.ACTION_FCM_TOKEN_REFRESH); + Compatibility.startService(this, intent); } }
\ No newline at end of file |