Android 源码阅读之SMS,MMS

主界面:

com.android.mms.ui.ConversationList.java  [extends ListActivity]

点击新建信息:onListItemClick -〉 position == 0 -〉createNewMessage()-〉 startActivity[ComposeMessageActivity]

com.android.mms.ui.ComposeMessageActivity.java

点击发送按钮:onClick -> mSendButton -> confirmSendMessageIfNeeded()  -> sendMessage(true) ->

mWorkingMessage.setPhoneId(phoneId); mWorkingMessage.send(mDebugRecipients);

com.android.mms.data.WorkingMessage.java

send:如果是彩信 sendMmsWork 如果是短信preSendSmsWorker

-------------------------------------------------------------------------------------------------------

短信流程:

preSendSmsWorker -〉 sendSmsWorker -〉SmsMessageSender.sendMessage(threadId)

com.android.mms.transaction.SmsMessageSender.java

sendMessage -> queueMessage ->

mContext.sendBroadcast[SmsReceiverService.ACTION_SEND_MESSAGE, SmsReceiver.class]

com.android.mms.transaction.SmsReceiver.java

com.android.mms.transaction.SmsReceiverService.java

handleMessage -> ACTION_SEND_MESSAGE -> handleSendMessage -> sendFirstQueuedMessage ->

SmsSingleRecipientSender.sendMessage

com.android.mms.transaction.SmsSingleRecipientSender.java

sendMessage -> SmsManager.sendMultipartTextMessage

进入Framework层

frameworks/base/telephony/java/android/telephony/SmsManager.java

sendMultipartTextMessage -> 一条短信是不是需要分多个部分(太长)?

ISms.sendMultipartText | ISms.sendText

frameworks/base/telephony/java/com/android/internal/telephony/IccSmsInterfaceManager.java

sendText -> CdmaSMSDispatcher.sendText | GsmSMSDispatcher.sendText

[cdma]

frameworks/base/telephony/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java

sendText -> sendSubmitPdu -> sendRawPdu ->

sendSms | sendMessage

sendSms -> CommandsInterface.sendCdmaSms

frameworks/base/telephony/java/com/android/internal/telephony/RIL.java

sendCdmaSms -> RIL_REQUEST_CDMA_SEND_SMS

hardware/ril_c/reference-ril/reference-cpb71.c

case RIL_REQUEST_CDMA_SEND_SMS: requestSendCdmaSMS -> at_send_command

[gsm]

frameworks/base/telephony/java/com/android/internal/telephony/gsm/GsmSMSDispatcher.java

sendText -> sendRawPdu ->

sendSms | sendMessage

sendSms -> CommandInterface.sendSMS

frameworks/base/telephony/java/com/android/internal/telephony/RIL.java

sendSMS -> RIL_REQUEST_SEND_SMS



现在读彩信,从sendMmsWork开始:

com.android.mms.data.WorkingMessage.java

sendMmsWorker -> MmsMessageSender.sendMessage(threadId)

com.android.mms.transaction.MmsMessageSender.java

sendMessage -> mContext.startService[TransactionService.class]

[注意 pdu.getMessageType() != PduHeaders.MESSAGE_TYPE_SEND_REQ throw new MmsException]

com.android.mms.transaction.TransactionService.java

onStartCommand -> launchTransaction -> ServiceHandler.sendMessage[EVENT_TRANSACTION_REQUEST]

ServiceHandler:handlemessage - EVENT_TRANSACTION_REQUEST - Transaction.SEND_TRANSACTION -

transaction = new SendTransaction - processTransaction(transaction)

SendTransaction.process

[注意,标红处查看代码 getTransactionType case PduHeaders.MESSAGE_TYPE_SEND_REQ:

return Transaction.SEND_TRANSACTION]

com.android.mms.transaction.SendTransaction.java

process -> run -> sendPdu -> HttpUtils.httpConnection



你可能感兴趣的:(Android 源码阅读之SMS,MMS)