Skip to content

Commit ecfb185

Browse files
Jean-Baptiste QueruAndroid Code Review
authored andcommitted
Merge "Preserve '+' in phone numbers imported from SIM."
2 parents f3ca9a5 + ce2a97a commit ecfb185

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

telephony/java/android/telephony/PhoneNumberUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,8 @@ && matchIntlPrefixAndCC(a, ia +1)
689689
return "";
690690
}
691691

692-
if ((bytes[offset] & 0xff) == TOA_International) {
692+
//Only TON field should be taken in concideration
693+
if ((bytes[offset] & 0xf0) == (TOA_International & 0xf0)) {
693694
prependPlus = true;
694695
}
695696

tests/CoreTests/com/android/internal/telephony/PhoneNumberUtilsTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ public void testA() throws Exception {
8282
assertEquals("17005550020",
8383
PhoneNumberUtils.calledPartyBCDToString(b, 0, 7));
8484

85+
b[0] = (byte) 0x80; b[1] = (byte) 0x71; b[2] = (byte) 0x00; b[3] = (byte) 0x55;
86+
b[4] = (byte) 0x05; b[5] = (byte) 0x20; b[6] = (byte) 0xF0;
87+
assertEquals("17005550020",
88+
PhoneNumberUtils.calledPartyBCDToString(b, 0, 7));
89+
90+
b[0] = (byte) 0x90; b[1] = (byte) 0x71; b[2] = (byte) 0x00; b[3] = (byte) 0x55;
91+
b[4] = (byte) 0x05; b[5] = (byte) 0x20; b[6] = (byte) 0xF0;
92+
assertEquals("+17005550020",
93+
PhoneNumberUtils.calledPartyBCDToString(b, 0, 7));
94+
8595
b[0] = (byte) 0x91; b[1] = (byte) 0x71; b[2] = (byte) 0x00; b[3] = (byte) 0x55;
8696
b[4] = (byte) 0x05; b[5] = (byte) 0x20; b[6] = (byte) 0xF0;
8797
assertEquals("+17005550020",

0 commit comments

Comments
 (0)