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

Commit 32ca6aae authored by Romain Guy's avatar Romain Guy Committed by Android Code Review
Browse files

Merge "Makes PhoneNumberUtils support international numbers after a CLIR command."

parents 4696f2fb adff0ad3
Loading
Loading
Loading
Loading
+33 −2
Original line number Diff line number Diff line
@@ -54,6 +54,12 @@ public class PhoneNumberUtils
    public static final char WAIT = ';';
    public static final char WILD = 'N';

    /*
     * Calling Line Identification Restriction (CLIR)
     */
    private static final String CLIR_ON = "*31#+";
    private static final String CLIR_OFF = "#31#+";

    /*
     * TOA = TON + NPI
     * See TS 24.008 section 10.5.4.7 for details.
@@ -179,8 +185,6 @@ public class PhoneNumberUtils
     *  Please note that the GSM wild character is allowed in the result.
     *  This must be resolved before dialing.
     *
     *  Allows + only in the first  position in the result string.
     *
     *  Returns null if phoneNumber == null
     */
    public static String
@@ -203,6 +207,11 @@ public class PhoneNumberUtils
            }
        }

        int pos = addPlusChar(phoneNumber);
        if (pos >= 0 && ret.length() > pos) {
            ret.insert(pos, '+');
        }

        return ret.toString();
    }

@@ -304,6 +313,28 @@ public class PhoneNumberUtils
        }
    }

    /** GSM codes
     *  Finds if a GSM code includes the international prefix (+).
     *
     * @param number the number to dial.
     *
     * @return the position where the + char will be inserted, -1 if the GSM code was not found.
     */
    private static int
    addPlusChar(String number) {
        int pos = -1;

        if (number.startsWith(CLIR_OFF)) {
            pos = CLIR_OFF.length() - 1;
        }

        if (number.startsWith(CLIR_ON)) {
            pos = CLIR_ON.length() - 1;
        }

        return pos;
    }

    /**
     * Extracts the post-dial sequence of DTMF control digits, pauses, and
     * waits. Strips separators. This string may be empty, but will not be null