android发送/解析彩信的几篇文章

android系统不调用系统界面后台发送彩信的实现

Android 彩信发送的两种方式+源代码

android 实现发送彩信方法 (MMS) 非调用系统彩信界面


另一篇:解析彩信 原文地址-

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


这里对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),这个事务应该算结束了。


转载于:https://my.oschina.net/artshell/blog/390530

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值