fakeagent

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 24 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package fakeagent is a phone simulator that speaks the real agent protocol over a tiny fake app, so servers, SDKs and CI can run without a device.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Discover

func Discover(timeout time.Duration) (addr, pub, name string, err error)

Discover broadcasts for a Droidline server on UDP 8778 and returns the first answer.

Types

type Agent

type Agent struct {
	DeviceID string
	Model    string
	Log      *slog.Logger
	// OnSAS is called with the 6-digit code during code pairing.
	OnSAS func(code string)
	// contains filtered or unexported fields
}

func New

func New(deviceID, model string, log *slog.Logger) (*Agent, error)

func Restore

func Restore(s Saved, log *slog.Logger) (*Agent, error)
func (a *Agent) DuplicateLink() error

DuplicateLink opens a second link while the first stays open, like a phone whose mobile connection died without the server noticing.

func (*Agent) GoOffline

func (a *Agent) GoOffline(d time.Duration)

GoOffline drops the link and blocks reconnects for d, like airplane mode.

func (*Agent) PairCode

func (a *Agent) PairCode(addr, serverPub string) error

PairCode pairs by comparing the 6-digit code; the server operator approves it.

func (*Agent) PairQR

func (a *Agent) PairQR(uri string) error

PairQR pairs using a droidline://pair URI.

func (*Agent) Paired

func (a *Agent) Paired() *Pairing

func (*Agent) PostNotification

func (a *Agent) PostNotification(pkg, title, text string)

PostNotification simulates an app posting a notification on the phone.

func (*Agent) PostSMS added in v0.1.13

func (a *Agent) PostSMS(address, text string)

PostSMS stores a text message in the simulated inbox, as if it had just arrived.

func (*Agent) Restart

func (a *Agent) Restart()

Restart simulates the app process dying: a new boot id and an empty cache.

func (*Agent) Run

func (a *Agent) Run() error

Run keeps the agent connected, reconnecting with backoff, until Stop.

func (*Agent) Save

func (a *Agent) Save() Saved

func (*Agent) Stop

func (a *Agent) Stop()

func (*Agent) UseRelay

func (a *Agent) UseRelay(on bool)

UseRelay makes later connections go through the relay from the config event.

type Pairing

type Pairing struct {
	ServerID    string
	ServerPub   string
	Addr        string
	RelayURL    string `json:",omitempty"`
	RelayTicket string `json:",omitempty"`
}

type Saved

type Saved struct {
	DeviceID string   `json:"device"`
	Model    string   `json:"model"`
	Key      string   `json:"key"`
	Pairing  *Pairing `json:"pairing"`
}

Saved is what the simulator keeps on disk to reconnect after a restart.

Jump to

Keyboard shortcuts

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