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;
}
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;
}
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;
}
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);
}
}
}
}
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);
}
}
}
}
Aggregations