1.短信发送的起点是在短信编辑界面,点击发送按钮开始的
public class ComposeMessageActivity extends Activity ...{
....
public void sendMessage(boolean bCheckEcmMode) {
....
//这里面准备发送的数据处理,比如生成PDU数据,存储到数据
mWorkingMessage.send(mDebugRecipients, mSelectedSubId);
}
mWorkingMessage中具体发送短信的工作在preSendSmsWorker方法里面
private void preSendSmsWorker(Conversation conv, String msgText, String recipientsInUI,
int subId, boolean hasBeenSplit) {
// just do a regular send. We’re already on a nonui thread so no need to fire
// off another thread to do this work.
/// M: Code analyze 047, For new feature ALPS00316567, add a parameter for msim . @{
sendSmsWorker是最主要的类,做了实际的发送工作,但他里面不是立即发送短信,而是发送短信的请求封装成SmsMessageSender,
sendSmsWorker(msgText, semiSepRecipients, threadId, subId);
/// @}
…
} .
SmsReceiverService
SmsMessageSender*******************************************
将待发送的短信存储到数据库表格中,content://sms/queued
然后再启动服务SmsReceiverService,让服务去单个发送每一条短信,SmsReceiverService重待发送短信表格中取出一条短信,然后交由
SmsSingleRecipientSender去发送。
MessageSender sender = new SmsMessageSender(mActivity, dests, msgText, threadId, subId);
短信发送处理
public boolean sendMessage(long token) throws MmsException {
号码处理,将其中的空格去除。得到有效的发送号码。
生成2个广播1.发送报告广播,2.发送短信广播
最终调用系统接口SmsManager smsManager = SmsManager.getSmsManagerForSubscriptionId(mSubId);
SmsManager***************************************************************************************************
public void sendMultipartTextMessage(
String destinationAddress, String scAddress, ArrayList<String> parts,
ArrayList<PendingIntent> sentIntents, ArrayList<PendingIntent> deliveryIntents) {
if (parts.size() > 1) {
try {
ISms iccISms = ISms.Stub.asInterface(ServiceManager.getService("isms"));
if (iccISms != null) {
iccISms.sendMultipartText(destinationAddress, scAddress, parts,
sentIntents, deliveryIntents);
}
} catch (RemoteException ex) {
// ignore it
}
} else {
PendingIntent sentIntent = null;
PendingIntent deliveryIntent = null;
if (sentIntents != null && sentIntents.size() > 0) {
sentIntent = sentIntents.get(0);
}
if (deliveryIntents != null && deliveryIntents.size() &