Lines Matching refs:number

50  * Various utilities for dealing with phone number strings.
57 * (See "What is a phone number?" doc)
84 * global-phone-number = ["+"] 1*( DIGIT / written-sep )
145 /** Extracts the phone number from an Intent.
147 * @param intent the intent to get the number of
150 * @return the phone number that would be called by the intent, or
151 * <code>null</code> if the number cannot be found.
154 String number = null;
189 number = c.getString(c.getColumnIndex(phoneColumn));
193 Rlog.e(LOG_TAG, "Error getting phone number.", e);
200 return number;
281 * Strips separators from a phone number string.
282 * @param phoneNumber phone number to strip.
506 // if the number of dialable chars in a and b match, but the matched chars < MIN_MATCH,
582 // Different Country Calling Code. Must be different phone number.
675 // - the remaining non-separator number is 1
736 * Returns the last numDigits of the reversed phone number
759 * TOA_International number
792 * See Also TS 51.011 10.5.1 "dialing number/ssc string"
797 * @param length is the number of bytes including TOA byte
828 // This is an "international number" and should have
829 // a plus prepended to the dialing number. But there
849 // where there is no dialing number so they
859 // So no dialing number and we'll just
869 // Assume group 4 is a dialing number
885 // number (i.e. group 4) such as *31#+11234567890.
1054 * Convert a dialing number to BCD byte array
1056 * @param number dialing number string
1057 * if the dialing number starts with '+', set to international TOA
1061 numberToCalledPartyBCD(String number) {
1062 return numberToCalledPartyBCDHelper(number, false);
1070 numberToCalledPartyBCDHelper(String number, boolean includeLength) {
1071 int numberLenReal = number.length();
1073 boolean hasPlus = number.indexOf('+') != -1;
1087 char c = number.charAt(i);
1146 * Breaks the given number down and formats it according to the rules
1147 * for the country the number is from.
1149 * @param source The phone number to format
1151 * formatting rules aren't known for the number
1163 * Formats the given number with the given formatting type. Currently
1166 * @param source the phone number to format
1167 * @param defaultFormattingType The default formatting rules to apply if the number does
1169 * @return The phone number formatted with the given formatting type.
1182 * Returns the phone number formatting type for the given locale.
1198 * Formats a phone number in-place. Currently {@link #FORMAT_JAPAN} and {@link #FORMAT_NANP}
1201 * @param text The number to be formatted, will be modified with the formatting
1202 * @param defaultFormattingType The default formatting rules to apply if the number does
1241 * Formats a phone number in-place using the NANP formatting rules. Numbers will be formatted
1252 * @param text the number to be formatted, will be modified with the formatting
1273 // When scanning the number we record where dashes need to be added,
1300 // Only NANP number supported for now
1356 * Formats a phone number in-place using the Japanese formatting rules.
1367 * @param text the number to be formatted, will be modified with
1378 * Removes all dashes from the number.
1380 * @param text the number to clear from dashes
1396 * @param phoneNumber the phone number to format.
1398 * @return the E.164 representation, or null if the given phone number is not valid.
1407 * @param phoneNumber the phone number to format.
1409 * @return the RFC3966 representation, or null if the given phone number is not valid.
1416 * Formats the raw phone number (string) using the specified {@code formatIdentifier}.
1418 * The given phone number must have an area code and could have a country code.
1420 * The defaultCountryIso is used to validate the given number and generate the formatted number
1421 * if the specified number doesn't have a country code.
1423 * @param rawPhoneNumber The phone number to format.
1426 * @return the formatted representation, or null if the specified number is not valid.
1446 * @param phoneNumber The phone number.
1448 * @return {@code true} if the number is international, {@code false} otherwise.
1452 // If no phone number is provided, it can't be international.
1472 * Format a phone number.
1474 * If the given number doesn't have the country code, the phone will be
1478 * the number to be formatted.
1481 * be used if the given number doesn't have the country code.
1482 * @return the formatted number, or null if the given number is not valid.
1523 * Format the phone number only if the given number hasn't been formatted.
1525 * The number which has only dailable character is treated as not being
1529 * the number to be formatted.
1531 * the E164 format number whose country code is used if the given
1537 * @return the formatted number if the given number has been formatted,
1538 * otherwise, return the given number.
1553 // The number to be parsed is in E164 format, so the default region used doesn't
1570 * Normalize a phone number by removing the characters other than digits. If
1571 * the given number has keypad letters, the letters will be converted to
1574 * @param phoneNumber the number to be normalized.
1575 * @return the normalized number.
1602 * @param number the number to perform the replacement on.
1603 * @return the replaced number.
1605 public static String replaceUnicodeDigits(String number) {
1606 StringBuilder normalizedDigits = new StringBuilder(number.length());
1607 for (char c : number.toCharArray()) {
1638 * Checks a given number against the list of
1641 * @param number the number to look up.
1642 * @return true if the number is in the list of emergency numbers
1645 public static boolean isEmergencyNumber(String number) {
1646 return isEmergencyNumber(getDefaultVoiceSubId(), number);
1650 * Checks a given number against the list of
1654 * @param number the number to look up.
1655 * @return true if the number is in the list of emergency numbers
1659 public static boolean isEmergencyNumber(int subId, String number) {
1660 // Return true only if the specified number *exactly* matches
1662 return isEmergencyNumberInternal(subId, number, true /* useExactMatch */);
1666 * Checks if given number might *potentially* result in
1669 * Specifically, this method will return true if the specified number
1670 * is an emergency number according to the list managed by the RIL or
1671 * SIM, *or* if the specified number simply starts with the same
1678 * @param number the number to look up.
1679 * @return true if the number is in the list of emergency numbers
1680 * listed in the RIL / SIM, *or* if the number starts with the
1685 public static boolean isPotentialEmergencyNumber(String number) {
1686 return isPotentialEmergencyNumber(getDefaultVoiceSubId(), number);
1690 * Checks if given number might *potentially* result in
1693 * Specifically, this method will return true if the specified number
1694 * is an emergency number according to the list managed by the RIL or
1695 * SIM, *or* if the specified number simply starts with the same
1703 * @param number the number to look up.
1704 * @return true if the number is in the list of emergency numbers
1705 * listed in the RIL / SIM, *or* if the number starts with the
1709 public static boolean isPotentialEmergencyNumber(int subId, String number) {
1712 return isEmergencyNumberInternal(subId, number, false /* useExactMatch */);
1719 * @param number the number to look up.
1721 * @param useExactMatch if true, consider a number to be an emergency
1722 * number only if it *exactly* matches a number listed in
1723 * the RIL / SIM. If false, a number is considered to be an
1724 * emergency number if it simply starts with the same digits
1727 * number that could *potentially* result in emergency calls
1729 * after a valid emergency number.)
1731 * @return true if the number is in the list of emergency numbers
1734 private static boolean isEmergencyNumberInternal(String number, boolean useExactMatch) {
1735 return isEmergencyNumberInternal(getDefaultVoiceSubId(), number, useExactMatch);
1743 * @param number the number to look up.
1745 * @param useExactMatch if true, consider a number to be an emergency
1746 * number only if it *exactly* matches a number listed in
1747 * the RIL / SIM. If false, a number is considered to be an
1748 * emergency number if it simply starts with the same digits
1751 * number that could *potentially* result in emergency calls
1753 * after a valid emergency number.)
1755 * @return true if the number is in the list of emergency numbers
1758 private static boolean isEmergencyNumberInternal(int subId, String number,
1760 return isEmergencyNumberInternal(subId, number, null, useExactMatch);
1764 * Checks if a given number is an emergency number for a specific country.
1766 * @param number the number to look up.
1767 * @param defaultCountryIso the specific country which the number should be checked against
1768 * @return if the number is an emergency number for the specific country, then return true,
1773 public static boolean isEmergencyNumber(String number, String defaultCountryIso) {
1774 return isEmergencyNumber(getDefaultVoiceSubId(), number, defaultCountryIso);
1778 * Checks if a given number is an emergency number for a specific country.
1781 * @param number the number to look up.
1782 * @param defaultCountryIso the specific country which the number should be checked against
1783 * @return if the number is an emergency number for the specific country, then return true,
1787 public static boolean isEmergencyNumber(int subId, String number, String defaultCountryIso) {
1788 return isEmergencyNumberInternal(subId, number,
1794 * Checks if a given number might *potentially* result in a call to an
1797 * Specifically, this method will return true if the specified number
1798 * is an emergency number in the specified country, *or* if the number
1799 * simply starts with the same digits as any emergency number for that
1806 * @param number the number to look up.
1807 * @param defaultCountryIso the specific country which the number should be checked against
1808 * @return true if the number is an emergency number for the specific
1809 * country, *or* if the number starts with the same digits as
1814 public static boolean isPotentialEmergencyNumber(String number, String defaultCountryIso) {
1815 return isPotentialEmergencyNumber(getDefaultVoiceSubId(), number, defaultCountryIso);
1819 * Checks if a given number might *potentially* result in a call to an
1822 * Specifically, this method will return true if the specified number
1823 * is an emergency number in the specified country, *or* if the number
1824 * simply starts with the same digits as any emergency number for that
1832 * @param number the number to look up.
1833 * @param defaultCountryIso the specific country which the number should be checked against
1834 * @return true if the number is an emergency number for the specific
1835 * country, *or* if the number starts with the same digits as
1839 public static boolean isPotentialEmergencyNumber(int subId, String number,
1841 return isEmergencyNumberInternal(subId, number,
1850 * @param number the number to look up.
1851 * @param defaultCountryIso the specific country which the number should be checked against
1852 * @param useExactMatch if true, consider a number to be an emergency
1853 * number only if it *exactly* matches a number listed in
1854 * the RIL / SIM. If false, a number is considered to be an
1855 * emergency number if it simply starts with the same digits
1858 * @return true if the number is an emergency number for the specified country.
1860 private static boolean isEmergencyNumberInternal(String number,
1863 return isEmergencyNumberInternal(getDefaultVoiceSubId(), number, defaultCountryIso,
1872 * @param number the number to look up.
1873 * @param defaultCountryIso the specific country which the number should be checked against
1874 * @param useExactMatch if true, consider a number to be an emergency
1875 * number only if it *exactly* matches a number listed in
1876 * the RIL / SIM. If false, a number is considered to be an
1877 * emergency number if it simply starts with the same digits
1880 * @return true if the number is an emergency number for the specified country.
1883 private static boolean isEmergencyNumberInternal(int subId, String number,
1886 // If the number passed in is null, just return false:
1887 if (number == null) return false;
1889 // If the number passed in is a SIP address, return false, since the
1896 if (isUriNumber(number)) {
1900 // Strip the separators from the number before comparing it
1902 number = extractNetworkPortionAlt(number);
1925 // It is not possible to append additional digits to an emergency number to dial
1926 // the number in Brazil - it won't connect.
1928 if (number.equals(emergencyNum)) {
1932 if (number.startsWith(emergencyNum)) {
1951 if (number.equals(emergencyNum)) {
1955 if (number.startsWith(emergencyNum)) {
1965 return info.isEmergencyNumber(number, defaultCountryIso);
1967 return info.connectsToEmergencyNumber(number, defaultCountryIso);
1975 * Checks if a given number is an emergency number for the country that the user is in.
1977 * @param number the number to look up.
1978 * @param context the specific context which the number should be checked against
1979 * @return true if the specified number is an emergency number for the country the user
1982 public static boolean isLocalEmergencyNumber(Context context, String number) {
1983 return isLocalEmergencyNumber(context, getDefaultVoiceSubId(), number);
1987 * Checks if a given number is an emergency number for the country that the user is in.
1990 * @param number the number to look up.
1991 * @param context the specific context which the number should be checked against
1992 * @return true if the specified number is an emergency number for the country the user
1996 public static boolean isLocalEmergencyNumber(Context context, int subId, String number) {
1997 return isLocalEmergencyNumberInternal(subId, number,
2003 * Checks if a given number might *potentially* result in a call to an
2007 * Specifically, this method will return true if the specified number
2008 * is an emergency number in the current country, *or* if the number
2009 * simply starts with the same digits as any emergency number for the
2016 * @param number the number to look up.
2017 * @param context the specific context which the number should be checked against
2018 * @return true if the specified number is an emergency number for a local country, based on the
2024 public static boolean isPotentialLocalEmergencyNumber(Context context, String number) {
2025 return isPotentialLocalEmergencyNumber(context, getDefaultVoiceSubId(), number);
2029 * Checks if a given number might *potentially* result in a call to an
2033 * Specifically, this method will return true if the specified number
2034 * is an emergency number in the current country, *or* if the number
2035 * simply starts with the same digits as any emergency number for the
2043 * @param number the number to look up.
2044 * @param context the specific context which the number should be checked against
2045 * @return true if the specified number is an emergency number for a local country, based on the
2051 String number) {
2052 return isLocalEmergencyNumberInternal(subId, number,
2061 * @param number the number to look up.
2062 * @param context the specific context which the number should be checked against
2063 * @param useExactMatch if true, consider a number to be an emergency
2064 * number only if it *exactly* matches a number listed in
2065 * the RIL / SIM. If false, a number is considered to be an
2066 * emergency number if it simply starts with the same digits
2069 * @return true if the specified number is an emergency number for a
2075 private static boolean isLocalEmergencyNumberInternal(String number,
2078 return isLocalEmergencyNumberInternal(getDefaultVoiceSubId(), number, context,
2087 * @param number the number to look up.
2088 * @param context the specific context which the number should be checked against
2089 * @param useExactMatch if true, consider a number to be an emergency
2090 * number only if it *exactly* matches a number listed in
2091 * the RIL / SIM. If false, a number is considered to be an
2092 * emergency number if it simply starts with the same digits
2095 * @return true if the specified number is an emergency number for a
2099 private static boolean isLocalEmergencyNumberInternal(int subId, String number,
2113 return isEmergencyNumberInternal(subId, number, countryIso, useExactMatch);
2117 * isVoiceMailNumber: checks a given number against the voicemail
2118 * number provided by the RIL and SIM card. The caller must have
2121 * @param number the number to look up.
2122 * @return true if the number is in the list of voicemail. False
2124 * to read the VM number.
2126 public static boolean isVoiceMailNumber(String number) {
2127 return isVoiceMailNumber(SubscriptionManager.getDefaultSubscriptionId(), number);
2131 * isVoiceMailNumber: checks a given number against the voicemail
2132 * number provided by the RIL and SIM card. The caller must have
2136 * @param number the number to look up.
2137 * @return true if the number is in the list of voicemail. False
2139 * to read the VM number.
2142 public static boolean isVoiceMailNumber(int subId, String number) {
2143 return isVoiceMailNumber(null, subId, number);
2147 * isVoiceMailNumber: checks a given number against the voicemail
2148 * number provided by the RIL and SIM card. The caller must have
2153 * @param number the number to look up.
2154 * @return true if the number is in the list of voicemail. False
2156 * to read the VM number.
2159 public static boolean isVoiceMailNumber(Context context, int subId, String number) {
2173 + ", number=" + number);
2178 // Strip the separators from the number before comparing it
2180 number = extractNetworkPortionAlt(number);
2181 if (TextUtils.isEmpty(number)) {
2182 if (DBG) log("isVoiceMailNumber: number is empty after stripping");
2186 // check if the carrier considers MDN to be an additional voicemail number
2202 if (DBG) log("isVoiceMailNumber: treating mdn as additional vm number");
2203 return compare(number, vmNumber) || compare(number, mdn);
2206 return compare(number, vmNumber);
2212 * specified phone number into the equivalent numeric digits,
2278 * This function checks if there is a plus sign (+) in the passed-in dialing number.
2322 * Process phone number for CDMA, converting plus code using the home network number format.
2391 // Format the string based on the rules for the country the number is from,
2444 * containing a phone number in its entirety.
2446 * @param phoneNumber A {@code CharSequence} the entirety of which represents a phone number.
2460 * annotating that location as containing a phone number.
2463 * @param start The starting character position of the phone number in {@code s}.
2464 * @param endExclusive The position after the ending character in the phone number {@code s}.
2475 * containing a phone number in its entirety.
2477 * @param phoneNumber A {@code CharSequence} the entirety of which represents a phone number.
2490 * annotating that location as containing a phone number.
2493 * @param start The starting character position of the phone number in {@code s}.
2494 * @param end The ending character position of the phone number in {@code s}.
2508 * @param phoneNumberString A {@code String} the entirety of which represents a phone number.
2516 // Parse the phone number
2542 // Split a phone number like "+20(123)-456#" using spaces, ignoring anything that is not
2544 private static String splitAtNonNumerics(CharSequence number) {
2545 StringBuilder sb = new StringBuilder(number.length());
2546 for (int i = 0; i < number.length(); i++) {
2547 sb.append(PhoneNumberUtils.is12Key(number.charAt(i))
2548 ? number.charAt(i)
2634 * Determines if the specified number is actually a URI
2635 * (i.e. a SIP address) rather than a regular PSTN phone number,
2636 * based on whether or not the number contains an "@" character.
2639 * @param number
2640 * @return true if number contains @
2642 public static boolean isUriNumber(String number) {
2645 // will ever be found in a legal PSTN number.)
2646 return number != null && (number.contains("@") || number.contains("%40"));
2653 * @param number SIP address of the form "username@domainname"
2659 public static String getUsernameFromUriNumber(String number) {
2662 int delimiterIndex = number.indexOf('@');
2664 delimiterIndex = number.indexOf("%40");
2668 "getUsernameFromUriNumber: no delimiter found in SIP addr '" + number + "'");
2669 delimiterIndex = number.length();
2671 return number.substring(0, delimiterIndex);
2676 * scheme {@link Uri}. If the source {@link Uri} does not contain a valid number, or is not
2686 // Per RFC3261, the "user" can be a telephone number.
2688 // In this case, the phone number is in the user field of the URI, and the parameters can be
2691 // A SIP URI can also specify a phone number in a format similar to:
2693 // In this case, the phone number is again in user field and the parameters can be ignored.
2704 String number = source.getSchemeSpecificPart();
2705 String numberParts[] = number.split("[@;:]");
2711 number = numberParts[0];
2713 return Uri.fromParts(PhoneAccount.SCHEME_TEL, number, null);
2718 * If the number format is
2728 // Convert the plus sign to the default IDP since it's an international number
2733 // TODO: for nonNanp, should the '+' be removed if following number is country code
2784 * This method takes a phone number and makes a valid SQL "LIKE"
2903 * If true, the number is country calling code.
3099 * The config held calling number conversion map, expected to convert to emergency number.
3104 * Converts to emergency number based on the conversion map.
3108 * @return The converted emergency number if the number matches conversion map,
3109 * otherwise original number.
3113 public static String convertToEmergencyNumber(Context context, String number) {
3114 if (context == null || TextUtils.isEmpty(number)) {
3115 return number;
3118 String normalizedNumber = normalizeNumber(number);
3120 // The number is already emergency number. Skip conversion.
3122 return number;
3132 return number;
3165 return number;