If dialing the server fails initially, attempt to start the server and retry.
This commit is contained in:
parent
bdf8f854c3
commit
0aa31c0548
11
dialer.go
11
dialer.go
|
@ -54,7 +54,16 @@ func (d *netDialer) Dial() (*wire.Conn, error) {
|
||||||
address := fmt.Sprintf("%s:%d", host, port)
|
address := fmt.Sprintf("%s:%d", host, port)
|
||||||
netConn, err := net.Dial("tcp", address)
|
netConn, err := net.Dial("tcp", address)
|
||||||
if err != nil {
|
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{
|
conn := &wire.Conn{
|
||||||
|
|
|
@ -11,8 +11,8 @@ import (
|
||||||
HostClient communicates with host services on the adb server.
|
HostClient communicates with host services on the adb server.
|
||||||
|
|
||||||
Eg.
|
Eg.
|
||||||
|
StartServer()
|
||||||
client := NewHostClient()
|
client := NewHostClient()
|
||||||
client.StartServer()
|
|
||||||
client.ListDevices()
|
client.ListDevices()
|
||||||
|
|
||||||
See list of services at https://android.googlesource.com/platform/system/core/+/master/adb/SERVICES.TXT.
|
See list of services at https://android.googlesource.com/platform/system/core/+/master/adb/SERVICES.TXT.
|
||||||
|
|
Loading…
Reference in a new issue