Reputation: 21
I did following steps
String sms_txt = "aaaaaaaaaa";
SubmitPdu smsg = SmsMessage.getSubmitPdu("+919412354222","+919535570716", sms_txt, false);
Note down encoded message value from smsg
encoded message = [1, 0, 12, -111, 25, 89, 83, 117, 112, 97, 0, 0, 10, -31, 112, 56, 28, 14, -121, -61, -31, 48]
byte[] sBuf={1, 0, 12, -111, 25, 89, 83, 117, 112, 97, 0, 0, 10, -31, 112, 56, 28, 14, -121, -61, -31, 48};
SmsMessage smsg1 = SmsMessage.createFromPdu(sBuf);
I am getting mWrappedSmsMessage = NULL
So my question is:
What is difference between PDU data created from getSubmitPdu
function and expected pdu input for createFromPdu
functiom?
Upvotes: 1
Views: 2299
Reputation: 1045
I wanted to use getSubmitPdu in some unit tests so I set out to find the answer by debugging the GSM source code. In a nutshell, getSubmitPdu is full of problems. It does at least two things that are incompatible with createFromPdu (which I believe to be correct for GSM because it can be used to create an SmsMessage from the incoming SMS intent provided by BroadcastReceiver). I didn't look any further than the two I found.
First, it tries to use the first byte as protocol info. Method createFromPdu expects the first byte to be the size of the encoded Service Center address (scAddress param on getSubmitPdu). Possibly you could repair this by prepending the encoded scAddress (available from SubmitPdu class) and throwing away the first byte but see the next issue.
Second, it omits the encoded timestamp (6 bytes) that should come between the destination address and the message body. Method createFromPdu unconditionaly tries to parse the timestamp .
At this point I am considering using PduUtils in SMSLib (http://code.google.com/p/smslib/) to create the Pdu.
Upvotes: 1