Browse Source

Split adb.go into server and device

pull/10/head
Daniel Martí 10 years ago
parent
commit
41a332f361
  1. 20
      adb/device.go
  2. 28
      adb/server.go

20
adb/adb.go → adb/device.go

@ -5,33 +5,13 @@ package adb
import ( import (
"bufio" "bufio"
"fmt"
"io" "io"
"net"
"os/exec" "os/exec"
"regexp" "regexp"
"strconv" "strconv"
"strings" "strings"
) )
const (
host = "127.0.0.1"
port = 5037
)
func IsServerRunning() bool {
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", host, port))
if err != nil {
return false
}
conn.Close()
return true
}
func StartServer() error {
return exec.Command("adb", "start-server").Run()
}
type Device struct { type Device struct {
ID string ID string
Usb string Usb string

28
adb/server.go

@ -0,0 +1,28 @@
// Copyright (c) 2015, Daniel Martí <mvdan@mvdan.cc>
// See LICENSE for licensing information
package adb
import (
"fmt"
"net"
"os/exec"
)
const (
host = "127.0.0.1"
port = 5037
)
func IsServerRunning() bool {
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", host, port))
if err != nil {
return false
}
conn.Close()
return true
}
func StartServer() error {
return exec.Command("adb", "start-server").Run()
}
Loading…
Cancel
Save