这里的SmsMessage是Android.telephony.SmsMessage。newFromCMT()中会根据电话类型(GSM/CDMA)选择具体的SmsMessage进行封装(因为Rational Rose中,同一工程中,不同包内的类也不允许同名,com.android.internal.telephony.gsm.SmsMessage用gsm.SmsMessage代替;com.android.internal.telephony.cdma.SmsMessage用cdma.SmsMessage代替。实际类型都是SmsMessage)。

mSMSRegistrant是RIL父类的成员。通过setOnNewSMS()/unSetOnNewSMS()设置和取消设置。SMSDispatcher的构造函数中注册了SMS的Registrant
mCm.setOnNewSMS(this, EVENT_NEW_SMS, null);
所以,调用mSMSRegistrant.notifyRegistrant(newAsyncResult(null, sms, null))之后,执行的是SMSDispatcher中Handler在handleMessage()中对EVENT_NEW_SMS的处理:
- SmsMessage sms;
- ar = (AsyncResult) msg.obj;
- if (ar.exception != null) {
- Log.e(TAG, "Exception processing incoming SMS. Exception:" +ar.exception);
- return;
- }
- sms = (SmsMessage) ar.result;
- try {
- int result = dispatchMessage(sms.mWrappedSmsMessage);
- if (result != Activity.RESULT_OK) {
- // RESULT_OK means thatmessage was broadcast for app(s) to handle.
- // Any other result, weshould ack here.
- boolean handled = (result== Intents.RESULT_SMS_HANDLED);
- notifyAndAcknowledgeLastIncomingSms(handled, result, null);
- }
- } catch (RuntimeException ex) {
- Log.e(TAG, "Exception dispatching message", ex);
- notifyAndAcknowledgeLastIncomingSms(false,Intents.RESULT_SMS_GENERIC_ERROR, null);
- }
SMSDispatcher是一个abstract的类,dispatchMessage()的具体实现在GsmSMSDispatcher或CdmaSMSDispatcher中。
GsmSMSDispatcher::dispatchMessage()中,会对Class 0类型的短信,有目标端口的短信,和长短信做处理。
