You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

三星Galaxy S23设备CallScreeningService无法正常工作的技术求助

CallScreeningService 无法在三星Galaxy S23上正常运行

近期从三星Galaxy S9更换至Galaxy S23后,发现应用中的CallScreeningService功能异常。已成功授予应用Call Screening Role,但来电时服务未触发,无日志输出,拦截功能失效。该应用在S9及各API级别模拟器上均能正常工作。

以下是相关代码:

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/Theme.Android13CallScreening"
        tools:targetApi="31">
        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <service
            android:name=".services.MyCustomCallScreeningService"
            android:exported="true"
            android:permission="android.permission.BIND_SCREENING_SERVICE">
            <intent-filter>
                <action android:name="android.telecom.CallScreeningService" />
            </intent-filter>
        </service>

    </application>

</manifest>

MainActivity.kt

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        requestRole()
    }

    private val REQUEST_ID = 1

    fun requestRole() {
        val roleManager = getSystemService(Context.ROLE_SERVICE) as RoleManager
        val intent = roleManager.createRequestRoleIntent(RoleManager.ROLE_CALL_SCREENING)
        startActivityForResult(intent, REQUEST_ID)
    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (requestCode == REQUEST_ID) {
            if (resultCode == android.app.Activity.RESULT_OK) {
                println("Your app is now the call screening app")
            } else {
                println("Your app is not the call screening app")
            }
        }
    }

}

MyCustomCallScreeningService.kt

class MyCustomCallScreeningService: CallScreeningService() {
    override fun onScreenCall(callDetails: Call.Details) {
        System.out.println("Should print this message when there is an incoming call")
        respondToCall(callDetails, CallResponse.Builder().build())
    }
}

可能的原因及解决方案

1. 三星One UI专属限制

三星Galaxy S23搭载的One UI(基于Android 13/14)对来电筛选功能有系统级优先级限制,默认可能优先启用自带来电拦截服务。

  • 操作步骤:打开「设置」→「应用」→「默认应用」→「来电筛选」,确认你的应用已设为默认;检查三星「智能管理器」或「电话」应用的拦截设置,关闭冲突规则或设第三方应用为优先。

2. 后台运行权限受限

Android 13+对后台应用管控更严格,S23可能限制了应用后台接收来电广播的权限。

  • 操作步骤:前往「设置」→「应用」→「你的应用」→「电池和设备维护」→「电池使用情况」→「后台限制」,设为「无限制」;开启「自启动权限」:「设置」→「应用」→「你的应用」→「权限」→「自启动」,允许应用自启动。

3. 补充权限声明

部分设备需要额外权限才能正常触发CallScreeningService,在AndroidManifest.xml中添加:

<uses-permission android:name="android.permission.READ_PHONE_STATE" />

若targetSdkVersion ≥33,需在MainActivity中动态申请该权限。

4. 优化Service响应逻辑

三星设备可能对回调响应有特殊要求,修改onScreenCall实现:

class MyCustomCallScreeningService: CallScreeningService() {
    override fun onScreenCall(callDetails: Call.Details) {
        Log.d("CallScreening", "Incoming call detected: ${callDetails.handle}")
        val response = CallResponse.Builder()
            .setDisallowCall(false) // 改为true可拦截来电
            .setRejectCall(false)
            .build()
        respondToCall(callDetails, response)
    }
}

使用Log.d替代System.out.println,便于在Logcat中查看日志。

5. 验证角色授予状态

在MainActivity中添加验证逻辑,确认应用是否真正持有来电筛选角色:

fun checkCurrentCallScreeningApp() {
    val roleManager = getSystemService(Context.ROLE_SERVICE) as RoleManager
    val isHoldingRole = roleManager.isRoleHeld(RoleManager.ROLE_CALL_SCREENING)
    Log.d("CallScreening", "Is app holding call screening role: $isHoldingRole")
}

在onActivityResult中调用该方法,排查角色授予是否异常。

6. 清除应用缓存数据

尝试清除应用缓存和数据后重新授权:

  • 操作步骤:「设置」→「应用」→「你的应用」→「存储」→「清除缓存」「清除数据」,重启应用并重新申请Call Screening Role。

内容的提问来源于stack exchange,提问作者Peter Brna

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.08 09:17:25