Search in sources :

Example 16 with EncodedStringValue

use of com.google.android.mms.pdu.EncodedStringValue 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)

Example 17 with EncodedStringValue

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

the class RetrieveTransaction method sendAcknowledgeInd.

private void sendAcknowledgeInd(RetrieveConf rc) throws MmsException, IOException {
    // Send M-Acknowledge.ind to MMSC if required.
    // If the Transaction-ID isn't set in the M-Retrieve.conf, it means
    // the MMS proxy-relay doesn't require an ACK.
    byte[] tranId = rc.getTransactionId();
    if (tranId != null) {
        // Create M-Acknowledge.ind
        AcknowledgeInd acknowledgeInd = new AcknowledgeInd(PduHeaders.CURRENT_MMS_VERSION, tranId);
        // insert the 'from' address per spec
        String lineNumber = MessageUtils.getLocalNumber();
        acknowledgeInd.setFrom(new EncodedStringValue(lineNumber));
        // Pack M-Acknowledge.ind and send it
        if (MmsConfig.getNotifyWapMMSC()) {
            sendPdu(new PduComposer(mContext, acknowledgeInd).make(), mContentLocation);
        } else {
            sendPdu(new PduComposer(mContext, acknowledgeInd).make());
        }
    }
}
Also used : EncodedStringValue(com.google.android.mms.pdu.EncodedStringValue) AcknowledgeInd(com.google.android.mms.pdu.AcknowledgeInd) PduComposer(com.google.android.mms.pdu.PduComposer)

Example 18 with EncodedStringValue

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

the class AddressUtils method getFrom.

public static String getFrom(Context context, Uri uri) {
    String msgId = uri.getLastPathSegment();
    Uri.Builder builder = Mms.CONTENT_URI.buildUpon();
    builder.appendPath(msgId).appendPath("addr");
    Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(), builder.build(), new String[] { Addr.ADDRESS, Addr.CHARSET }, Addr.TYPE + "=" + PduHeaders.FROM, null, null);
    if (cursor != null) {
        try {
            if (cursor.moveToFirst()) {
                String from = cursor.getString(0);
                if (!TextUtils.isEmpty(from)) {
                    byte[] bytes = PduPersister.getBytes(from);
                    int charset = cursor.getInt(1);
                    return new EncodedStringValue(charset, bytes).getString();
                }
            }
        } finally {
            cursor.close();
        }
    }
    return context.getString(R.string.hidden_sender_address);
}
Also used : EncodedStringValue(com.google.android.mms.pdu.EncodedStringValue) Cursor(android.database.Cursor) Uri(android.net.Uri)

Example 19 with EncodedStringValue

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

the class DownloadManager method getMessage.

private String getMessage(Uri uri) throws MmsException {
    NotificationInd ind = (NotificationInd) PduPersister.getPduPersister(mContext).load(uri);
    EncodedStringValue v = ind.getSubject();
    String subject = (v != null) ? v.getString() : mContext.getString(R.string.no_subject);
    v = ind.getFrom();
    String from = (v != null) ? Contact.get(v.getString(), false).getName() : mContext.getString(R.string.unknown_sender);
    return mContext.getString(R.string.dl_failure_notification, subject, from);
}
Also used : EncodedStringValue(com.google.android.mms.pdu.EncodedStringValue) NotificationInd(com.google.android.mms.pdu.NotificationInd)

Aggregations

EncodedStringValue (com.google.android.mms.pdu.EncodedStringValue)19 Uri (android.net.Uri)9 MmsException (com.google.android.mms.MmsException)9 ContentValues (android.content.ContentValues)6 IOException (java.io.IOException)5 Cursor (android.database.Cursor)4 SendReq (com.google.android.mms.pdu.SendReq)4 PduComposer (com.google.android.mms.pdu.PduComposer)3 PduPersister (com.google.android.mms.pdu.PduPersister)3 InputStream (java.io.InputStream)3 Intent (android.content.Intent)2 Resources (android.content.res.Resources)2 NotificationInd (com.google.android.mms.pdu.NotificationInd)2 ReadRecInd (com.google.android.mms.pdu.ReadRecInd)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 HashSet (java.util.HashSet)2 SpannableString (android.text.SpannableString)1 ContentRestrictionException (com.android.mms.ContentRestrictionException)1 ExceedMessageSizeException (com.android.mms.ExceedMessageSizeException)1 ResolutionException (com.android.mms.ResolutionException)1