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