diff options
Diffstat (limited to 'src/com/android/incallui/CallerInfo.java')
-rw-r--r-- | src/com/android/incallui/CallerInfo.java | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/src/com/android/incallui/CallerInfo.java b/src/com/android/incallui/CallerInfo.java index 4047d990..c5d39719 100644 --- a/src/com/android/incallui/CallerInfo.java +++ b/src/com/android/incallui/CallerInfo.java @@ -20,6 +20,7 @@ import android.content.Context; import android.database.Cursor; import android.graphics.Bitmap; import android.graphics.drawable.Drawable; +import android.location.Country; import android.location.CountryDetector; import android.net.Uri; import android.provider.ContactsContract.CommonDataKinds.Phone; @@ -560,17 +561,27 @@ public class CallerInfo { * is in. */ private static String getCurrentCountryIso(Context context, Locale locale) { - String countryIso; - CountryDetector detector = (CountryDetector) context.getSystemService( - Context.COUNTRY_DETECTOR); - if (detector != null) { - countryIso = detector.detectCountry().getCountryIso(); - } else { - countryIso = locale.getCountry(); - Log.v(TAG, "No CountryDetector; falling back to countryIso based on locale: " + String countryIso = null; + CountryDetector detector = (CountryDetector) context.getSystemService( + Context.COUNTRY_DETECTOR); + if (detector != null) { + Country country = detector.detectCountry(); + if (country != null) { + countryIso = country.getCountryIso(); + } else { + Log.e(TAG, "CountryDetector.detectCountry() returned null."); + } + } + if (countryIso == null) { + countryIso = locale.getCountry(); + Log.w(TAG, "No CountryDetector; falling back to countryIso based on locale: " + countryIso); - } - return countryIso; + } + return countryIso; + } + + protected static String getCurrentCountryIso(Context context) { + return getCurrentCountryIso(context, Locale.getDefault()); } /** |