One initialization
Phone boot initialization calls the Gsmphone constructor.
Gsmphone (context context, Commandsinterface CI, Phonenotifier notifier, Boolean Unittestmode)
Create MSMS = new Gsmsmsdispatcher (this);
This class inherits from Smsdispatcher. A message is initialized in a constructor in class Smsdispatcher
Mcm.setonnewsms (this, event_new_sms, null);
Mcm.setonsmsstatus (this, event_new_sms_status_report, null);
Mcm.setoniccsmsfull (this, event_icc_full, null);
Handlemessage defines the message handler function for SMS
public void Handlemessage (Message msg) {
......
Case EVENT_NEW_SMS:
......
}
Msimsmsintmanager = new Simsmsinterfacemanager (this);
Simsmsinterfacemanager inherits from the implementation class Iccsmsinterfacemanager is isms.stub.
The Isms.adil is implemented in the Iccsmsinterfacemanager class. To implement a remote call by using the method defined in the
Two SMS Send
SMS Send Call interface
Smsmanager SMS = Smsmanager.getdefault ();
Sms.sendtextmessage (string1, NULL, string2, p, NULL);
Sendtextmessage calls SENDRAWPDU.
Create a SENDRAWPDU in the
ISms iccisms = ISms.Stub.asInterface (Servicemanager.getservice ("isms"));
Instantiate the Iccsmsinterfacemanager via the Aidl interface. Call in Smsdispatcher.java
protected void Sendrawpdu (byte[] smsc, byte[] PDU, Pendingintent sentintent,
Pendingintent deliveryintent) function.
The Sendsms interface is then called through the stub interface.
Ril.java in Sendsms
public void
Sendsms (String Smscpdu, String PDU, Message result) {
Rilrequest RR
= Rilrequest.obtain (ril_request_send_sms, result);
.....
Send (RR);
}
Send a request for ril_request_send_sms to the rild layer.
The connection between Rild and modem is similar to other applications and is no longer duplicated.
Receiving three messages
There is no repetition between Modem and Rild. Start by receiving a message from the RIL layer.
Ril.java Rilreceiver received the letter SMS message ProcessResponse (p); Receiving SMS is an active escalation
Call the processunsolicited function.
private void processunsolicited (Parcel p) {
.........
Case Ril_unsol_response_new_sms:ret = responsestring (p); Break
.......
Switch (response) {
Case RIL_UNSOL_RESPONSE_NEW_SMS: {
.......
Smsmessage SMS;
.......
SMS = SMSMESSAGE.NEWFROMCMT (a);
if (msmsregistrant! = null) {
Msmsregistrant
. Notifyregistrant (new AsyncResult (NULL, SMS, NULL));
}
Break
}
.......
}
Msmsregistrant calls the Notifyregistrant method into the Registrant.java file.
Internalnotifyregistrant calls the SendMessage method.
public void Notifyregistrant (AsyncResult ar)
{
Internalnotifyregistrant (Ar.result, ar.exception);
}
Internalnotifyregistrant messages are sent to the message queue when the message is received.
/*package*/void
Internalnotifyregistrant (Object result, throwable exception)
{
Handler h = gethandler ();
if (h = = null) {
Clear ();
} else {
Message msg = Message.obtain ();
Msg.what = what;
Msg.obj = new AsyncResult (userobj, result, exception);
H.sendmessage (msg);
}
}
SendMessage calls the Handler.java file in turn sendmessage->sendmessagedelayed-> sendmessageattime The SMS message is added to the message queue in Sendmessageattime.
Sent = Queue.enqueuemessage (msg, uptimemillis);
public boolean sendmessageattime (Message msg, long Uptimemillis)
{
Boolean sent = false;
MessageQueue queue = Mqueue;
if (queue! = null) {
Msg.target = this;
Sent = Queue.enqueuemessage (msg, uptimemillis);
}
else {
RuntimeException e = new RuntimeException (
This + "sendmessageattime () called with no Mqueue");
LOG.W ("Looper", E.getmessage (), E);
}
return sent;
}
The Looper.java loop method. Used to dispatch messages in Message Queuing.
public static final void loop () {
Looper me = Mylooper ();
MessageQueue queue = Me.mqueue;
while (true) {
Message msg = Queue.next (); Might block
if (!me.mrun) {
Break
//}
if (msg! = null) {
if (Msg.target = = null) {
No Target is a magic identifier for the quit message.
Return
}
if (me.mlogging!= null) me.mLogging.println (
">>>>> dispatching to" + Msg.target + ""
+ Msg.callback + ":" + msg.what
);
Msg.target.dispatchMessage (msg);
if (me.mlogging!= null) me.mLogging.println (
"<<<<< finished to" + Msg.target + ""
+ Msg.callback);
Msg.recycle ();
}
}
}
The DispatchMessage function calls the current handle message handler function.
public void DispatchMessage (Message msg) {
if (msg.callback! = null) {
Handlecallback (msg);
} else {
if (mcallback! = null) {
if (Mcallback.handlemessage (msg)) {
Return
}
}
Handlemessage (msg);
}
}
Call into Smsdispatcher.java
public void Handlemessage (Message msg) {
AsyncResult ar;
Switch (msg.what) {
Case EVENT_NEW_SMS:
.........
}
}
This enables the processing of newly received text messages.