diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index c6467b7d36..e4720d340b 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -5,7 +5,7 @@
android:versionCode="58"
android:versionName="1.0.2">
-
+
+
+
@@ -192,6 +194,9 @@
+
+
+
@@ -205,6 +210,10 @@
+
+
+
+
= Build.VERSION_CODES.KITKAT &&
+ intent.getAction().equals(WAP_PUSH_RECEIVE_ACTION) && Util.isDefaultSmsProvider(context))
+ return false;
+
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean(ApplicationPreferencesActivity.ALL_MMS_PERF, true))
return true;
diff --git a/src/org/thoughtcrime/securesms/service/SmsListener.java b/src/org/thoughtcrime/securesms/service/SmsListener.java
index e6836e95d3..fb06444409 100644
--- a/src/org/thoughtcrime/securesms/service/SmsListener.java
+++ b/src/org/thoughtcrime/securesms/service/SmsListener.java
@@ -21,6 +21,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
+import android.os.Build;
import android.preference.PreferenceManager;
import android.telephony.SmsMessage;
import android.util.Log;
@@ -28,12 +29,14 @@ import android.util.Log;
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
import org.thoughtcrime.securesms.protocol.WirePrefix;
import org.thoughtcrime.securesms.sms.IncomingTextMessage;
+import org.thoughtcrime.securesms.util.Util;
import java.util.ArrayList;
public class SmsListener extends BroadcastReceiver {
private static final String SMS_RECEIVED_ACTION = "android.provider.Telephony.SMS_RECEIVED";
+ private static final String SMS_DELIVERED_ACTION = "android.provider.Telephony.SMS_DELIVER";
private boolean isExemption(SmsMessage message, String messageBody) {
@@ -99,6 +102,10 @@ public class SmsListener extends BroadcastReceiver {
if (!ApplicationMigrationService.isDatabaseImported(context))
return false;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT &&
+ intent.getAction().equals(SMS_RECEIVED_ACTION) && Util.isDefaultSmsProvider(context))
+ return false;
+
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("pref_all_sms", true))
return true;
@@ -140,7 +147,9 @@ public class SmsListener extends BroadcastReceiver {
context.sendBroadcast(challengeIntent);
abortBroadcast();
- } else if (intent.getAction().equals(SMS_RECEIVED_ACTION) && isRelevant(context, intent)) {
+ } else if ((intent.getAction().equals(SMS_RECEIVED_ACTION) ||
+ intent.getAction().equals(SMS_DELIVERED_ACTION)) &&
+ isRelevant(context, intent)) {
Intent receivedIntent = new Intent(context, SendReceiveService.class);
receivedIntent.setAction(SendReceiveService.RECEIVE_SMS_ACTION);
receivedIntent.putExtra("ResultCode", this.getResultCode());
diff --git a/src/org/thoughtcrime/securesms/util/Util.java b/src/org/thoughtcrime/securesms/util/Util.java
index dc3a0617e3..6767ddd677 100644
--- a/src/org/thoughtcrime/securesms/util/Util.java
+++ b/src/org/thoughtcrime/securesms/util/Util.java
@@ -24,6 +24,8 @@ import android.text.SpannableString;
import android.text.style.StyleSpan;
import android.util.Log;
import android.widget.EditText;
+import android.os.Build;
+import android.provider.Telephony;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -184,6 +186,11 @@ public class Util {
return new String(bout.toByteArray());
}
+ public static boolean isDefaultSmsProvider(Context context){
+ return (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) ||
+ (Telephony.Sms.getDefaultSmsPackage(context) == context.getPackageName());
+ }
+
// public static Bitmap loadScaledBitmap(InputStream src, int targetWidth, int targetHeight) {
// return BitmapFactory.decodeStream(src);
//// BitmapFactory.Options options = new BitmapFactory.Options();