If dialing the server fails initially, attempt to start the server and retry.

This commit is contained in:
Zach Klippenstein 2015-09-07 16:06:20 -07:00
parent bdf8f854c3
commit 0aa31c0548
2 changed files with 11 additions and 2 deletions

View file

@ -54,7 +54,16 @@ func (d *netDialer) Dial() (*wire.Conn, error) {
address := fmt.Sprintf("%s:%d", host, port)
netConn, err := net.Dial("tcp", address)
if err != nil {
return nil, util.WrapErrorf(err, util.ServerNotAvailable, "error dialing %s", address)
// Attempt to start the server and try again.
if err = StartServer(); err != nil {
return nil, util.WrapErrorf(err, util.ServerNotAvailable, "error starting server")
}
address = fmt.Sprintf("%s:%d", host, port)
netConn, err = net.Dial("tcp", address)
if err != nil {
return nil, util.WrapErrorf(err, util.ServerNotAvailable, "error dialing %s", address)
}
}
conn := &wire.Conn{

View file

@ -11,8 +11,8 @@ import (
HostClient communicates with host services on the adb server.
Eg.
StartServer()
client := NewHostClient()
client.StartServer()
client.ListDevices()
See list of services at https://android.googlesource.com/platform/system/core/+/master/adb/SERVICES.TXT.