Merge "Incorrect decoding when TP-OA contains non-integer information" am: 2bcc7fac89
am: 74bd3daaac
Change-Id: Idc00a34295cdcbefa19636643bff3c3bf2323446
This commit is contained in:
@@ -39785,8 +39785,10 @@ package android.telephony {
|
||||
public class PhoneNumberUtils {
|
||||
ctor public PhoneNumberUtils();
|
||||
method public static void addTtsSpan(android.text.Spannable, int, int);
|
||||
method public static java.lang.String calledPartyBCDFragmentToString(byte[], int, int);
|
||||
method public static java.lang.String calledPartyBCDToString(byte[], int, int);
|
||||
method public static deprecated java.lang.String calledPartyBCDFragmentToString(byte[], int, int);
|
||||
method public static java.lang.String calledPartyBCDFragmentToString(byte[], int, int, int);
|
||||
method public static deprecated java.lang.String calledPartyBCDToString(byte[], int, int);
|
||||
method public static java.lang.String calledPartyBCDToString(byte[], int, int, int);
|
||||
method public static boolean compare(java.lang.String, java.lang.String);
|
||||
method public static boolean compare(android.content.Context, java.lang.String, java.lang.String);
|
||||
method public static java.lang.String convertKeypadLettersToDigits(java.lang.String);
|
||||
@@ -39819,12 +39821,15 @@ package android.telephony {
|
||||
method public static byte[] networkPortionToCalledPartyBCD(java.lang.String);
|
||||
method public static byte[] networkPortionToCalledPartyBCDWithLength(java.lang.String);
|
||||
method public static java.lang.String normalizeNumber(java.lang.String);
|
||||
method public static byte[] numberToCalledPartyBCD(java.lang.String);
|
||||
method public static deprecated byte[] numberToCalledPartyBCD(java.lang.String);
|
||||
method public static byte[] numberToCalledPartyBCD(java.lang.String, int);
|
||||
method public static java.lang.String replaceUnicodeDigits(java.lang.String);
|
||||
method public static java.lang.String stringFromStringAndTOA(java.lang.String, int);
|
||||
method public static java.lang.String stripSeparators(java.lang.String);
|
||||
method public static java.lang.String toCallerIDMinMatch(java.lang.String);
|
||||
method public static int toaFromString(java.lang.String);
|
||||
field public static final int BCD_EXTENDED_TYPE_CALLED_PARTY = 2; // 0x2
|
||||
field public static final int BCD_EXTENDED_TYPE_EF_ADN = 1; // 0x1
|
||||
field public static final int FORMAT_JAPAN = 2; // 0x2
|
||||
field public static final int FORMAT_NANP = 1; // 0x1
|
||||
field public static final int FORMAT_UNKNOWN = 0; // 0x0
|
||||
|
||||
@@ -43217,8 +43217,10 @@ package android.telephony {
|
||||
public class PhoneNumberUtils {
|
||||
ctor public PhoneNumberUtils();
|
||||
method public static void addTtsSpan(android.text.Spannable, int, int);
|
||||
method public static java.lang.String calledPartyBCDFragmentToString(byte[], int, int);
|
||||
method public static java.lang.String calledPartyBCDToString(byte[], int, int);
|
||||
method public static deprecated java.lang.String calledPartyBCDFragmentToString(byte[], int, int);
|
||||
method public static java.lang.String calledPartyBCDFragmentToString(byte[], int, int, int);
|
||||
method public static deprecated java.lang.String calledPartyBCDToString(byte[], int, int);
|
||||
method public static java.lang.String calledPartyBCDToString(byte[], int, int, int);
|
||||
method public static boolean compare(java.lang.String, java.lang.String);
|
||||
method public static boolean compare(android.content.Context, java.lang.String, java.lang.String);
|
||||
method public static java.lang.String convertKeypadLettersToDigits(java.lang.String);
|
||||
@@ -43251,12 +43253,15 @@ package android.telephony {
|
||||
method public static byte[] networkPortionToCalledPartyBCD(java.lang.String);
|
||||
method public static byte[] networkPortionToCalledPartyBCDWithLength(java.lang.String);
|
||||
method public static java.lang.String normalizeNumber(java.lang.String);
|
||||
method public static byte[] numberToCalledPartyBCD(java.lang.String);
|
||||
method public static deprecated byte[] numberToCalledPartyBCD(java.lang.String);
|
||||
method public static byte[] numberToCalledPartyBCD(java.lang.String, int);
|
||||
method public static java.lang.String replaceUnicodeDigits(java.lang.String);
|
||||
method public static java.lang.String stringFromStringAndTOA(java.lang.String, int);
|
||||
method public static java.lang.String stripSeparators(java.lang.String);
|
||||
method public static java.lang.String toCallerIDMinMatch(java.lang.String);
|
||||
method public static int toaFromString(java.lang.String);
|
||||
field public static final int BCD_EXTENDED_TYPE_CALLED_PARTY = 2; // 0x2
|
||||
field public static final int BCD_EXTENDED_TYPE_EF_ADN = 1; // 0x1
|
||||
field public static final int FORMAT_JAPAN = 2; // 0x2
|
||||
field public static final int FORMAT_NANP = 1; // 0x1
|
||||
field public static final int FORMAT_UNKNOWN = 0; // 0x0
|
||||
|
||||
@@ -40009,8 +40009,10 @@ package android.telephony {
|
||||
public class PhoneNumberUtils {
|
||||
ctor public PhoneNumberUtils();
|
||||
method public static void addTtsSpan(android.text.Spannable, int, int);
|
||||
method public static java.lang.String calledPartyBCDFragmentToString(byte[], int, int);
|
||||
method public static java.lang.String calledPartyBCDToString(byte[], int, int);
|
||||
method public static deprecated java.lang.String calledPartyBCDFragmentToString(byte[], int, int);
|
||||
method public static java.lang.String calledPartyBCDFragmentToString(byte[], int, int, int);
|
||||
method public static deprecated java.lang.String calledPartyBCDToString(byte[], int, int);
|
||||
method public static java.lang.String calledPartyBCDToString(byte[], int, int, int);
|
||||
method public static boolean compare(java.lang.String, java.lang.String);
|
||||
method public static boolean compare(android.content.Context, java.lang.String, java.lang.String);
|
||||
method public static java.lang.String convertKeypadLettersToDigits(java.lang.String);
|
||||
@@ -40043,12 +40045,15 @@ package android.telephony {
|
||||
method public static byte[] networkPortionToCalledPartyBCD(java.lang.String);
|
||||
method public static byte[] networkPortionToCalledPartyBCDWithLength(java.lang.String);
|
||||
method public static java.lang.String normalizeNumber(java.lang.String);
|
||||
method public static byte[] numberToCalledPartyBCD(java.lang.String);
|
||||
method public static deprecated byte[] numberToCalledPartyBCD(java.lang.String);
|
||||
method public static byte[] numberToCalledPartyBCD(java.lang.String, int);
|
||||
method public static java.lang.String replaceUnicodeDigits(java.lang.String);
|
||||
method public static java.lang.String stringFromStringAndTOA(java.lang.String, int);
|
||||
method public static java.lang.String stripSeparators(java.lang.String);
|
||||
method public static java.lang.String toCallerIDMinMatch(java.lang.String);
|
||||
method public static int toaFromString(java.lang.String);
|
||||
field public static final int BCD_EXTENDED_TYPE_CALLED_PARTY = 2; // 0x2
|
||||
field public static final int BCD_EXTENDED_TYPE_EF_ADN = 1; // 0x1
|
||||
field public static final int FORMAT_JAPAN = 2; // 0x2
|
||||
field public static final int FORMAT_NANP = 1; // 0x1
|
||||
field public static final int FORMAT_UNKNOWN = 0; // 0x0
|
||||
|
||||
@@ -77,9 +77,28 @@ public class PhoneNumberUtils
|
||||
public static final int TOA_International = 0x91;
|
||||
public static final int TOA_Unknown = 0x81;
|
||||
|
||||
/*
|
||||
* The BCD extended type used to determine the extended char for the digit which is greater than
|
||||
* 9.
|
||||
*
|
||||
* see TS 51.011 section 10.5.1 EF_ADN(Abbreviated dialling numbers)
|
||||
*/
|
||||
public static final int BCD_EXTENDED_TYPE_EF_ADN = 1;
|
||||
|
||||
/*
|
||||
* The BCD extended type used to determine the extended char for the digit which is greater than
|
||||
* 9.
|
||||
*
|
||||
* see TS 24.008 section 10.5.4.7 Called party BCD number
|
||||
*/
|
||||
public static final int BCD_EXTENDED_TYPE_CALLED_PARTY = 2;
|
||||
|
||||
static final String LOG_TAG = "PhoneNumberUtils";
|
||||
private static final boolean DBG = false;
|
||||
|
||||
private static final String BCD_EF_ADN_EXTENDED = "*#,N;";
|
||||
private static final String BCD_CALLED_PARTY_EXTENDED = "*#abc";
|
||||
|
||||
/*
|
||||
* global-phone-number = ["+"] 1*( DIGIT / written-sep )
|
||||
* written-sep = ("-"/".")
|
||||
@@ -799,11 +818,33 @@ public class PhoneNumberUtils
|
||||
*
|
||||
* @return partial string on invalid decode
|
||||
*
|
||||
* FIXME(mkf) support alphanumeric address type
|
||||
* currently implemented in SMSMessage.getAddress()
|
||||
* @deprecated use {@link #calledPartyBCDToString(byte[], int, int, int)} instead. Calling this
|
||||
* method is equivalent to calling {@link #calledPartyBCDToString(byte[], int, int)} with
|
||||
* {@link #BCD_EXTENDED_TYPE_EF_ADN} as the extended type.
|
||||
*/
|
||||
public static String
|
||||
calledPartyBCDToString (byte[] bytes, int offset, int length) {
|
||||
@Deprecated
|
||||
public static String calledPartyBCDToString(byte[] bytes, int offset, int length) {
|
||||
return calledPartyBCDToString(bytes, offset, length, BCD_EXTENDED_TYPE_EF_ADN);
|
||||
}
|
||||
|
||||
/**
|
||||
* 3GPP TS 24.008 10.5.4.7
|
||||
* Called Party BCD Number
|
||||
*
|
||||
* See Also TS 51.011 10.5.1 "dialing number/ssc string"
|
||||
* and TS 11.11 "10.3.1 EF adn (Abbreviated dialing numbers)"
|
||||
*
|
||||
* @param bytes the data buffer
|
||||
* @param offset should point to the TOA (aka. TON/NPI) octet after the length byte
|
||||
* @param length is the number of bytes including TOA byte
|
||||
* and must be at least 2
|
||||
* @param bcdExtType used to determine the extended bcd coding
|
||||
* @see #BCD_EXTENDED_TYPE_EF_ADN
|
||||
* @see #BCD_EXTENDED_TYPE_CALLED_PARTY
|
||||
*
|
||||
*/
|
||||
public static String calledPartyBCDToString(
|
||||
byte[] bytes, int offset, int length, int bcdExtType) {
|
||||
boolean prependPlus = false;
|
||||
StringBuilder ret = new StringBuilder(1 + length * 2);
|
||||
|
||||
@@ -817,7 +858,7 @@ public class PhoneNumberUtils
|
||||
}
|
||||
|
||||
internalCalledPartyBCDFragmentToString(
|
||||
ret, bytes, offset + 1, length - 1);
|
||||
ret, bytes, offset + 1, length - 1, bcdExtType);
|
||||
|
||||
if (prependPlus && ret.length() == 0) {
|
||||
// If the only thing there is a prepended plus, return ""
|
||||
@@ -902,14 +943,13 @@ public class PhoneNumberUtils
|
||||
return ret.toString();
|
||||
}
|
||||
|
||||
private static void
|
||||
internalCalledPartyBCDFragmentToString(
|
||||
StringBuilder sb, byte [] bytes, int offset, int length) {
|
||||
private static void internalCalledPartyBCDFragmentToString(
|
||||
StringBuilder sb, byte [] bytes, int offset, int length, int bcdExtType) {
|
||||
for (int i = offset ; i < length + offset ; i++) {
|
||||
byte b;
|
||||
char c;
|
||||
|
||||
c = bcdToChar((byte)(bytes[i] & 0xf));
|
||||
c = bcdToChar((byte)(bytes[i] & 0xf), bcdExtType);
|
||||
|
||||
if (c == 0) {
|
||||
return;
|
||||
@@ -930,7 +970,7 @@ public class PhoneNumberUtils
|
||||
break;
|
||||
}
|
||||
|
||||
c = bcdToChar(b);
|
||||
c = bcdToChar(b, bcdExtType);
|
||||
if (c == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -943,49 +983,65 @@ public class PhoneNumberUtils
|
||||
/**
|
||||
* Like calledPartyBCDToString, but field does not start with a
|
||||
* TOA byte. For example: SIM ADN extension fields
|
||||
*
|
||||
* @deprecated use {@link #calledPartyBCDFragmentToString(byte[], int, int, int)} instead.
|
||||
* Calling this method is equivalent to calling
|
||||
* {@link #calledPartyBCDFragmentToString(byte[], int, int, int)} with
|
||||
* {@link #BCD_EXTENDED_TYPE_EF_ADN} as the extended type.
|
||||
*/
|
||||
@Deprecated
|
||||
public static String calledPartyBCDFragmentToString(byte[] bytes, int offset, int length) {
|
||||
return calledPartyBCDFragmentToString(bytes, offset, length, BCD_EXTENDED_TYPE_EF_ADN);
|
||||
}
|
||||
|
||||
public static String
|
||||
calledPartyBCDFragmentToString(byte [] bytes, int offset, int length) {
|
||||
/**
|
||||
* Like calledPartyBCDToString, but field does not start with a
|
||||
* TOA byte. For example: SIM ADN extension fields
|
||||
*/
|
||||
public static String calledPartyBCDFragmentToString(
|
||||
byte[] bytes, int offset, int length, int bcdExtType) {
|
||||
StringBuilder ret = new StringBuilder(length * 2);
|
||||
|
||||
internalCalledPartyBCDFragmentToString(ret, bytes, offset, length);
|
||||
|
||||
internalCalledPartyBCDFragmentToString(ret, bytes, offset, length, bcdExtType);
|
||||
return ret.toString();
|
||||
}
|
||||
|
||||
/** returns 0 on invalid value */
|
||||
private static char
|
||||
bcdToChar(byte b) {
|
||||
/**
|
||||
* Returns the correspond character for given {@code b} based on {@code bcdExtType}, or 0 on
|
||||
* invalid code.
|
||||
*/
|
||||
private static char bcdToChar(byte b, int bcdExtType) {
|
||||
if (b < 0xa) {
|
||||
return (char)('0' + b);
|
||||
} else switch (b) {
|
||||
case 0xa: return '*';
|
||||
case 0xb: return '#';
|
||||
case 0xc: return PAUSE;
|
||||
case 0xd: return WILD;
|
||||
|
||||
default: return 0;
|
||||
return (char) ('0' + b);
|
||||
}
|
||||
|
||||
String extended = null;
|
||||
if (BCD_EXTENDED_TYPE_EF_ADN == bcdExtType) {
|
||||
extended = BCD_EF_ADN_EXTENDED;
|
||||
} else if (BCD_EXTENDED_TYPE_CALLED_PARTY == bcdExtType) {
|
||||
extended = BCD_CALLED_PARTY_EXTENDED;
|
||||
}
|
||||
if (extended == null || b - 0xa >= extended.length()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return extended.charAt(b - 0xa);
|
||||
}
|
||||
|
||||
private static int
|
||||
charToBCD(char c) {
|
||||
if (c >= '0' && c <= '9') {
|
||||
private static int charToBCD(char c, int bcdExtType) {
|
||||
if ('0' <= c && c <= '9') {
|
||||
return c - '0';
|
||||
} else if (c == '*') {
|
||||
return 0xa;
|
||||
} else if (c == '#') {
|
||||
return 0xb;
|
||||
} else if (c == PAUSE) {
|
||||
return 0xc;
|
||||
} else if (c == WILD) {
|
||||
return 0xd;
|
||||
} else if (c == WAIT) {
|
||||
return 0xe;
|
||||
} else {
|
||||
throw new RuntimeException ("invalid char for BCD " + c);
|
||||
}
|
||||
|
||||
String extended = null;
|
||||
if (BCD_EXTENDED_TYPE_EF_ADN == bcdExtType) {
|
||||
extended = BCD_EF_ADN_EXTENDED;
|
||||
} else if (BCD_EXTENDED_TYPE_CALLED_PARTY == bcdExtType) {
|
||||
extended = BCD_CALLED_PARTY_EXTENDED;
|
||||
}
|
||||
if (extended == null || extended.indexOf(c) == -1) {
|
||||
throw new RuntimeException("invalid char for BCD " + c);
|
||||
}
|
||||
return 0xa + extended.indexOf(c);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1034,40 +1090,60 @@ public class PhoneNumberUtils
|
||||
*
|
||||
* Returns null if network portion is empty.
|
||||
*/
|
||||
public static byte[]
|
||||
networkPortionToCalledPartyBCD(String s) {
|
||||
public static byte[] networkPortionToCalledPartyBCD(String s) {
|
||||
String networkPortion = extractNetworkPortion(s);
|
||||
return numberToCalledPartyBCDHelper(networkPortion, false);
|
||||
return numberToCalledPartyBCDHelper(
|
||||
networkPortion, false, BCD_EXTENDED_TYPE_EF_ADN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as {@link #networkPortionToCalledPartyBCD}, but includes a
|
||||
* one-byte length prefix.
|
||||
*/
|
||||
public static byte[]
|
||||
networkPortionToCalledPartyBCDWithLength(String s) {
|
||||
public static byte[] networkPortionToCalledPartyBCDWithLength(String s) {
|
||||
String networkPortion = extractNetworkPortion(s);
|
||||
return numberToCalledPartyBCDHelper(networkPortion, true);
|
||||
return numberToCalledPartyBCDHelper(
|
||||
networkPortion, true, BCD_EXTENDED_TYPE_EF_ADN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a dialing number to BCD byte array
|
||||
*
|
||||
* @param number dialing number string
|
||||
* if the dialing number starts with '+', set to international TOA
|
||||
* @param number dialing number string. If the dialing number starts with '+', set to
|
||||
* international TOA
|
||||
*
|
||||
* @return BCD byte array
|
||||
*
|
||||
* @deprecated use {@link #numberToCalledPartyBCD(String, int)} instead. Calling this method
|
||||
* is equivalent to calling {@link #numberToCalledPartyBCD(String, int)} with
|
||||
* {@link #BCD_EXTENDED_TYPE_EF_ADN} as the extended type.
|
||||
*/
|
||||
@Deprecated
|
||||
public static byte[] numberToCalledPartyBCD(String number) {
|
||||
return numberToCalledPartyBCD(number, BCD_EXTENDED_TYPE_EF_ADN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a dialing number to BCD byte array
|
||||
*
|
||||
* @param number dialing number string. If the dialing number starts with '+', set to
|
||||
* international TOA
|
||||
* @param bcdExtType used to determine the extended bcd coding
|
||||
* @see #BCD_EXTENDED_TYPE_EF_ADN
|
||||
* @see #BCD_EXTENDED_TYPE_CALLED_PARTY
|
||||
*
|
||||
* @return BCD byte array
|
||||
*/
|
||||
public static byte[]
|
||||
numberToCalledPartyBCD(String number) {
|
||||
return numberToCalledPartyBCDHelper(number, false);
|
||||
public static byte[] numberToCalledPartyBCD(String number, int bcdExtType) {
|
||||
return numberToCalledPartyBCDHelper(number, false, bcdExtType);
|
||||
}
|
||||
|
||||
/**
|
||||
* If includeLength is true, prepend a one-byte length value to
|
||||
* the return array.
|
||||
*/
|
||||
private static byte[]
|
||||
numberToCalledPartyBCDHelper(String number, boolean includeLength) {
|
||||
private static byte[] numberToCalledPartyBCDHelper(
|
||||
String number, boolean includeLength, int bcdExtType) {
|
||||
int numberLenReal = number.length();
|
||||
int numberLenEffective = numberLenReal;
|
||||
boolean hasPlus = number.indexOf('+') != -1;
|
||||
@@ -1087,7 +1163,8 @@ public class PhoneNumberUtils
|
||||
char c = number.charAt(i);
|
||||
if (c == '+') continue;
|
||||
int shift = ((digitCount & 0x01) == 1) ? 4 : 0;
|
||||
result[extraBytes + (digitCount >> 1)] |= (byte)((charToBCD(c) & 0x0F) << shift);
|
||||
result[extraBytes + (digitCount >> 1)] |=
|
||||
(byte)((charToBCD(c, bcdExtType) & 0x0F) << shift);
|
||||
digitCount++;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +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;
|
||||
@@ -71,8 +72,11 @@ public class GsmSmsAddress extends SmsAddress {
|
||||
// Make sure the final unused BCD digit is 0xf
|
||||
origBytes[length - 1] |= 0xf0;
|
||||
}
|
||||
address = PhoneNumberUtils.calledPartyBCDToString(origBytes,
|
||||
OFFSET_TOA, length - OFFSET_TOA);
|
||||
address = PhoneNumberUtils.calledPartyBCDToString(
|
||||
origBytes,
|
||||
OFFSET_TOA,
|
||||
length - OFFSET_TOA,
|
||||
PhoneNumberUtils.BCD_EXTENDED_TYPE_CALLED_PARTY);
|
||||
|
||||
// And restore origBytes
|
||||
origBytes[length - 1] = lastByte;
|
||||
|
||||
@@ -535,8 +535,8 @@ public class SmsMessage extends SmsMessageBase {
|
||||
} else {
|
||||
// SC address
|
||||
try {
|
||||
ret = PhoneNumberUtils
|
||||
.calledPartyBCDToString(mPdu, mCur, len);
|
||||
ret = PhoneNumberUtils.calledPartyBCDToString(
|
||||
mPdu, mCur, len, PhoneNumberUtils.BCD_EXTENDED_TYPE_CALLED_PARTY);
|
||||
} catch (RuntimeException tr) {
|
||||
Rlog.d(LOG_TAG, "invalid SC address: ", tr);
|
||||
ret = null;
|
||||
|
||||
Reference in New Issue
Block a user