短信发送UML图
W:\Android8.1_intergration_2\vendor\mediatek\proprietary\packages\apps\Mms\src\com\android\mms\data\WorkingMessage.java
/**
* Send this message over the network. Will call back with onMessageSent() once
* it has been dispatched to the telephony stack. This WorkingMessage object is
* no longer useful after this method has been called.
*(通过网络发送此消息。 将使用onMessageSent()回调一次
它已被发送到电话堆栈。 这个WorkingMessage对象是
调用此方法后不再有用。)
* @throws ContentRestrictionException if sending an MMS and uaProfUrl is not defined
* in mms_config.xml.
* M: Code analyze 047, For new feature ALPS00316567,
* extend this method for msim, add a parameter for subId
*/
public void send(final String recipientsInUI, final int subId) {
}
W:\Android8.1_intergration_2\vendor\mediatek\proprietary\frameworks\opt\telephony-base\java\mediatek\telephony\MtkSmsManager.java
public void sendTextMessage(
String destinationAddress, String scAddress, String text,
PendingIntent sentIntent, PendingIntent deliveryIntent) {
sendTextMessageInternal(destinationAddress, scAddress, text,
sentIntent, deliveryIntent, true /* persistMessageForCarrierApp*/);
}
private void sendTextMessageInternal(String destinationAddress, String scAddress,
String text, PendingIntent sentIntent, PendingIntent deliveryIntent,
boolean persistMessageForCarrierApp) {
if (TextUtils.isEmpty(destinationAddress)) {
throw new IllegalArgumentException("Invalid destinationAddress");
}
try {
ISms iccISms = getISmsService();
iccISms.sendTextForSubscriber(getSubscriptionId(), ActivityThread.currentPackageName(),
destinationAddress,
scAddress, text, sentIntent, deliveryIntent,
persistMessageForCarrierApp);
} catch (RemoteException ex) {
// ignore it
// MTK-START
Rlog.d(TAG, "sendTextMessage, RemoteException!");
// MTK-END
}
}
UiccSmsController
@Override
public void sendTextForSubscriber(int subId, String callingPackage, String destAddr,
String scAddr, String text, PendingIntent sentIntent, PendingIntent deliveryIntent,
boolean persistMessageForNonDefaultSmsApp) {
IccSmsInterfaceManager iccSmsIntMgr = getIccSmsInterfaceManager(subId);
if (iccSmsIntMgr != null) {
iccSmsIntMgr.sendText(callingPackage, destAddr, scAddr, text, sentIntent,
deliveryIntent, persistMessageForNonDefaultSmsApp);
} else {
Rlog.e(LOG_TAG,"sendTextForSubscriber iccSmsIntMgr is null for" +
" Subscription: " + subId);
sendErrorInPendingIntent(sentIntent, SmsManager.RESULT_ERROR_GENERIC_FAILURE);
}
}
IccSmsInterfaceManager
/**
* A permissions check before passing to {@link IccSmsInterfaceManager#sendTextInternal}.
* This method checks only if the calling package has the permission to send the sms.
*/
public void sendText(String callingPackage, String destAddr, String scAddr,
String text, PendingIntent sentIntent, PendingIntent deliveryIntent,
boolean persistMessageForNonDefaultSmsApp) {
mPhone.getContext().enforceCallingPermission(
Manifest.permission.SEND_SMS,
"Sending SMS message");
sendTextInternal(callingPackage, destAddr, scAddr, text, sentIntent, deliveryIntent,
persistMessageForNonDefaultSmsApp);
}
/**
* Send a text based SMS.
*
* @param destAddr the address to send the message to
* @param scAddr is the service center address or null to use
* the current default SMSC
* @param text the body of the message to send
* @param sentIntent if not NULL this <code>PendingIntent</code> is
* broadcast when the message is successfully sent, or failed.
* The result code will be <code>Activity.RESULT_OK<code> for success,
* or one of these errors:<br>
* <code>RESULT_ERROR_GENERIC_FAILURE</code><br>
* <code>RESULT_ERROR_RADIO_OFF</code><br>
* <code>RESULT_ERROR_NULL_PDU</code><br>
* For <code>RESULT_ERROR_GENERIC_FAILURE</code> the sentIntent may include
* the extra "errorCode" containing a radio technology specific value,
* generally only useful for troubleshooting.<br>
* The per-application based SMS control checks sentIntent. If sentIntent
* is NULL the caller will be checked against all unknown applications,
* which cause smaller number of SMS to be sent in checking period.
* @param deliveryIntent if not NULL this <code>PendingIntent</code> is
* broadcast when the message is delivered to the recipient. The
* raw pdu of the status report is in the extended data ("pdu").
*/
// MTK-START
// Modified for sub class
protected void sendTextInternal(String callingPackage, String destAddr, String scAddr,
String text, PendingIntent sentIntent, PendingIntent deliveryIntent,
boolean persistMessageForNonDefaultSmsApp) {
// MTK-END
if (Rlog.isLoggable("SMS", Log.VERBOSE)) {
log("sendText: destAddr=" + destAddr + " scAddr=" + scAddr +
" text='"+ text + "' sentIntent=" +
sentIntent + " deliveryIntent=" + deliveryIntent);
}
if (mAppOps.noteOp(AppOpsManager.OP_SEND_SMS, Binder.getCallingUid(),
callingPackage) != AppOpsManager.MODE_ALLOWED) {
return;
}
if (!persistMessageForNonDefaultSmsApp) {
enforcePrivilegedAppPermissions();
}
destAddr = filterDestAddress(destAddr);
mDispatcher.sendText(destAddr, scAddr, text, sentIntent, deliveryIntent,
null/*messageUri*/, callingPackage, persistMessageForNonDefaultSmsApp);
}
发送短信的Log分析:(以下是应用层的log)
/***********************************************************************************/
V study_message: sendMessage
V study_message: WorkingMessage_send:recipientsInUI=18862631722,subId=1
V study_message: WorkingMessage_Worksend_sms:123
V study_message: WorkingMessage_preSendSmsWorker:msgText123,recipientsInUI:18862631722,subId:1,hasBeenSplit:false
V study_message: WorkingMessage_sendSmsWorker:123,semiSepRecipients:18862631722,threadId:3,subId:1
V study_message: SmsMessageSender_sendMessage:token:3
V study_message: SmsMessageSender:queueMessage_token:3
V study_message: SmsMessageSender:queueMessage_smsUri:null
V study_message: SmsReceiver_onReceiveWithPrivilege:action:com.android.mms.transaction.SEND_MESSAGE,privileged:false
V study_message: SmsReceiver_beginStartingService:action:com.android.mms.transaction.SEND_MESSAGE
V study_message: SmsReciverService_onStartCommand:onCreate
V study_message: SmsReciverService_onStartCommand:action:com.android.mms.transaction.SEND_MESSAGE,flags:0,startId:1
V study_message: SmsReceiverService_handleSendMessage_sendFirstQueuedMessage,mSending:false
V study_message: SmsReceiverService_sendFirstQueuedMessage
V study_message: SmsReceiverService_c:[email protected]
V study_message: SmsSingleRecipientSender_constructor:dest:18862631722,msgText:123,threadId:3,requestDeliveryReport:false,uri:content://sms/2,subId:1
V study_message: SmsSingleRecipientSender_sendMessage:token:-1
V study_message: SmsReceiver_finishStartingService_startId:1
V study_message: SmsReceiver_onReceiveWithPrivilege:action:com.android.mms.transaction.MESSAGE_SENT,privileged:false
V study_message: SmsReceiver_beginStartingService:action:com.android.mms.transaction.MESSAGE_SENT
V study_message: SmsReciverService_onStartCommand:onCreate
V study_message: SmsReciverService_onStartCommand:action:com.android.mms.transaction.MESSAGE_SENT,flags:0,startId:1
V study_message: SmsReceiverService_sendFirstQueuedMessage
V study_message: SmsReceiverService_c:[email protected]
V study_message: SmsReceiver_finishStartingService_startId:1
/**************************************************************************************************************/