appetizerio / replaykit

[DEPRECATED] Command line tools for recording, replaying and mirroring touchscreen events for Android
Apache License 2.0
245 stars 61 forks source link

Not working for Android x86 VirtualBox cases: need to locate emulated touchscreen device #12

Closed ebspeter closed 6 years ago

ebspeter commented 6 years ago

Hi,

Getting the error on running the trace command.

F:\www\android\win32>adb devices
List of devices attached
192.168.1.6:5555        device

F:\www\android\win32>appetizer devices list
[{"uid": "192.168.1.6:5555", "serialno": "192.168.1.6:5555", "brand": "Android-x86", "screenheight": 600, "device": "x86", "manufacturer": "innotek GmbH", "sdk": "19", "name": "android_x86", "heapsize": "512m", "model": "VirtualBox", "screenwidth": 800, "os": "4.4.4"}]

F:\www\android\win32>appetizer trace record --device 192.168.1.6:5555 mytrace.trace
The device does not have proper permissions for getevent

F:\www\android\win32>adb shell getevent -l
add device 1: /dev/input/event7
  name:     "Android Power Button"
add device 2: /dev/input/event1
  name:     "Sleep Button"
add device 3: /dev/input/event0
  name:     "Power Button"
add device 4: /dev/input/event2
  name:     "Video Bus"
add device 5: /dev/input/event4
  name:     "PC Speaker"
could not get driver version for /dev/input/mouse1, Not a typewriter
add device 6: /dev/input/event6
  name:     "ImExPS/2 Generic Explorer Mouse"
add device 7: /dev/input/event5
  name:     "AT Translated Set 2 keyboard"
could not get driver version for /dev/input/mice, Not a typewriter
could not get driver version for /dev/input/mouse0, Not a typewriter
add device 8: /dev/input/event3
  name:     "VirtualBox USB Tablet"

OS: Windows 8.1 adb in C:\adb\platform-tools

mingyuan-xia commented 6 years ago

I suppose this is a androix-86 emulator running in VirtualBox. As I can see from getevent -l, there is no Linux device file representing the "touchscreen", I am afraid this emulator might not be supported. You can probably try GenyMotion or the original Android emulator.

ebspeter commented 6 years ago

That was the quickest reply ever on Github!

I didn't notice that, but the inputs are there:

F:\www\docker\android\win32>adb shell input
Usage: input [<source>] <command> [<arg>...]

The sources are:
      trackball
      joystick
      touchnavigation
      mouse
      keyboard
      gamepad
      touchpad
      dpad
      stylus
      touchscreen

The commands and default sources are:
      text <string> (Default: touchscreen)
      keyevent [--longpress] <key code number or name> ... (Default: keyboard)
      tap <x> <y> (Default: touchscreen)
      swipe <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen)
      press (Default: trackball)
      roll <dx> <dy> (Default: trackball)

EDIT: I realized that is the options for the command and not the device, but tap works fine:

F:\www\docker\android\win32>adb shell input tap 400 530 //Clicks Home

I will try another emulator, what do you mean by "the original Android emulator"?

Do you have any advice on running emulators on Docker? I am trying to automate using an app from Google play.

Thanks!

mingyuan-xia commented 6 years ago

I credit slack, which pushes this issue to me and I happen to be with my keyboard. "The original Android emulator" means the one shipped with Android SDK. Best compatibility, though being a bit inefficient (memory hungry) and lack of some features. We have a small server running such emulators plus real devices connected though WiFI/USB. We use the "farm" to test many APKs concurrently. I coded up a tiny scripts to manage them: https://github.com/appetizerio/haem 'running emulators on Docker' you mean dockerized Android emulators?

ebspeter commented 6 years ago

Yes,

I've got one of these up and running: https://github.com/softsam/docker-android-emulator but can only view (VNC inputs not supported) and no playstore installed. Was thinking if maybe you had some advice.

I have also been thinking to install a new VM with the full Android SDK and run multiple emulators on that.

mingyuan-xia commented 6 years ago
  1. I guess the missing VNC input is sort-of related to this issue. Might need someone to code up an emulator Linux evdev device~~
  2. If you have sufficient server budget (mainly memory), you can consider: this plus haem, fully headless Android SDK + Google emulator(s) (with play store naturally) + a bit of swarm management (haem)
ebspeter commented 6 years ago

Cool, i just watched the video this morning. I have a dedicated 4core/16Gb to play with, not sure if it's enough though.

The device is actually /dev/input/event3, maybe you could expose an optional argument to pass the device address into appetizer trace.

example:

appetizer trace record --device 192.168.1.6:5555 --touchscreen /dev/input/event3 mytrace.trace
...
add device 8: /dev/input/event3
  name:     "VirtualBox USB Tablet"
...

Mouse click:

adb shell -l 
/dev/input/event3: EV_ABS       ABS_X                00007cff
/dev/input/event3: EV_ABS       ABS_Y                00007a81
/dev/input/event3: EV_SYN       SYN_REPORT           00000000
/dev/input/event3: EV_MSC       MSC_SCAN             00090001
/dev/input/event3: EV_KEY       BTN_LEFT             DOWN
/dev/input/event3: EV_SYN       SYN_REPORT           00000000
/dev/input/event3: EV_MSC       MSC_SCAN             00090001
/dev/input/event3: EV_KEY       BTN_LEFT             UP
mingyuan-xia commented 6 years ago

Will do in the next version. The detection part is kinda tricky, many OEM customizations. Some have dual device files to confuse... 16G should be enough for 3-5 emulators.

mingyuan-xia commented 6 years ago

--touchscreen option is added since 00efa1981daf19b4f0041e05f9e1fd85a66d93dc