Touch Android Without Touching

  • 760 views
Uploaded on

Describe how Android input system designed. …

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.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
760
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
0
Comments
0
Likes
2

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Touch Android without Touching SeongJae Park <sj38.park@gmail.com>
  • 2. Who Am I SeongJae Park sj38.park@gmail.com
  • 3. Developpeurs Miserables Tale of A Little Developer
  • 4. Let's change the world Write once I Dreamed A Dream Image source: Link
  • 5. So Different From This Hell I'm Living Image source: Link
  • 6. Freedom Is Mine ● Freedom: ○ Touch Android without... ○ Touching, Rooting, Network Setting
  • 7. Android Input System Human Device
  • 8. Android Input System Human Device Firmware Electrical signal
  • 9. Android Input System Human Device Firmware Device Driver Electrical signal HID or interrupt or ...
  • 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. 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. 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. 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. 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. /dev/input - getevent ● See input device[s] information $ adb shell getevent -[l]p [input device file path]
  • 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. /dev/input - sendevent $ adb shell sendevent <device> <type> <code> <value>
  • 18. /dev/input - sendevent $ adb shell sendevent <device> <type> <code> <value> Powerful, But Too Slow...
  • 19. Input Method Application View InputMethodManagerS ervice InputMethodService InputMethodManager InputConnection
  • 20. Input Method InputConnection.sendKeyEvent() Application View InputMethodManagerS ervice InputMethodService InputMethodManager InputConnection
  • 21. Input Method InputConnection.sendKeyEvent() Only key event & text Application View InputMethodManagerS ervice InputMethodService InputMethodManager InputConnection
  • 22. There is a monkey in the Android $ adb shell monkey -v 5000 a.k.a Stress Test image source: Link
  • 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. monkeyrunner monkey Tamer image source: Link
  • 25. monkeyrunner monkey Tamer Provide Android test API image source: Link
  • 26. monkeyrunner monkey Tamer Provide Android test API Uses Jython image source: Link
  • 27. monkey & monkeyrunner monkey InputManager device
  • 28. monkey & monkeyrunner monkey InputManager device
  • 29. monkey & monkeyrunner monkey InputManager adb adbd device
  • 30. monkey & monkeyrunner monkey InputManager ChimpChat adb port-forwarding adbd device
  • 31. monkey & monkeyrunner monkey InputManager monkeyrunner ChimpChat adb port-forwarding python program adbd device
  • 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. 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. ash: ash is a shell Devices Control Program Like a shell
  • 35. ash: ash is a shell Devices Control Program Like a shell Use monkeyrunner for Android control
  • 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. 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. ash: ash is a shell
  • 39. Do You Hear The People Sing People Who will not be machines again Image Source: Link