STF STF 是通过什么方式与执行 adb nodaemon server -a -P 5037 建立连接的

x · July 26, 2018 · Last by 隐身 replied at August 16, 2018 · 2237 hits

最近需要做一个远程控制手机执行脚本的计划,所以想到了 stf,很好奇它是怎么与 执行 adb nodaemon server -a -P 5037 的机器建立连接通信的,但是逛了半天百度和各种论坛还是没有解决我这个疑惑。请赐教。感觉这种方式要比 adb connect 连接手机的方式稳定很多。

共收到 6 条回复 时间 点赞

stf 启动 provider 过程中指定了 adb server 的 IP 与端口。

x #2 · July 26, 2018 Author
乾行 回复

那是是否也就是说用 adb connect 连接?我试了,可是没有成功!

x 回复

使用的 adbkit 去连接的
1、stf 源码

2、看了 adbkit 实现了 adb remote 连接相关的协议,具体代码翻看adb/protocol.coffee

Command = require '../../command'
Protocol = require '../../protocol'

class ConnectCommand extends Command
  # Possible replies:
  # "unable to connect to 192.168.2.2:5555"
  # "connected to 192.168.2.2:5555"
  # "already connected to 192.168.2.2:5555"
  RE_OK = /connected to|already connected/

  execute: (host, port) ->
    this._send "host:connect:#{host}:#{port}"
    @parser.readAscii 4
      .then (reply) =>
        switch reply
          when Protocol.OKAY
            @parser.readValue()
              .then (value) ->
                if RE_OK.test value
                  "#{host}:#{port}"
                else
                  throw new Error value.toString()
          when Protocol.FAIL
            @parser.readError()
          else
            @parser.unexpected reply, 'OKAY or FAIL'

module.exports = ConnectCommand
x #5 · July 27, 2018 Author
乾行 回复

非常感谢.

其实就是 adb connect

7Floor has deleted
需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up