adb

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2019 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Ref link https://github.com/openstf/adbkit/blob/master/src/adb/tcpusb/socket.coffee

Index

Constants

View Source
const (
	StateUnauthorized = DeviceState("unauthorized")
	StateDisconnected = DeviceState("disconnected")
	StateOffline      = DeviceState("offline")
	StateOnline       = DeviceState("device")
)
View Source
const (
	// host:transport-any and host:<request>
	DeviceAny deviceDescriptorType = iota
	// host:transport:<serial> and host-serial:<serial>:<request>
	DeviceSerial
	// host:transport-usb and host-usb:<request>
	DeviceUsb
	// host:transport-local and host-local:<request>
	DeviceLocal
)
View Source
const (
	ModeDir        uint32 = 0040000
	ModeSocket            = 0140000
	ModeSymlink           = 0120000
	ModeRegular           = 0100000
	ModeNamedPipe         = 0010000
	ModeCharDevice        = 0020000
	ModeSetuid            = 0004000
	ModeSetgid            = 0002000
	ModePerm              = 0000777
)
View Source
const (
	UINT16_MAX = 0xFFFF
	UINT32_MAX = 0xFFFFFFFF

	AUTH_TOKEN        = 1
	AUTH_SIGNATURE    = 2
	AUTH_RSAPUBLICKEY = 3

	TOKEN_LENGTH = 20
)

Variables

View Source
var (
	ErrChecksum   = errors.New("adb: checksum error")
	ErrCheckMagic = errors.New("adb: magic error")
)

Functions

This section is empty.

Types

type ADBConn

type ADBConn struct {
	io.Closer
	// contains filtered or unexported fields
}

func NewADBConn

func NewADBConn(conn net.Conn) *ADBConn

func (*ADBConn) CheckOKAY

func (conn *ADBConn) CheckOKAY() error

CheckOKAY check OKAY, or FAIL

func (*ADBConn) DecodeString

func (conn *ADBConn) DecodeString() (string, error)

func (*ADBConn) Encode

func (conn *ADBConn) Encode(v []byte) error

func (*ADBConn) EncodeString

func (conn *ADBConn) EncodeString(s string) error

func (*ADBConn) Err

func (conn *ADBConn) Err() error

func (*ADBConn) Read

func (conn *ADBConn) Read(p []byte) (n int, err error)

func (*ADBConn) ReadN

func (conn *ADBConn) ReadN(n int) (data []byte, err error)

func (*ADBConn) ReadNString

func (conn *ADBConn) ReadNString(n int) (data string, err error)

func (*ADBConn) ReadUint32

func (conn *ADBConn) ReadUint32() (i uint32, err error)

func (*ADBConn) Write

func (conn *ADBConn) Write(p []byte) (n int, err error)

func (*ADBConn) WriteLE

func (conn *ADBConn) WriteLE(v interface{}) error

write data with little endian

func (*ADBConn) WriteObjects

func (conn *ADBConn) WriteObjects(objs ...interface{}) error

WriteObjects according to type

func (*ADBConn) WriteString

func (conn *ADBConn) WriteString(s string) (int, error)

type ADBDaemon

type ADBDaemon struct {
	// contains filtered or unexported fields
}

ADBDaemon implement service for command: adb connect

func NewADBDaemon

func NewADBDaemon(device *Device) *ADBDaemon

func (*ADBDaemon) ListenAndServe

func (s *ADBDaemon) ListenAndServe(addr string) error

func (*ADBDaemon) Serve

func (s *ADBDaemon) Serve(ln net.Listener) error

type Client

type Client struct {
	Addr string
}

func NewClient

func NewClient(addr string) *Client

func (*Client) Device

func (c *Client) Device(descriptor DeviceDescriptor) *Device

func (*Client) DeviceWithSerial

func (c *Client) DeviceWithSerial(serial string) *Device

func (*Client) KillServer

func (c *Client) KillServer() error

KillServer tells the server to quit immediately

func (*Client) ListDevices

func (c *Client) ListDevices() (devs []*Device, err error)

ListDevices returns the list of connected devices

func (*Client) ServerVersion

func (c *Client) ServerVersion() (v int, err error)

ServerVersion returns int. 39 means 1.0.39

func (*Client) StartServer

func (c *Client) StartServer() (err error)

type Device

type Device struct {
	// contains filtered or unexported fields
}

Device

func (*Device) OpenShell

func (d *Device) OpenShell(cmd string) (rwc io.ReadWriteCloser, err error)

func (*Device) OpenTransport

func (d *Device) OpenTransport() (conn *ADBConn, err error)

OpenTransport is a low level function Connect to adbd.exe and send <host-prefix>:transport and check OKAY conn should be Close after using

func (*Device) Properties

func (ad *Device) Properties() (props map[string]PropValue, err error)

func (*Device) RunCommand

func (d *Device) RunCommand(args ...string) (output string, err error)

func (*Device) Serial

func (d *Device) Serial() (serial string, err error)

func (*Device) ServeTCP

func (d *Device) ServeTCP(in net.Conn)

ServeTCP acts as adbd(Daemon) for adb connect

func (*Device) Stat

func (d *Device) Stat(path string) (info os.FileInfo, err error)

func (*Device) String

func (d *Device) String() string

type DeviceDescriptor

type DeviceDescriptor struct {
	// contains filtered or unexported fields
}

func AnyDevice

func AnyDevice() DeviceDescriptor

func AnyLocalDevice

func AnyLocalDevice() DeviceDescriptor

func AnyUsbDevice

func AnyUsbDevice() DeviceDescriptor

func DeviceWithSerial

func DeviceWithSerial(serial string) DeviceDescriptor

func (DeviceDescriptor) String

func (d DeviceDescriptor) String() string

type DeviceState

type DeviceState string

type Packet

type Packet struct {
	Command string
	Arg0    uint32
	Arg1    uint32
	Body    []byte
}

Packet is a meta for adb connect

func (Packet) BodySkipNull

func (pkt Packet) BodySkipNull() []byte

func (Packet) DumpToStdout

func (pkt Packet) DumpToStdout()

func (Packet) EncodeToBytes

func (pkt Packet) EncodeToBytes() []byte

func (Packet) WriteTo

func (pkt Packet) WriteTo(wr io.Writer) (n int, err error)

type PacketReader

type PacketReader struct {
	C chan Packet
	// contains filtered or unexported fields
}

func NewPacketReader

func NewPacketReader(reader io.Reader) *PacketReader

func (*PacketReader) Err

func (p *PacketReader) Err() error

type PacketWriter

type PacketWriter struct {
	// contains filtered or unexported fields
}

func NewPacketWriter

func NewPacketWriter(w io.Writer) *PacketWriter

func (*PacketWriter) WritePacket

func (p *PacketWriter) WritePacket(pkt Packet) error

type PropValue

type PropValue string

func (PropValue) Bool

func (p PropValue) Bool() bool

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session created when adb connected

func NewSession

func NewSession(conn net.Conn, device *Device) *Session

func (*Session) Serve

func (s *Session) Serve()

type TransportService

type TransportService struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL