Android SMS MMS send and receive process (Application layer)

Source: Internet
Author: User

The information delivery process for the confirmsendmessageifneeded part of Composemessageactivity. Mainly with the confirmation of the validity of the recipient, then turn to SendMessage method to send.



Composemessageactivity.sendmessage
As can be seen in this method, the main thing to do is to confirm the validity of the mobile phone status. Finally, call Workingmessage's Send method for sending information.


As you can see from

Workingmessage.send
, in this method, different types of messages are called separately to handle them. And some brief preprocessing of MMS.
 

 
SMS part:
Workingmessage.presendsmsworker
As shown, this is the sending process for the SMS part. There are more things involved in this method. The workingmessage in the original composemessage can be updated because it has been transferred to a new thread to send the message using Workingmessage. Then verify that the owning session exists and create a new one if it does not exist. The
then serializes the receiver, calling Sendsmsworker. Create a smsmessagesender to put the message in the Send queue (the Type field is set to 6). Notification Smsreceiver sent. The
Smsreceiver calls the first text message in the Smsreceiverservice send queue.
before sending, but also according to the different phone cards, the text message content into several blocks, to ensure that the size of each block does not exceed the limit of the card. In the sentintent of the last text message after the segment, set Extra_message_sent_send_next to True. This way, when the text message is sent successfully, the Smsreceiverservice Handlesmssent method is called, and the first line in the queue is sent. The
then assigns a sentintent to each block, and when sent out, modifies its state. If a report is required, a deliveryintent is also specified for the processing of the message report. These two intent will be encapsulated in the Smstracker and, when sent successfully, are removed from the handlesendcomplete of Smsdispatcher. The sentintent is immediately executed and the message state is converted to sent. Deliveryintent is added to the deliverypendinglist, and is executed when the message is reported (specific code in different dispatcher). After the
is sent, the upper limit, message display list and drafts are processed accordingly.
 

 

Smsreceiverservice.handlesmssent processing after a message is sent
When Sentintent is executed, the mailbox of the message is updated according to different results.


Messagestatusreceiver Message Report
When a report needs to be received, the corresponding deliveryintent is removed from the deliverypendinglist in the Smsdispatcher according to the different types of phones after the report is received.


Smsreceiverservice.handlesmsreceived Receive SMS
When a message is received by Rilreceiver, it is passed up from Ril, and intent call Privilegedsmsreceiver is generated via Smsdispatcher's Dispatchpdus method.


MMS section:
Workingmessage.sendmmsworker
As you can see, MMS is sent in a similar process to the SMS process. Need to reset the workingmessage to get the actual threadid. After sending all the unnecessary information, call Composemessageactivity's onmessagesent. It's just a multimedia message. Instead of creating a presendsmsworker-like approach, all content is processed in Sendmmsworker. Also, the location for deleting drafts differs.


Transactionservice.onstartcommand
MMS messages are sent in a network way, unlike text messages.
Each time a call is taken, all the MMS messages to be sent before the current time are due_time. It then encapsulates its URI and transactiontype into Transactionbundle, which is passed to Servicehandler. The type is set to Event_transaction_request. Create a Sendtransaction object in Servicehandler. The Processtransaction method is then called, depending on whether the current transaction is in the queue, and the current connection state determines which queue the Sendtransaction object is placed in (mpending is to be sent, Mprocessing is sent in). Also use the Sendmessagedelayed method to send a message labeled event_continue_mms_connectivity to keep the connection.
Next, put Transactionservice into the list of observers for the transaction object so that the MMS message to be sent continues to be sent after a successful post.
Next, use the Sendtransaction Run method to get the specified multimedia message from the database and construct sendreq to send the encoded MMS message via Httputils. Depending on the sending result, choose whether to save the error status to the database, or to transfer the MMS message to the Sent box and notify Transactionservice to process the MMS message to be sent.
 

 

Transactionservice.update
After the method executes, the transaction is removed from the mprocessing list first. If mpending is not empty, it means that MMS is in the basic processing but not sent status, so call Mservicehandler, set up event_handle_next_pending_transaction for processing. Take the first one out of the mpending queue and leave it to processtransaction for processing. As previously said, the call to Processtransaction transaction will be added to the mprocessing queue, and this transaction sent by the successful, will again notify its observers, In turn, call Transactionservice's Update method to continue sending the information in the mpending queue. Therefore, MMS messages in the Mpending queue are automatically sent out sequentially. The
then notifies the user (including message unread, message reports, and so on) of the message that was sent successfully, using notification. and send Android.intent.action.TRANSACTION_COMPLETED_ACTION broadcast (the broadcast is not currently received, it should be a broadcast to support the application developers).
 

 

The MMS Receive application Layer section of

Pushreceiver
Android starts from Pushreceiver. When OnReceive is called, make the screen light for 5 seconds, then create a receivepushtask and use its Execute method. Receivepushtask is a asynctask that implements the Doinbackground method. When intent is passed in, the data in Doinbackground is converted to GENERICPDU and different actions are made based on their message type.
If a report or read report is sent, it is stored in the database.
If it is an MMS notification, it is not processed if it already exists. Otherwise, it will be stored in the database. Start Transactionservice for processing. The process in
Transactionservice is primarily called Mservicehandler, which is the same as when sending MMS messages, except that Notificationtransaction is created here.
Notify MMSc only if the automatic download is not supported or if the data transfer is not turned on. Otherwise, download the appropriate MMS, delete the MMS notification, notify MMSc, delete the MMS message that exceeds the capacity limit, and notify Transactionservice to process the rest of the MMS messages to be sent.
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.