summaryrefslogtreecommitdiff
path: root/android/PhoneNumberUtils.cpp
AgeCommit message (Collapse)Author
2017-07-18Fix false positives comparing local and intl numbersFrancisco Pimenta
Previously when comparing local phone numbers with international it was possible to match the wrong number because the first digit of the area code was being treated as a skippable trunk digit, e.g: "550-123-4567" would be considered equal to "+14501234567". Since there are two different algorithms (loose/old and strict) there are two solutions with the same basic goal: Only ignore mismatches if there's an actual extra digit which could possibly be the trunk digit, i.e: "0550-123-4567" is acceptable as equal to "+15501234567". NB: The US not having a trunk digit to begin with is a different issue entirely - the code is agnostic on which country has which trunk digits! For "loose" matching we achieve this by checking the length of the mismatch. For "strict" matching we keep track of the supposed trunk digit and compare it against the current position in match. So for the above example 5 != 4. Several new unit tests were added (including replicating tests for OldPhoneNumberUtils). I broke down the c++ tests into smaller methods for additional readability. NB: By adding more tests I uncovered that two digit trunk prefixes were never handled correctly for the "strict" matching case. "Loose" matching is much more robust. I commented out the "strict" test cases. Test: All unit tests pass for PhoneNumberUtilsTest, OldPhoneNumberUtilsTest and DatabaseGeneralTest. Bug: 63179537 Bug: 63178542 Bug: 62916088 Change-Id: Idc2a1c2c2f64ed29995208503de4755c521e1c82
2011-01-06Adding a custom function to support legacy API compatibilityDmitri Plotnikov
Bug: 3210604 Change-Id: I6e9a20ec7887375b67c42a28cff54e2e9d399ea6
2009-09-20Revert the default phone number comparation algorithm.Daisuke Miyakawa
Now developers have to explicitly set the third argument of PHONE_NUMBERS_COMPARE() into 1, when they want to use "strict" phone number comparation algorithm, which was used in Donut. In default, PHONE_NUMBER_COMPARE() now uses "loose" phone number comparation algorithm, which had been used in Cupcake. Internal issue id: 1892808
2009-09-02Fix the implementation of phone_number_compare in accordance with the tests ↵Daisuke Miyakawa
in PhoneNumberUtils.java. Due to the Thailand's special case, the code became a little nastier than before, but I believe it is inevitable...
2009-08-31fix bug 2015059: where the native sqlite comparison method ↵Wei Huang
phone_number_compare() treated all alpha addresses as the same phone number. - changed phone_number_compare() to handle alpha chars. Before this change the algorithm skipped over all non-dialable chars for comparison, and thus treating "foo" and "bar" as the same addresses. now we don't skip any char that's alpha. This would treat "foo" and "bar" as separate addresses, as well as treating "1-800-flowers" and "800-flowers" as the same number.
2009-07-20Fix a bug in which "16\d+6" matches 166 and the number is handled as ↵Daisuke Miyakawa
Thailand one...
2009-07-07"Rewrite" PhoneNumberUtil so that it compares two phone strings using as ↵Daisuke Miyakawa
many characters as possible, unlike the previous implementation. Unlike the change 5480, this considers the NDD-problem mentioned in the internal issue 1949010. This time, 1-650-555-1234 and 650-555-1234 match each other. Added tests for the cases. related internal issue: 1868702, 1949010
2009-07-07Revert ""Rewrite" PhoneNumberUtil so that it compares two phone strings ↵Daisuke Miyakawa
using as many characters as possible, unlike the previous implementation." This reverts commit de43094477419f8a190a6f97b47d346827310a02. related internal issue: 1949010
2009-06-26"Rewrite" PhoneNumberUtil so that it compares two phone strings using as ↵Daisuke Miyakawa
many characters as possible, unlike the previous implementation. The new implementation considers country code seriously. To confirm this change does not do something wrong, I also created another change (https://android-git.corp.google.com/g/Gerrit#change,4036). All tests related to PhoneNumberUtils pass, including Thailand's ugly buggy behavior around country code handling :-P Also Add tests for PhoneNumberUtils, which can be executed in the usual workstation like this: > g++ -Wall external/sqlite/android/PhoneNumberUtils.cpp external/sqlite/android/PhoneNumberUtilsTest.cpp > ./a.out This change fixes the internal bug 1868702.
2009-03-03auto import from //depot/cupcake/@135843The Android Open Source Project
2009-03-03auto import from //depot/cupcake/@135843The Android Open Source Project
2009-02-10auto import from //branches/cupcake/...@130745The Android Open Source Project
2008-12-17Code drop from //branches/cupcake/...@124589The Android Open Source Project
2008-10-21Initial ContributionThe Android Open Source Project