From eea484af017e144672b15a1ddbac9e2afb61a069 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 20 Jan 2021 08:14:36 +0100 Subject: [PATCH] move SMS receiver into its own BroadcastReceiver --- src/main/AndroidManifest.xml | 4 +--- .../conversations/services/EventReceiver.java | 4 +++- src/quicksy/AndroidManifest.xml | 9 ++++++++ .../services/QuickConversationsService.java | 2 +- .../conversations/services/SMSReceiver.java | 22 +++++++++++++++++++ 5 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 src/quicksy/java/eu/siacs/conversations/services/SMSReceiver.java diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index ab7f1e000..c98aae041 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -72,14 +72,12 @@ - + - diff --git a/src/main/java/eu/siacs/conversations/services/EventReceiver.java b/src/main/java/eu/siacs/conversations/services/EventReceiver.java index 38d12fe75..c9bc3170b 100644 --- a/src/main/java/eu/siacs/conversations/services/EventReceiver.java +++ b/src/main/java/eu/siacs/conversations/services/EventReceiver.java @@ -5,7 +5,9 @@ import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.preference.PreferenceManager; + import androidx.core.content.ContextCompat; + import android.util.Log; import com.google.common.base.Strings; @@ -27,7 +29,7 @@ public class EventReceiver extends BroadcastReceiver { if (extras != null) { intentForService.putExtras(extras); } - if ("ui".equals(action) || QuickConversationsService.SMS_RETRIEVED_ACTION.equals(action) || hasEnabledAccounts(context)) { + if ("ui".equals(action) || hasEnabledAccounts(context)) { Compatibility.startService(context, intentForService); } else { Log.d(Config.LOGTAG, "EventReceiver ignored action " + intentForService.getAction()); diff --git a/src/quicksy/AndroidManifest.xml b/src/quicksy/AndroidManifest.xml index ed68582b3..1c30d2f28 100644 --- a/src/quicksy/AndroidManifest.xml +++ b/src/quicksy/AndroidManifest.xml @@ -32,5 +32,14 @@ android:label="@string/enter_your_name" android:launchMode="singleTask" /> + + + + + + diff --git a/src/quicksy/java/eu/siacs/conversations/services/QuickConversationsService.java b/src/quicksy/java/eu/siacs/conversations/services/QuickConversationsService.java index 0b56a00f9..c5d1d7b9b 100644 --- a/src/quicksy/java/eu/siacs/conversations/services/QuickConversationsService.java +++ b/src/quicksy/java/eu/siacs/conversations/services/QuickConversationsService.java @@ -134,7 +134,7 @@ public class QuickConversationsService extends AbstractQuickConversationsService connection.setReadTimeout(Config.SOCKET_TIMEOUT * 1000); setHeader(connection); final int code = connection.getResponseCode(); - if (code == 200 || code == 201) { + if (code == 200) { createAccountAndWait(phoneNumber, 0L); } else if (code == 429) { createAccountAndWait(phoneNumber, retryAfter(connection)); diff --git a/src/quicksy/java/eu/siacs/conversations/services/SMSReceiver.java b/src/quicksy/java/eu/siacs/conversations/services/SMSReceiver.java new file mode 100644 index 000000000..f68d51e8c --- /dev/null +++ b/src/quicksy/java/eu/siacs/conversations/services/SMSReceiver.java @@ -0,0 +1,22 @@ +package eu.siacs.conversations.services; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.util.Log; + +import com.google.common.base.Strings; + +import eu.siacs.conversations.Config; +import eu.siacs.conversations.utils.Compatibility; + +public class SMSReceiver extends BroadcastReceiver { + + @Override + public void onReceive(final Context context, final Intent intent) { + intent.setClass(context, XmppConnectionService.class); + Compatibility.startService(context, intent); + } +}