summaryrefslogtreecommitdiffstats
path: root/telephony/java
diff options
context:
space:
mode:
authorJake Hamby <jhamby@google.com>2013-10-08 16:31:16 -0700
committerJake Hamby <jhamby@google.com>2013-10-08 16:31:16 -0700
commit7f5bee01ec5d0a01bf63313dfa0798ccdb1eac99 (patch)
tree9ac8eb373c88a68a60f3a2d81a876e1d930619fc /telephony/java
parentc23ee579ac21f1f67a30d75e8ac7cbd49ba2fe7d (diff)
downloadframeworks_base-7f5bee01ec5d0a01bf63313dfa0798ccdb1eac99.zip
frameworks_base-7f5bee01ec5d0a01bf63313dfa0798ccdb1eac99.tar.gz
frameworks_base-7f5bee01ec5d0a01bf63313dfa0798ccdb1eac99.tar.bz2
Fix NPE in CallerInfo.getCurrentCountryIso().
Internal method CallerInfo.getCurrentCountryIso() can throw NPE if the country detector's detectCountry() method returns null. Add code to check that the Country is not null before calling getCountryIso() on it. Change fallback logic to call locale.getCountry() whenever countryIso was not assigned. Bug: 10607906 Change-Id: I08fe3f4d942f67c37a2e6ff0b067fe32ad8a6fa5
Diffstat (limited to 'telephony/java')
-rw-r--r--telephony/java/com/android/internal/telephony/CallerInfo.java29
1 files changed, 18 insertions, 11 deletions
diff --git a/telephony/java/com/android/internal/telephony/CallerInfo.java b/telephony/java/com/android/internal/telephony/CallerInfo.java
index 6978551..e3c664b 100644
--- a/telephony/java/com/android/internal/telephony/CallerInfo.java
+++ b/telephony/java/com/android/internal/telephony/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;
@@ -561,17 +562,23 @@ 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();
- Rlog.w(TAG, "No CountryDetector; falling back to countryIso based on locale: "
- + countryIso);
- }
- return countryIso;
+ 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 {
+ Rlog.e(TAG, "CountryDetector.detectCountry() returned null.");
+ }
+ }
+ if (countryIso == null) {
+ countryIso = locale.getCountry();
+ Rlog.w(TAG, "No CountryDetector; falling back to countryIso based on locale: "
+ + countryIso);
+ }
+ return countryIso;
}
/**