Touch Android Without Touching

1,789
-1

Published on

Describe how Android input system designed.
Describe the ways to make input event(such as touch, key press, ...) on Android in programmatic way, not manual way.

This can be helpful for some people thinking about Android remote control or test automation.

Published in: Technology
0 Comments
6 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,789
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
6
Embeds 0
No embeds

No notes for slide

Touch Android Without Touching

  1. 1. Touch Android without Touching SeongJae Park <sj38.park@gmail.com>
  2. 2. Who Am I SeongJae Park sj38.park@gmail.com
  3. 3. Developpeurs Miserables Tale of A Little Developer
  4. 4. Let's change the world Write once I Dreamed A Dream Image source: Link
  5. 5. So Different From This Hell I'm Living Image source: Link
  6. 6. Freedom Is Mine ● Freedom: ○ Touch Android without... ○ Touching, Rooting, Network Setting
  7. 7. Android Input System Human Device
  8. 8. Android Input System Human Device Firmware Electrical signal
  9. 9. Android Input System Human Device Firmware Device Driver Electrical signal HID or interrupt or ...
  10. 10. Android Input System Human Device Firmware Device Driver File System Electrical signal HID or interrupt or ... linux input event (linux/input.h defined)
  11. 11. Android Input System Human Device Firmware Device Driver File System Input Manager Service Input Reader Electrical signal HID or interrupt or ... linux input event (linux/input.h defined)
  12. 12. Android Input System Human Device Firmware Device Driver File System Input Manager Service EventHub Input Reader Electrical signal HID or interrupt or ... linux input event (linux/input.h defined) /dev/input/
  13. 13. Android Input System Human Device Firmware Device Driver File System Input Manager Service EventHub Input Reader Input Dispatcher Electrical signal HID or interrupt or ... linux input event (linux/input.h defined) /dev/input/
  14. 14. Android Input System Human Device Firmware Device Driver File System Input Manager Service EventHub Input Reader Input Dispatcher Window Electrical signal HID or interrupt or ... linux input event (linux/input.h defined) /dev/input/
  15. 15. /dev/input - getevent ● See input device[s] information $ adb shell getevent -[l]p [input device file path]
  16. 16. /dev/input - getevent ● See input device[s] information $ adb shell getevent -[l]p [input device file path] ● See live events $ adb shell getevent -[l]t [input device file path]
  17. 17. /dev/input - sendevent $ adb shell sendevent <device> <type> <code> <value>
  18. 18. /dev/input - sendevent $ adb shell sendevent <device> <type> <code> <value> Powerful, But Too Slow...
  19. 19. Input Method Application View InputMethodManagerS ervice InputMethodService InputMethodManager InputConnection
  20. 20. Input Method InputConnection.sendKeyEvent() Application View InputMethodManagerS ervice InputMethodService InputMethodManager InputConnection
  21. 21. Input Method InputConnection.sendKeyEvent() Only key event & text Application View InputMethodManagerS ervice InputMethodService InputMethodManager InputConnection
  22. 22. There is a monkey in the Android $ adb shell monkey -v 5000 a.k.a Stress Test image source: Link
  23. 23. There is a monkey in the Android $ adb shell monkey -v 5000 a.k.a Stress Test If We Can Tame Him... image source: Link
  24. 24. monkeyrunner monkey Tamer image source: Link
  25. 25. monkeyrunner monkey Tamer Provide Android test API image source: Link
  26. 26. monkeyrunner monkey Tamer Provide Android test API Uses Jython image source: Link
  27. 27. monkey & monkeyrunner monkey InputManager device
  28. 28. monkey & monkeyrunner monkey InputManager device
  29. 29. monkey & monkeyrunner monkey InputManager adb adbd device
  30. 30. monkey & monkeyrunner monkey InputManager ChimpChat adb port-forwarding adbd device
  31. 31. monkey & monkeyrunner monkey InputManager monkeyrunner ChimpChat adb port-forwarding python program adbd device
  32. 32. monkeyrunner $ monkeyrunner >>> from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice >>> device = MonkeyRunner.waitForConnection() >>> device.touch(100, 200, MonkeyDevice.DOWN_AND_UP) >>> device.press('KEYCODE_MENU', MonkeyDevice.DOWN_AND_UP) >>> result = device.takeSnapshot() >>> result.writeToFile('results/1.png', 'png')
  33. 33. monkeyrunner One weak point: drag void drag ( tuple start, tuple end, float duration, integer steps) Simulates a drag gesture (touch, hold, and move) on this device's screen. Arguments start The starting point of the drag gesture, in the form of a tuple (x,y) where x and y are integers. end The end point of the drag gesture, in the form of a tuple (x,y) where x and y are integers. duration The duration of the drag gesture in seconds. The default is 1.0 seconds. steps The number of steps to take when interpolating points. The default is 10.
  34. 34. ash: ash is a shell Devices Control Program Like a shell
  35. 35. ash: ash is a shell Devices Control Program Like a shell Use monkeyrunner for Android control
  36. 36. ash: ash is a shell Devices Control Program Like a shell Use monkeyrunner for Android control Provide real-time function test recording feature
  37. 37. ash: ash is a shell Devices Control Program Like a shell Use monkeyrunner for Android control Provide real-time function test recording feature Google HackFair 2012
  38. 38. ash: ash is a shell
  39. 39. Do You Hear The People Sing People Who will not be machines again Image Source: Link

×