client

package
v0.0.0-...-3ed38a9 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2023 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// RGB888 encodes 3 bytes per pixel.
	RGB888 = FrameFormat(protocol.StreamDisplayRequest_RGB888)

	// VP8 codec. Uses intermediate frames.
	VP8 = FrameFormat(protocol.StreamDisplayRequest_VP8)
)
View Source
const (
	// EmulatorError signifies the emulator failed to start.
	EmulatorError = EmulatorState(protocol.AgentState_ERROR)

	// EmulatorOff signifies the emulator is off.
	EmulatorOff = EmulatorState(protocol.AgentState_OFF)

	// EmulatorStarting signifies the emulator is booting.
	EmulatorStarting = EmulatorState(protocol.AgentState_STARTING)

	// EmulatorRunning signifies the emulator is running and adb has connected.
	EmulatorRunning = EmulatorState(protocol.AgentState_RUNNING)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client represents a connection to a agent.

func Connect

func Connect(addr string) (*Client, error)

Connect opens a new connection to the given address.

func (*Client) Close

func (c *Client) Close() error

func (*Client) ListDirectory

func (c *Client) ListDirectory(ctx context.Context, path string) ([]sync.DirectoryEntry, error)

ListDirectory list all files in a directory. Requires that the emulator has reached the "running" state, otherwise an error will be returned.

func (*Client) OpenShell

func (c *Client) OpenShell(ctx context.Context, request shell.Request) (*shell.Shell, error)

OpenShell opens an ADB shell to the emulator. Requires that the emulator has reached the "running" state, otherwise an error will be returned.

func (*Client) PullFile

func (c *Client) PullFile(ctx context.Context, path string) (*sync.PullStream, error)

PullFile starts a file download transfer for the given path. Requires that the emulator has reached the "running" state, otherwise an error will be returned.

func (*Client) PushFile

func (c *Client) PushFile(ctx context.Context, path string, mode uint32) (*sync.PushStream, error)

PushFile starts a file upload transfer for the given path. Requires that the emulator has reached the "running" state, otherwise an error will be returned.

func (*Client) SendInput

func (c *Client) SendInput(ctx context.Context, event InputEvent) error

SendInput forward an input event to the emulator.

func (*Client) StartEmulator

func (c *Client) StartEmulator(ctx context.Context, request StartEmulatorRequest) error

StartEmulator requests the emulator starts. An error will be returned if the emulator is already running.

func (*Client) StatFile

func (c *Client) StatFile(ctx context.Context, path string, followLinks bool) (*sync.FileStat, error)

StatFile stats a given path, optionally following links. Requires that the emulator has reached the "running" state, otherwise an error will be returned.

func (*Client) StopEmulator

func (c *Client) StopEmulator(ctx context.Context, forceExit bool) error

StopEmulator requests the emulator exists.

func (*Client) StreamDisplay

func (c *Client) StreamDisplay(ctx context.Context, request DisplayRequest) (*DisplayStream, error)

StreamDisplay streams the display in the requested format. An initial value will be immediately produced with the current display content. This stream can and should be started before the emulator is started to ensure no frames are missed. The stream will is persistent between emulator restarts.

func (*Client) StreamState

func (c *Client) StreamState(ctx context.Context) (*StateStream, error)

StreamState streams the state of the agent process. An initial value will be immediately produced with the current agent state. Subsequent values may indicate a change in the agent state, however this is not guaranteed and the same state can be delivered multiple times.

func (*Client) StreamSysLog

func (c *Client) StreamSysLog(ctx context.Context) (*SysLogStream, error)

StreamSysLog streams the system log (kernel messages). Previous messages are not returned. This stream can and should be started before the emulator is started to ensure no messages are missed. The stream will is persistent between emulator restarts.

type DisplayRequest

type DisplayRequest struct {
	// Format specifies the frame encoding format.
	Format FrameFormat

	// MaxFPS specifies the maximum number of frames to encode per second.
	// Extra frames will be dropped, with the most recent frame encoded every 1/max_fps seconds.
	// Set to 0 to disable limit.
	MaxFPS uint32

	// KeyframeInterval specifies how often in milliseconds to encode a keyframe.
	// Set to 0 to only send when required. Not all formats use intermediate frames.
	KeyframeInterval uint32
}

A DisplayRequest represents the configuration the display should be streamed.

type DisplayStream

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

DisplayStream represents a stream of display frames.

func (*DisplayStream) Recv

func (s *DisplayStream) Recv() (*Frame, error)

Recv blocks until a new frame is generated.

type EmulatorState

type EmulatorState protocol.AgentState_EmulatorState

EmulatorState represents the state of android emulator.

type Frame

type Frame struct {
	// Keyframe specifies whether this is a key frame. For some formats, this will always be true.
	Keyframe bool
	// Width specifies the width of the frame.
	Width uint32
	// Height specifies the height of the frame.
	Height uint32
	// Data contains the raw frame data.
	Data []byte
}

Frame represents a single display frame.

type FrameFormat

FrameFormat represents the format to encode frames with.

type InputEvent

type InputEvent interface {
	ToRequest() protocol.InputRequest
}

type StartEmulatorRequest

type StartEmulatorRequest struct {
	// RamSize signifies memory in MBs.
	RamSize uint32

	// CoreCount signifies the number of cores.
	CoreCount uint32

	// LcdDensity signifies the DPI of the main display.
	LcdDensity uint32

	// LcdWidth signifies the width of the main display.
	LcdWidth uint32

	// LcdHeight signifies the height of the main display.
	LcdHeight uint32

	// RootADB requests the ADB connection is rooted. This does not guarantee the connection is rooted.
	RootADB bool
}

StartEmulatorRequest represents a request to boot the emulator with the given configuration.

Example Settings: Ram: 2048 Cores: 1 Display 720x1280 320dpi

type State

type State struct {
	// EmulatorState stores the state of the emulator.
	EmulatorState EmulatorState

	// EmulatorError stores the error message associated with the error state.
	EmulatorError *string
}

State represents the current state of the agent process and the virtual machine being controlled.

type StateStream

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

StateStream represents a stream of agent states.

func (*StateStream) Recv

func (s *StateStream) Recv() (*State, error)

Recv blocks until a new state is received.

type SysLogEntry

type SysLogEntry struct {
	// Line represents the raw line.
	Line string
}

SysLogEntry represents a syslog entry.

type SysLogStream

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

SysLogStream represents a stream of syslog entries.

func (*SysLogStream) Recv

func (s *SysLogStream) Recv() (*SysLogEntry, error)

Recv blocks until a new entry is received.

type TouchEvent

type TouchEvent struct {
	// A unique id to represent a pointer. Ids can be reused. Ids are shared amongst all connections.
	Identifier uint32

	// Coords
	X uint32
	Y uint32

	// Pointer device. A pressure of 0 must be sent to signal the event of the touch.
	Pressure   uint32
	TouchMajor int32
	TouchMinor int32
}

func (TouchEvent) ToRequest

func (e TouchEvent) ToRequest() protocol.InputRequest

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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