Prevent crash if security exception is thrown when placing call with Telecom Manager

This commit is contained in:
Sylvain Berfini 2022-03-02 14:08:59 +01:00
parent 4a05302722
commit 2c846f6727

View file

@ -61,10 +61,14 @@ class TelecomHelper private constructor(context: Context) {
) { ) {
Log.i("[Telecom Helper] Call state changed: ${call.state}") Log.i("[Telecom Helper] Call state changed: ${call.state}")
if (call.dir == Call.Dir.Incoming && call.state == Call.State.IncomingReceived) { try {
onIncomingCall(call) if (call.dir == Call.Dir.Incoming && call.state == Call.State.IncomingReceived) {
} else if (call.dir == Call.Dir.Outgoing && call.state == Call.State.OutgoingProgress) { onIncomingCall(call)
onOutgoingCall(call) } else if (call.dir == Call.Dir.Outgoing && call.state == Call.State.OutgoingProgress) {
onOutgoingCall(call)
}
} catch (se: SecurityException) {
Log.e("[Telecom Helper] Exception while trying to place call: $se")
} }
} }
} }