adb

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: CC0-1.0 Imports: 17 Imported by: 0

Documentation

Overview

Package adb runs bounded shell-v2 commands through an already paired local adbd.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrProtocol       = errors.New("unsupported or invalid ADB protocol")
	ErrAuthentication = errors.New("ADB authentication failed; check wireless debugging and pairing")
)

Protocol and authentication errors let callers distinguish permanent failures from socket errors.

Example: a revoked pairing is exposed as ErrAuthentication rather than retried indefinitely.

Functions

This section is empty.

Types

type Client

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

Client holds one immutable, already paired RSA identity.

Example: NewClient reads a dedicated SDK-generated adbkey.

func NewClient

func NewClient(keyPEM []byte) (*Client, error)

NewClient validates a single PKCS1 or PKCS8 RSA private key and creates its ADB certificate.

Example: NewClient(keyPEM) accepts the output of adb keygen; it does not pair keys.

func (*Client) Shell

func (c *Client) Shell(
	ctx context.Context,
	port Port,
	command string,
) (_result Result, _err error)

Shell executes one command using TLS 1.3 and shell-v2 on literal IPv4 loopback.

Example: Shell(ctx, discoveredPort, "id -u") returns the authenticated shell's result.

type ExitError

type ExitError struct{ Code int }

ExitError reports a completed command with a nonzero exit code.

Example: unsupported fixed-performance hardware may return exit 255.

func (*ExitError) Error

func (e *ExitError) Error() string

Error describes the nonzero exit without including command output or credentials.

Example: a caller can separately inspect the bounded Result.Stderr.

func (*ExitError) Unwrap

func (e *ExitError) Unwrap() error

Unwrap identifies command failure as distinct from a transport failure.

Example: errors.As retrieves ExitError without suggesting that authentication failed.

type Port

type Port int

Port identifies the current local adbd TLS listening port, obtained through discovery.

Example: Port(37001) always addresses 127.0.0.1, never a remote host.

type Result

type Result struct {
	Stdout   string
	Stderr   string
	ExitCode int
}

Result records the last command's bounded output and shell exit status.

Example: ExitCode zero means the shell command reported success.

Jump to

Keyboard shortcuts

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