Fix duplicate MMS bug in KitKat.

1) Fix for typo that caused duplicate incoming MMS.

2) Only pay attention to "use for all" properties in < KitKat.
This commit is contained in:
Moxie Marlinspike 2013-12-02 21:39:09 -08:00
parent 8f7f1ea49c
commit aad82e314d
2 changed files with 25 additions and 12 deletions

View File

@ -21,6 +21,7 @@ import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.preference.PreferenceManager;
import android.provider.Telephony;
import android.util.Log;
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
@ -34,21 +35,28 @@ import ws.com.google.android.mms.pdu.PduParser;
public class MmsListener extends BroadcastReceiver {
private static final String WAP_PUSH_RECEIVE_ACTION = "android.provider.Telephony.WAP_PUSH_RECEIVE";
private boolean isRelevent(Context context, Intent intent) {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.DONUT)
private boolean isRelevant(Context context, Intent intent) {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.DONUT) {
return false;
}
if (!ApplicationMigrationService.isDatabaseImported(context))
if (!ApplicationMigrationService.isDatabaseImported(context)) {
return false;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT &&
intent.getAction().equals(WAP_PUSH_RECEIVE_ACTION) && Util.isDefaultSmsProvider(context))
Telephony.Sms.Intents.WAP_PUSH_RECEIVED_ACTION.equals(intent.getAction()) &&
Util.isDefaultSmsProvider(context))
{
return false;
}
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean(ApplicationPreferencesActivity.ALL_MMS_PERF, true))
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT &&
PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean(ApplicationPreferencesActivity.ALL_MMS_PERF, true))
{
return true;
}
byte[] mmsData = intent.getByteArrayExtra("data");
PduParser parser = new PduParser(mmsData);
@ -67,9 +75,10 @@ public class MmsListener extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.w("MmsListener", "Got MMS broadcast...");
Log.w("MmsListener", "Got MMS broadcast..." + intent.getAction());
if (isRelevent(context, intent)) {
if (isRelevant(context, intent)) {
Log.w("MmsListener", "Relevant!");
intent.setAction(SendReceiveService.RECEIVE_MMS_ACTION);
intent.putExtra("ResultCode", this.getResultCode());
intent.setClass(context, SendReceiveService.class);

View File

@ -103,10 +103,14 @@ public class SmsListener extends BroadcastReceiver {
return false;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT &&
intent.getAction().equals(SMS_RECEIVED_ACTION) && Util.isDefaultSmsProvider(context))
SMS_RECEIVED_ACTION.equals(intent.getAction()) &&
Util.isDefaultSmsProvider(context))
{
return false;
}
if (PreferenceManager.getDefaultSharedPreferences(context)
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT &&
PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean(ApplicationPreferencesActivity.ALL_SMS_PREF, true))
{
return true;