彩信下载
PduPersister.java loadParts 在发送mms前,会调用,就是将数据库表中的数据转成pdu用于发送;接收彩信时,也要调用。
据观察,接收后,数据库已经不正常。
设成不自动下载,仅收通知,查看log 发现没有调用loadParts
点击下载,调用loadParts
照最直观的想法,应该是普通数据,准备发送时,转成pdu,然后发送,收到pdu,转成普通数据,存储。读取的时候直接读取普通数据。
那么,这里下载时,为什么需要loadParts,这应该是创建pdu的过程啊?
仔细查看调用loadParts的loadFromDB,在PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF和PduHeaders.MESSAGE_TYPE_SEND_REQ时,调用loadParts(msgId);
从log可以看到,无论发送,接收,下载彩信,都会调用loadFromDB,但是,数据都是用SqliteWrapper.query取出来的。
发送好理解,创建彩信时已经保存了,接收呢?在loadFromDB前已经存入数据库了?
看接收流程:
SMSDispatcher.java handleMessage(Message msg){ EVENT_NEW_SMS: 调用CdmaSMSDispatcher.java 的dispatchMessage(SmsMessageBase smsb){
sms = (SmsMessage)smsb; sms.parseSms();teleService = sms.getTeleService(); teleService为SmsEnvelope.TELESERVICE_WAP就调用processCdmaWapPdu(sms, sms.messageRef, sms.getOrginationAddress()); 看log得知,这时,是接收不下载的流程。
知识小点:public abstract void sendOrderedBroadcast(Intent intent,String receiverPermission, BroadcastReceiver resultReceiver,Handler scheduler, int initialCode, String initialData,Bundle initialExtras);
这个广播中receiverPermission设置后,只有这些权限的才能接收。
彩信接收不下载,存入pdu表,下载后,将彩信文字内容插入words
每次打开彩信,都会调用PduPersister load pdu use content type:
下载:RetrieveTransaction( 550): RetrieveTransaction download from URL:http://10.234.45.180:80/... result pdu is:.... ...
下载:
NotificationTransaction.java
run()
byte[] retrieveConfData = getPdu(mContentLocation) -> HttpUtils.httpConnection(...) 下载数据
GenericPdu pdu = new PduParser(retrieveConfData).parse(mPhoneId);
NotificationTraction run() -> PduPersister p; p.persist(pdu, Inbox.CONTENT_URI,mPhoneId) -> persistPart
PduPersister.java persistPart(PduPart part, long msgId) 将part中的Part.CHARSET Part.CONTENT_TYPE Part.FILENAME Part.NAME 等等取出来,存到指定的uri下面。
收彩信过程中,哪里触发连接网络? cmwap or ctwap
TransactionService.java
protected int beginMmsConnectivity() throws IOException{
}
ConnectivityService.java
public int startUsingNetworkFeature(int networkType, String feature, IBinder binder){
}
07-15 11:29:35收到彩信
main log
07-15 11:29:35.950 294 343 D harish : SPRDRIL--- RIL_UNSOL_RESPONSE_NEW_SMS------
07-15 11:29:35.950 294 294 D WAP PUSH: Rx: 4506246170706c69636174696f6e2f766e642e7761702e6d6d732d6d65737361676500b487af848c8298504c646a526c373475707544008d9083687474703a2f2f3231312e3133362e3131322e38342f504c646a526c373475707544008805810303f48089178031353032313232373835332f545950453d504c4d4e008a808e0301927c
07-15 11:29:35.950 294 294 D WAP PUSH: Start new wap pdu
07-15 11:29:35.950 294 294 D WAP PUSH: Start parse
07-15 11:29:35.950 294 294 D WAP PUSH: mimeType= application/vnd.wap.mms-message
07-15 11:29:35.950 294 294 D WAP PUSH: binaryContentType 2= 62
07-15 11:29:35.950 215 325 E Parcel : Reading a NULL string not supported here.
07-15 11:29:35.960 292 292 V ReceiverSmsState: onReceive action = android.provider.Telephony.WAP_PUSH_RECEIVED ,mimetype = application/vnd.wap.mms-message
07-15 11:29:35.960 292 292 D ReceiverSmsState: the sender number is : 15021227853
07-15 11:29:35.960 292 292 V ReceiverSmsState: number = 15021227853
07-15 11:29:35.960 292 292 V ReceiverSmsState: body is
07-15 11:29:35.960 292 292 D CallFireWall: CheckIsBlockNumber(incoming = 15021227853 , isBlockMessage = true , isVideoCall = false)...
07-15 11:29:35.970 1147 1147 V PushReceiver: Received PUSH Intent: Intent { act=android.provider.Telephony.WAP_PUSH_RECEIVED typ=application/vnd.wap.mms-message cmp=com.android.mms/.transaction.PushReceiver (has extras) }
07-15 11:29:35.970 215 376 E Parcel : Reading a NULL string not supported here.
07-15 11:29:35.970 1147 2043 D PushReceiver: doInBackground type:130
07-15 11:29:35.970 661 661 I MovieViewReceiver: Received Intent: Intent { act=android.provider.Telephony.WAP_PUSH_RECEIVED typ=application/vnd.wap.mms-message cmp=com.cooliris.media/.MovieViewReceiver (has extras) }
07-15 11:29:35.980 294 294 D GaoMi : SMS mResultReceiver
07-15 11:29:36.000 1147 2043 D PduPersister: persist start .....
system log
07-15 11:29:35.980 215 221 W ActivityManager: Permission Denial: receiving Intent { act=android.provider.Telephony.WAP_PUSH_RECEIVED typ=application/vnd.wap.mms-message (has extras) } to com.android.settings requires android.permission.RECEIVE_MMS due to sender com.android.phone (uid 1001)
07-15 11:29:36.200 215 221 D ConnectivityService: startUsingNetworkFeature for net 0: enableMMS0
07-15 11:29:36.200 215 221 D ConnectivityService: startUsing same Mms Feature as current mMmsFeatureState=CONNECTING
07-15 11:29:36.200 215 221 D ConnectivityService: if type is MMS,continue setup data call
07-15 11:29:36.200 215 221 D ConnectivityService: getMobileDataEnabled[0] returning true
07-15 11:29:36.200 215 221 D ConnectivityService: network = Mobile data state: CONNECTED
07-15 11:29:36.200 215 221 D ConnectivityService: ni.isConnectedOrConnecting()=true
07-15 11:29:36.200 215 221 D ConnectivityService: adding dns 211.136.112.50 for mobile
07-15 11:29:36.200 215 221 D ConnectivityService: get net.gprs.http-proxy value=
07-15 11:29:36.210 215 221 D ConnectivityService: adding dns 211.136.150.66 for mobile
07-15 11:29:36.210 215 221 D ConnectivityService: get net.gprs.http-proxy value=
07-15 11:29:36.210 215 221 D ConnectivityService: adding dns 211.136.150.66 for mobile
07-15 11:29:36.210 215 221 D ConnectivityService: get net.gprs.http-proxy value=
07-15 11:29:36.210 215 221 D ConnectivityService: adding dns 211.136.112.50 for mobile
07-15 11:29:36.210 215 221 D ConnectivityService: get net.gprs.http-proxy value=
07-15 11:29:36.210 215 221 D ConnectivityService: special network already active
GsmDataConnectionTracker.java 是一开机就创建的么?因为有创建sTracker = MpdpMsmsGsmDataConnectionTracker[PhoneFactory.getSimCount()];的动作
即会根据是否支持mpdp而创建,在onEnableNewApn时调用onEnableNewApnInternal()要根据sTracker中的对象类型,决定是否调用mpdp相关的函数。
MpdpMsmsGsmDataConnectionTracker.java
public void onEnableNewApnInternal(){
Log.i("GSM","***********************try to setup new pdp Connection");
trySetupData(reason);
}
如果当前是cmnet连接,则要创建cmwap连接。
protected boolean setupData(String reason){
pdp = findFreePdp();
pdp.connect(msg, apn);
mActivePdp = pdp;
}
GsmDataConnection.java
protected void onConnect(ConnectionParams cp){
phone.mCM.setupDataCall(...);
}