MMS send process and SMS is not exactly the same, workingmessage refresh the recipient, generate MMS can send Pdu-sendreq, and then will write MMS to the database, the Sendreq will be sent to the database, and then read out from the database sendreq, and identifies it as a draft, and then constructs the Mmsmessagesender, passing in the URI of the recipient and MMS, and letting it send. The UI is also invoked again during this period to initialize the recipient edit box and information edit box.
Mmsmessagesender from the database to read the MMS sent Pdu-sendreq,google built-in package com.google.android.mms.*, which encapsulates all the methods to operate the PDU, This includes writing the PDU to the database (Pdupersister.persist ()) and reading the Build PDU (Pdupersister.load ()) from the database. Then according to the current MMS configuration and other information to update sendreq, such as setting expiration,priority,date and size, the MMS moved to Outbox, and then start Transactionservice to process MMS. SendMessage () returned to this. Workingmessage will back up the UI interface again, because the multimedia message is already in the database, so the UI refreshes the information list to show just the MMS, at which point the status should be being sent.
Transactionservice, and SMS Smsreceiverservice similar, is responsible for processing MMS services, can send, receive and so on. For Transactionservice, all the processes that need to be processed, whether sent or received, are a transaction. It has two queues inside, one that is currently being processed (processing) and one that is transaction (pending) transaction. It maintains these two queues, checks the network connections, opens the MMS network connection, prepares and examines the environment, and then takes the first one from the queue to be processed, puts it in the queue being processed, and processes the transaction, which is called transaction.process ().
Send MMS is a sendtransaction, its process () method is responsible for sending MMS, it will create a separate thread to do so does not block transactionservice, processing services can be processed to other transaction. It will first remove the MMS pdu,m-send.req from the Database (sendreq), update some fields, such as date, and then call the method SENDPDU in its parent class Transaction.java to send the Sendreq out SENDPDU () Returns the result sent (send confirmation). TRANSACTION.SENDPDU () will set up the network first, then directly call the Httpconnection () method in Httputils, send the MMS with HTTP, At the same time get the return message (Response) to sendtransaction. Sendtransaction checks the results of the send, returns the results (send confirmation), analyzes the status and updates to the database (for example, sending failed or sent successfully). The UI will monitor the status changes and update the information list.
To this end, a MMS is sent.
As mentioned earlier, Transactionsettings is a related configuration information for a process that contains MMSC (multimedia message Service Center), proxy, and ProxyPort. This information, especially for sending and receiving, is very important. Because of the mobile phone information, not the mobile phone directly to the recipient of the phone, but directly to the service center, followed by the service center to send information to the corresponding recipient of the phone. For MMS is also the case, httputils through the HTTP protocol to send MMS to MMSC, it is a URL, and then for the sender, MMS sent out, MMS Service Center (MMSC) will handle the next send process, service center is related to mobile phone operations, It is provided by the operator. For MMS to send MMS, is not deliberately specified transactionsettings, meaning that it does not specify MMSC and proxy, then Transactionservice will use the system default MMSC, Proxy as Transcationsetting,mmsc,proxy and proxyport need to be queried from the telephony database, which is related to the APN settings of specific handsets and specific operators. So, if you want to change the configuration information for MMS, you can only change the APN system settings to complete.
And the message sent does not involve SMSC (SMS Service center), because the frameworks in the tool has been encapsulated Smsmanager provides a number of ways to send text messages, it may be to deal with SMSC related things.
Summary, you can see that the database plays an important role in the process of sending information, when the information left the editor immediately written to the database, the sending process of each class is the first load from the database information, and then do the appropriate processing, and then write back to the database or update the state, And then to the next process to deal with. The so-called pending message queue does not have the corresponding data structure, they are the information in the database and the state is to be sent. So the information is written to the database after it leaves the editor, only the state has been changing, from send to sent, or send failed, or if the telephony service is not available to be sent, but for the UI page may not be so many states, it may only show sent, sent and sent failed.