From cec25c4e8afdc56451f7405f8605c1d67433e2ff Mon Sep 17 00:00:00 2001 From: David Brown Date: Thu, 23 Jun 2011 14:17:27 -0700 Subject: [PATCH] CallerInfo query: Turn on "geo description" lookup for unknown numbers With the latest version of the external/libphonenumber library we now have real data for the PhoneNumberOfflineGeocoder.getDescriptionForNumber() feature. So enable it in the CallerInfo query. This means that the incoming call UI will now show a geo description like "California" or "Maryland" (along with the number) for unknown incoming numbers. I also needed to work around an issue with the latest phonenumber library: The new library apparently requires countryIso to be uppercase (e.g. "US") but the CountryDetector.detectCountry().getCountryIso() call currently returns "us", which causes PhoneNumberUtil.parse() to fail. (This also broke some ContactsProvider tests too.) So force the countryIso to uppercase for now. TESTED (on Crespo): - Incoming calls from an unknown number: ==> State name is now displayed. - Incoming calls from a number that matches a contact: ==> no change in behavior Bug: 4595580 Change-Id: I03126e1eee99d428e76bbbad5b3856be3874f549 --- .../com/android/internal/telephony/CallerInfo.java | 12 ++++++++++++ .../internal/telephony/CallerInfoAsyncQuery.java | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/telephony/java/com/android/internal/telephony/CallerInfo.java b/telephony/java/com/android/internal/telephony/CallerInfo.java index 76b8b65291de7..ab93e2a90ea9c 100644 --- a/telephony/java/com/android/internal/telephony/CallerInfo.java +++ b/telephony/java/com/android/internal/telephony/CallerInfo.java @@ -526,8 +526,20 @@ public class CallerInfo { + countryIso); } + // Temp workaround: The current libphonenumber library requires + // the countryIso to be uppercase (e.g. "US") but the + // detector.detectCountry().getCountryIso() call currently returns + // "us". Passing "us" to util.parse() will just result in a + // NumberParseException. + // So force the countryIso to uppercase for now. + // TODO: remove this once getCountryIso() is fixed to always + // return uppercase. + countryIso = countryIso.toUpperCase(); + PhoneNumber pn = null; try { + if (VDBG) Log.v(TAG, "parsing '" + number + + "' for countryIso '" + countryIso + "'..."); pn = util.parse(number, countryIso); if (VDBG) Log.v(TAG, "- parsed number: " + pn); } catch (NumberParseException e) { diff --git a/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java b/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java index 1bd9b0cff5903..2e8a7421b4d71 100644 --- a/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java +++ b/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java @@ -55,7 +55,7 @@ public class CallerInfoAsyncQuery { // PhoneNumberOfflineGeocoder to look up a "geo description"? // (TODO: This could become a flag in config.xml if it ever needs to be // configured on a per-product basis.) - private static final boolean ENABLE_UNKNOWN_NUMBER_GEO_DESCRIPTION = false; + private static final boolean ENABLE_UNKNOWN_NUMBER_GEO_DESCRIPTION = true; /** * Interface for a CallerInfoAsyncQueryHandler result return.