0%

安卓无线ADB连接

  1. 在手机上安装QPython
    GitHub上的下载链接

  2. 在手机上打开QPython软件的Terminal,安装uiautomator2

    1
    2
    # Since uiautomator2 is still developing, you have to add --pre to install development version
    pip install --pre uiautomator2
  3. 在手机上安装app-uiautomator.apk
    最新版下载链接

  4. 导入最新版的atx-agent到手机中
    最新版下载地址
    下载以linux_armv7.tar.gz结尾的二进制包。绝大部分手机都是linux-arm架构的。
    解压出atx-agent文件,导入到手机中并启动:

    1
    2
    3
    4
    5
    adb push atx-agent /data/local/tmp
    adb shell chmod 755 /data/local/tmp/atx-agent
    # launch atx-agent in daemon mode
    adb shell /data/local/tmp/atx-agent -d
    # example: server started, listening on 192.168.28.230:7912

    假设手机的地址是$DEVICE_URL(eg: http://192.168.28.230:7912)

  5. 无线访问手机系统

    1. 获取当前程序版本

      1
      2
      curl $DEVICE_URL/version
      # expect example: 0.0.7
    2. 安装应用

      1
      2
      curl -X POST -d url="http://some-host/some.apk" $DEVICE_URL/install
      # expect example: install id
      1
      2
      3
      4
      5
      6
      7
      # get install progress
      curl -X GET $DEVICE_URL/install/1
      {"id":"1","totalSize":985435,"copiedSize":16951,"message":"downloading"}
      # or
      {"id":"1","totalSize":985435,"copiedSize":985435,"message":"success installed"}
      # or
      {"id":"1","totalSize":985435,"copiedSize":342641,"message":"error install","error":"exit status 1"}
    3. 上传文件

      1
      2
      3
      4
      5
      # 上传到/sdcard目录下 (url以/结尾)
      curl -F "file=@somefile.txt" $DEVICE_URL/upload/sdcard/

      # 上传到/sdcard/tmp.txt
      curl -F "file=@somefile.txt" $DEVICE_URL/upload/sdcard/tmp.txt
    4. 程序自升级
      升级程序从gihub releases里面直接下载,升级完后自动重启

      1
      2
      # 升级到最新版
      curl 10.0.0.1:7912/upgrade
      1
      2
      # 指定升级的版本
      curl "$DEVICE_URL/upgrade?version=0.0.7"
    5. ATX Log Path

      1
      /sdcard/atx-agent.log

RESOURCE:
testerhome_10361
testerhome_10298
github_uiautomator2
github_android-uiautomator-server
github_atx-agent
github_qpython