forked from upstream-mirrors/quik
Respect subId when downloading MMS
Ported over from changes in https://github.com/klinker41/android-smsmms/pull/162/files
This commit is contained in:
@@ -18,6 +18,8 @@ import android.text.TextUtils;
|
|||||||
import com.android.mms.MmsConfig;
|
import com.android.mms.MmsConfig;
|
||||||
import com.klinker.android.send_message.BroadcastUtils;
|
import com.klinker.android.send_message.BroadcastUtils;
|
||||||
import com.klinker.android.send_message.MmsReceivedReceiver;
|
import com.klinker.android.send_message.MmsReceivedReceiver;
|
||||||
|
import com.klinker.android.send_message.SmsManagerFactory;
|
||||||
|
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
import java.io.File;
|
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) {
|
if (location == null || mMap.get(location) != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -80,7 +82,7 @@ public class DownloadManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
grantUriPermission(context, contentUri);
|
grantUriPermission(context, contentUri);
|
||||||
SmsManager.getDefault().downloadMultimediaMessage(context,
|
SmsManagerFactory.INSTANCE.createSmsManager(subscriptionId).downloadMultimediaMessage(context,
|
||||||
location, contentUri, configOverrides, pendingIntent);
|
location, contentUri, configOverrides, pendingIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import android.net.Uri;
|
|||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.provider.Telephony.Mms;
|
import android.provider.Telephony.Mms;
|
||||||
import android.provider.Telephony.Mms.Inbox;
|
import android.provider.Telephony.Mms.Inbox;
|
||||||
|
|
||||||
import com.android.mms.MmsConfig;
|
import com.android.mms.MmsConfig;
|
||||||
import com.google.android.mms.ContentType;
|
import com.google.android.mms.ContentType;
|
||||||
import com.google.android.mms.MmsException;
|
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.PduParser;
|
||||||
import com.google.android.mms.pdu_alt.PduPersister;
|
import com.google.android.mms.pdu_alt.PduPersister;
|
||||||
import com.google.android.mms.pdu_alt.ReadOrigInd;
|
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.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
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_DELIVER_ACTION;
|
||||||
import static android.provider.Telephony.Sms.Intents.WAP_PUSH_RECEIVED_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
|
* Receives Intent.WAP_PUSH_RECEIVED_ACTION intents and starts the
|
||||||
@@ -141,7 +146,8 @@ public class PushReceiver extends BroadcastReceiver {
|
|||||||
downloadedUrls.add(location);
|
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 {
|
} else {
|
||||||
Timber.v("Skip downloading duplicate message: " + new String(nInd.getContentLocation()));
|
Timber.v("Skip downloading duplicate message: " + new String(nInd.getContentLocation()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -300,7 +300,7 @@ public class TransactionService extends Service implements Observer {
|
|||||||
Uri uri = ContentUris.withAppendedId(Mms.CONTENT_URI,
|
Uri uri = ContentUris.withAppendedId(Mms.CONTENT_URI,
|
||||||
cursor.getLong(columnIndexOfMsgId));
|
cursor.getLong(columnIndexOfMsgId));
|
||||||
com.android.mms.transaction.DownloadManager.getInstance().
|
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.
|
// can't handle many messages at once.
|
||||||
break;
|
break;
|
||||||
@@ -688,7 +688,7 @@ public class TransactionService extends Service implements Observer {
|
|||||||
Uri u = Uri.parse(args.getUri());
|
Uri u = Uri.parse(args.getUri());
|
||||||
com.android.mms.transaction.DownloadManager.getInstance().
|
com.android.mms.transaction.DownloadManager.getInstance().
|
||||||
downloadMultimediaMessage(TransactionService.this,
|
downloadMultimediaMessage(TransactionService.this,
|
||||||
((RetrieveTransaction) transaction).getContentLocation(TransactionService.this, u), u, false);
|
((RetrieveTransaction) transaction).getContentLocation(TransactionService.this, u), u, false, Utils.getDefaultSubscriptionId());
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user