Search in sources :

Example 1 with PduBody

use of com.google.android.mms.pdu.PduBody 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 2 with PduBody

use of com.google.android.mms.pdu.PduBody 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 3 with PduBody

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

the class ComposeMessageActivity method isDrmRingtoneWithRights.

/**
 * Returns true if any part is drm'd audio with ringtone rights.
 * @param msgId
 * @return true if one of the parts is drm'd audio with rights to save as a ringtone.
 */
private boolean isDrmRingtoneWithRights(long msgId) {
    PduBody body = null;
    try {
        body = SlideshowModel.getPduBody(this, ContentUris.withAppendedId(Mms.CONTENT_URI, msgId));
    } catch (MmsException e) {
        Log.e(TAG, "isDrmRingtoneWithRights 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)) {
            String mimeType = MmsApp.getApplication().getDrmManagerClient().getOriginalMimeType(part.getDataUri());
            if (ContentType.isAudioType(mimeType) && DrmUtils.haveRightsForAction(part.getDataUri(), DrmStore.Action.RINGTONE)) {
                return true;
            }
        }
    }
    return false;
}
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 4 with PduBody

use of com.google.android.mms.pdu.PduBody 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 5 with PduBody

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

the class SlideshowEditActivity method onPause.

@Override
protected void onPause() {
    super.onPause();
    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)

Aggregations

PduBody (com.google.android.mms.pdu.PduBody)11 MmsException (com.google.android.mms.MmsException)9 PduPart (com.google.android.mms.pdu.PduPart)6 SpannableString (android.text.SpannableString)4 Uri (android.net.Uri)1 ExceedMessageSizeException (com.android.mms.ExceedMessageSizeException)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1