Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 047e816f authored by Raph Levien's avatar Raph Levien
Browse files

Revert "Change Linkify leniency to VALID"

This reverts commit 9dfe86d4.

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
parent 613fffcd
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -450,7 +450,7 @@ public class Linkify {
    private static final void gatherTelLinks(ArrayList<LinkSpec> links, Spannable s) {
    private static final void gatherTelLinks(ArrayList<LinkSpec> links, Spannable s) {
        PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
        PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
        Iterable<PhoneNumberMatch> matches = phoneUtil.findNumbers(s.toString(),
        Iterable<PhoneNumberMatch> 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) {
        for (PhoneNumberMatch match : matches) {
            LinkSpec spec = new LinkSpec();
            LinkSpec spec = new LinkSpec();
            spec.url = "tel:" + PhoneNumberUtils.normalizeNumber(match.rawString());
            spec.url = "tel:" + PhoneNumberUtils.normalizeNumber(match.rawString());