这里对froyo(非标准)里mms模块收彩信的函数调用关系进行一点解说。这里只说的是收到彩信,但是还没有下载(设为手工下载)
首先,mms是通过WAPPUSH实现的,具体在com.android.internal.telephony包里的WapPushOverSms类。
这个类里除了构造函数,另一个public的就是dispatchWapPdu()了
仔细查看下,就会找到dispatchWapPdu_MMS()这个函数
- private void dispatchWapPdu_MMS(byte[] pdu, int transactionId, int pduType,
- int headerStartIndex, int headerLength) {
- byte[] header = new byte[headerLength];
- System.arraycopy(pdu, headerStartIndex, header, 0, header.length);
- int dataIndex = headerStartIndex + headerLength;
- byte[] data = new byte[pdu.length - dataIndex];
- System.arraycopy(pdu, dataIndex, data, 0, data.length);
- Intent intent = new Intent(Intents.WAP_PUSH_RECEIVED_ACTION);
- intent.setType(WspTypeDecoder.CONTENT_MIME_TYPE_B_MMS);
- intent.putExtra("transactionId", transactionId);
- intent.putExtra("pduType", pduType);
- intent.putExtra("header", header);
- intent.putExtra("data", data);
- mSmsDispatcher.dispatch(intent, "android.permission.RECEIVE_MMS");
- }
注意别混了, mSmsDispatcher.dispatch的第二个参数不是action的意思,而是权限,实际这个intent的action就是Intents.WAP_PUSH_RECEIVED_ACTION
然后,mms包(com.android.mms.transaction)下的onReceive会得到这个intent,进行处理
在这个onReceive里,会调用内部类去执行:
- new ReceivePushTask(context).execute(intent);
在这个内部类的doInBackground方法里,则会再继续根据pdu类型,来判断如何处理
- Uri uri = p.persist(pdu, Inbox.CONTENT_URI, phoneId);
- // Start service to finish the notification transaction.
- Intent svc = new Intent(mContext, TransactionService.class);
- svc.putExtra(TransactionBundle.URI, uri.toString());
- svc.putExtra(TransactionBundle.TRANSACTION_TYPE,
- Transaction.NOTIFICATION_TRANSACTION);
- mContext.startService(svc);
在TransactionService里,实际上会最终调用NotificationTransaction
- int type = PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND;
- if ((ind != null) && (ind.getMessageType() == type)) {
- transaction = new NotificationTransaction(
- TransactionService.this, serviceId,
- transactionSettings, (NotificationInd) ind,phoneId);
- }
在NotificationTransaction里,则会完成Notification事务
- // Don't try to download when data is suspended, as it will fail, so defer download
- if (!autoDownload || dataSuspended) {
- downloadManager.markState(mUri, DownloadManager.STATE_UNSTARTED);
- sendNotifyRespInd(status);
- return;
- }
到这里(sendNotifyRespInd),这个事务应该算结束了。