move SMS receiver into its own BroadcastReceiver
This commit is contained in:
parent
47d619b28e
commit
eea484af01
|
@ -72,14 +72,12 @@
|
|||
|
||||
<service android:name=".services.XmppConnectionService" />
|
||||
|
||||
<receiver android:name=".services.EventReceiver"
|
||||
android:permission="com.google.android.gms.auth.api.phone.permission.SEND">
|
||||
<receiver android:name=".services.EventReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
|
||||
<action android:name="android.intent.action.ACTION_SHUTDOWN" />
|
||||
<action android:name="android.media.RINGER_MODE_CHANGED" />
|
||||
<action android:name="com.google.android.gms.auth.api.phone.SMS_RETRIEVED"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -32,5 +32,14 @@
|
|||
android:label="@string/enter_your_name"
|
||||
android:launchMode="singleTask" />
|
||||
|
||||
<receiver
|
||||
android:name=".services.SMSReceiver"
|
||||
android:exported="true"
|
||||
android:permission="com.google.android.gms.auth.api.phone.permission.SEND">
|
||||
<intent-filter>
|
||||
<action android:name="com.google.android.gms.auth.api.phone.SMS_RETRIEVED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
</application>
|
||||
</manifest>
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue