Prevent crash if DMTF setting doesn't exists (Samsung A51)

This commit is contained in:
Sylvain Berfini 2025-03-16 20:34:29 +01:00
parent 71e1734ca0
commit 614ac7f9cf

View file

@ -30,6 +30,7 @@ import android.os.Handler
import android.os.HandlerThread
import android.os.Looper
import android.provider.Settings
import android.provider.Settings.SettingNotFoundException
import androidx.annotation.AnyThread
import androidx.annotation.UiThread
import androidx.annotation.WorkerThread
@ -896,14 +897,18 @@ class CoreContext
@WorkerThread
fun playDtmf(character: Char, duration: Int = 200, ignoreSystemPolicy: Boolean = false) {
if (ignoreSystemPolicy || Settings.System.getInt(
context.contentResolver,
Settings.System.DTMF_TONE_WHEN_DIALING
) != 0
) {
core.playDtmf(character, duration)
} else {
Log.w("$TAG Numpad DTMF tones are disabled in system settings, not playing them")
try {
if (ignoreSystemPolicy || Settings.System.getInt(
context.contentResolver,
Settings.System.DTMF_TONE_WHEN_DIALING
) != 0
) {
core.playDtmf(character, duration)
} else {
Log.w("$TAG Numpad DTMF tones are disabled in system settings, not playing them")
}
} catch (snfe: SettingNotFoundException) {
Log.e("$TAG DTMF_TONE_WHEN_DIALING system setting not found: $snfe")
}
}