示例#1
0
文件: raw-adb.go 项目: freakmac/adbfs
func doCommand(cmd string) error {
	conn, err := goadb.NewDialer("", *port).Dial()
	if err != nil {
		log.Fatal(err)
	}
	defer conn.Close()

	if err := wire.SendMessageString(conn, cmd); err != nil {
		return err
	}

	status, err := conn.ReadStatus()
	if err != nil {
		return err
	}

	var msg string
	for err == nil {
		msg, err = wire.ReadMessageString(conn)
		if err == nil {
			fmt.Printf("%s> %s\n", status, msg)
		}
	}

	if err != io.EOF {
		return err
	}

	return nil
}
示例#2
0
// ClientConfig returns a goadb.ClientConfig from CLI arguments.
func (c *BaseConfig) ClientConfig() goadb.ClientConfig {
	return goadb.ClientConfig{
		Dialer: goadb.NewDialer("", c.AdbPort),
	}
}