Skip to content

Commit

Permalink
start adb server when dial 5037 error
Browse files Browse the repository at this point in the history
  • Loading branch information
codeskyblue committed Dec 11, 2018
1 parent 5d0e98c commit 83dffb8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion adb.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,17 @@ func (c *AdbClient) newConnection() (conn *AdbConnection, err error) {
return &AdbConnection{netConn}, nil
}

// Version returns adb server version
func (c *AdbClient) Version() (string, error) {
ver, err := c.rawVersion()
if err == nil {
return ver, nil
}
exec.Command(adbPath(), "start-server").Run()
return c.rawVersion()
}

// Version returns adb server version
func (c *AdbClient) rawVersion() (string, error) {
conn, err := c.newConnection()
if err != nil {
return "", err
Expand Down

0 comments on commit 83dffb8

Please sign in to comment.