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

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

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

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


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

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


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

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

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 .net

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

new ReceivePushTask(context).execute(intent);

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

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

相关文章
相关标签/搜索