device

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 12 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 device finds the Android devices and iOS simulators this machine can drive.

Index

Constants

This section is empty.

Variables

View Source
var WebAvailable = func() bool { return false }

WebAvailable reports whether a browser for web flows exists (set by the web driver).

Functions

func ADB

func ADB() string

ADB returns the path to adb, preferring ANDROID_HOME and the default SDK location.

func AppInstalled

func AppInstalled(ctx context.Context, d Info, appID string) bool

AppInstalled reports whether the app (package or bundle id) is installed on the device. It answers true when it cannot tell, so a failed check never hides a device.

func IsURL

func IsURL(s string) bool

IsURL reports whether an app id is a web address (a web flow's url:).

Types

type ADBDevice

type ADBDevice struct {
	Serial string
	// contains filtered or unexported fields
}

ADBDevice runs adb commands against one device.

func NewADB

func NewADB(serial string) *ADBDevice

func (*ADBDevice) ExistingForward

func (a *ADBDevice) ExistingForward(ctx context.Context, remote string) int

ExistingForward returns the local port already forwarded to remote, or 0.

func (*ADBDevice) Forward

func (a *ADBDevice) Forward(ctx context.Context, remote string) (int, error)

Forward forwards a free local TCP port to a device socket ("localabstract:name" or "tcp:N") and returns the local port.

func (*ADBDevice) Run

func (a *ADBDevice) Run(ctx context.Context, args ...string) (string, error)

Run runs `adb -s serial args...` and returns stdout.

func (*ADBDevice) Shell

func (a *ADBDevice) Shell(ctx context.Context, script string) (string, error)

Shell runs a shell command on the device.

type Info

type Info struct {
	Platform Platform `json:"platform"`
	Serial   string   `json:"serial"` // adb serial or simulator UDID
	Name     string   `json:"name"`
	Model    string   `json:"model,omitempty"`
	Emulator bool     `json:"emulator"`
	State    string   `json:"state"`
}

Info describes one device that is connected and ready (an Android device in the "device" state, or a booted iOS simulator).

func List

func List(ctx context.Context) []Info

List returns every ready device, Android first, then iOS. Errors from one platform's tooling (adb missing, not on macOS) are ignored so the other still works.

func Pick

func Pick(devs []Info, platform Platform, want string) (Info, error)

Pick chooses a device. want may be empty, a serial/UDID, or a device name (case-insensitive). platform may be empty to allow either.

func WebDevice

func WebDevice(n int) Info

WebDevice is the n-th browser device. Browsers are made on demand, so a flow with two web roles gets two.

func (Info) String

func (i Info) String() string

type Platform

type Platform string
const (
	Android Platform = "android"
	IOS     Platform = "ios"
	Web     Platform = "web"
)

Jump to

Keyboard shortcuts

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