mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-30 13:35:18 +00:00
Lollipop MMS API doesn't seem to work reliably until L_MR1
Fixes #6663 Fixes #6668 // FREEBIE
This commit is contained in:
parent
4dd5a92817
commit
4509077338
@ -100,7 +100,7 @@ public class MmsDownloadJob extends MasterSecretJob {
|
|||||||
Log.w(TAG, e);
|
Log.w(TAG, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.w(TAG, "Downloading mms at " + Uri.parse(contentLocation).getHost());
|
Log.w(TAG, "Downloading mms at " + Uri.parse(contentLocation).getHost() + ", subscription ID: " + notification.get().getSubscriptionId());
|
||||||
|
|
||||||
RetrieveConf retrieveConf = new CompatMmsConnection(context).retrieve(contentLocation, transactionId, notification.get().getSubscriptionId());
|
RetrieveConf retrieveConf = new CompatMmsConnection(context).retrieve(contentLocation, transactionId, notification.get().getSubscriptionId());
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.thoughtcrime.securesms.mms;
|
package org.thoughtcrime.securesms.mms;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Build.VERSION;
|
import android.os.Build.VERSION;
|
||||||
import android.os.Build.VERSION_CODES;
|
import android.os.Build.VERSION_CODES;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
@ -29,16 +30,16 @@ public class CompatMmsConnection implements OutgoingMmsConnection, IncomingMmsCo
|
|||||||
public SendConf send(@NonNull byte[] pduBytes, int subscriptionId)
|
public SendConf send(@NonNull byte[] pduBytes, int subscriptionId)
|
||||||
throws UndeliverableMessageException
|
throws UndeliverableMessageException
|
||||||
{
|
{
|
||||||
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
|
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP_MR1) {
|
||||||
try {
|
try {
|
||||||
Log.w(TAG, "Sending via Lollipop API");
|
Log.w(TAG, "Sending via Lollipop API");
|
||||||
return new OutgoingLollipopMmsConnection(context).send(pduBytes, subscriptionId);
|
return new OutgoingLollipopMmsConnection(context).send(pduBytes, subscriptionId);
|
||||||
} catch (UndeliverableMessageException e) {
|
} catch (UndeliverableMessageException e) {
|
||||||
Log.w(TAG, e);
|
Log.w(TAG, e);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Log.w(TAG, "Falling back to legacy connection...");
|
Log.w(TAG, "Falling back to legacy connection...");
|
||||||
|
}
|
||||||
|
|
||||||
if (subscriptionId == -1) {
|
if (subscriptionId == -1) {
|
||||||
Log.w(TAG, "Sending via legacy connection");
|
Log.w(TAG, "Sending via legacy connection");
|
||||||
@ -55,6 +56,11 @@ public class CompatMmsConnection implements OutgoingMmsConnection, IncomingMmsCo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP && VERSION.SDK_INT < VERSION_CODES.LOLLIPOP_MR1) {
|
||||||
|
Log.w(TAG, "Falling back to sending via Lollipop API");
|
||||||
|
return new OutgoingLollipopMmsConnection(context).send(pduBytes, subscriptionId);
|
||||||
|
}
|
||||||
|
|
||||||
throw new UndeliverableMessageException("Both lollipop and legacy connections failed...");
|
throw new UndeliverableMessageException("Both lollipop and legacy connections failed...");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,17 +71,19 @@ public class CompatMmsConnection implements OutgoingMmsConnection, IncomingMmsCo
|
|||||||
int subscriptionId)
|
int subscriptionId)
|
||||||
throws MmsException, MmsRadioException, ApnUnavailableException, IOException
|
throws MmsException, MmsRadioException, ApnUnavailableException, IOException
|
||||||
{
|
{
|
||||||
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
|
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP_MR1) {
|
||||||
Log.w(TAG, "Receiving via Lollipop API");
|
Log.w(TAG, "Receiving via Lollipop API");
|
||||||
try {
|
try {
|
||||||
return new IncomingLollipopMmsConnection(context).retrieve(contentLocation, transactionId, subscriptionId);
|
return new IncomingLollipopMmsConnection(context).retrieve(contentLocation, transactionId, subscriptionId);
|
||||||
} catch (MmsException e) {
|
} catch (MmsException e) {
|
||||||
Log.w(TAG, e);
|
Log.w(TAG, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log.w(TAG, "Falling back to receiving via legacy connection");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subscriptionId == -1) {
|
if (VERSION.SDK_INT < 22 || subscriptionId == -1) {
|
||||||
Log.w(TAG, "Falling back to receiving via legacy connection");
|
Log.w(TAG, "Receiving via legacy API");
|
||||||
try {
|
try {
|
||||||
return new IncomingLegacyMmsConnection(context).retrieve(contentLocation, transactionId, subscriptionId);
|
return new IncomingLegacyMmsConnection(context).retrieve(contentLocation, transactionId, subscriptionId);
|
||||||
} catch (MmsRadioException | ApnUnavailableException | IOException e) {
|
} catch (MmsRadioException | ApnUnavailableException | IOException e) {
|
||||||
@ -83,6 +91,11 @@ public class CompatMmsConnection implements OutgoingMmsConnection, IncomingMmsCo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP && VERSION.SDK_INT < VERSION_CODES.LOLLIPOP_MR1) {
|
||||||
|
Log.w(TAG, "Falling back to receiving via Lollipop API");
|
||||||
|
return new IncomingLollipopMmsConnection(context).retrieve(contentLocation, transactionId, subscriptionId);
|
||||||
|
}
|
||||||
|
|
||||||
throw new IOException("Both lollipop and fallback APIs failed...");
|
throw new IOException("Both lollipop and fallback APIs failed...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user