开发者

What Android Code writes an Incoming SMS Message to the SMS Database?

SMS messages are encoded in a PDU format (http://www.dreamfabric.com/sms/) when they are sent and end up in a database in Android ("content://sms"). I am trying to find out what the data flow is when an SMS message is received. In particular I would like to know what piece of code decodes the PDU and makes the entry into the SMS database.

The reason I am interested is that in some cases the timestamp in the database is different than the time the message was sent. For me in some locations it is 5 hours in the future. It depends on the tower, and I have been told it is because it gets the wrong time from the tower. However, the time stamp, including the time zone, should be encoded in the PDU and the time on the phone, which also comes from the tower, is correct. Thus, it doesn't make sense to me. I am trying to trace it down.

Thanks.


androidnoob,

Thanks for the information. I can get all the messages in "content://sms" or开发者_运维知识库 "content://sms/inbox" or "content://sms/sent" or some others. I think that is what the links you suggest are about. These messages are in databases and have already been put there by the code I think I am after.

I can also set a BroadcastReceiver for "android.provider.Telephony.SMS_RECEIVED". The messages I get in the callback are not yet in the database. The PDUs are available, but I don't know if they are the same ones that got sent or if they are generated.

The classes that supply this information are in com.android.internal.telephony. These classes are not in android.jar, and I do not have the source code to trace into them. It appears they may be obtained from git://android.get.kernel.org/platform/base/telephony. The problem is (1) I am not very experienced with Git and (2) this repository appears to be down owing to its being hacked around Sept. 1. In any event I haven't been able to get them, owing either to its being down or my inexperience.

I have not been able to test what happens when I am in the location that gives the bad time stamp, but I have noticed that if I send a message to myself where I am now, the incoming time stamp is about 30 sec before the time I actually sent the message, according to the device time. At the time of the callback the message I sent is in the database, and some time later the received message is also in the database, with its incoming time stamp (date column) and a higher _id, usually the originating _id + 1. This means it has a higher _id but an earlier time. This makes it look like the message was received slightly before it was sent. In the bad location the time stamp is 5 hours in the future instead of 30 sec in the past. In neither case does it appear to be the time on the device when it was sent.


I'm not familiar with the SMS parsing code myself, but after a quick look around in the android framework, it looks like frameworks/base/core/java/com/google/android/mms/pdu/PduParser.java is where the main SMS parsing logic is.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜