Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2e7481d1 authored by Tomasz Wasilczyk's avatar Tomasz Wasilczyk Committed by Android (Google) Code Review
Browse files

Merge "Fix Telecom CTS crashes when checking for emergency/voicemail number" into main

parents 953fe0a4 373cca20
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ public class SystemEmergencyHelper extends EmergencyHelper {
                        mIsInEmergencyCall = mTelephonyManager.isEmergencyNumber(
                                intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER));
                        dispatchEmergencyStateChanged();
                    } catch (IllegalStateException e) {
                    } catch (IllegalStateException | UnsupportedOperationException e) {
                        Log.w(TAG, "Failed to call TelephonyManager.isEmergencyNumber().", e);
                    }
                }
+12 −2
Original line number Diff line number Diff line
@@ -483,18 +483,28 @@ public class CallerInfoAsyncQuery {

        // check to see if these are recognized numbers, and use shortcuts if we can.
        TelephonyManager tm = context.getSystemService(TelephonyManager.class);

        boolean isEmergencyNumber = false;
        try {
            isEmergencyNumber = tm.isEmergencyNumber(number);
        } catch (IllegalStateException ise) {
        } catch (IllegalStateException | UnsupportedOperationException 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)
            // UnsupportedOperationException: telephony.calling may not be supported on this device
            isEmergencyNumber = PhoneNumberUtils.isLocalEmergencyNumber(context, number);
        }

        boolean isVoicemailNumber;
        try {
            isVoicemailNumber = PhoneNumberUtils.isVoiceMailNumber(context, subId, number);
        } catch (UnsupportedOperationException ex) {
            isVoicemailNumber = false;
        }

        if (isEmergencyNumber) {
            cw.event = EVENT_EMERGENCY_NUMBER;
        } else if (PhoneNumberUtils.isVoiceMailNumber(context, subId, number)) {
        } else if (isVoicemailNumber) {
            cw.event = EVENT_VOICEMAIL_NUMBER;
        } else {
            cw.event = EVENT_NEW_QUERY;