Fixed telecom manager feature availability check

This commit is contained in:
Sylvain Berfini 2026-02-02 11:56:12 +01:00
parent 74929f690f
commit ec34edabf8
4 changed files with 33 additions and 2 deletions

View file

@ -23,6 +23,8 @@ import android.app.Activity
import android.app.Notification
import android.app.PictureInPictureParams
import android.app.Service
import android.content.Context
import android.content.pm.PackageManager
import android.net.Uri
import android.provider.MediaStore
import org.linphone.core.tools.Log
@ -74,5 +76,13 @@ class Api28Compatibility {
else -> Uri.EMPTY
}
}
fun hasTelecomManagerFeature(context: Context): Boolean {
val hasFeature = context.packageManager.hasSystemFeature(
PackageManager.FEATURE_CONNECTION_SERVICE
)
Log.i("$TAG Feature [${PackageManager.FEATURE_CONNECTION_SERVICE}] is [${if (hasFeature) "available" else "not available"}]")
return hasFeature
}
}
}

View file

@ -25,10 +25,13 @@ import android.content.Context
import android.content.pm.PackageManager
import android.os.Build
import androidx.annotation.RequiresApi
import org.linphone.core.tools.Log
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
class Api33Compatibility {
companion object {
private const val TAG = "[API 33 Compatibility]"
fun getAllRequiredPermissionsArray(): Array<String> {
return arrayOf(
Manifest.permission.POST_NOTIFICATIONS,
@ -49,5 +52,13 @@ class Api33Compatibility {
options.isPendingIntentBackgroundActivityLaunchAllowed = true
return options
}
fun hasTelecomManagerFeature(context: Context): Boolean {
val hasFeature = context.packageManager.hasSystemFeature(
PackageManager.FEATURE_TELECOM
)
Log.i("$TAG Feature [${PackageManager.FEATURE_TELECOM}] is [${if (hasFeature) "available" else "not available"}]")
return hasFeature
}
}
}

View file

@ -100,6 +100,15 @@ class Compatibility {
)
}
fun hasTelecomManagerFeature(context: Context): Boolean {
if (Version.sdkAboveOrEqual(Version.API33_ANDROID_13_TIRAMISU)) {
return Api33Compatibility.hasTelecomManagerFeature(context)
} else if (Version.sdkAboveOrEqual(Version.API26_O_80)) {
return Api28Compatibility.hasTelecomManagerFeature(context)
}
return false
}
fun hasFullScreenIntentPermission(context: Context): Boolean {
if (Version.sdkAboveOrEqual(Version.API34_ANDROID_14_UPSIDE_DOWN_CAKE)) {
return Api34Compatibility.hasFullScreenIntentPermission(context)

View file

@ -35,6 +35,7 @@ import org.linphone.core.CoreListenerStub
import org.linphone.core.tools.Log
import org.linphone.utils.LinphoneUtils
import androidx.core.net.toUri
import org.linphone.compatibility.Compatibility
class TelecomManager
@WorkerThread
@ -68,13 +69,13 @@ class TelecomManager
}
}
private val hasTelecomFeature = context.packageManager.hasSystemFeature("android.software.telecom")
private val hasTelecomFeature = Compatibility.hasTelecomManagerFeature(context)
private var currentlyFollowedCalls: Int = 0
init {
Log.i(
"$TAG android.software.telecom feature is [${if (hasTelecomFeature) "available" else "not available"}]"
"$TAG Feature is [${if (hasTelecomFeature) "available" else "not available"}]"
)
if (hasTelecomFeature) {
try {