Skip to content

Commit 3487787

Browse files
Jake HambyAndroid (Google) Code Review
authored andcommitted
Merge "Fix bug in CDMA WDP datagram handling (fixes incoming MMS)." into ics-mr0
2 parents 35af363 + 929ca5e commit 3487787

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

telephony/java/com/android/internal/telephony/SMSDispatcher.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ protected int dispatchNormalMessage(SmsMessageBase sms) {
518518
* @param address the originating address
519519
* @param referenceNumber distinguishes concatenated messages from the same sender
520520
* @param sequenceNumber the order of this segment in the message
521+
* (starting at 0 for CDMA WDP datagrams and 1 for concatenated messages).
521522
* @param messageCount the number of segments in the message
522523
* @param timestamp the service center timestamp in millis
523524
* @param destPort the destination port for the message, or -1 for no destination port
@@ -583,7 +584,11 @@ protected int processMessagePart(byte[] pdu, String address, int referenceNumber
583584
for (int i = 0; i < cursorCount; i++) {
584585
cursor.moveToNext();
585586
int cursorSequence = cursor.getInt(SEQUENCE_COLUMN);
586-
pdus[cursorSequence - 1] = HexDump.hexStringToByteArray(
587+
// GSM sequence numbers start at 1; CDMA WDP datagram sequence numbers start at 0
588+
if (!isCdmaWapPush) {
589+
cursorSequence--;
590+
}
591+
pdus[cursorSequence] = HexDump.hexStringToByteArray(
587592
cursor.getString(PDU_COLUMN));
588593

589594
// Read the destination port from the first segment (needed for CDMA WAP PDU).
@@ -593,7 +598,12 @@ protected int processMessagePart(byte[] pdu, String address, int referenceNumber
593598
}
594599
}
595600
// This one isn't in the DB, so add it
596-
pdus[sequenceNumber - 1] = pdu;
601+
// GSM sequence numbers start at 1; CDMA WDP datagram sequence numbers start at 0
602+
if (isCdmaWapPush) {
603+
pdus[sequenceNumber] = pdu;
604+
} else {
605+
pdus[sequenceNumber - 1] = pdu;
606+
}
597607

598608
// Remove the parts from the database
599609
mResolver.delete(mRawUri, where, whereArgs);

telephony/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,18 @@ public int dispatchMessage(SmsMessageBase smsb) {
198198
protected int processCdmaWapPdu(byte[] pdu, int referenceNumber, String address) {
199199
int index = 0;
200200

201-
int msgType = pdu[index++];
201+
int msgType = (0xFF & pdu[index++]);
202202
if (msgType != 0) {
203203
Log.w(TAG, "Received a WAP SMS which is not WDP. Discard.");
204204
return Intents.RESULT_SMS_HANDLED;
205205
}
206-
int totalSegments = pdu[index++]; // >= 1
207-
int segment = pdu[index++]; // >= 0
206+
int totalSegments = (0xFF & pdu[index++]); // >= 1
207+
int segment = (0xFF & pdu[index++]); // >= 0
208+
209+
if (segment >= totalSegments) {
210+
Log.e(TAG, "WDP bad segment #" + segment + " expecting 0-" + (totalSegments - 1));
211+
return Intents.RESULT_SMS_HANDLED;
212+
}
208213

209214
// Only the first segment contains sourcePort and destination Port
210215
int sourcePort = 0;

0 commit comments

Comments
 (0)