use IPv6 routing API then fallback to Lollipop

1) Utilize the hidden API requestRouteToHostAddress that takes an
   InetAddress (IPv6-capable) instead of a forced IPv4 integer-
   encoded address. Will fallback to the IPv4 one if reflection
   fails for whatever reason.

2) If on Lollipop and our manual MMS code doesn't work, will try
   to use the Lollipop API and give it 60 seconds instead of 30,
   since I did run into the timeout not being long enough in
   certain conditions and I'm thinking maybe it just wasn't long
   enough for some carriers.

Closes #3105
// FREEBIE
This commit is contained in:
Jake McGinty
2015-05-01 12:03:05 -07:00
parent b354825150
commit ab82ff0b69
6 changed files with 98 additions and 39 deletions

View File

@@ -12,6 +12,7 @@ import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.database.MmsDatabase;
import org.thoughtcrime.securesms.jobs.requirements.MasterSecretRequirement;
import org.thoughtcrime.securesms.mms.ApnUnavailableException;
import org.thoughtcrime.securesms.mms.CompatMmsConnection;
import org.thoughtcrime.securesms.mms.IncomingLollipopMmsConnection;
import org.thoughtcrime.securesms.mms.IncomingMediaMessage;
import org.thoughtcrime.securesms.mms.IncomingLegacyMmsConnection;
@@ -89,7 +90,7 @@ public class MmsDownloadJob extends MasterSecretJob {
Log.w(TAG, "Downloading mms at " + Uri.parse(contentLocation).getHost());
RetrieveConf retrieveConf = getMmsConnection(context).retrieve(contentLocation, transactionId);
RetrieveConf retrieveConf = new CompatMmsConnection(context).retrieve(contentLocation, transactionId);
if (retrieveConf == null) {
throw new MmsException("RetrieveConf was null");
}
@@ -123,16 +124,6 @@ public class MmsDownloadJob extends MasterSecretJob {
}
}
private IncomingMmsConnection getMmsConnection(Context context)
throws ApnUnavailableException
{
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
return new IncomingLollipopMmsConnection(context);
} else {
return new IncomingLegacyMmsConnection(context);
}
}
@Override
public void onCanceled() {
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);

View File

@@ -11,6 +11,7 @@ import org.thoughtcrime.securesms.database.MmsDatabase;
import org.thoughtcrime.securesms.database.NoSuchMessageException;
import org.thoughtcrime.securesms.jobs.requirements.MasterSecretRequirement;
import org.thoughtcrime.securesms.mms.ApnUnavailableException;
import org.thoughtcrime.securesms.mms.CompatMmsConnection;
import org.thoughtcrime.securesms.mms.MediaConstraints;
import org.thoughtcrime.securesms.mms.MmsSendResult;
import org.thoughtcrime.securesms.mms.OutgoingLegacyMmsConnection;
@@ -68,11 +69,11 @@ public class MmsSendJob extends SendJob {
validateDestinations(message);
final byte[] pduBytes = getPduBytes(masterSecret, message);
final SendConf sendConf = getMmsConnection(context).send(pduBytes);
final SendConf sendConf = new CompatMmsConnection(context).send(pduBytes);
final MmsSendResult result = getSendResult(sendConf, message);
database.markAsSent(messageId, result.getMessageId(), result.getResponseStatus());
} catch (UndeliverableMessageException | IOException | ApnUnavailableException e) {
} catch (UndeliverableMessageException | IOException e) {
Log.w(TAG, e);
database.markAsSentFailed(messageId);
notifyMediaMessageDeliveryFailed(context, messageId);
@@ -94,16 +95,6 @@ public class MmsSendJob extends SendJob {
notifyMediaMessageDeliveryFailed(context, messageId);
}
private OutgoingMmsConnection getMmsConnection(Context context)
throws ApnUnavailableException
{
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
return new OutgoingLollipopMmsConnection(context);
} else {
return new OutgoingLegacyMmsConnection(context);
}
}
private byte[] getPduBytes(MasterSecret masterSecret, SendReq message)
throws IOException, UndeliverableMessageException, InsecureFallbackApprovalException
{