Search in sources :

Example 11 with RetrieveConf

use of com.google.android.mms.pdu_alt.RetrieveConf in project Signal-Android by WhisperSystems.

the class IncomingLegacyMmsConnection method retrieve.

public RetrieveConf retrieve(Apn contentApn, byte[] transactionId, boolean usingMmsRadio, boolean useProxyIfAvailable) throws IOException, ApnUnavailableException {
    byte[] pdu = null;
    final boolean useProxy = useProxyIfAvailable && contentApn.hasProxy();
    final String targetHost = useProxy ? contentApn.getProxy() : Uri.parse(contentApn.getMmsc()).getHost();
    if (checkRouteToHost(context, targetHost, usingMmsRadio)) {
        Log.i(TAG, "got successful route to host " + targetHost);
        pdu = execute(constructRequest(contentApn, useProxy));
    }
    if (pdu == null) {
        throw new IOException("Connection manager could not obtain route to host.");
    }
    RetrieveConf retrieved = (RetrieveConf) new PduParser(pdu).parse();
    if (retrieved == null) {
        Log.w(TAG, "Couldn't parse PDU, byte response: " + Arrays.toString(pdu));
        Log.w(TAG, "Couldn't parse PDU, ASCII:         " + new String(pdu));
        throw new IOException("Bad retrieved PDU");
    }
    sendRetrievedAcknowledgement(transactionId, usingMmsRadio, useProxy);
    return retrieved;
}
Also used : PduParser(com.google.android.mms.pdu_alt.PduParser) IOException(java.io.IOException) RetrieveConf(com.google.android.mms.pdu_alt.RetrieveConf)

Aggregations

RetrieveConf (com.google.android.mms.pdu_alt.RetrieveConf)11 PduParser (com.google.android.mms.pdu_alt.PduParser)8 IOException (java.io.IOException)8 MmsException (com.google.android.mms.MmsException)5 Uri (android.net.Uri)4 ContentValues (android.content.ContentValues)3 GenericPdu (com.google.android.mms.pdu_alt.GenericPdu)3 PduPersister (com.google.android.mms.pdu_alt.PduPersister)3 TargetApi (android.annotation.TargetApi)2 SmsManager (android.telephony.SmsManager)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 TimeoutException (java.util.concurrent.TimeoutException)2 ApnUnavailableException (org.thoughtcrime.securesms.mms.ApnUnavailableException)2 CompatMmsConnection (org.thoughtcrime.securesms.mms.CompatMmsConnection)2 MmsException (org.thoughtcrime.securesms.mms.MmsException)2 MmsRadioException (org.thoughtcrime.securesms.mms.MmsRadioException)2 MmsBodyProvider (org.thoughtcrime.securesms.providers.MmsBodyProvider)2 Intent (android.content.Intent)1 Resources (android.content.res.Resources)1