以编程方式接听Whatsapp视频通话 [英] Answering a Whatsapp video call programmatically

查看:48
本文介绍了以编程方式接听Whatsapp视频通话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用Android中的AccessibilityService自动应答whatsapp视频通话?

Is there a way to auto answer whatsapp video call using AccessibilityService in Android?

或者有没有一种方法可以刺激点击耳机/蓝牙的呼叫应答按钮?如何获取应答按钮的ID?使用无障碍服务执行点击

OR is there a way to stimulate a click on headset's/bluetooth's call answering button? How can i get the id of the answering button?? to perform a click with accessibility service

我知道从Android 8.0 Oreo开始,我们具有ANSWER_PHONE_CALLS权限,但是对于我的项目,我想使用旧设备进行远程监控.

I know that starting from Android 8.0 Oreo we have ANSWER_PHONE_CALLS permission, but for my project i want to use an old device for remote monitoring.

任何帮助将不胜感激!

-----更新:由于hemisphire先生和Kahbazi先生的回答,该应用程序可以接听电话,但需要是系统应用程序才能正常工作!有没有什么方法可以使它在不成为系统应用程序的情况下正常工作?没有耳机的按钮破解?

----- Update: Thanks to the answer of Mr. hemisphire and Mr. Kahbazi, the app is able to answer the call,but needs to be a system app to work! is there any way to make it work without being a system app? without the headset's button hack?

public class AnswerCall  extends AccessibilityService {
    @Override
    public void onAccessibilityEvent( AccessibilityEvent event )
    {
        if(event.getEventType() == TYPE_WINDOW_CONTENT_CHANGED)
        {

            if(event.getPackageName().equals("com.whatsapp"))
            {

                Thread thread = new Thread() {
                    @Override
                    public void run() {
                        try {
                            while(true) {
                                Instrumentation inst = new Instrumentation();
                                inst.sendKeyDownUpSync(KeyEvent.KEYCODE_HEADSETHOOK);
                            }
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                };

                thread.start();
                StringBuilder sb = new StringBuilder();
                List<CharSequence> texts = event.getText();
                if (!texts.isEmpty())
                {
                    for (CharSequence s : event.getText()) {
                        sb.append(s);
                    }
                    if(sb.toString().equals("Incoming video call"))
                        Log.d( "onAccessibilityEvent", "whatsapp video call" );

                }
            }
        }
    }

    @Override
    public void onInterrupt() {

    }
}

推荐答案

我认为您无法做自己想做的事情.使用AccessibilityService,您可以知道视频通话的时间:

I don't think you can do what you want. Using the AccessibilityService you can know when the video call comes in:

@Override
public void onAccessibilityEvent( AccessibilityEvent event )
{
    if(event.getEventType() == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED)
    {
        if(event.getPackageName().equals("com.whatsapp"))
        {
            StringBuilder sb = new StringBuilder();
            List<CharSequence> texts = event.getText();
            if (!texts.isEmpty()) 
            {
                for (CharSequence s : event.getText()) 
                {
                    sb.append(s);
                }
                if(sb.toString().equals("Incoming video call"))
                {
                    Log.d( "onAccessibilityEvent", "whatsapp video call" );
                }
            }
        }
    }
}

但是,我从未能够通过编程方式接听电话.在中的问题如何出现在Android 5.0(Lollipop)中以编程方式回答了吗?在枚举所有可能的选项方面做得很好,但是大多数都需要root和/或成为系统应用.

However, I've never been able to answer the call programmatically. The question at How can incoming calls be answered programmatically in Android 5.0 (Lollipop)? does a great job of enumerating all possible options, but most require root and/or being a system app.

这篇关于以编程方式接听Whatsapp视频通话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆