use of com.google.android.mms.pdu.PduPart 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;
}
use of com.google.android.mms.pdu.PduPart 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;
}
use of com.google.android.mms.pdu.PduPart 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;
}
use of com.google.android.mms.pdu.PduPart in project android-aosp-mms by slvn.
the class UriImage method getResizedImageAsPart.
/**
* Get a version of this image resized to fit the given dimension and byte-size limits. Note
* that the content type of the resulting PduPart may not be the same as the content type of
* this UriImage; always call {@link PduPart#getContentType()} to get the new content type.
*
* @param widthLimit The width limit, in pixels
* @param heightLimit The height limit, in pixels
* @param byteLimit The binary size limit, in bytes
* @return A new PduPart containing the resized image data
*/
public PduPart getResizedImageAsPart(int widthLimit, int heightLimit, int byteLimit) {
PduPart part = new PduPart();
byte[] data = getResizedImageData(mWidth, mHeight, widthLimit, heightLimit, byteLimit, mUri, mContext);
if (data == null) {
if (LOCAL_LOGV) {
Log.v(TAG, "Resize image failed.");
}
return null;
}
part.setData(data);
// getResizedImageData ALWAYS compresses to JPEG, regardless of the original content type
part.setContentType(ContentType.IMAGE_JPEG.getBytes());
return part;
}
use of com.google.android.mms.pdu.PduPart in project android-aosp-mms by slvn.
the class SmilHelper method getDocument.
public static SMILDocument getDocument(PduBody pb) {
// Find SMIL part in the message.
PduPart smilPart = findSmilPart(pb);
SMILDocument document = null;
// Try to load SMIL document from existing part.
if (smilPart != null) {
document = getSmilDocument(smilPart);
}
if (document == null) {
// Create a new SMIL document.
document = createSmilDocument(pb);
}
return document;
}
Aggregations