mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-04-17 21:38:29 +00:00
Fixed telecom manager feature availability check
This commit is contained in:
parent
452a749d1b
commit
3fc19e10fc
4 changed files with 33 additions and 2 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,10 +24,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,
|
||||
|
|
@ -42,5 +45,13 @@ class Api33Compatibility {
|
|||
Manifest.permission.POST_NOTIFICATIONS
|
||||
) == PackageManager.PERMISSION_GRANTED
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,6 +97,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)
|
||||
|
|
|
|||
|
|
@ -36,6 +36,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
|
||||
|
|
@ -69,13 +70,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"}]"
|
||||
)
|
||||
try {
|
||||
callsManager.registerAppWithTelecom(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue