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

Commit cefa4768 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Handle IllegalStateException from TelephonyManager." into qt-qpr1-dev

parents a8bd6def b32fd035
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;
        }
    }
}