adbproto

package module
v0.0.0-...-01e462b Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2022 License: MIT Imports: 12 Imported by: 1

README

ADB protocol implementation for Go

GoでAndroidのADBに接続するためのパッケージです. chrome-watchのために作ったものです.

  • PC上の adb-server を経由せずに直接Androidデバイス上の adbd と通信します
  • platform-toolsには依存しないので,単体でAndroidデバイスを操作するアプリケーションを作れます
  • プロトコルの実装のみで,USBなどの実装は含んでいません.サンプルではTCPIPで待ち受けている adbd に接続しています
  • ADB接続の認証はRSA鍵のみサポートしています.RSA鍵が登録済みであればTLS接続も可能です。

Usage

T.B.D.

cmds/shelladb shell のような動作をするサンプルです.

go run cmds/shell/main.go -t 192.168.0.123:5555
go run cmds/shell/main.go -t 192.168.0.123:5555 shell ls -la /sdcard/

TODO

  • File transfer

License

MIT License

Documentation

Overview

Simple ADB client

Index

Constants

View Source
const (
	A_SYNC = 0x434e5953
	A_CNXN = 0x4e584e43
	A_AUTH = 0x48545541
	A_OPEN = 0x4e45504f
	A_OKAY = 0x59414b4f
	A_CLSE = 0x45534c43
	A_WRTE = 0x45545257
	A_STLS = 0x534C5453

	A_STLS_VERSION_MIN = 0x01000000
	A_STLS_VERSION     = 0x01000000
)

https://android.googlesource.com/platform/packages/modules/adb/+/master/protocol.txt

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

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

func Connect

func Connect(rw io.ReadWriter, key *rsa.PrivateKey) (*Conn, error)

func (*Conn) Close

func (c *Conn) Close()

func (*Conn) Closed

func (c *Conn) Closed() <-chan struct{}

func (*Conn) Open

func (c *Conn) Open(dest string) (*Stream, error)

func (*Conn) Send

func (c *Conn) Send(p *Packet) error

type PackerHeader

type PackerHeader struct {
	Command    uint32
	Arg0       uint32
	Arg1       uint32
	DataLength uint32
	DataSum    uint32 // NOTE: data_crc32 is not CRC32...
	Magic      uint32
}

type Packet

type Packet struct {
	PackerHeader
	Data []byte
}

func NewPacket

func NewPacket(cmd, arg0, arg1 uint32, data []byte) *Packet

func (*Packet) IsValid

func (p *Packet) IsValid() bool

func (*Packet) ReadFrom

func (p *Packet) ReadFrom(r io.Reader) (int64, error)

func (*Packet) WriteTo

func (p *Packet) WriteTo(w io.Writer) (int64, error)

type Stream

type Stream struct {
	Ch chan []byte
	// contains filtered or unexported fields
}

func (*Stream) Close

func (s *Stream) Close() error

func (*Stream) Read

func (s *Stream) Read(b []byte) (int, error)

func (*Stream) Write

func (s *Stream) Write(b []byte) (int, error)

Directories

Path Synopsis
cmds

Jump to

Keyboard shortcuts

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