android系統不調用系統界面後臺發送彩信的實現 html
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),這個事務應該算結束了。