android的收彩信通知的过程解析

这里对froyo(非标准)里mms模块收彩信的函数调用关系进行一点解说。这里只说的是收到彩信,但是还没有下载(设为手工下载)
首先,mms是通过WAPPUSH实现的,具体在com.android.internal.telephony包里的WapPushOverSms类。
这个类里除了构造函数,另一个public的就是dispatchWapPdu()了

仔细查看下,就会找到dispatchWapPdu_MMS()这个函数

  1. private void dispatchWapPdu_MMS(byte[] pduint transactionIdint pduType,
  2.                                     int headerStartIndexint headerLength) {
  3.         byte[] header = new byte[headerLength];
  4.         System.arraycopy(pduheaderStartIndexheader0header.length);
  5.         int dataIndex = headerStartIndex + headerLength;
  6.         byte[] data = new byte[pdu.length - dataIndex];
  7.         System.arraycopy(pdudataIndexdata0data.length);
  8.  
  9.         Intent intent = new Intent(Intents.WAP_PUSH_RECEIVED_ACTION);
  10.         intent.setType(WspTypeDecoder.CONTENT_MIME_TYPE_B_MMS);
  11.         intent.putExtra("transactionId"transactionId);
  12.         intent.putExtra("pduType"pduType);
  13.         intent.putExtra("header"header);
  14.         intent.putExtra("data"data);
  15.        
  16.         mSmsDispatcher.dispatch(intent"android.permission.RECEIVE_MMS");
  17.     }

注意别混了, mSmsDispatcher.dispatch的第二个参数不是action的意思,而是权限,实际这个intent的action就是Intents.WAP_PUSH_RECEIVED_ACTION

然后,mms包(com.android.mms.transaction)下的onReceive会得到这个intent,进行处理
在这个onReceive里,会调用内部类去执行:

  1. new ReceivePushTask(context).execute(intent);

在这个内部类的doInBackground方法里,则会再继续根据pdu类型,来判断如何处理

  1. Uri uri = p.persist(pduInbox.CONTENT_URIphoneId);
  2.                             // Start service to finish the notification transaction.
  3.                             Intent svc = new Intent(mContextTransactionService.class);
  4.                             svc.putExtra(TransactionBundle.URIuri.toString());
  5.                             svc.putExtra(TransactionBundle.TRANSACTION_TYPE,
  6.                                     Transaction.NOTIFICATION_TRANSACTION);
  7.                             mContext.startService(svc);

在TransactionService里,实际上会最终调用NotificationTransaction

  1. int type = PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND;
  2.                                     if ((ind != null) && (ind.getMessageType() == type)) {
  3.                                         transaction = new NotificationTransaction(
  4.                                                 TransactionService.thisserviceId,
  5.                                                 transactionSettings(NotificationInd) ind,phoneId);
  6.                                     }

在NotificationTransaction里,则会完成Notification事务

  1. // Don't try to download when data is suspended, as it will fail, so defer download
  2.             if (!autoDownload || dataSuspended) {
  3.                 downloadManager.markState(mUriDownloadManager.STATE_UNSTARTED);
  4.                 sendNotifyRespInd(status);
  5.                 return;
  6.             }

到这里(sendNotifyRespInd),这个事务应该算结束了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值