use of com.google.android.mms.pdu_alt.PduBody in project qksms by moezbhatti.
the class MessageUtils method saveRingtone.
/**
* Copies media from an Mms to the DrmProvider
*
* @param context
* @param msgId
*/
public static boolean saveRingtone(Context context, long msgId) {
boolean result = true;
PduBody body = null;
try {
body = SlideshowModel.getPduBody(context, 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(context, part, Long.toHexString(msgId));
}
}
return result;
}
use of com.google.android.mms.pdu_alt.PduBody in project qksms by moezbhatti.
the class MessageUtils 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 context
* @param msgId
*/
public static boolean copyMedia(Context context, long msgId) {
boolean result = true;
PduBody body = null;
try {
body = SlideshowModel.getPduBody(context, 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(context, part, Long.toHexString(msgId));
}
return result;
}
use of com.google.android.mms.pdu_alt.PduBody in project qksms by moezbhatti.
the class MessageUtils method isForwardable.
/**
* Returns true if all drm'd parts are forwardable.
*
* @param context
* @param msgId
* @return true if all drm'd parts are forwardable.
*/
public static boolean isForwardable(Context context, long msgId) {
PduBody body = null;
try {
body = SlideshowModel.getPduBody(context, ContentUris.withAppendedId(Mms.CONTENT_URI, msgId));
} catch (MmsException e) {
Log.e(TAG, "getDrmMimeType 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) && !DrmUtils.haveRightsForAction(part.getDataUri(), DrmStore.Action.TRANSFER)) {
return false;
}
}
return true;
}
Aggregations