Skip to content
This repository was archived by the owner on Oct 11, 2019. It is now read-only.
Mingyuan Xia edited this page Jun 7, 2016 · 7 revisions

Welcome to the chimpchat-rest wiki!

chimpchat-rest is a Java application running on the host PC to control a USB-connected Android device, exposing APIs as REST APIs. It internally uses the chimpchat.jar and ddmlib.jar within the Android SDK <sdk>/tools/lib/. These two libraries can communicate with the device via an ADB connection. To use chimpchat-rest, make sure Android SDK is installed and ADB is available in the bash shell. Once started, the chimpchat-rest listens at 0.0.0.0:8080 by default. Alternatively, it accepts two parameters like chimpchat-rest 127.0.0.1 8181.

Play with it

gradle run to start the server

A list of commands to test with:

  • curl -X GET "http://localhost:8080/init?serialno=xxxxxxx"
    • ALWAYS DO THIS FIRST, before executing other commands
    • Make sure the device wakes up. Otherwise, stop the server and retry. This stability issue is aware at #1.
  • curl -X GET "http://localhost:8080/touch?x=500&y=500&t=downAndUp"
  • curl -X GET "http://localhost:8080/press?keyname=KEYCODE_MENU"
  • curl -X GET "http://localhost:8080/drag?startx=0&starty=0&endx=200&endy=200&steps=10&ms=100"
  • curl -X GET "http://localhost:8080/install?apk=/home/kenmark/1.apk"
  • curl -X GET "http://localhost:8080/remove?pkg=com.example.haha"
  • curl -X GET "http://localhost:8080/push?src=/home/kenmark/1.txt&dst=/sdcard/1.txt"
  • curl -X GET "http://localhost:8080/pull?src=/sdcard/1.txt&dst=/home/kenmark/1.txt"
  • curl -X GET "http://localhost:8080/getProp?prop=ro.product.model"
  • curl -X GET "http://localhost:8080/getVar?var=imei"
  • curl -X GET "http://localhost:8080/type?s=www.google.com"
  • curl -X GET "http://localhost:8080/wake"
  • curl -X GET "http://localhost:8080/reboot"
  • curl --data "am start -n com.android.settings/.Settings" http://localhost:8080/shell
    • THIS IS A POST

You can also use Chrome to play with it.

Troubleshooting

  • Get an error when init-ing the device:
INFO: Error starting command: monkey --port 12345
com.android.ddmlib.ShellCommandUnresponsiveException

It looks scary but it also seems to be benign: https://groups.google.com/forum/#!topic/android-developers/ZKu4MTkr1Jc

  • Sometimes the /init returns fine but follow-up commands fail. This is a problem in chimpchat itself. See this. Try /init again and sometimes it will be gone. I will try fixing this nasty bug.

Clone this wiki locally