diff options
author | Jake Hamby <jhamby@google.com> | 2012-08-20 13:51:16 -0700 |
---|---|---|
committer | android code review <noreply-gerritcodereview@google.com> | 2012-08-20 13:51:16 -0700 |
commit | 026b1a184c918c9e0ddd028073084e443e5ae0fc (patch) | |
tree | 2b9e6aa1177bc2ab4ba82c9903fe07501cab9cf1 /src | |
parent | f0414167059ea8ac7daae752e0ce7bd858df7f92 (diff) | |
parent | 5ad6947b2d955a4e972d556090922d77aa6a2641 (diff) | |
download | frameworks_opt_telephony-026b1a184c918c9e0ddd028073084e443e5ae0fc.zip frameworks_opt_telephony-026b1a184c918c9e0ddd028073084e443e5ae0fc.tar.gz frameworks_opt_telephony-026b1a184c918c9e0ddd028073084e443e5ae0fc.tar.bz2 |
Merge "Telephony: Fix MT SMS with invalid TOA field causing crash issue"
Diffstat (limited to 'src')
-rw-r--r-- | src/java/com/android/internal/telephony/gsm/GsmSmsAddress.java | 8 | ||||
-rw-r--r-- | src/java/com/android/internal/telephony/gsm/SmsMessage.java | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/java/com/android/internal/telephony/gsm/GsmSmsAddress.java b/src/java/com/android/internal/telephony/gsm/GsmSmsAddress.java index c163803..fa188f3 100644 --- a/src/java/com/android/internal/telephony/gsm/GsmSmsAddress.java +++ b/src/java/com/android/internal/telephony/gsm/GsmSmsAddress.java @@ -17,7 +17,7 @@ package com.android.internal.telephony.gsm; import android.telephony.PhoneNumberUtils; - +import java.text.ParseException; import com.android.internal.telephony.GsmAlphabet; import com.android.internal.telephony.SmsAddress; @@ -35,9 +35,10 @@ public class GsmSmsAddress extends SmsAddress { * @param offset the offset of the Address-Length byte * @param length the length in bytes rounded up, e.g. "2 + * (addressLength + 1) / 2" + * @throws ParseException */ - public GsmSmsAddress(byte[] data, int offset, int length) { + public GsmSmsAddress(byte[] data, int offset, int length) throws ParseException { origBytes = new byte[length]; System.arraycopy(data, offset, origBytes, 0, length); @@ -49,7 +50,8 @@ public class GsmSmsAddress extends SmsAddress { // TOA must have its high bit set if ((toa & 0x80) != 0x80) { - throw new RuntimeException("Invalid TOA - high bit must be set"); + throw new ParseException("Invalid TOA - high bit must be set. toa = " + toa, + offset + OFFSET_TOA); } if (isAlphanumeric()) { diff --git a/src/java/com/android/internal/telephony/gsm/SmsMessage.java b/src/java/com/android/internal/telephony/gsm/SmsMessage.java index 1ed1478..76a4b7f 100644 --- a/src/java/com/android/internal/telephony/gsm/SmsMessage.java +++ b/src/java/com/android/internal/telephony/gsm/SmsMessage.java @@ -29,6 +29,7 @@ import com.android.internal.telephony.SmsMessageBase; import java.io.ByteArrayOutputStream; import java.io.UnsupportedEncodingException; +import java.text.ParseException; import static com.android.internal.telephony.SmsConstants.MessageClass; import static com.android.internal.telephony.SmsConstants.ENCODING_UNKNOWN; @@ -560,7 +561,12 @@ public class SmsMessage extends SmsMessageBase { int addressLength = pdu[cur] & 0xff; int lengthBytes = 2 + (addressLength + 1) / 2; - ret = new GsmSmsAddress(pdu, cur, lengthBytes); + try { + ret = new GsmSmsAddress(pdu, cur, lengthBytes); + } catch (ParseException e) { + Log.e(LOG_TAG, e.getMessage()); + ret = null; + } cur += lengthBytes; |