1、 return; boolean isMms = mWorkingMessage.requiresMms(); /是否需要以彩信形式发送 if (mRecipientsEditor.hasInvalidRecipient(isMms) /是否含有不合法的收件人 if (mRecipientsEditor.hasValidRecipient(isMms) /有合法的和不合法的,弹出尝试发送对话框 String title = getResourcesString(R.string.has_invalid_recipient, mRecipientsEditor.formatInvalidNumb
2、ers(isMms); new AlertDialog.Builder(this) .setIcon(android.R.drawable.ic_dialog_alert) .setTitle(title) .setMessage(R.string.invalid_recipient_message) .setPositiveButton(R.string.try_to_send, newSendIgnoreInvalidRecipientListener() .setNegativeButton(R.string.no, new CancelSendingListener() .show()
3、; else /如果全是不合法的联系人,提示不能发送信息 .setTitle(R.string.cannot_send_message) .setMessage(R.string.cannot_send_message_reason) .setPositiveButton(R.string.yes, new CancelSendingListener() else /判断收件人没有问题,接着发送信息 -3. src/android/mms/ui/poseMessageActivity.javaprivate void sendMessage(boolean bCheckEcmMode) Log
4、.v(TAG, sendMessage); if (bCheckEcmMode) / TODO: expose this in telephony layer for SDK build String inEcm = SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE); /判断是否处于紧急拨号模式,得到的inEcm一般为空inEcm = + inEcm); if (Boolean.parseBoolean(inEcm) try startActivityForResult( new Intent(TelephonyInte
5、nts.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS,null), REQUEST_CODE_ECM_EXIT_DIALOG); catch (ActivityNotFoundException e) / continue to send message Log.e(TAG, Cannot find EmergencyCallbackModeExitDialog, e);mSendingMessage) / send can change the recipients. Make sure we remove the listeners firstand then a
6、dd / them back once the recipient list has settled. removeRecipientsListeners(); /取消对收件人的监听 mWorkingMessage.send(); /发送信息- mSentMessage = true; mSendingMessage = true; addRecipientsListeners(); /重新添加收件人监听 / But bail out if we are supposed to exit after the message is sent. if (mExitOnSent) /如果mExitO
7、nSent为true,信息发送完成后退出Activity finish();4. src/android/mms/data/WorkingMessage.java/* * Send this message over the network. Will call back with onMessageSent() once * it has been dispatched to the telephonystack. This WorkingMessage object is * no longer useful after this method hasbeen called. */ pub
8、lic void send() if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE) LogTag.debug(send / Get ready to write to disk. prepareForSave(true /* notify */);/主要做一下同步收件人和WorkingMessage,彩信时在准备其他一些东西 / We need the recipient list for both SMS and MMS. final Conversation conv = mConversation; String msgTxt = mT
9、ext.toString();msgText = + msgTxt); if (requiresMms()| addressContainsEmailToMms(conv, msgTxt) / Make local copies of the bits we need for sending a message, / because we will be doing it off of the main thread, which will / immediately continue on to resetting some of this state. final Uri mmsUri =
10、 mMessageUri; /如果第一次发送,此时mmsUri为null,如果是重发,则是草稿箱的地址 mMessageUri =content:/mms/drafts/1 final PduPersister persister = PduPersister.getPduPersister(mContext); final SlideshowModel slideshow = mSlideshow; final SendReq sendReq = makeSendReq(conv,mSubject); / Do the dirty work of sending the message of
11、f of the main UI thread. new Thread(new Runnable() public void run() / Make sure the text in slide 0 is no longer holding onto a reference to / the text in the message text box. slideshow.prepareForSend(); sendMmsWorker(conv, mmsUri, persister, slideshow, sendReq); ).start(); else / Same rules apply
12、 as above. final String msgText = mText.toString();/取出短消息 + msgText); preSendSmsWorker(conv, msgText);/发送信息- / update the Recipient cache with the new to address, if its different RecipientIdCache.updateNumbers(conv.getThreadId(),conv.getRecipients(); / Mark the message as discarded because it is of
13、f the marketafter being sent. mDiscarded = true;5. src/android/mms/data/WorkingMessage.javaprivate void sendMmsWorker(Conversation conv, Uri mmsUri, PduPersisterpersister, SlideshowModel slideshow, SendReq sendReq) sendMmsWorker / If user tries to send the message, its a signal the inputtedtext is w
14、hat they wanted. UserHappinessSignals.userAcceptedImeText(mContext); / First make sure we dont have too many outstanding unsent message. Cursor cursor = null; cursor = SqliteWrapper.query(mContext, mContentResolver, Mms.Outbox.CONTENT_URI,MMS_OUTBOX_PROJECTION, null, null, null); if (cursor != null)
15、 /如果MMS_OUTBOX里有未发送的彩信,并且总的大小已经超过了彩信的最大限制,则取消此次发送,并存入草稿箱query Mms.Outbox.CONTENT_URI is not empty long maxMessageSize = MmsConfig.getMaxSizeScaleForPendingMmsAllowed()* MmsConfig.getMaxMessageSize();MmsConfig.getMaxSizeScaleForPendingMmsAllowed() = + MmsConfig.getMaxSizeScaleForPendingMmsAllowed();M
16、msConfig.getMaxMessageSize()() = + MmsConfig.getMaxMessageSize(); long totalPendingSize = 0; while (cursor.moveToNext() totalPendingSize +=cursor.getLong(MMS_MESSAGE_SIZE_INDEX);totalPendingSize = + totalPendingSize); if (totalPendingSize = maxMessageSize) unDiscard(); / itwasnt successfully sent. A
17、llow it to be saved as a draft. mStatusListener.onMaxPendingMessagesReached(); elsequery Mms.Outbox.CONTENT_URI is empty finally = null) cursor.close(); mStatusListener.onPreMessageSent(); / Make sure we are still using the correct thread ID for our / recipient set. long threadId = conv.ensureThread
18、Id(); if (Log.isLoggable(LogTag.APP, Log.VERBOSE) sendMmsWorker: update draft MMS message + mmsUri); if (mmsUri = null) /如果是首次发送,先把彩信保存入草稿箱 / Create a new MMS message if one hasnt been made yet.mmsUri = null and startcreateDraftMmsMessage mmsUri = createDraftMmsMessage(persister,sendReq, slideshow);
19、 else / Otherwise, sync the MMS message in progress to disk.mmsUri = updateDraftMmsMessage updateDraftMmsMessage(mmsUri,persister, slideshow, sendReq); / Be paranoid and clean any draft SMS up. deleteDraftSmsMessage(threadId); / Resize all the resizeable attachments (e.g. pictures) to fit / in the r
20、emaining space in the slideshow. int error = 0; slideshow.finalResize(mmsUri); catch (ExceedMessageSizeException e1) error = MESSAGE_SIZE_EXCEEDED; catch (MmsException e1) error = UNKNOWN_ERROR; if (error != 0) markMmsMessageWithError(mmsUri); mStatusListener.onAttachmentError(error); MessageSender
21、sender = new MmsMessageSender(mContext, mmsUri, slideshow.getCurrentMessageSize();sender.sendMessage(threadId) / The message was sent through SMS protocol, we should / delete the copy which was previously saved in MMS drafts. SqliteWrapper.delete(mContext, mContentResolver, mmsUri, null, null); / Make sure this thread isnt over the limits in message count
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1