From 313830cc236fcd220b6a2b4963b24d1593e683f0 Mon Sep 17 00:00:00 2001 From: Nate Myren Date: Mon, 25 Nov 2024 14:54:33 -0800 Subject: Catch errors related to Telephony being unavailable in ECMService On some devices, like tablets, there may be telecom calls (from things like VOIP apps), but not telephony (sim cards). These exceptions should be caught when checking for emergency numbers Fixes: 380718851 Test: manual Flag: none Change-Id: I1a6de95b114d7d206d583f2d79f6ab34011e9220 --- .../java/com/android/ecm/EnhancedConfirmationService.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'service') diff --git a/service/java/com/android/ecm/EnhancedConfirmationService.java b/service/java/com/android/ecm/EnhancedConfirmationService.java index 1bbba1079..dde9fe2fd 100644 --- a/service/java/com/android/ecm/EnhancedConfirmationService.java +++ b/service/java/com/android/ecm/EnhancedConfirmationService.java @@ -158,9 +158,16 @@ public class EnhancedConfirmationService extends SystemService { private @CallType int getCallType(Call call) { String number = getPhoneNumber(call); - if (number != null && mTelephonyManager.isEmergencyNumber(number)) { - return CALL_TYPE_EMERGENCY; - } else if (number != null) { + try { + if (number != null && mTelephonyManager.isEmergencyNumber(number)) { + return CALL_TYPE_EMERGENCY; + } + } catch (IllegalStateException | UnsupportedOperationException e) { + // If either of these are thrown, the telephony service is not available on the current + // device, either because the device lacks telephony calling, or the telephony service + // is unavailable. + } + if (number != null) { return hasContactWithPhoneNumber(number) ? CALL_TYPE_TRUSTED : CALL_TYPE_UNTRUSTED; } else { return hasContactWithDisplayName(call.getDetails().getCallerDisplayName()) -- cgit v1.2.3-59-g8ed1b