use of com.google.android.mms.pdu.SendReq in project android-aosp-mms by slvn.
the class WorkingMessage method saveAsMms.
/**
* Force the message to be saved as MMS and return the Uri of the message.
* Typically used when handing a message off to another activity.
*/
public Uri saveAsMms(boolean notify) {
if (DEBUG)
LogTag.debug("saveAsMms mConversation=%s", mConversation);
// If we have discarded the message, just bail out.
if (mDiscarded) {
LogTag.warn("saveAsMms mDiscarded: true mConversation: " + mConversation + " returning NULL uri and bailing");
return null;
}
// FORCE_MMS behaves as sort of an "invisible attachment", making
// the message seem non-empty (and thus not discarded). This bit
// is sticky until the last other MMS bit is removed, at which
// point the message will fall back to SMS.
updateState(FORCE_MMS, true, notify);
// Collect our state to be written to disk.
prepareForSave(true);
try {
// Make sure we are saving to the correct thread ID.
DraftCache.getInstance().setSavingDraft(true);
if (!mConversation.getRecipients().isEmpty()) {
mConversation.ensureThreadId();
}
mConversation.setDraftState(true);
PduPersister persister = PduPersister.getPduPersister(mActivity);
SendReq sendReq = makeSendReq(mConversation, mSubject);
// have one already, make sure it is synced to disk.
if (mMessageUri == null) {
mMessageUri = createDraftMmsMessage(persister, sendReq, mSlideshow, null, mActivity, null);
} else {
updateDraftMmsMessage(mMessageUri, persister, mSlideshow, sendReq, null);
}
mHasMmsDraft = true;
} finally {
DraftCache.getInstance().setSavingDraft(false);
}
return mMessageUri;
}
use of com.google.android.mms.pdu.SendReq in project android-aosp-mms by slvn.
the class WorkingMessage method makeSendReq.
/**
* makeSendReq should always return a non-null SendReq, whether the dest addresses are
* valid or not.
*/
private static SendReq makeSendReq(Conversation conv, CharSequence subject) {
String[] dests = conv.getRecipients().getNumbers(true);
SendReq req = new SendReq();
EncodedStringValue[] encodedNumbers = EncodedStringValue.encodeStrings(dests);
if (encodedNumbers != null) {
req.setTo(encodedNumbers);
}
if (!TextUtils.isEmpty(subject)) {
req.setSubject(new EncodedStringValue(subject.toString()));
}
req.setDate(System.currentTimeMillis() / 1000L);
return req;
}
use of com.google.android.mms.pdu.SendReq in project android-aosp-mms by slvn.
the class WorkingMessage method asyncUpdateDraftMmsMessage.
private void asyncUpdateDraftMmsMessage(final Conversation conv, final boolean isStopping) {
if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
LogTag.debug("asyncUpdateDraftMmsMessage conv=%s mMessageUri=%s", conv, mMessageUri);
}
final HashMap<Uri, InputStream> preOpenedFiles = mSlideshow.openPartFiles(mContentResolver);
new Thread(new Runnable() {
@Override
public void run() {
try {
DraftCache.getInstance().setSavingDraft(true);
final PduPersister persister = PduPersister.getPduPersister(mActivity);
final SendReq sendReq = makeSendReq(conv, mSubject);
if (mMessageUri == null) {
mMessageUri = createDraftMmsMessage(persister, sendReq, mSlideshow, null, mActivity, preOpenedFiles);
} else {
updateDraftMmsMessage(mMessageUri, persister, mSlideshow, sendReq, preOpenedFiles);
}
ensureThreadIdIfNeeded(conv, isStopping);
conv.setDraftState(true);
if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
LogTag.debug("asyncUpdateDraftMmsMessage conv: " + conv + " uri: " + mMessageUri);
}
// Be paranoid and delete any SMS drafts that might be lying around. Must do
// this after ensureThreadId so conv has the correct thread id.
asyncDeleteDraftSmsMessage(conv);
} finally {
DraftCache.getInstance().setSavingDraft(false);
closePreOpenedFiles(preOpenedFiles);
}
}
}, "WorkingMessage.asyncUpdateDraftMmsMessage").start();
}
Aggregations