refactor: replace gadb with optimized version authoried by @appl3s

This commit is contained in:
lilong.129
2023-04-13 22:41:45 +08:00
parent d552a14101
commit e35a11a25f
13 changed files with 509 additions and 34 deletions
+10
View File
@@ -34,9 +34,18 @@ func newTransport(address string, readTimeout ...time.Duration) (tp transport, e
func (t transport) Send(command string) (err error) {
msg := fmt.Sprintf("%04x%s", len(command), command)
log.Debug().Str("cmd", command).Msg("run adb command")
return _send(t.sock, []byte(msg))
}
func (t transport) SendBytes(b []byte) (err error) {
return _send(t.sock, b)
}
func (t transport) Conn() net.Conn {
return t.sock
}
func (t transport) VerifyResponse() (err error) {
var status string
if status, err = t.ReadStringN(4); err != nil {
@@ -103,6 +112,7 @@ func (t transport) Close() (err error) {
if t.sock == nil {
return nil
}
_ = DisableTimeWait(t.sock.(*net.TCPConn))
return t.sock.Close()
}