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

Commit b32fd035 authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Handle IllegalStateException from TelephonyManager.

Some TelephonyManager APIs can throw an IllegalStateException; these
methods no longer exist in Master.  However, adding in exception handling
here to ensure crashes do not impact QT-based devices.
Note: This has already been fixed in AOSP and master, hence the
do not merge anywhere.

Test: Run telecom unit tests.
Bug: 134100020
Bug: 139088691
Merged-In: I49f632243704ba08a106867c58573e5631dda5d6
Merged-In: Ia42c5bce2fd010d9e5ba3d4a76575d27c7940608
Change-Id: If9ae7cf06d4a5af6c15276c59222a1d4f7c6de58
parent bfd55454
Loading
Loading
Loading
Loading
+15 −7
Original line number Diff line number Diff line
@@ -24,16 +24,24 @@ import android.telephony.TelephonyManager;
public class PhoneNumberUtilsAdapterImpl implements PhoneNumberUtilsAdapter {
    @Override
    public boolean isLocalEmergencyNumber(Context context, String number) {
        try {
            TelephonyManager tm = (TelephonyManager) context.getSystemService(
                    Context.TELEPHONY_SERVICE);
            return tm.isEmergencyNumber(number);
        } catch (IllegalStateException ise) {
            return false;
        }
    }

    @Override
    public boolean isPotentialLocalEmergencyNumber(Context context, String number) {
        try {
            TelephonyManager tm = (TelephonyManager) context.getSystemService(
                    Context.TELEPHONY_SERVICE);
            return tm.isPotentialEmergencyNumber(number);
        } catch (IllegalStateException ise) {
            return false;
        }
    }

    @Override
+7 −3
Original line number Diff line number Diff line
@@ -70,8 +70,12 @@ public final class TelephonyUtil {
    }

    public static boolean shouldProcessAsEmergency(Context context, Uri handle) {
        try {
            TelephonyManager tm = (TelephonyManager) context.getSystemService(
                    Context.TELEPHONY_SERVICE);
            return handle != null && tm.isEmergencyNumber(handle.getSchemeSpecificPart());
        } catch (IllegalStateException ise) {
            return false;
        }
    }
}