proxy

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: CC0-1.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadRequest

func ReadRequest(
	r io.Reader,
) (descriptor string, code uint32, flags uint32, data []byte, err error)

ReadRequest deserializes a transaction request from r.

func ReadResponse

func ReadResponse(
	r io.Reader,
) (statusCode uint32, data []byte, err error)

ReadResponse deserializes a transaction response from r.

func WriteRequest

func WriteRequest(
	w io.Writer,
	descriptor string,
	code uint32,
	flags uint32,
	data []byte,
) error

WriteRequest serializes a transaction request onto w.

func WriteResponse

func WriteResponse(
	w io.Writer,
	statusCode uint32,
	data []byte,
) error

WriteResponse serializes a transaction response onto w.

Types

type Daemon

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

Daemon is a device-side TCP server that forwards binder transactions from a host-side proxy to the Android binder driver.

func NewDaemon

func NewDaemon(
	ctx context.Context,
	opts ...DaemonOption,
) (_ *Daemon, _err error)

NewDaemon opens the binder driver and creates a ServiceManager.

func (*Daemon) Close

func (d *Daemon) Close(
	ctx context.Context,
) error

Close releases the binder driver.

func (*Daemon) Serve

func (d *Daemon) Serve(
	ctx context.Context,
) (_err error)

Serve accepts TCP connections and handles binder transactions. Blocks until ctx is cancelled.

type DaemonOption

type DaemonOption interface {
	// contains filtered or unexported methods
}

DaemonOption configures a Daemon.

func DaemonOptionListenAddr

func DaemonOptionListenAddr(addr string) DaemonOption

DaemonOptionListenAddr sets the TCP address the daemon listens on.

func DaemonOptionMapSize

func DaemonOptionMapSize(size uint32) DaemonOption

DaemonOptionMapSize sets the mmap size for the binder driver.

type DaemonOptions

type DaemonOptions []DaemonOption

DaemonOptions is a slice of DaemonOption.

type RemoteTransport

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

RemoteTransport sends binder transactions over TCP to a device-side Daemon. It implements a Transact method compatible with generated proxy code.

func NewRemoteTransport

func NewRemoteTransport(
	addr string,
) (_ *RemoteTransport, _err error)

NewRemoteTransport connects to the daemon at the given TCP address.

func (*RemoteTransport) Close

func (rt *RemoteTransport) Close() error

Close closes the TCP connection to the daemon.

func (*RemoteTransport) Transact

func (rt *RemoteTransport) Transact(
	ctx context.Context,
	descriptor string,
	code uint32,
	flags uint32,
	data *parcel.Parcel,
) (_ *parcel.Parcel, _err error)

Transact sends a binder transaction request to the remote daemon and returns the reply parcel.

type Session

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

Session orchestrates the full remote-binder-proxy flow: cross-compile and push the daemon, start it, set up port forwarding, and create a RemoteTransport.

func NewSession

func NewSession(
	ctx context.Context,
	deviceSerial string,
	opts ...SessionOption,
) (_ *Session, _err error)

NewSession creates a Session: pushes the daemon to the device, starts it, sets up port forwarding, and connects.

func (*Session) Close

func (s *Session) Close(
	ctx context.Context,
) error

Close kills the daemon, removes the binary, tears down port forwarding, and closes the transport.

func (*Session) Transport

func (s *Session) Transport() *RemoteTransport

Transport returns the RemoteTransport connected to the device daemon.

type SessionOption

type SessionOption interface {
	// contains filtered or unexported methods
}

SessionOption configures a Session.

func SessionOptionDaemonBin

func SessionOptionDaemonBin(path string) SessionOption

SessionOptionDaemonBin sets the path to a pre-built daemon binary, skipping cross-compilation.

func SessionOptionLocalPort

func SessionOptionLocalPort(port int) SessionOption

SessionOptionLocalPort sets the local TCP port for ADB forwarding.

func SessionOptionRemotePort

func SessionOptionRemotePort(port int) SessionOption

SessionOptionRemotePort sets the remote TCP port the daemon listens on.

type SessionOptions

type SessionOptions []SessionOption

SessionOptions is a slice of SessionOption.

type TransactError

type TransactError struct {
	Descriptor string
	Code       binder.TransactionCode
	StatusCode uint32
}

TransactError indicates that the daemon returned a non-zero status code.

func (*TransactError) Error

func (e *TransactError) Error() string

Jump to

Keyboard shortcuts

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