Loading telephony/java/android/telephony/PhoneNumberUtils.java +27 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import com.android.i18n.phonenumbers.Phonenumber.PhoneNumber; import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.location.CountryDetector; import android.net.Uri; import android.os.SystemProperties; import android.provider.Contacts; Loading Loading @@ -1572,6 +1573,32 @@ public class PhoneNumberUtils return isEmergencyNumber(number); } /** * Checks if a given number is an emergency number for the country that the user is in. The * current country is determined using the CountryDetector. * * @param number the number to look up. * @param context the specific context which the number should be checked against * @return if a phone number is an emergency number for a local country, based on the * CountryDetector. * @see android.location.CountryDetector * @hide */ public static boolean isLocalEmergencyNumber(String number, Context context) { String countryIso; CountryDetector detector = (CountryDetector) context.getSystemService( Context.COUNTRY_DETECTOR); if (detector != null) { countryIso = detector.detectCountry().getCountryIso(); } else { Locale locale = context.getResources().getConfiguration().locale; countryIso = locale.getCountry(); Log.w(LOG_TAG, "No CountryDetector; falling back to countryIso based on locale: " + countryIso); } return isEmergencyNumber(number, countryIso); } /** * isVoiceMailNumber: checks a given number against the voicemail * number provided by the RIL and SIM card. The caller must have Loading telephony/java/com/android/internal/telephony/CallerInfo.java +1 −3 Original line number Diff line number Diff line Loading @@ -254,9 +254,7 @@ public class CallerInfo { // Change the callerInfo number ONLY if it is an emergency number // or if it is the voicemail number. If it is either, take a // shortcut and skip the query. Locale locale = context.getResources().getConfiguration().locale; String countryIso = getCurrentCountryIso(context, locale); if (PhoneNumberUtils.isEmergencyNumber(number, countryIso)) { if (PhoneNumberUtils.isLocalEmergencyNumber(number, context)) { return new CallerInfo().markAsEmergency(context); } else if (PhoneNumberUtils.isVoiceMailNumber(number)) { return new CallerInfo().markAsVoiceMail(); Loading telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java +1 −3 Original line number Diff line number Diff line Loading @@ -403,9 +403,7 @@ public class CallerInfoAsyncQuery { cw.number = number; // check to see if these are recognized numbers, and use shortcuts if we can. CountryDetector detector = (CountryDetector) context.getSystemService( Context.COUNTRY_DETECTOR); if (PhoneNumberUtils.isEmergencyNumber(number, detector.detectCountry().getCountryIso())) { if (PhoneNumberUtils.isLocalEmergencyNumber(number, context)) { cw.event = EVENT_EMERGENCY_NUMBER; } else if (PhoneNumberUtils.isVoiceMailNumber(number)) { cw.event = EVENT_VOICEMAIL_NUMBER; Loading telephony/java/com/android/internal/telephony/cdma/CdmaCallTracker.java +3 −2 Original line number Diff line number Diff line Loading @@ -190,7 +190,8 @@ public final class CdmaCallTracker extends CallTracker { String inEcm=SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE, "false"); boolean isPhoneInEcmMode = inEcm.equals("true"); boolean isEmergencyCall = PhoneNumberUtils.isEmergencyNumber(dialString); boolean isEmergencyCall = PhoneNumberUtils.isLocalEmergencyNumber(dialString, phone.getContext()); // Cancel Ecm timer if a second emergency call is originating in Ecm mode if (isPhoneInEcmMode && isEmergencyCall) { Loading Loading @@ -1059,7 +1060,7 @@ public final class CdmaCallTracker extends CallTracker { * Disable data call when emergency call is connected */ private void disableDataCallInEmergencyCall(String dialString) { if (PhoneNumberUtils.isEmergencyNumber(dialString)) { if (PhoneNumberUtils.isLocalEmergencyNumber(dialString, phone.getContext())) { if (Phone.DEBUG_PHONE) log("disableDataCallInEmergencyCall"); mIsInEmergencyCall = true; phone.mDataConnectionTracker.setInternalDataEnabled(false); Loading telephony/java/com/android/internal/telephony/gsm/GsmMmiCode.java +1 −1 Original line number Diff line number Diff line Loading @@ -496,7 +496,7 @@ public final class GsmMmiCode extends Handler implements MmiCode { return false; } if (PhoneNumberUtils.isEmergencyNumber(dialString)) { if (PhoneNumberUtils.isLocalEmergencyNumber(dialString, phone.getContext())) { return false; } else { return isShortCodeUSSD(dialString, phone); Loading Loading
telephony/java/android/telephony/PhoneNumberUtils.java +27 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import com.android.i18n.phonenumbers.Phonenumber.PhoneNumber; import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.location.CountryDetector; import android.net.Uri; import android.os.SystemProperties; import android.provider.Contacts; Loading Loading @@ -1572,6 +1573,32 @@ public class PhoneNumberUtils return isEmergencyNumber(number); } /** * Checks if a given number is an emergency number for the country that the user is in. The * current country is determined using the CountryDetector. * * @param number the number to look up. * @param context the specific context which the number should be checked against * @return if a phone number is an emergency number for a local country, based on the * CountryDetector. * @see android.location.CountryDetector * @hide */ public static boolean isLocalEmergencyNumber(String number, Context context) { String countryIso; CountryDetector detector = (CountryDetector) context.getSystemService( Context.COUNTRY_DETECTOR); if (detector != null) { countryIso = detector.detectCountry().getCountryIso(); } else { Locale locale = context.getResources().getConfiguration().locale; countryIso = locale.getCountry(); Log.w(LOG_TAG, "No CountryDetector; falling back to countryIso based on locale: " + countryIso); } return isEmergencyNumber(number, countryIso); } /** * isVoiceMailNumber: checks a given number against the voicemail * number provided by the RIL and SIM card. The caller must have Loading
telephony/java/com/android/internal/telephony/CallerInfo.java +1 −3 Original line number Diff line number Diff line Loading @@ -254,9 +254,7 @@ public class CallerInfo { // Change the callerInfo number ONLY if it is an emergency number // or if it is the voicemail number. If it is either, take a // shortcut and skip the query. Locale locale = context.getResources().getConfiguration().locale; String countryIso = getCurrentCountryIso(context, locale); if (PhoneNumberUtils.isEmergencyNumber(number, countryIso)) { if (PhoneNumberUtils.isLocalEmergencyNumber(number, context)) { return new CallerInfo().markAsEmergency(context); } else if (PhoneNumberUtils.isVoiceMailNumber(number)) { return new CallerInfo().markAsVoiceMail(); Loading
telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java +1 −3 Original line number Diff line number Diff line Loading @@ -403,9 +403,7 @@ public class CallerInfoAsyncQuery { cw.number = number; // check to see if these are recognized numbers, and use shortcuts if we can. CountryDetector detector = (CountryDetector) context.getSystemService( Context.COUNTRY_DETECTOR); if (PhoneNumberUtils.isEmergencyNumber(number, detector.detectCountry().getCountryIso())) { if (PhoneNumberUtils.isLocalEmergencyNumber(number, context)) { cw.event = EVENT_EMERGENCY_NUMBER; } else if (PhoneNumberUtils.isVoiceMailNumber(number)) { cw.event = EVENT_VOICEMAIL_NUMBER; Loading
telephony/java/com/android/internal/telephony/cdma/CdmaCallTracker.java +3 −2 Original line number Diff line number Diff line Loading @@ -190,7 +190,8 @@ public final class CdmaCallTracker extends CallTracker { String inEcm=SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE, "false"); boolean isPhoneInEcmMode = inEcm.equals("true"); boolean isEmergencyCall = PhoneNumberUtils.isEmergencyNumber(dialString); boolean isEmergencyCall = PhoneNumberUtils.isLocalEmergencyNumber(dialString, phone.getContext()); // Cancel Ecm timer if a second emergency call is originating in Ecm mode if (isPhoneInEcmMode && isEmergencyCall) { Loading Loading @@ -1059,7 +1060,7 @@ public final class CdmaCallTracker extends CallTracker { * Disable data call when emergency call is connected */ private void disableDataCallInEmergencyCall(String dialString) { if (PhoneNumberUtils.isEmergencyNumber(dialString)) { if (PhoneNumberUtils.isLocalEmergencyNumber(dialString, phone.getContext())) { if (Phone.DEBUG_PHONE) log("disableDataCallInEmergencyCall"); mIsInEmergencyCall = true; phone.mDataConnectionTracker.setInternalDataEnabled(false); Loading
telephony/java/com/android/internal/telephony/gsm/GsmMmiCode.java +1 −1 Original line number Diff line number Diff line Loading @@ -496,7 +496,7 @@ public final class GsmMmiCode extends Handler implements MmiCode { return false; } if (PhoneNumberUtils.isEmergencyNumber(dialString)) { if (PhoneNumberUtils.isLocalEmergencyNumber(dialString, phone.getContext())) { return false; } else { return isShortCodeUSSD(dialString, phone); Loading