Search in sources :

Example 1 with ReadRecInd

use of com.google.android.mms.pdu_alt.ReadRecInd in project qksms by moezbhatti.

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);
        boolean group;
        try {
            group = com.moez.QKSMS.mmssms.Transaction.settings.getGroup();
        } catch (Exception e) {
            group = PreferenceManager.getDefaultSharedPreferences(context).getBoolean("pref_key_compose_group", true);
        }
        PduPersister.getPduPersister(context).persist(readRec, Uri.parse("content://mms/outbox"), true, group, null);
        Intent service = new Intent(TransactionService.HANDLE_PENDING_TRANSACTIONS_ACTION, null, context, TransactionService.class);
        context.startService(service);
    } 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_alt.EncodedStringValue) MmsException(com.google.android.mms.MmsException) ReadRecInd(com.google.android.mms.pdu_alt.ReadRecInd) InvalidHeaderValueException(com.google.android.mms.InvalidHeaderValueException) Intent(android.content.Intent) MmsException(com.google.android.mms.MmsException) InvalidHeaderValueException(com.google.android.mms.InvalidHeaderValueException)

Example 2 with ReadRecInd

use of com.google.android.mms.pdu_alt.ReadRecInd in project qksms by moezbhatti.

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 = Utils.getMyPhoneNumber(mContext);
        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) {
            Timber.v(e, "Failed to send M-Read-Rec.Ind.");
        }
    } catch (MmsException e) {
        if (LOCAL_LOGV) {
            Timber.v(e, "Failed to load message from Outbox.");
        }
    } catch (RuntimeException e) {
        if (LOCAL_LOGV) {
            Timber.e(e, "Unexpected RuntimeException.");
        }
    } finally {
        if (mTransactionState.getState() != TransactionState.SUCCESS) {
            mTransactionState.setState(TransactionState.FAILED);
            mTransactionState.setContentUri(mReadReportURI);
        }
        notifyObservers();
    }
}
Also used : EncodedStringValue(com.google.android.mms.pdu_alt.EncodedStringValue) MmsException(com.google.android.mms.MmsException) PduPersister(com.google.android.mms.pdu_alt.PduPersister) ReadRecInd(com.google.android.mms.pdu_alt.ReadRecInd) IOException(java.io.IOException) Uri(android.net.Uri) PduComposer(com.google.android.mms.pdu_alt.PduComposer)

Aggregations

MmsException (com.google.android.mms.MmsException)2 EncodedStringValue (com.google.android.mms.pdu_alt.EncodedStringValue)2 ReadRecInd (com.google.android.mms.pdu_alt.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_alt.PduComposer)1 PduPersister (com.google.android.mms.pdu_alt.PduPersister)1 IOException (java.io.IOException)1