Tweak MMS retrieval and submission.

1) Only attempt direct connect outside of MMS radio mode on CDMA.

2) Don't switch back to normal radio state if pending messages remain.
This commit is contained in:
Moxie Marlinspike 2013-03-03 18:44:58 -08:00
parent 27e039c4a6
commit ef6a5c69af
2 changed files with 14 additions and 6 deletions

View file

@ -18,6 +18,7 @@ package org.thoughtcrime.securesms.service;
import android.content.Context;
import android.content.Intent;
import android.telephony.TelephonyManager;
import android.util.Log;
import org.thoughtcrime.securesms.R;
@ -46,7 +47,8 @@ public class MmsDownloader extends MmscProcessor {
public void process(MasterSecret masterSecret, Intent intent) {
if (intent.getAction().equals(SendReceiveService.DOWNLOAD_MMS_ACTION)) {
DownloadItem item = new DownloadItem(masterSecret, false, false,
boolean isCdma = ((TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE)).getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA;
DownloadItem item = new DownloadItem(masterSecret, !isCdma, false,
intent.getLongExtra("message_id", -1),
intent.getLongExtra("thread_id", -1),
intent.getStringExtra("content_location"),
@ -147,7 +149,9 @@ public class MmsDownloader extends MmscProcessor {
downloadMms(item);
}
finishConnectivity();
if (pendingMessages.isEmpty())
finishConnectivity();
} else if (!isConnected() && !isConnectivityPossible()) {
pendingMessages.clear();

View file

@ -64,13 +64,14 @@ public class MmsSender extends MmscProcessor {
public void process(MasterSecret masterSecret, Intent intent) {
if (intent.getAction().equals(SendReceiveService.SEND_MMS_ACTION)) {
long messageId = intent.getLongExtra("message_id", -1);
boolean isCdma = ((TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE)).getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA;
MmsDatabase database = DatabaseFactory.getEncryptingMmsDatabase(context, masterSecret);
try {
List<SendReq> sendRequests = getOutgoingMessages(masterSecret, messageId);
for (SendReq sendRequest : sendRequests) {
handleSendMmsAction(new SendItem(masterSecret, sendRequest, messageId != -1, false, false));
handleSendMmsAction(new SendItem(masterSecret, sendRequest, messageId != -1, !isCdma, false));
}
} catch (MmsException me) {
@ -192,12 +193,15 @@ public class MmsSender extends MmscProcessor {
return;
}
for (SendItem item : pendingMessages) {
List<SendItem> outgoing = (List<SendItem>)pendingMessages.clone();
pendingMessages.clear();
for (SendItem item : outgoing) {
sendMmsMessage(item);
}
pendingMessages.clear();
finishConnectivity();
if (pendingMessages.isEmpty())
finishConnectivity();
}
private boolean isInconsistentResponse(SendReq send, SendConf response) {