Restrict telecom usage to API 37.

This commit is contained in:
Cody Henthorne
2026-04-10 12:18:38 -04:00
parent 179908fba6
commit f5cb1b0efa
2 changed files with 17 additions and 16 deletions

View File

@@ -317,23 +317,23 @@ class ActiveCallManager(
@get:RequiresApi(30)
override val serviceType: Int
get() {
val telecom = Build.VERSION.SDK_INT >= 34 && AndroidTelecomUtil.hasActiveController()
val telecom = Build.VERSION.SDK_INT >= 36 && AndroidTelecomUtil.hasActiveController()
return if (telecom) {
var type = if (telecom) {
ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL
} else {
var type = ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC
if (Permissions.hasAll(this, Manifest.permission.RECORD_AUDIO)) {
type = type or ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE
}
if (Permissions.hasAll(this, Manifest.permission.CAMERA)) {
type = type or ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA
}
type
ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC
}
if (Permissions.hasAll(this, Manifest.permission.RECORD_AUDIO)) {
type = type or ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE
}
if (Permissions.hasAll(this, Manifest.permission.CAMERA)) {
type = type or ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA
}
return type
}
@Suppress("DEPRECATION")

View File

@@ -34,7 +34,7 @@ object AndroidTelecomUtil {
@JvmStatic
val telecomSupported: Boolean
get() {
if (Build.VERSION.SDK_INT >= 34 && !systemRejected && isTelecomAllowedForDevice()) {
if (Build.VERSION.SDK_INT >= 36 && !systemRejected && isTelecomAllowedForDevice()) {
if (!registered) {
registerPhoneAccount()
}
@@ -48,11 +48,12 @@ object AndroidTelecomUtil {
@JvmStatic
fun registerPhoneAccount() {
if (Build.VERSION.SDK_INT >= 34 && !systemRejected) {
if (Build.VERSION.SDK_INT >= 36 && !systemRejected) {
Log.i(TAG, "Registering with CallsManager")
try {
callsManager.registerAppWithTelecom(
CallsManager.CAPABILITY_BASELINE or CallsManager.CAPABILITY_SUPPORTS_VIDEO_CALLING
capabilities = CallsManager.CAPABILITY_BASELINE or CallsManager.CAPABILITY_SUPPORTS_VIDEO_CALLING,
backwardsCompatSdkLevel = 37
)
Log.i(TAG, "CallsManager registration successful")
registered = true