Merge "Revert "Use TelephonyManager#isEmergencyNumber() instead""

This commit is contained in:
Treehugger Robot
2021-05-11 17:10:29 +00:00
committed by Gerrit Code Review
3 changed files with 13 additions and 4 deletions

View File

@@ -28,6 +28,7 @@ import android.location.LocationManager;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.SystemClock; import android.os.SystemClock;
import android.os.UserHandle; import android.os.UserHandle;
import android.telephony.PhoneNumberUtils;
import android.telephony.PhoneStateListener; import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.util.Log; import android.util.Log;
@@ -160,7 +161,7 @@ public class GpsNetInitiatedHandler {
be set to true when the phone is having emergency call, and then will be set to true when the phone is having emergency call, and then will
be set to false by mPhoneStateListener when the emergency call ends. be set to false by mPhoneStateListener when the emergency call ends.
*/ */
mIsInEmergencyCall = mTelephonyManager.isEmergencyNumber(phoneNumber); mIsInEmergencyCall = PhoneNumberUtils.isEmergencyNumber(phoneNumber);
if (DEBUG) Log.v(TAG, "ACTION_NEW_OUTGOING_CALL - " + getInEmergency()); if (DEBUG) Log.v(TAG, "ACTION_NEW_OUTGOING_CALL - " + getInEmergency());
} else if (action.equals(LocationManager.MODE_CHANGED_ACTION)) { } else if (action.equals(LocationManager.MODE_CHANGED_ACTION)) {
updateLocationMode(); updateLocationMode();

View File

@@ -406,8 +406,7 @@ public class CallerInfo {
// Change the callerInfo number ONLY if it is an emergency number // Change the callerInfo number ONLY if it is an emergency number
// or if it is the voicemail number. If it is either, take a // or if it is the voicemail number. If it is either, take a
// shortcut and skip the query. // shortcut and skip the query.
TelephonyManager tm = context.getSystemService(TelephonyManager.class); if (PhoneNumberUtils.isLocalEmergencyNumber(context, number)) {
if (tm.isEmergencyNumber(number)) {
return new CallerInfo().markAsEmergency(context); return new CallerInfo().markAsEmergency(context);
} else if (PhoneNumberUtils.isVoiceMailNumber(null, subId, number)) { } else if (PhoneNumberUtils.isVoiceMailNumber(null, subId, number)) {
return new CallerInfo().markAsVoiceMail(context, subId); return new CallerInfo().markAsVoiceMail(context, subId);

View File

@@ -483,7 +483,16 @@ public class CallerInfoAsyncQuery {
// check to see if these are recognized numbers, and use shortcuts if we can. // check to see if these are recognized numbers, and use shortcuts if we can.
TelephonyManager tm = context.getSystemService(TelephonyManager.class); TelephonyManager tm = context.getSystemService(TelephonyManager.class);
if (tm.isEmergencyNumber(number)) { boolean isEmergencyNumber = false;
try {
isEmergencyNumber = tm.isEmergencyNumber(number);
} catch (IllegalStateException ise) {
// Ignore the exception that Telephony is not up. Use PhoneNumberUtils API now.
// Ideally the PhoneNumberUtils API needs to be removed once the
// telphony service not up issue can be fixed (b/187412989)
isEmergencyNumber = PhoneNumberUtils.isLocalEmergencyNumber(context, number);
}
if (isEmergencyNumber) {
cw.event = EVENT_EMERGENCY_NUMBER; cw.event = EVENT_EMERGENCY_NUMBER;
} else if (PhoneNumberUtils.isVoiceMailNumber(context, subId, number)) { } else if (PhoneNumberUtils.isVoiceMailNumber(context, subId, number)) {
cw.event = EVENT_VOICEMAIL_NUMBER; cw.event = EVENT_VOICEMAIL_NUMBER;