Respect specified adb server port when issuing adb start-server (#28)

When a custom host/port is specified for connecting to the adb server, they are used to establish the connection. However, if the server is not running, they are not passed to the `adb start-server` command, and so the connection will fail because the server isn't listening on the expected port.

This change passes the address to the command, according to the following line from the adb usage info:
```
 -L SOCKET  listen on given socket for adb server [default=tcp:localhost:5037]
```
This commit is contained in:
Tobias Salzmann 2017-05-30 02:51:45 +02:00 committed by Zach Klippenstein
parent 6cf99d9b4a
commit 029cc6bee4

View file

@ -109,7 +109,7 @@ func (s *realServer) Dial() (*wire.Conn, error) {
// StartServer ensures there is a server running.
func (s *realServer) Start() error {
output, err := s.config.fs.CmdCombinedOutput(s.config.PathToAdb, "start-server")
output, err := s.config.fs.CmdCombinedOutput(s.config.PathToAdb, "-L", fmt.Sprintf("tcp:%s", s.address), "start-server")
outputStr := strings.TrimSpace(string(output))
return errors.WrapErrorf(err, errors.ServerNotAvailable, "error starting server: %s\noutput:\n%s", err, outputStr)
}