android 来电过滤,Call Screening(来电过滤) on Android N

本文介绍了Android 7.0中的Call Screening服务,这是一个允许默认电话应用筛选和控制来电的新特性。通过实现CallScreeningService,电话应用可以决定是否拒绝、隐藏来电记录或通知。CallScreeningService的四个主要方法:setDisallowCall(), setRejectCall(), setSkipCallLog(), setSkipNotification(),分别用于阻止来电、拒接、不记录到通话记录和不显示未接通知。尽管当前只有测试代码,但Call Screening为来电过滤提供了更多可能性,可以作为黑名单功能的补充。" 99704206,8687836,Linux系统管理:文件系统与LVM详解,"['Linux系统管理', '文件系统', 'LVM', '磁盘管理']

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

之前在看Android官方文档系统的时候看到Android N 一系列新增和改变的特性,因为工作中负责的部分和通话有关,就尤其注意到了这个Call Screening。

下面来简单介绍一下Call Screening是什么,以及它在通话流程中起了哪些作用。

PS:一下代码全部来自Mokee mkn-mr1,

来自android官方的解释

Call Screening

Android 7.0 allows the default phone app to screen incoming calls. The phone app does this by implementing the new CallScreeningService, which allows the phone app to perform a number of actions based on an incoming call's

Reject the incoming call

Do not allow the call to the call log

Do not show the user a notification for the call

For more information, see the reference documentation for

来电过滤(Call Screening)

Android 7.0 允许默认的手机应用过滤来电。手机应用执行此操作的方式是实现新的 CallScreeningService,该方法允许手机应用基于来电的

拒绝来电

不允许来电到达通话记录

不向用户显示来电通知

如需了解详细信息,请参阅可下载的 API 参考中的 android.telecom.CallScreeningService。

读者可能会奇怪 Call Screening翻译成“

呼叫筛选

”可能更合适些,来电过滤 或许应该是IncomingCall filter的翻译啊(其实这也是有道理的,看了代码就知晓了)。

上面的文字有两个重点 based on an incoming call's Call.Details和 CallScreeningService。

应该是从

Call.Details来判断需不需要过滤,先不看去判断哪些具体的条件,我们先看看CallScreeningService

在代码中是什么样子的。

CallScreeningService

public abstract class CallScreeningService

extends Service

This service can be implemented by the default dialer (see

Below is an example manifest registration for a CallScreeningService.

首先它是一个services,需要在拨号软件中实现,在AndroidManifest中的声明如上。

分析在源码中的使用

下面到源码中看这个是怎么使用的。

但是得到的第一个就是失望的消息,,

目前只有测试相关的代码

cts/tests/tests/telecom/src/android/telecom/cts/MockCallScreeningService.java 注册了CallScreeningService,也就是说我们在Android N中并看不到这个功能的实际使用。

但是我们依然可以窥探一下CallScreeningService的功能以及在现有代码中的作用

PS:所有代码来自Mokee mkn-mr1

publicstaticclassBuilder{privatebooleanmShouldDisallowCall;privatebooleanmShouldRejectCall;privatebooleanmShouldSkipCallLog;privatebooleanmShouldSkipNotification;/** Sets whether the incoming call should be blocked.*/publicBuildersetDisallowCall(booleanshouldDisallowCall){mShouldDisallowCall=shouldDisallowCall;returnthis;}/** Sets whether the incoming call should be disconnected as if the user had manually* rejected it. This property should only be set to true if the call is disallowed.*/publicBuildersetRejectCall(booleanshouldRejectCall){mShouldRejectCall=shouldRejectCall;returnthis;}/** Sets whether the incoming call should not be displayed in the call log. This property* should only be set to true if the call is disallowed.*/publicBuildersetSkipCallLog(booleanshouldSkipCallLog){mShouldSkipCallLog=shouldSkipCallLog;returnthis;}/** Sets whether a missed call notification should not be shown for the incoming call.* This property should only be set to true if the call is disallowed.*/publicBuildersetSkipNotification(booleanshouldSkipNotification){mShouldSkipNotification=shouldSkipNotification;returnthis;}publicCallResponsebuild(){returnnewCallResponse(mShouldDisallowCall,mShouldRejectCall,mShouldSkipCallLog,mShouldSkipNotification);}}

四个重要的方法:setDisallowCall(), setRejectCall(), setSkipCallLog(), setSkipNotification(), 从这4个方法也可以大概知道,这个“

来电过滤

”能做的具体的事情是什么:1. 完全阻止来电(类似黑名单),2. 是否拒接来电, 3. 是否在CallLog中显示, 4. 是否要显示未接通知(这跟前面不就是一样的嘛),也就是说 可以通过这4个方法设置来电的提醒方式。

在cts代码中使用

再看一下在cts代码中的使用的

privateCallScreeningServiceCallbackscreateCallbacks(){returnnewCallScreeningServiceCallbacks(){@OverridepublicvoidonScreenCall(Call.DetailscallDetails){mCallFound=true;CallScreening

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值