Catch exception from TelephonyManager#isEmergencyNumber to avoid crash

Bug: 247967305
Test: presubmits
Change-Id: I48d24e5ea0a9d67e39a2908a5c3246e0d6476f2e
(cherry picked from commit cf445af0af)
This commit is contained in:
Yu-Han Yang
2022-09-26 20:37:19 +00:00
parent 35512533d3
commit cbed4a2287

View File

@@ -16,6 +16,8 @@
package com.android.server.location.injector;
import static com.android.server.location.LocationManagerService.TAG;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -23,6 +25,7 @@ import android.content.IntentFilter;
import android.os.SystemClock;
import android.telephony.TelephonyCallback;
import android.telephony.TelephonyManager;
import android.util.Log;
import com.android.server.FgThread;
@@ -67,8 +70,12 @@ public class SystemEmergencyHelper extends EmergencyHelper {
}
synchronized (SystemEmergencyHelper.this) {
mIsInEmergencyCall = mTelephonyManager.isEmergencyNumber(
intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER));
try {
mIsInEmergencyCall = mTelephonyManager.isEmergencyNumber(
intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER));
} catch (IllegalStateException e) {
Log.w(TAG, "Failed to call TelephonyManager.isEmergencyNumber().", e);
}
}
}
}, new IntentFilter(Intent.ACTION_NEW_OUTGOING_CALL));