Search in sources :

Example 46 with MmsException

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

the class SlideEditorActivity method onPause.

@Override
protected void onPause() {
    super.onPause();
    // remove any callback to display a progress spinner
    if (mAsyncDialog != null) {
        mAsyncDialog.clearPendingProgressDialog();
    }
    synchronized (this) {
        if (mDirty) {
            try {
                PduBody pb = mSlideshowModel.toPduBody();
                PduPersister.getPduPersister(this).updateParts(mUri, pb, null);
                mSlideshowModel.sync(pb);
            } catch (MmsException e) {
                Log.e(TAG, "Cannot update the message: " + mUri, e);
            }
        }
    }
}
Also used : MmsException(com.google.android.mms.MmsException) PduBody(com.google.android.mms.pdu.PduBody)

Example 47 with MmsException

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

the class ComposeMessageActivity method saveRingtone.

/**
 * Copies media from an Mms to the DrmProvider
 * @param msgId
 */
private boolean saveRingtone(long msgId) {
    boolean result = true;
    PduBody body = null;
    try {
        body = SlideshowModel.getPduBody(this, ContentUris.withAppendedId(Mms.CONTENT_URI, msgId));
    } catch (MmsException e) {
        Log.e(TAG, "copyToDrmProvider can't load pdu body: " + msgId);
    }
    if (body == null) {
        return false;
    }
    int partNum = body.getPartsNum();
    for (int i = 0; i < partNum; i++) {
        PduPart part = body.getPart(i);
        String type = new String(part.getContentType());
        if (DrmUtils.isDrmType(type)) {
            // All parts (but there's probably only a single one) have to be successful
            // for a valid result.
            result &= copyPart(part, Long.toHexString(msgId));
        }
    }
    return result;
}
Also used : MmsException(com.google.android.mms.MmsException) PduBody(com.google.android.mms.pdu.PduBody) PduPart(com.google.android.mms.pdu.PduPart) SpannableString(android.text.SpannableString)

Example 48 with MmsException

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

the class ComposeMessageActivity method copyMedia.

/**
 * Copies media from an Mms to the "download" directory on the SD card. If any of the parts
 * are audio types, drm'd or not, they're copied to the "Ringtones" directory.
 * @param msgId
 */
private boolean copyMedia(long msgId) {
    boolean result = true;
    PduBody body = null;
    try {
        body = SlideshowModel.getPduBody(this, ContentUris.withAppendedId(Mms.CONTENT_URI, msgId));
    } catch (MmsException e) {
        Log.e(TAG, "copyMedia can't load pdu body: " + msgId);
    }
    if (body == null) {
        return false;
    }
    int partNum = body.getPartsNum();
    for (int i = 0; i < partNum; i++) {
        PduPart part = body.getPart(i);
        // all parts have to be successful for a valid result.
        result &= copyPart(part, Long.toHexString(msgId));
    }
    return result;
}
Also used : MmsException(com.google.android.mms.MmsException) PduBody(com.google.android.mms.pdu.PduBody) PduPart(com.google.android.mms.pdu.PduPart)

Example 49 with MmsException

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

the class MmsReceivedReceiver method getNotificationTask.

private List<CommonAsyncTask> getNotificationTask(Context context, Intent intent, byte[] response) {
    if (response.length == 0) {
        Timber.v("MmsReceivedReceiver.sendNotification blank response");
        return null;
    }
    if (getMmscInfoForReceptionAck() == null) {
        Timber.v("No MMSC information set, so no notification tasks will be able to complete");
        return null;
    }
    final GenericPdu pdu = (new PduParser(response, new MmsConfig.Overridden(new MmsConfig(context), null).getSupportMmsContentDisposition())).parse();
    if (pdu == null || !(pdu instanceof RetrieveConf)) {
        Timber.e("MmsReceivedReceiver.sendNotification failed to parse pdu");
        return null;
    }
    try {
        final NotificationInd ind = getNotificationInd(context, intent);
        final MmscInformation mmsc = getMmscInfoForReceptionAck();
        final TransactionSettings transactionSettings = new TransactionSettings(mmsc.mmscUrl, mmsc.mmsProxy, mmsc.proxyPort);
        final List<CommonAsyncTask> responseTasks = new ArrayList<>();
        responseTasks.add(new AcknowledgeIndTask(context, ind, transactionSettings, (RetrieveConf) pdu));
        responseTasks.add(new NotifyRespTask(context, ind, transactionSettings));
        return responseTasks;
    } catch (MmsException e) {
        Timber.e(e, "error");
        return null;
    }
}
Also used : PduParser(com.google.android.mms.pdu_alt.PduParser) NotificationInd(com.google.android.mms.pdu_alt.NotificationInd) ArrayList(java.util.ArrayList) MmsException(com.google.android.mms.MmsException) MmsConfig(com.android.mms.service_alt.MmsConfig) TransactionSettings(com.android.mms.transaction.TransactionSettings) GenericPdu(com.google.android.mms.pdu_alt.GenericPdu) RetrieveConf(com.google.android.mms.pdu_alt.RetrieveConf)

Example 50 with MmsException

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

the class PduPersister method persistPart.

public Uri persistPart(PduPart part, long msgId, HashMap<Uri, InputStream> preOpenedFiles) throws MmsException {
    Uri uri = Uri.parse("content://mms/" + msgId + "/part");
    ContentValues values = new ContentValues(8);
    int charset = part.getCharset();
    if (charset != 0) {
        values.put(Part.CHARSET, charset);
    }
    String contentType = getPartContentType(part);
    if (contentType != null) {
        // Change it to "image/jpeg"
        if (ContentType.IMAGE_JPG.equals(contentType)) {
            contentType = ContentType.IMAGE_JPEG;
        }
        values.put(Part.CONTENT_TYPE, contentType);
        // To ensure the SMIL part is always the first part.
        if (ContentType.APP_SMIL.equals(contentType)) {
            values.put(Part.SEQ, -1);
        }
    } else {
        throw new MmsException("MIME type of the part must be set.");
    }
    if (part.getFilename() != null) {
        String fileName = new String(part.getFilename());
        values.put(Part.FILENAME, fileName);
    }
    if (part.getName() != null) {
        String name = new String(part.getName());
        values.put(Part.NAME, name);
    }
    Object value = null;
    if (part.getContentDisposition() != null) {
        value = toIsoString(part.getContentDisposition());
        values.put(Part.CONTENT_DISPOSITION, (String) value);
    }
    if (part.getContentId() != null) {
        value = toIsoString(part.getContentId());
        values.put(Part.CONTENT_ID, (String) value);
    }
    if (part.getContentLocation() != null) {
        value = toIsoString(part.getContentLocation());
        values.put(Part.CONTENT_LOCATION, (String) value);
    }
    Uri res = SqliteWrapper.insert(mContext, mContentResolver, uri, values);
    if (res == null) {
        throw new MmsException("Failed to persist part, return null.");
    }
    persistData(part, res, contentType, preOpenedFiles);
    // After successfully store the data, we should update
    // the dataUri of the part.
    part.setDataUri(res);
    return res;
}
Also used : ContentValues(android.content.ContentValues) MmsException(com.google.android.mms.MmsException) Uri(android.net.Uri)

Aggregations

MmsException (com.google.android.mms.MmsException)88 Uri (android.net.Uri)32 ContentValues (android.content.ContentValues)27 Cursor (android.database.Cursor)21 IOException (java.io.IOException)18 Intent (android.content.Intent)12 EncodedStringValue (com.google.android.mms.pdu.EncodedStringValue)9 PduBody (com.google.android.mms.pdu.PduBody)9 ByteArrayOutputStream (java.io.ByteArrayOutputStream)9 ContentResolver (android.content.ContentResolver)8 InputStream (java.io.InputStream)8 PduPersister (com.google.android.mms.pdu.PduPersister)7 PduPersister (com.google.android.mms.pdu_alt.PduPersister)7 Entry (java.util.Map.Entry)7 SpannableString (android.text.SpannableString)6 PduBody (com.google.android.mms.pdu_alt.PduBody)6 PduPart (com.google.android.mms.pdu_alt.PduPart)6 FileNotFoundException (java.io.FileNotFoundException)6 InvalidHeaderValueException (com.google.android.mms.InvalidHeaderValueException)5 PduPart (com.google.android.mms.pdu.PduPart)5