diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2018-04-18 02:42:35 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-04-18 02:42:35 +0000 |
commit | d92873ffb4f8563294924c7dcf2d8bf840b4ebb5 (patch) | |
tree | b3c906e6253b82c88de50ad57825019649ed3e7c /java/com/android/dialer/phonenumberproto/DialerPhoneNumberUtil.java | |
parent | 3bc04ceaa5cfec4f64a348c6b93fb5a6f031cb77 (diff) | |
parent | 9e73256fa20b95dd05bf9b46fe43ad96c3823178 (diff) |
Merge "Improved support for short codes in Coalescer."
Diffstat (limited to 'java/com/android/dialer/phonenumberproto/DialerPhoneNumberUtil.java')
-rw-r--r-- | java/com/android/dialer/phonenumberproto/DialerPhoneNumberUtil.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/java/com/android/dialer/phonenumberproto/DialerPhoneNumberUtil.java b/java/com/android/dialer/phonenumberproto/DialerPhoneNumberUtil.java index a5b9520fd..d8079efe3 100644 --- a/java/com/android/dialer/phonenumberproto/DialerPhoneNumberUtil.java +++ b/java/com/android/dialer/phonenumberproto/DialerPhoneNumberUtil.java @@ -29,6 +29,7 @@ import com.google.i18n.phonenumbers.PhoneNumberUtil; import com.google.i18n.phonenumbers.PhoneNumberUtil.MatchType; import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat; import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber; +import com.google.i18n.phonenumbers.ShortNumberInfo; /** * Wrapper for selected methods in {@link PhoneNumberUtil} which uses the {@link DialerPhoneNumber} @@ -38,11 +39,13 @@ import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber; */ public class DialerPhoneNumberUtil { private final PhoneNumberUtil phoneNumberUtil; + private final ShortNumberInfo shortNumberInfo; @WorkerThread - public DialerPhoneNumberUtil(@NonNull PhoneNumberUtil phoneNumberUtil) { + public DialerPhoneNumberUtil() { Assert.isWorkerThread(); - this.phoneNumberUtil = Assert.isNotNull(phoneNumberUtil); + this.phoneNumberUtil = PhoneNumberUtil.getInstance(); + this.shortNumberInfo = ShortNumberInfo.getInstance(); } /** @@ -159,6 +162,13 @@ public class DialerPhoneNumberUtil { return firstNumberIn.getNormalizedNumber().equals(secondNumberIn.getNormalizedNumber()); } + // Both numbers are parseable, first check for short codes to so that a number like "5555" + // doesn't match "55555" (due to those being a SHORT_NSN_MATCH below). + if (shortNumberInfo.isPossibleShortNumber(phoneNumber1) + || shortNumberInfo.isPossibleShortNumber(phoneNumber2)) { + return firstNumberIn.getNormalizedNumber().equals(secondNumberIn.getNormalizedNumber()); + } + // Both numbers are parseable, use more sophisticated libphonenumber matching. MatchType matchType = phoneNumberUtil.isNumberMatch(phoneNumber1, phoneNumber2); |