Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 77789f73 authored by moezbhatti's avatar moezbhatti
Browse files

Respect subId when downloading MMS

parent 443e58b2
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ import android.text.TextUtils;
import com.android.mms.MmsConfig;
import com.klinker.android.send_message.BroadcastUtils;
import com.klinker.android.send_message.MmsReceivedReceiver;
import com.klinker.android.send_message.SmsManagerFactory;

import timber.log.Timber;

import java.io.File;
@@ -41,7 +43,7 @@ public class DownloadManager {

    }

    public void downloadMultimediaMessage(final Context context, final String location, Uri uri, boolean byPush) {
    public void downloadMultimediaMessage(final Context context, final String location, Uri uri, boolean byPush, int subscriptionId) {
        if (location == null || mMap.get(location) != null) {
            return;
        }
@@ -80,7 +82,7 @@ public class DownloadManager {
        }

        grantUriPermission(context, contentUri);
        SmsManager.getDefault().downloadMultimediaMessage(context,
        SmsManagerFactory.INSTANCE.createSmsManager(subscriptionId).downloadMultimediaMessage(context,
                location, contentUri, configOverrides, pendingIntent);
    }

+9 −3
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.net.Uri;
import android.os.AsyncTask;
import android.provider.Telephony.Mms;
import android.provider.Telephony.Mms.Inbox;

import com.android.mms.MmsConfig;
import com.google.android.mms.ContentType;
import com.google.android.mms.MmsException;
@@ -38,16 +39,20 @@ import com.google.android.mms.pdu_alt.PduHeaders;
import com.google.android.mms.pdu_alt.PduParser;
import com.google.android.mms.pdu_alt.PduPersister;
import com.google.android.mms.pdu_alt.ReadOrigInd;
import timber.log.Timber;
import com.klinker.android.send_message.Utils;

import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import timber.log.Timber;

import static android.provider.Telephony.Sms.Intents.WAP_PUSH_DELIVER_ACTION;
import static android.provider.Telephony.Sms.Intents.WAP_PUSH_RECEIVED_ACTION;
import static com.google.android.mms.pdu_alt.PduHeaders.*;
import static com.google.android.mms.pdu_alt.PduHeaders.MESSAGE_TYPE_DELIVERY_IND;
import static com.google.android.mms.pdu_alt.PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND;
import static com.google.android.mms.pdu_alt.PduHeaders.MESSAGE_TYPE_READ_ORIG_IND;

/**
 * Receives Intent.WAP_PUSH_RECEIVED_ACTION intents and starts the
@@ -141,7 +146,8 @@ public class PushReceiver extends BroadcastReceiver {
                                downloadedUrls.add(location);
                            }

                            DownloadManager.getInstance().downloadMultimediaMessage(mContext, location, uri, true);
                            int subId = intent.getIntExtra("subscription", Utils.getDefaultSubscriptionId());
                            DownloadManager.getInstance().downloadMultimediaMessage(mContext, location, uri, true, subId);
                        } else {
                            Timber.v("Skip downloading duplicate message: " + new String(nInd.getContentLocation()));
                        }
+2 −2
Original line number Diff line number Diff line
@@ -300,7 +300,7 @@ public class TransactionService extends Service implements Observer {
                            Uri uri = ContentUris.withAppendedId(Mms.CONTENT_URI,
                                    cursor.getLong(columnIndexOfMsgId));
                            com.android.mms.transaction.DownloadManager.getInstance().
                                    downloadMultimediaMessage(this, PushReceiver.getContentLocation(this, uri), uri, false);
                                    downloadMultimediaMessage(this, PushReceiver.getContentLocation(this, uri), uri, false,  Utils.getDefaultSubscriptionId());

                            // can't handle many messages at once.
                            break;
@@ -688,7 +688,7 @@ public class TransactionService extends Service implements Observer {
                                Uri u = Uri.parse(args.getUri());
                                com.android.mms.transaction.DownloadManager.getInstance().
                                        downloadMultimediaMessage(TransactionService.this,
                                                ((RetrieveTransaction) transaction).getContentLocation(TransactionService.this, u), u, false);
                                                ((RetrieveTransaction) transaction).getContentLocation(TransactionService.this, u), u, false, Utils.getDefaultSubscriptionId());
                                return;