简体   繁体   English

拦截已扎根的Android(Jelly Bean)中的来电

[英]Intercept incoming call in a rooted Android (Jelly Bean)

I'm looking to intercept calls in order to block all calls from numbers not stored in Contacts and to avoid all sorts of notifications set by default Phone app – in status bar, on its icon (number of missed calls), etc. 我希望拦截电话,以阻止未存储在“联系人”中的号码中的所有电话,并避免默认情况下在“电话”应用中设置的各种通知 -在状态栏中,其图标(未接来电的数量)等。

All devices are Samsung Galaxy Core Duos, so I have Blocking mode as an undesirable way of blocking all calls from numbers not stored in Contacts. 所有设备均为Samsung Galaxy Core Duos,因此我具有阻止模式,这是一种阻止所有未使用联系人存储的电话的方式。 My main problem is finding a way to disable (avoid) aforementioned notifications. 我的主要问题是找到一种禁用(避免)上述通知的方法。 I know I can empty my call log, and I am doing it, but notifications stay, both in status bar and on icon. 我知道我可以清空我的通话记录,并且正在这样做,但是无论在状态栏中还是在图标上,通知都保持不变。 That being said, I believe either both or none can be solved. 话虽这么说,我相信两者都不能解决。

Is there a way to do this for rooted devices running Jelly Bean? 有没有办法针对运行Jelly Bean的有根设备执行此操作?

Since there's no proper way of using abortBroadcast() in this case, as android.intent.action.PHONE_STATE is not being received via an ordered broadcast (no system's sendOrderedBroadcast() call, like with received short message, but plain old sendBroadcast() instead), all receivers must receive this intent "at the same time". 由于在这种情况下没有正确的方法使用abortBroadcast() ,因此无法通过有序广播来接收android.intent.action.PHONE_STATE (没有系统的sendOrderedBroadcast()调用,就像收到的短消息一样,只是普通的sendBroadcast()相反),所有接收者都必须“同时”收到此意图。

To make my goal possibly impossible, as far as I can see, things start happening even before the broadcast. 据我所知,为了使我的目标不可能实现,甚至在广播之前就开始发生事情。 Furthermore, nothing "legally receivable" happens before the call to sendBroadcast() , as thoroughly yet briefly described in this blog post . 此外,在调用sendBroadcast()之前,没有发生任何“合法可接收的事件”, 本博文中已进行了全面而简短的描述。 By the way, this post was submitted in 2009. Has anything related to this problem changed since then? 顺便说一句,该帖子于2009年提交。此后与该问题有关的任何内容有变化吗?

Is it possible to solve this using shell? 是否可以使用shell解决此问题? If yes, how? 如果是,怎么办?

The code that's emptying call log is the following: 清空通话记录的代码如下:

context.getContentResolver().delete(android.provider.CallLog.Calls.CONTENT_URI, null, null);

I have permissions needed (for instance: WRITE_CALL_LOG , READ_CONTACTS , WRITE_CONTACTS ) and this works. 我有需要的权限(例如: WRITE_CALL_LOGREAD_CONTACTSWRITE_CONTACTS )和工作原理。 Call log shows to be empty when I touch Phone app icon or status bar notification. 当我触摸“电话”应用程序图标或状态栏通知时,呼叫日志显示为空。

I solved it using this piece of code: 我使用这段代码解决了它:

Runtime runtime = Runtime.getRuntime();
try
{
    runtime.exec("service call phone 5 \n");
}
catch (Exception e)
{
    e.printStackTrace();
}

It marks call as ended, instead of marking it as missed, and ended calls do not show notifications of any kind. 它会将呼叫标记为结束,而不是将其标记为未接,并且结束呼叫不会显示任何通知。

If 5 doesn't work, try some other digits, like 4, 6, 8, etc. 如果5不起作用,请尝试其他一些数字,例如4、6、8等。

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

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