summaryrefslogtreecommitdiffstats
path: root/telephony
diff options
context:
space:
mode:
authorWei Huang <weih@google.com>2009-10-23 11:49:20 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2009-10-23 11:49:20 -0700
commit76c8da22119e50be19620636ca703b1415df9beb (patch)
tree992a494855d961053dab94a6415f8597727252e8 /telephony
parentd437ac6a7c4fde988f7d737bafd30744137f3af8 (diff)
parent2c726389fb4a6d3b9b3ab67063527b341079f9c4 (diff)
downloadframeworks_base-76c8da22119e50be19620636ca703b1415df9beb.zip
frameworks_base-76c8da22119e50be19620636ca703b1415df9beb.tar.gz
frameworks_base-76c8da22119e50be19620636ca703b1415df9beb.tar.bz2
am 2c726389: am 45db67f2: Merge change I808651dc into eclair-mr2
Merge commit '2c726389fb4a6d3b9b3ab67063527b341079f9c4' * commit '2c726389fb4a6d3b9b3ab67063527b341079f9c4': bug #2180646: make comparing "404-04" and "40404" return true in PhoneNumberUtils.compare().
Diffstat (limited to 'telephony')
-rw-r--r--telephony/java/android/telephony/PhoneNumberUtils.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java
index a0a1b14..6b33f52 100644
--- a/telephony/java/android/telephony/PhoneNumberUtils.java
+++ b/telephony/java/android/telephony/PhoneNumberUtils.java
@@ -378,6 +378,8 @@ public class PhoneNumberUtils
compareLoosely(String a, String b) {
int ia, ib;
int matched;
+ int numNonDialableCharsInA = 0;
+ int numNonDialableCharsInB = 0;
if (a == null || b == null) return a == b;
@@ -398,6 +400,7 @@ public class PhoneNumberUtils
if (!isDialable(ca)) {
ia--;
skipCmp = true;
+ numNonDialableCharsInA++;
}
cb = b.charAt(ib);
@@ -405,6 +408,7 @@ public class PhoneNumberUtils
if (!isDialable(cb)) {
ib--;
skipCmp = true;
+ numNonDialableCharsInB++;
}
if (!skipCmp) {
@@ -416,13 +420,16 @@ public class PhoneNumberUtils
}
if (matched < MIN_MATCH) {
- int aLen = a.length();
+ int effectiveALen = a.length() - numNonDialableCharsInA;
+ int effectiveBLen = b.length() - numNonDialableCharsInB;
- // if the input strings match, but their lengths < MIN_MATCH,
- // treat them as equal.
- if (aLen == b.length() && aLen == matched) {
+
+ // if the number of dialable chars in a and b match, but the matched chars < MIN_MATCH,
+ // treat them as equal (i.e. 404-04 and 40404)
+ if (effectiveALen == effectiveBLen && effectiveALen == matched) {
return true;
}
+
return false;
}