简体   繁体   English

在 Android 上拦截来电

[英]Intercepting incoming calls on Android

I would like to write software for my Android phone that intercepts incoming calls and plays a short audio clip instructing the caller to press "1" to proceed with the call.我想为我的 Android 手机编写软件来拦截来电并播放一段简短的音频剪辑,指示来电者按“1”继续通话。 This is for fighting telemarketers.这是为了对抗电话推销员。

Is this possible with the current (Android 7 "Nougat") API?当前的(Android 7“Nougat”)API 是否可以做到这一点?

Notes:笔记:

  • It's hard to get a clear answer because in 2012, Android 2.3 (Gingerbread) removed some vital API related to modifying the phone state, see here .很难得到明确的答案,因为在 2012 年,Android 2.3 (Gingerbread) 删除了一些与修改手机状态相关的重要 API,请参见此处 However, Android 7 ("Nougat") seems to support call-blocking (see here ), so I'm hopeful that the current API supports intercepting calls.但是,Android 7(“Nougat”)似乎支持调用阻塞(请参阅此处),因此我希望当前的 API 支持拦截调用。

  • I don't want to forward calls to some server as suggested here .我不想按照此处的建议将呼叫转发到某个服务器。

  • I would prefer to write the software myself, and not install an app like Hiya.我更愿意自己编写软件,而不是安装像 Hiya 这样的应用程序。

  • I have a regular phone number assigned by my carrier (no fancy Google Voice or VOIP stuff), and I use the standard "Phone" app.我有一个由我的运营商分配的普通电话号码(没有花哨的 Google 语音或 VOIP 内容),我使用标准的“电话”应用程序。

  • My phone is not rooted.我的手机没有root。

  • This is inspired by the Jolly Roger Telephone Company anti-telemarketer bot.这是受Jolly Roger Telephone Company反电话营销机器人的启发。

  • I previously asked a similar question for iPhones here .我之前在这里为 iPhone 提出了类似的问题。

Thanks.谢谢。

The specific documentation link is Android 7.0 - Number Blocking feature具体文档链接为Android 7.0 - Number Blocking feature

Android 7.0 now supports number blocking in the platform and provides a framework API to let service providers maintain a blocked-number list. Android 7.0 现在支持平台号码拦截,并提供框架 API 来让服务提供商维护一个拦截号码列表。 The default SMS app, the default phone app, and carrier apps can read from and write to the blocked-number list.默认短信应用程序、默认电话应用程序和运营商应用程序可以读取和写入阻止号码列表。 The list is not accessible to other apps.其他应用程序无法访问该列表。

The last line highlights that this isn't a general access feature.最后一行强调这不是一般访问功能。

Drilling down in to BlockedNumberContract深入到BlockedNumberContract

Only the system, the default SMS application, and the default phone app (See getDefaultDialerPackage()), and carrier apps (See CarrierService) can read, and write to the blockednumber provider.只有系统、默认 SMS 应用程序和默认电话应用程序(请参阅 getDefaultDialerPackage())和运营商应用程序(请参阅 CarrierService)可以读取和写入被阻止的号码提供程序。 However, canCurrentUserBlockNumbers(Context) can be accessed by any application.但是,任何应用程序都可以访问 canCurrentUserBlockNumbers(Context)。

So if you are the default dialer or default SMS app you should have access.因此,如果您是默认拨号器或默认 SMS 应用程序,您应该有权访问。 If you aren't either of those then all any app can do is find out if the feature is available.如果您不是其中任何一个,那么任何应用程序所能做的就是找出该功能是否可用。

Additionally I'm not aware of a general way to inject audio into a call, see: Call Stream Modification on Android此外,我不知道将音频注入呼叫的一般方法,请参阅: Android 上的呼叫流修改

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM