From a2c93480e35ec06e44f4ccfa8657eacf3353be46 Mon Sep 17 00:00:00 2001 From: Jay Shrauner Date: Mon, 21 Oct 2013 11:54:19 -0700 Subject: [PATCH] Fix CountryDetector NPE Fix CountryDetector NPE by calling CallerInfo.getCurrentCountryIso() which checks for potential nulls. Bug:11291034 Change-Id: I0a4412c432551c64ec30652d69636442653ee337 --- .../java/com/android/internal/telephony/CallerInfo.java | 4 ++++ .../com/android/internal/telephony/CallerInfoAsyncQuery.java | 5 +---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/telephony/java/com/android/internal/telephony/CallerInfo.java b/telephony/java/com/android/internal/telephony/CallerInfo.java index e3c664b4066c0..f6143eddbd387 100644 --- a/telephony/java/com/android/internal/telephony/CallerInfo.java +++ b/telephony/java/com/android/internal/telephony/CallerInfo.java @@ -581,6 +581,10 @@ public class CallerInfo { return countryIso; } + protected static String getCurrentCountryIso(Context context) { + return getCurrentCountryIso(context, Locale.getDefault()); + } + /** * @return a string debug representation of this instance. */ diff --git a/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java b/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java index dd5f6444c3d79..c63be914bfe5f 100644 --- a/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java +++ b/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java @@ -20,7 +20,6 @@ import android.content.AsyncQueryHandler; import android.content.Context; import android.database.Cursor; import android.database.SQLException; -import android.location.CountryDetector; import android.net.Uri; import android.os.Handler; import android.os.Looper; @@ -271,11 +270,9 @@ public class CallerInfoAsyncQuery { // Use the number entered by the user for display. if (!TextUtils.isEmpty(cw.number)) { - CountryDetector detector = (CountryDetector) mQueryContext.getSystemService( - Context.COUNTRY_DETECTOR); mCallerInfo.phoneNumber = PhoneNumberUtils.formatNumber(cw.number, mCallerInfo.normalizedNumber, - detector.detectCountry().getCountryIso()); + CallerInfo.getCurrentCountryIso(mQueryContext)); } }