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),这个事务应该算结束了。
更多相关文章
- C语言函数以及函数的使用
- Android Camera源码函数结构
- H5 Web网页通过JS(JavaScript)脚本调用Android本地原生方法函数
- android 回调函数二:应用实例
- android 7.0 系统关闭彩信过CTA测试的方法
- android NDK JNI设置自己的log输出函数
- Android build/envsetup.sh 脚本分析(lunch函数)
- Android Hook学习之ptrace函数的使用
- Android中回调函数的理解---本人Android纯新手