Nexus one ignores touch events sent via ADB

ε祈祈猫儿з 提交于 2019-12-08 13:57:30

I think you need to set your X and Y axis touch points and then try to send the events. Also, make sure that you convert this

adb shell sendevent /dev/input/event3 0003 48 104
adb shell sendevent /dev/input/event3 0003 50 10
adb shell sendevent /dev/input/event3 0003 53 200
adb shell sendevent /dev/input/event3 0003 54 57
adb shell sendevent /dev/input/event3 0000 2 00000000

into decimal values like this (as I did only for first line but you will need to do that for all),

adb shell sendevent /dev/input/event3 3 72 260.

For more information, look at this link http://softteco.blogspot.com/2011/03/android-low-level-shell-click-on-screen.html

I managed to simulate a touch click in Nexus 7 (Android 4.2.0) using the following code:

public static void performClick(int x, int y) {

    try {
        executeCommand("sendevent /dev/input/event0 3 57 21");
        executeCommand("sendevent /dev/input/event0 3 48 9");
        executeCommand("sendevent /dev/input/event0 3 58 182");
        executeCommand("sendevent /dev/input/event0 3 53 " + x);
        executeCommand("sendevent /dev/input/event0 3 54 " + y);
        executeCommand("sendevent /dev/input/event0 0 0 0");
        executeCommand("sendevent /dev/input/event0 3 57 4294967295");
        executeCommand("sendevent /dev/input/event0 0 0 0");

    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (TimeoutException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }       
}

private static void executeCommand(String command) throws InterruptedException, IOException, TimeoutException {
    CommandCapture cmd = new CommandCapture(0, command);
    RootTools.getShell(true).add(cmd).waitForFinish();
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!