Loading telephony/java/android/telephony/PhoneNumberUtils.java +27 −6 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import com.android.i18n.phonenumbers.ShortNumberUtil; import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.location.Country; import android.location.CountryDetector; import android.net.Uri; import android.os.SystemProperties; Loading Loading @@ -77,6 +78,7 @@ public class PhoneNumberUtils static final String LOG_TAG = "PhoneNumberUtils"; private static final boolean DBG = false; private static Country sCountryDetector = null; /* * global-phone-number = ["+"] 1*( DIGIT / written-sep ) * written-sep = ("-"/".") Loading Loading @@ -2021,12 +2023,9 @@ public class PhoneNumberUtils private static boolean isLocalEmergencyNumberInternal(int subId, String number, Context context, boolean useExactMatch) { String countryIso; CountryDetector detector = (CountryDetector) context.getSystemService( Context.COUNTRY_DETECTOR); if (detector != null && detector.detectCountry() != null) { countryIso = detector.detectCountry().getCountryIso(); } else { String countryIso = getCountryIso(context); Rlog.w(LOG_TAG, "isLocalEmergencyNumberInternal" + countryIso); if (countryIso == null) { Locale locale = context.getResources().getConfiguration().locale; countryIso = locale.getCountry(); Rlog.w(LOG_TAG, "No CountryDetector; falling back to countryIso based on locale: " Loading @@ -2035,6 +2034,28 @@ public class PhoneNumberUtils return isEmergencyNumberInternal(subId, number, countryIso, useExactMatch); } private static String getCountryIso(Context context) { Rlog.w(LOG_TAG, "getCountryIso " + sCountryDetector); if (sCountryDetector == null) { CountryDetector detector = (CountryDetector) context.getSystemService( Context.COUNTRY_DETECTOR); if (detector != null) { sCountryDetector = detector.detectCountry(); } } if (sCountryDetector == null) { return null; } else { return sCountryDetector.getCountryIso(); } } /** @hide */ public static void resetCountryDetectorInfo() { sCountryDetector = null; } /** * isVoiceMailNumber: checks a given number against the voicemail * number provided by the RIL and SIM card. The caller must have Loading Loading
telephony/java/android/telephony/PhoneNumberUtils.java +27 −6 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import com.android.i18n.phonenumbers.ShortNumberUtil; import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.location.Country; import android.location.CountryDetector; import android.net.Uri; import android.os.SystemProperties; Loading Loading @@ -77,6 +78,7 @@ public class PhoneNumberUtils static final String LOG_TAG = "PhoneNumberUtils"; private static final boolean DBG = false; private static Country sCountryDetector = null; /* * global-phone-number = ["+"] 1*( DIGIT / written-sep ) * written-sep = ("-"/".") Loading Loading @@ -2021,12 +2023,9 @@ public class PhoneNumberUtils private static boolean isLocalEmergencyNumberInternal(int subId, String number, Context context, boolean useExactMatch) { String countryIso; CountryDetector detector = (CountryDetector) context.getSystemService( Context.COUNTRY_DETECTOR); if (detector != null && detector.detectCountry() != null) { countryIso = detector.detectCountry().getCountryIso(); } else { String countryIso = getCountryIso(context); Rlog.w(LOG_TAG, "isLocalEmergencyNumberInternal" + countryIso); if (countryIso == null) { Locale locale = context.getResources().getConfiguration().locale; countryIso = locale.getCountry(); Rlog.w(LOG_TAG, "No CountryDetector; falling back to countryIso based on locale: " Loading @@ -2035,6 +2034,28 @@ public class PhoneNumberUtils return isEmergencyNumberInternal(subId, number, countryIso, useExactMatch); } private static String getCountryIso(Context context) { Rlog.w(LOG_TAG, "getCountryIso " + sCountryDetector); if (sCountryDetector == null) { CountryDetector detector = (CountryDetector) context.getSystemService( Context.COUNTRY_DETECTOR); if (detector != null) { sCountryDetector = detector.detectCountry(); } } if (sCountryDetector == null) { return null; } else { return sCountryDetector.getCountryIso(); } } /** @hide */ public static void resetCountryDetectorInfo() { sCountryDetector = null; } /** * isVoiceMailNumber: checks a given number against the voicemail * number provided by the RIL and SIM card. The caller must have Loading