Handles Telephony service not up fatal exception in CallerInfoAsyncQuery

Bug: 181062609
Test: Treehugger
Change-Id: I5df03a61f55f863e17594aa3239433a5048a4890
This commit is contained in:
Shuo Qian
2021-05-05 20:47:23 +00:00
parent f94486117f
commit 839508eea2

View File

@@ -483,7 +483,16 @@ public class CallerInfoAsyncQuery {
// check to see if these are recognized numbers, and use shortcuts if we can.
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;
} else if (PhoneNumberUtils.isVoiceMailNumber(context, subId, number)) {
cw.event = EVENT_VOICEMAIL_NUMBER;