From 047e816fe2e6c94ff425188c4b12f02921d3f5bf Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Wed, 17 Dec 2014 14:31:39 -0800 Subject: Revert "Change Linkify leniency to VALID" This reverts commit 9dfe86d4102b93885b947917fccee35053cfc9f2. That change moved the lenience from POSSIBLE to VALID, which eliminated false positive links, especially 4 digit phone numbers, but caused significant false negatives, leading to CTS test failures (android.text.util.cts.LinkifyTest#testAddLinks7 in particular). The true fix requires new functionality to validate phone numbers in a mobile context. In the meantime, the best solution is to revert. Bug: 18708556 --- core/java/android/text/util/Linkify.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'core/java/android/text') diff --git a/core/java/android/text/util/Linkify.java b/core/java/android/text/util/Linkify.java index 14be269..c1341e1 100644 --- a/core/java/android/text/util/Linkify.java +++ b/core/java/android/text/util/Linkify.java @@ -402,7 +402,7 @@ public class Linkify { } boolean hasPrefix = false; - + for (int i = 0; i < prefixes.length; i++) { if (url.regionMatches(true, 0, prefixes[i], 0, prefixes[i].length())) { @@ -450,7 +450,7 @@ public class Linkify { private static final void gatherTelLinks(ArrayList links, Spannable s) { PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance(); Iterable matches = phoneUtil.findNumbers(s.toString(), - Locale.getDefault().getCountry(), Leniency.VALID, Long.MAX_VALUE); + Locale.getDefault().getCountry(), Leniency.POSSIBLE, Long.MAX_VALUE); for (PhoneNumberMatch match : matches) { LinkSpec spec = new LinkSpec(); spec.url = "tel:" + PhoneNumberUtils.normalizeNumber(match.rawString()); -- cgit v1.1