Catch possible phone permission exception on specific devices.

fork-5.53.8
Greyson Parrelli 2022-10-14 13:51:35 -04:00
rodzic 14a9e22b5e
commit 00e70212c5
1 zmienionych plików z 8 dodań i 3 usunięć

Wyświetl plik

@ -47,9 +47,14 @@ public class TelephonyUtil {
}
public static boolean isAnyPstnLineBusy(@NonNull Context context) {
if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) {
return getManager(context).getCallState() != TelephonyManager.CALL_STATE_IDLE;
} else {
try {
if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) {
return getManager(context).getCallState() != TelephonyManager.CALL_STATE_IDLE;
} else {
return false;
}
} catch (SecurityException e) {
Log.w(TAG, "Failed to determine if busy!", e);
return false;
}
}