Search in sources :

Example 1 with ReadRecInd

use of com.google.android.mms.pdu.ReadRecInd in project android-aosp-mms by slvn.

the class MmsMessageSender method sendReadRec.

public static void sendReadRec(Context context, String to, String messageId, int status) {
    EncodedStringValue[] sender = new EncodedStringValue[1];
    sender[0] = new EncodedStringValue(to);
    try {
        final ReadRecInd readRec = new ReadRecInd(new EncodedStringValue(PduHeaders.FROM_INSERT_ADDRESS_TOKEN_STR.getBytes()), messageId.getBytes(), PduHeaders.CURRENT_MMS_VERSION, status, sender);
        readRec.setDate(System.currentTimeMillis() / 1000);
        PduPersister.getPduPersister(context).persist(readRec, Mms.Outbox.CONTENT_URI, true, MessagingPreferenceActivity.getIsGroupMmsEnabled(context), null);
        context.startService(new Intent(context, TransactionService.class));
    } catch (InvalidHeaderValueException e) {
        Log.e(TAG, "Invalide header value", e);
    } catch (MmsException e) {
        Log.e(TAG, "Persist message failed", e);
    }
}
Also used : EncodedStringValue(com.google.android.mms.pdu.EncodedStringValue) MmsException(com.google.android.mms.MmsException) ReadRecInd(com.google.android.mms.pdu.ReadRecInd) InvalidHeaderValueException(com.google.android.mms.InvalidHeaderValueException) Intent(android.content.Intent)

Example 2 with ReadRecInd

use of com.google.android.mms.pdu.ReadRecInd in project android-aosp-mms by slvn.

the class ReadRecTransaction method run.

public void run() {
    PduPersister persister = PduPersister.getPduPersister(mContext);
    try {
        // Load M-read-rec.ind from outbox
        ReadRecInd readRecInd = (ReadRecInd) persister.load(mReadReportURI);
        // insert the 'from' address per spec
        String lineNumber = MessageUtils.getLocalNumber();
        readRecInd.setFrom(new EncodedStringValue(lineNumber));
        // Pack M-read-rec.ind and send it
        byte[] postingData = new PduComposer(mContext, readRecInd).make();
        sendPdu(postingData);
        Uri uri = persister.move(mReadReportURI, Sent.CONTENT_URI);
        mTransactionState.setState(TransactionState.SUCCESS);
        mTransactionState.setContentUri(uri);
    } catch (IOException e) {
        if (LOCAL_LOGV) {
            Log.v(TAG, "Failed to send M-Read-Rec.Ind.", e);
        }
    } catch (MmsException e) {
        if (LOCAL_LOGV) {
            Log.v(TAG, "Failed to load message from Outbox.", e);
        }
    } catch (RuntimeException e) {
        if (LOCAL_LOGV) {
            Log.e(TAG, "Unexpected RuntimeException.", e);
        }
    } finally {
        if (mTransactionState.getState() != TransactionState.SUCCESS) {
            mTransactionState.setState(TransactionState.FAILED);
            mTransactionState.setContentUri(mReadReportURI);
        }
        notifyObservers();
    }
}
Also used : EncodedStringValue(com.google.android.mms.pdu.EncodedStringValue) MmsException(com.google.android.mms.MmsException) PduPersister(com.google.android.mms.pdu.PduPersister) ReadRecInd(com.google.android.mms.pdu.ReadRecInd) IOException(java.io.IOException) Uri(android.net.Uri) PduComposer(com.google.android.mms.pdu.PduComposer)

Aggregations

MmsException (com.google.android.mms.MmsException)2 EncodedStringValue (com.google.android.mms.pdu.EncodedStringValue)2 ReadRecInd (com.google.android.mms.pdu.ReadRecInd)2 Intent (android.content.Intent)1 Uri (android.net.Uri)1 InvalidHeaderValueException (com.google.android.mms.InvalidHeaderValueException)1 PduComposer (com.google.android.mms.pdu.PduComposer)1 PduPersister (com.google.android.mms.pdu.PduPersister)1 IOException (java.io.IOException)1