Loading telephony/java/android/telephony/TelephonyManager.java +8 −3 Original line number Diff line number Diff line Loading @@ -10256,15 +10256,20 @@ public class TelephonyManager { } /** * Checks if the supplied number is an emergency number based on current locale, sim, default, * modem and network. * Identifies if the supplied phone number is an emergency number that matches a known * emergency number based on current locale, SIM card(s), Android database, modem, network, * or defaults. * * <p>This method assumes that only dialable phone numbers are passed in; non-dialable * numbers are not considered emergency numbers. A dialable phone number consists only * of characters/digits identified by {@link PhoneNumberUtils#isDialable(char)}. * * <p>The subscriptions which the identification would be based on, are all the active * subscriptions, no matter which subscription could be used to create TelephonyManager. * * @param number - the number to look up * @return {@code true} if the given number is an emergency number based on current locale, * sim, modem and network; {@code false} otherwise. * SIM card(s), Android database, modem, network or defaults; {@code false} otherwise. */ public boolean isEmergencyNumber(@NonNull String number) { try { Loading telephony/java/android/telephony/emergency/EmergencyNumber.java +12 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.hardware.radio.V1_4.EmergencyNumberSource; import android.hardware.radio.V1_4.EmergencyServiceCategory; import android.os.Parcel; import android.os.Parcelable; import android.telephony.PhoneNumberUtils; import android.telephony.Rlog; import java.lang.annotation.Retention; Loading Loading @@ -673,11 +674,20 @@ public final class EmergencyNumber implements Parcelable, Comparable<EmergencyNu } /** * Validate Emergency Number address that only allows '0'-'9', '*', or '#' * Validate Emergency Number address that only contains the dialable character * {@link PhoneNumberUtils#isDialable(char)} * * @hide */ public static boolean validateEmergencyNumberAddress(String address) { return address.matches("[0-9*#]+"); if (address == null) { return false; } for (char c : address.toCharArray()) { if (!PhoneNumberUtils.isDialable(c)) { return false; } } return true; } } Loading
telephony/java/android/telephony/TelephonyManager.java +8 −3 Original line number Diff line number Diff line Loading @@ -10256,15 +10256,20 @@ public class TelephonyManager { } /** * Checks if the supplied number is an emergency number based on current locale, sim, default, * modem and network. * Identifies if the supplied phone number is an emergency number that matches a known * emergency number based on current locale, SIM card(s), Android database, modem, network, * or defaults. * * <p>This method assumes that only dialable phone numbers are passed in; non-dialable * numbers are not considered emergency numbers. A dialable phone number consists only * of characters/digits identified by {@link PhoneNumberUtils#isDialable(char)}. * * <p>The subscriptions which the identification would be based on, are all the active * subscriptions, no matter which subscription could be used to create TelephonyManager. * * @param number - the number to look up * @return {@code true} if the given number is an emergency number based on current locale, * sim, modem and network; {@code false} otherwise. * SIM card(s), Android database, modem, network or defaults; {@code false} otherwise. */ public boolean isEmergencyNumber(@NonNull String number) { try { Loading
telephony/java/android/telephony/emergency/EmergencyNumber.java +12 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.hardware.radio.V1_4.EmergencyNumberSource; import android.hardware.radio.V1_4.EmergencyServiceCategory; import android.os.Parcel; import android.os.Parcelable; import android.telephony.PhoneNumberUtils; import android.telephony.Rlog; import java.lang.annotation.Retention; Loading Loading @@ -673,11 +674,20 @@ public final class EmergencyNumber implements Parcelable, Comparable<EmergencyNu } /** * Validate Emergency Number address that only allows '0'-'9', '*', or '#' * Validate Emergency Number address that only contains the dialable character * {@link PhoneNumberUtils#isDialable(char)} * * @hide */ public static boolean validateEmergencyNumberAddress(String address) { return address.matches("[0-9*#]+"); if (address == null) { return false; } for (char c : address.toCharArray()) { if (!PhoneNumberUtils.isDialable(c)) { return false; } } return true; } }