summaryrefslogtreecommitdiffstats
path: root/telephony/java
diff options
context:
space:
mode:
authorShaopeng Jia <shaopengjia@google.com>2011-09-14 17:36:18 +0200
committerShaopeng Jia <shaopengjia@google.com>2011-09-16 20:28:39 +0200
commit6b7c3f8a1cd8b638defc28a3249746e99b8039ae (patch)
tree2df7c0af5951cfc7bcf9e127a19770d37631b02d /telephony/java
parent09bd49a8a74cafe7f03aee769bfe0748bf3c2b51 (diff)
downloadframeworks_base-6b7c3f8a1cd8b638defc28a3249746e99b8039ae.zip
frameworks_base-6b7c3f8a1cd8b638defc28a3249746e99b8039ae.tar.gz
frameworks_base-6b7c3f8a1cd8b638defc28a3249746e99b8039ae.tar.bz2
Update code to use location aware isEmergencyNumber.
Bug: 5247602 Change-Id: Ieeda4a17464795b3591db754bc991759609f88c2
Diffstat (limited to 'telephony/java')
-rw-r--r--telephony/java/android/telephony/PhoneNumberUtils.java27
-rw-r--r--telephony/java/com/android/internal/telephony/CallerInfo.java4
-rw-r--r--telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java4
-rw-r--r--telephony/java/com/android/internal/telephony/cdma/CdmaCallTracker.java5
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/GsmMmiCode.java2
5 files changed, 33 insertions, 9 deletions
diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java
index e898aac..3e8d255 100644
--- a/telephony/java/android/telephony/PhoneNumberUtils.java
+++ b/telephony/java/android/telephony/PhoneNumberUtils.java
@@ -24,6 +24,7 @@ import com.android.i18n.phonenumbers.Phonenumber.PhoneNumber;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
+import android.location.CountryDetector;
import android.net.Uri;
import android.os.SystemProperties;
import android.provider.Contacts;
@@ -1573,6 +1574,32 @@ public class PhoneNumberUtils
}
/**
+ * 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.
+ *
+ * @param number the number to look up.
+ * @param context the specific context which the number should be checked against
+ * @return if a phone number is an emergency number for a local country, based on the
+ * CountryDetector.
+ * @see android.location.CountryDetector
+ * @hide
+ */
+ public static boolean isLocalEmergencyNumber(String number, Context context) {
+ String countryIso;
+ CountryDetector detector = (CountryDetector) context.getSystemService(
+ Context.COUNTRY_DETECTOR);
+ if (detector != null) {
+ countryIso = detector.detectCountry().getCountryIso();
+ } else {
+ Locale locale = context.getResources().getConfiguration().locale;
+ countryIso = locale.getCountry();
+ Log.w(LOG_TAG, "No CountryDetector; falling back to countryIso based on locale: "
+ + countryIso);
+ }
+ return isEmergencyNumber(number, countryIso);
+ }
+
+ /**
* isVoiceMailNumber: checks a given number against the voicemail
* number provided by the RIL and SIM card. The caller must have
* the READ_PHONE_STATE credential.
diff --git a/telephony/java/com/android/internal/telephony/CallerInfo.java b/telephony/java/com/android/internal/telephony/CallerInfo.java
index 7c37a65..6324550 100644
--- a/telephony/java/com/android/internal/telephony/CallerInfo.java
+++ b/telephony/java/com/android/internal/telephony/CallerInfo.java
@@ -254,9 +254,7 @@ public class CallerInfo {
// Change the callerInfo number ONLY if it is an emergency number
// or if it is the voicemail number. If it is either, take a
// shortcut and skip the query.
- Locale locale = context.getResources().getConfiguration().locale;
- String countryIso = getCurrentCountryIso(context, locale);
- if (PhoneNumberUtils.isEmergencyNumber(number, countryIso)) {
+ if (PhoneNumberUtils.isLocalEmergencyNumber(number, context)) {
return new CallerInfo().markAsEmergency(context);
} else if (PhoneNumberUtils.isVoiceMailNumber(number)) {
return new CallerInfo().markAsVoiceMail();
diff --git a/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java b/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java
index 17734ca..4912749 100644
--- a/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java
+++ b/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java
@@ -403,9 +403,7 @@ public class CallerInfoAsyncQuery {
cw.number = number;
// check to see if these are recognized numbers, and use shortcuts if we can.
- CountryDetector detector = (CountryDetector) context.getSystemService(
- Context.COUNTRY_DETECTOR);
- if (PhoneNumberUtils.isEmergencyNumber(number, detector.detectCountry().getCountryIso())) {
+ if (PhoneNumberUtils.isLocalEmergencyNumber(number, context)) {
cw.event = EVENT_EMERGENCY_NUMBER;
} else if (PhoneNumberUtils.isVoiceMailNumber(number)) {
cw.event = EVENT_VOICEMAIL_NUMBER;
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaCallTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaCallTracker.java
index db19321..83efc51 100644
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaCallTracker.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaCallTracker.java
@@ -190,7 +190,8 @@ public final class CdmaCallTracker extends CallTracker {
String inEcm=SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE, "false");
boolean isPhoneInEcmMode = inEcm.equals("true");
- boolean isEmergencyCall = PhoneNumberUtils.isEmergencyNumber(dialString);
+ boolean isEmergencyCall =
+ PhoneNumberUtils.isLocalEmergencyNumber(dialString, phone.getContext());
// Cancel Ecm timer if a second emergency call is originating in Ecm mode
if (isPhoneInEcmMode && isEmergencyCall) {
@@ -1059,7 +1060,7 @@ public final class CdmaCallTracker extends CallTracker {
* Disable data call when emergency call is connected
*/
private void disableDataCallInEmergencyCall(String dialString) {
- if (PhoneNumberUtils.isEmergencyNumber(dialString)) {
+ if (PhoneNumberUtils.isLocalEmergencyNumber(dialString, phone.getContext())) {
if (Phone.DEBUG_PHONE) log("disableDataCallInEmergencyCall");
mIsInEmergencyCall = true;
phone.mDataConnectionTracker.setInternalDataEnabled(false);
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmMmiCode.java b/telephony/java/com/android/internal/telephony/gsm/GsmMmiCode.java
index 680b3cd..3799894 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmMmiCode.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmMmiCode.java
@@ -496,7 +496,7 @@ public final class GsmMmiCode extends Handler implements MmiCode {
return false;
}
- if (PhoneNumberUtils.isEmergencyNumber(dialString)) {
+ if (PhoneNumberUtils.isLocalEmergencyNumber(dialString, phone.getContext())) {
return false;
} else {
return isShortCodeUSSD(dialString, phone);