|
24 | 24 | import android.content.Context; |
25 | 25 | import android.content.Intent; |
26 | 26 | import android.database.Cursor; |
| 27 | +import android.location.CountryDetector; |
27 | 28 | import android.net.Uri; |
28 | 29 | import android.os.SystemProperties; |
29 | 30 | import android.provider.Contacts; |
@@ -1572,6 +1573,32 @@ public static boolean isEmergencyNumber(String number, String defaultCountryIso) |
1572 | 1573 | return isEmergencyNumber(number); |
1573 | 1574 | } |
1574 | 1575 |
|
| 1576 | + /** |
| 1577 | + * Checks if a given number is an emergency number for the country that the user is in. The |
| 1578 | + * current country is determined using the CountryDetector. |
| 1579 | + * |
| 1580 | + * @param number the number to look up. |
| 1581 | + * @param context the specific context which the number should be checked against |
| 1582 | + * @return if a phone number is an emergency number for a local country, based on the |
| 1583 | + * CountryDetector. |
| 1584 | + * @see android.location.CountryDetector |
| 1585 | + * @hide |
| 1586 | + */ |
| 1587 | + public static boolean isLocalEmergencyNumber(String number, Context context) { |
| 1588 | + String countryIso; |
| 1589 | + CountryDetector detector = (CountryDetector) context.getSystemService( |
| 1590 | + Context.COUNTRY_DETECTOR); |
| 1591 | + if (detector != null) { |
| 1592 | + countryIso = detector.detectCountry().getCountryIso(); |
| 1593 | + } else { |
| 1594 | + Locale locale = context.getResources().getConfiguration().locale; |
| 1595 | + countryIso = locale.getCountry(); |
| 1596 | + Log.w(LOG_TAG, "No CountryDetector; falling back to countryIso based on locale: " |
| 1597 | + + countryIso); |
| 1598 | + } |
| 1599 | + return isEmergencyNumber(number, countryIso); |
| 1600 | + } |
| 1601 | + |
1575 | 1602 | /** |
1576 | 1603 | * isVoiceMailNumber: checks a given number against the voicemail |
1577 | 1604 | * number provided by the RIL and SIM card. The caller must have |
|
0 commit comments