summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/phonenumberproto
diff options
context:
space:
mode:
authorzachh <zachh@google.com>2018-01-17 16:32:18 -0800
committerCopybara-Service <copybara-piper@google.com>2018-01-17 16:37:56 -0800
commit6d123ee49dadb918acf5a3c57fee57d3aff6bab2 (patch)
tree9f6712592e098fe5c26f8609285aa5c373896aba /java/com/android/dialer/phonenumberproto
parent10f6e8222a5ee1cc2da1b107c3a344b34c726501 (diff)
Relax number matching when coalescing rows in new call log.
We currently require two numbers to be a PhoneNumberUtil.MatchType.EXACT_MATCH to coalesce them, but this means that two numbers like "456-7890" and "408 456-7890" won't ever be collapsed. This is potentially a likely situation since it is possible to dial numbers without an area code so we should better support it (and the old call log coalesces such numbers today). Bug: 70989626 Test: unit PiperOrigin-RevId: 182289194 Change-Id: If884d5a1f2631116a2729e0635f9a97aeca3e057
Diffstat (limited to 'java/com/android/dialer/phonenumberproto')
-rw-r--r--java/com/android/dialer/phonenumberproto/DialerPhoneNumberUtil.java26
1 files changed, 20 insertions, 6 deletions
diff --git a/java/com/android/dialer/phonenumberproto/DialerPhoneNumberUtil.java b/java/com/android/dialer/phonenumberproto/DialerPhoneNumberUtil.java
index 8969737d4..d37f7fa1d 100644
--- a/java/com/android/dialer/phonenumberproto/DialerPhoneNumberUtil.java
+++ b/java/com/android/dialer/phonenumberproto/DialerPhoneNumberUtil.java
@@ -70,6 +70,14 @@ public class DialerPhoneNumberUtil {
}
dialerPhoneNumber.setRawInput(rawInput.build());
+ // If the number is a service number, just store the raw input and don't bother trying to parse
+ // it. PhoneNumberUtil#parse ignores these characters which can lead to confusing behavior, such
+ // as the numbers "#123" and "123" being considered the same. The "#" can appear in the middle
+ // of a service number and the "*" can appear at the beginning (see a bug).
+ if (numberToParse != null && (numberToParse.contains("#") || numberToParse.startsWith("*"))) {
+ return dialerPhoneNumber.build();
+ }
+
try {
dialerPhoneNumber.setDialerInternalPhoneNumber(
Converter.pojoToProto(phoneNumberUtil.parse(numberToParse, defaultRegion)));
@@ -95,21 +103,27 @@ public class DialerPhoneNumberUtil {
}
/**
- * Returns true if the two numbers were parseable by libphonenumber and are an {@link
- * MatchType#EXACT_MATCH} or if they have the same raw input.
+ * Returns true if the two numbers were parseable by libphonenumber and are a {@link
+ * MatchType#SHORT_NSN_MATCH} or {@link MatchType#NSN_MATCH} or {@link MatchType#EXACT_MATCH} or
+ * if they have the same raw input.
+ *
+ * @see PhoneNumberUtil#isNumberMatch(PhoneNumber, PhoneNumber)
*/
@WorkerThread
- public boolean isExactMatch(
+ public boolean isMatch(
@NonNull DialerPhoneNumber firstNumberIn, @NonNull DialerPhoneNumber secondNumberIn) {
Assert.isWorkerThread();
if (!Assert.isNotNull(firstNumberIn).hasDialerInternalPhoneNumber()
|| !Assert.isNotNull(secondNumberIn).hasDialerInternalPhoneNumber()) {
return firstNumberIn.getRawInput().equals(secondNumberIn.getRawInput());
}
- return isNumberMatch(
+ MatchType matchType =
+ isNumberMatch(
firstNumberIn.getDialerInternalPhoneNumber(),
- secondNumberIn.getDialerInternalPhoneNumber())
- == MatchType.EXACT_MATCH;
+ secondNumberIn.getDialerInternalPhoneNumber());
+ return matchType == MatchType.SHORT_NSN_MATCH
+ || matchType == MatchType.NSN_MATCH
+ || matchType == MatchType.EXACT_MATCH;
}
/**