From 0205537536431204b11459e9d2d2eccf3924c6cd Mon Sep 17 00:00:00 2001 From: Daisuke Miyakawa Date: Tue, 24 Apr 2012 12:41:42 -0700 Subject: [PATCH] Add debug log for 5914560 and 6383850 This won't be shown in usual condition since in most cases the method will just use the block just above the logging and return true/false there. On the other hand this might be useful if the case is truely exceptional and thus this path is really used. Bug: 5914560 Bug: 6383850 Change-Id: I2242f93a9b905b5a39d997aa30d9fd6f5bfbdf49 --- .../android/telephony/PhoneNumberUtils.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java index 183beb1daf50c..5afe56c78e861 100644 --- a/telephony/java/android/telephony/PhoneNumberUtils.java +++ b/telephony/java/android/telephony/PhoneNumberUtils.java @@ -1711,6 +1711,13 @@ public class PhoneNumberUtils return false; } + // STOPSHIP: remove this after figuring out issue 5914560, 6383850. + Log.d(LOG_TAG, "System property doesn't provide any emergency numbers." + + " Use embedded logic for determining emergency numbers." + + " number: " + toLogSafePhoneNumber(number) + + ", Iso: " + defaultCountryIso + + ", useExactMatch: " + useExactMatch); + // No ecclist system property, so use our own list. if (defaultCountryIso != null) { ShortNumberUtil util = new ShortNumberUtil(); @@ -1728,6 +1735,21 @@ public class PhoneNumberUtils } } + private static String toLogSafePhoneNumber(String number) { + // Do exactly same thing as Uri#toSafeString() does, which will enable us to compare + // sanitized phone numbers. + StringBuilder builder = new StringBuilder(); + for (int i = 0; i < number.length(); i++) { + char c = number.charAt(i); + if (c == '-' || c == '@' || c == '.') { + builder.append(c); + } else { + builder.append('x'); + } + } + return builder.toString(); + } + /** * Checks if a given number is an emergency number for the country that the user is in. The * current country is determined using the CountryDetector.