adb

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyHome       = 3
	KeyBack       = 4
	KeyCall       = 5
	KeyEndCall    = 6
	KeyDPadUp     = 19
	KeyDPadDown   = 20
	KeyDPadLeft   = 21
	KeyDPadRight  = 22
	KeyDPadCenter = 23
	KeyVolumeUp   = 24
	KeyVolumeDown = 25
	KeyPower      = 26
	KeyCamera     = 27
	KeyClear      = 28
	KeyMenu       = 82
	KeySearch     = 84
	KeyMediaPlay  = 85
	KeyMediaStop  = 86
	KeyMediaNext  = 87
	KeyMediaPrev  = 88
	KeyMediaPause = 127
	KeyMute       = 91
	KeyTab        = 61
	KeyEnter      = 66
	KeyDelete     = 67
	KeyRecents    = 187
	KeyBrightDown = 220
	KeyBrightUp   = 221
	KeySleep      = 223
	KeyWakeUp     = 224
)

Variables

View Source
var Gestures = []GestureDef{
	{"Swipe Up", GestureParams{0.50, 0.75, 0.50, 0.25, 300}},
	{"Swipe Down", GestureParams{0.50, 0.25, 0.50, 0.75, 300}},
	{"Swipe Left", GestureParams{0.75, 0.50, 0.25, 0.50, 300}},
	{"Swipe Right", GestureParams{0.25, 0.50, 0.75, 0.50, 300}},
	{"Scroll Up", GestureParams{0.50, 0.60, 0.50, 0.40, 200}},
	{"Scroll Down", GestureParams{0.50, 0.40, 0.50, 0.60, 200}},
	{"Fling Up", GestureParams{0.50, 0.80, 0.50, 0.20, 80}},
	{"Fling Down", GestureParams{0.50, 0.20, 0.50, 0.80, 80}},
	{"Pull Down", GestureParams{0.50, 0.02, 0.50, 0.60, 300}},
	{"Pull Up", GestureParams{0.50, 0.98, 0.50, 0.40, 300}},
}

Gestures is the list of predefined gesture presets.

Functions

func BatteryStatusName

func BatteryStatusName(status int) string

Types

type BackupOptions

type BackupOptions struct {
	APK      bool
	OBB      bool
	Shared   bool
	All      bool
	System   bool
	Packages []string
}

type BatteryInfo

type BatteryInfo struct {
	Level       int
	Temperature int
	Voltage     int
	Status      string
	Health      string
}

type CPUInfo

type CPUInfo struct {
	User   float64
	System float64
	Idle   float64
	IOWait float64
}

type Client

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

func NewClient

func NewClient() (*Client, error)

func NewClientWithPath

func NewClientWithPath(adbPath string) *Client

func (*Client) AdbPath

func (c *Client) AdbPath() string

func (*Client) Backup

func (c *Client) Backup(ctx context.Context, serial, outputPath string, options BackupOptions) error

func (*Client) Bugreport

func (c *Client) Bugreport(ctx context.Context, serial, outputPath string) error

func (*Client) Cat

func (c *Client) Cat(ctx context.Context, serial, path string) (string, error)

func (*Client) Chmod

func (c *Client) Chmod(ctx context.Context, serial, path, mode string) error

func (*Client) Chown

func (c *Client) Chown(ctx context.Context, serial, path, owner string) error

func (*Client) ClearData

func (c *Client) ClearData(ctx context.Context, serial, pkg string) error

func (*Client) CollapseNotifications

func (c *Client) CollapseNotifications(ctx context.Context, serial string) error

CollapseNotifications closes the notification shade.

func (*Client) Connect

func (c *Client) Connect(ctx context.Context, host string) error

func (*Client) DeleteSetting

func (c *Client) DeleteSetting(ctx context.Context, serial string, namespace SettingNamespace, key string) error

func (*Client) DisablePackage

func (c *Client) DisablePackage(ctx context.Context, serial, pkg string) error

func (*Client) DisableVerity

func (c *Client) DisableVerity(ctx context.Context, serial string) error

func (*Client) DisableWifi

func (c *Client) DisableWifi(ctx context.Context, serial string) error

func (*Client) Disconnect

func (c *Client) Disconnect(ctx context.Context, host string) error

func (*Client) DiskFree

func (c *Client) DiskFree(ctx context.Context, serial string) ([]DiskUsage, error)

func (*Client) DumpUIHierarchy

func (c *Client) DumpUIHierarchy(ctx context.Context, serial string) (string, error)

DumpUIHierarchy captures the current UI hierarchy as XML.

func (*Client) Dumpsys

func (c *Client) Dumpsys(ctx context.Context, serial, service string) (string, error)

func (*Client) DumpsysList

func (c *Client) DumpsysList(ctx context.Context, serial string) ([]string, error)

func (*Client) EnablePackage

func (c *Client) EnablePackage(ctx context.Context, serial, pkg string) error

func (*Client) EnableVerity

func (c *Client) EnableVerity(ctx context.Context, serial string) error

func (*Client) EnableWifi

func (c *Client) EnableWifi(ctx context.Context, serial string) error

func (*Client) Exec

func (c *Client) Exec(ctx context.Context, args ...string) (*ExecResult, error)

func (*Client) ExecDevice

func (c *Client) ExecDevice(ctx context.Context, serial string, args ...string) (*ExecResult, error)

func (*Client) ExpandNotifications

func (c *Client) ExpandNotifications(ctx context.Context, serial string) error

ExpandNotifications pulls down the notification shade.

func (*Client) ExpandQuickSettings

func (c *Client) ExpandQuickSettings(ctx context.Context, serial string) error

ExpandQuickSettings pulls down the quick settings panel.

func (*Client) Find

func (c *Client) Find(ctx context.Context, serial, path, name string) ([]string, error)

func (*Client) FindAndTapElement

func (c *Client) FindAndTapElement(ctx context.Context, serial, text, resourceID string, index int) error

FindAndTapElement dumps the UI, finds an element by text or resource ID, and taps it. The index parameter selects which match to tap when multiple elements match (0-based).

func (*Client) ForceStop

func (c *Client) ForceStop(ctx context.Context, serial, pkg string) error

func (*Client) Forward

func (c *Client) Forward(ctx context.Context, serial, local, remote string) error

func (*Client) ForwardList

func (c *Client) ForwardList(ctx context.Context, serial string) ([]ForwardRule, error)

func (*Client) ForwardRemove

func (c *Client) ForwardRemove(ctx context.Context, serial, local string) error

func (*Client) ForwardRemoveAll

func (c *Client) ForwardRemoveAll(ctx context.Context, serial string) error

func (*Client) GetAPKPath

func (c *Client) GetAPKPath(ctx context.Context, serial, pkg string) (string, error)

func (*Client) GetAirplaneMode

func (c *Client) GetAirplaneMode(ctx context.Context, serial string) (bool, error)

GetAirplaneMode returns whether airplane mode is enabled.

func (*Client) GetAppMemInfo

func (c *Client) GetAppMemInfo(ctx context.Context, serial, pkg string) (string, error)

func (*Client) GetAutoRotation

func (c *Client) GetAutoRotation(ctx context.Context, serial string) (bool, error)

GetAutoRotation returns whether auto-rotation is enabled.

func (*Client) GetBatteryInfo

func (c *Client) GetBatteryInfo(ctx context.Context, serial string) (*BatteryInfo, error)

func (*Client) GetBrightness

func (c *Client) GetBrightness(ctx context.Context, serial string) (int, error)

GetBrightness returns the current screen brightness (0-255).

func (*Client) GetCPUUsage

func (c *Client) GetCPUUsage(ctx context.Context, serial string) (*CPUInfo, error)

func (*Client) GetClipboard

func (c *Client) GetClipboard(ctx context.Context, serial string) (string, error)

func (*Client) GetCurrentActivity

func (c *Client) GetCurrentActivity(ctx context.Context, serial string) (string, error)

func (*Client) GetDevice

func (c *Client) GetDevice(ctx context.Context, serial string) (*Device, error)

func (*Client) GetDeviceInfo

func (c *Client) GetDeviceInfo(ctx context.Context, serial string) (*DeviceInfo, error)

func (*Client) GetDiskUsage

func (c *Client) GetDiskUsage(ctx context.Context, serial string) ([]DiskUsage, error)

func (*Client) GetDisplayInfo

func (c *Client) GetDisplayInfo(ctx context.Context, serial string) (*DisplayInfo, error)

func (*Client) GetFocusedApp

func (c *Client) GetFocusedApp(ctx context.Context, serial string) (string, error)

GetFocusedApp returns the package name of the currently focused application.

func (*Client) GetFontScale

func (c *Client) GetFontScale(ctx context.Context, serial string) (float64, error)

func (*Client) GetIPAddress

func (c *Client) GetIPAddress(ctx context.Context, serial string) (string, error)

func (*Client) GetMemInfo

func (c *Client) GetMemInfo(ctx context.Context, serial string) (*MemInfo, error)

func (*Client) GetNetstat

func (c *Client) GetNetstat(ctx context.Context, serial string) ([]NetConnection, error)

func (*Client) GetNetworkInfo

func (c *Client) GetNetworkInfo(ctx context.Context, serial string) (*NetworkInfo, error)

func (*Client) GetPackageInfo

func (c *Client) GetPackageInfo(ctx context.Context, serial, pkg string) (*PackageDetail, error)

func (*Client) GetProp

func (c *Client) GetProp(ctx context.Context, serial, key string) (string, error)

func (*Client) GetSELinuxStatus

func (c *Client) GetSELinuxStatus(ctx context.Context, serial string) (string, error)

func (*Client) GetScreenSize

func (c *Client) GetScreenSize(ctx context.Context, serial string) (width, height int, err error)

func (*Client) GetSerialNo

func (c *Client) GetSerialNo(ctx context.Context, serial string) (string, error)

func (*Client) GetSetting

func (c *Client) GetSetting(ctx context.Context, serial string, namespace SettingNamespace, key string) (string, error)

func (*Client) GetState

func (c *Client) GetState(ctx context.Context, serial string) (DeviceState, error)

func (*Client) GetTopProcesses

func (c *Client) GetTopProcesses(ctx context.Context, serial string, count int) ([]ProcessInfo, error)

func (*Client) GetUsageStats

func (c *Client) GetUsageStats(ctx context.Context, serial string) (string, error)

func (*Client) GetVolume

func (c *Client) GetVolume(ctx context.Context, serial string) (int, error)

GetVolume returns the current media volume via dumpsys audio.

func (*Client) GetWifiStatus

func (c *Client) GetWifiStatus(ctx context.Context, serial string) (bool, error)

func (*Client) GetWindowInfo

func (c *Client) GetWindowInfo(ctx context.Context, serial string) (string, error)

func (*Client) GrantPermission

func (c *Client) GrantPermission(ctx context.Context, serial, pkg, permission string) error

func (*Client) Head

func (c *Client) Head(ctx context.Context, serial, path string, lines int) (string, error)

Head reads the first n lines of a file safely using ShellArgs.

func (*Client) HumanSwipe

func (c *Client) HumanSwipe(ctx context.Context, serial string, screenW, screenH int, p GestureParams) error

HumanSwipe performs a swipe gesture with small random perturbations to simulate natural human touch behavior. Adds ±10px endpoint jitter and ±5px perpendicular drift so the path is never a perfect straight line.

func (*Client) InstallAPK

func (c *Client) InstallAPK(ctx context.Context, serial, path string, options InstallOptions) error

func (*Client) IsRooted

func (c *Client) IsRooted(ctx context.Context, serial string) bool

func (*Client) IsScreenOn

func (c *Client) IsScreenOn(ctx context.Context, serial string) (bool, error)

IsScreenOn checks whether the device screen is currently on.

func (*Client) KeyEvent

func (c *Client) KeyEvent(ctx context.Context, serial string, keycode int) error

func (*Client) KillProcess

func (c *Client) KillProcess(ctx context.Context, serial string, pid int) error

func (*Client) KillProcessByName

func (c *Client) KillProcessByName(ctx context.Context, serial, name string) error

func (*Client) KillServer

func (c *Client) KillServer(ctx context.Context) error

func (*Client) ListActivities

func (c *Client) ListActivities(ctx context.Context, serial, pkg string) ([]string, error)

func (*Client) ListAppPermissions

func (c *Client) ListAppPermissions(ctx context.Context, serial, pkg string) ([]PermissionInfo, error)

func (*Client) ListDevices

func (c *Client) ListDevices(ctx context.Context) ([]*Device, error)

func (*Client) ListDir

func (c *Client) ListDir(ctx context.Context, serial, dirPath string) ([]FileInfo, error)

func (*Client) ListNotifications

func (c *Client) ListNotifications(ctx context.Context, serial string) ([]NotificationInfo, error)

func (*Client) ListPackages

func (c *Client) ListPackages(ctx context.Context, serial string, options ListOptions) ([]PackageInfo, error)

func (*Client) ListPermissions

func (c *Client) ListPermissions(ctx context.Context, serial, group string) ([]string, error)

func (*Client) ListProcesses

func (c *Client) ListProcesses(ctx context.Context, serial string) ([]ProcessInfo, error)

func (*Client) ListProps

func (c *Client) ListProps(ctx context.Context, serial string) (map[string]string, error)

func (*Client) ListSettings

func (c *Client) ListSettings(ctx context.Context, serial string, namespace SettingNamespace) (map[string]string, error)

func (*Client) LogcatClear

func (c *Client) LogcatClear(ctx context.Context, serial string) error

func (*Client) LogcatDump

func (c *Client) LogcatDump(ctx context.Context, serial string, options LogcatOptions) ([]LogEntry, error)

func (*Client) LogcatStream

func (c *Client) LogcatStream(ctx context.Context, serial string, options LogcatOptions) (<-chan LogEntry, error)

func (*Client) LongPress

func (c *Client) LongPress(ctx context.Context, serial string, x, y, durationMs int) error

func (*Client) MediaNext

func (c *Client) MediaNext(ctx context.Context, serial string) error

MediaNext sends the media next track key event.

func (*Client) MediaPause

func (c *Client) MediaPause(ctx context.Context, serial string) error

MediaPause sends the media pause key event.

func (*Client) MediaPlay

func (c *Client) MediaPlay(ctx context.Context, serial string) error

MediaPlay sends the media play key event.

func (*Client) MediaPrev

func (c *Client) MediaPrev(ctx context.Context, serial string) error

MediaPrev sends the media previous track key event.

func (*Client) Mkdir

func (c *Client) Mkdir(ctx context.Context, serial, path string) error

func (*Client) OpenURL

func (c *Client) OpenURL(ctx context.Context, serial, url string) error

OpenURL opens a URL in the default browser.

func (*Client) Pair

func (c *Client) Pair(ctx context.Context, host, code string) error

func (*Client) Ping

func (c *Client) Ping(ctx context.Context, serial, host string, count int) (*PingResult, error)

func (*Client) Pull

func (c *Client) Pull(ctx context.Context, serial, remote, local string) error

func (*Client) Push

func (c *Client) Push(ctx context.Context, serial, local, remote string) error

func (*Client) PutSetting

func (c *Client) PutSetting(ctx context.Context, serial string, namespace SettingNamespace, key, value string) error

func (*Client) Reboot

func (c *Client) Reboot(ctx context.Context, serial, mode string) error

func (*Client) Remount

func (c *Client) Remount(ctx context.Context, serial string) error

func (*Client) Remove

func (c *Client) Remove(ctx context.Context, serial, path string) error

func (*Client) ResetBattery

func (c *Client) ResetBattery(ctx context.Context, serial string) error

func (*Client) ResetDensity

func (c *Client) ResetDensity(ctx context.Context, serial string) error

func (*Client) ResetDisplaySize

func (c *Client) ResetDisplaySize(ctx context.Context, serial string) error

func (*Client) Restore

func (c *Client) Restore(ctx context.Context, serial, backupPath string) error

func (*Client) Reverse

func (c *Client) Reverse(ctx context.Context, serial, remote, local string) error

func (*Client) ReverseList

func (c *Client) ReverseList(ctx context.Context, serial string) ([]ForwardRule, error)

func (*Client) ReverseRemove

func (c *Client) ReverseRemove(ctx context.Context, serial, remote string) error

func (*Client) ReverseRemoveAll

func (c *Client) ReverseRemoveAll(ctx context.Context, serial string) error

func (*Client) RevokePermission

func (c *Client) RevokePermission(ctx context.Context, serial, pkg, permission string) error

func (*Client) Root

func (c *Client) Root(ctx context.Context) error

func (*Client) RootDevice

func (c *Client) RootDevice(ctx context.Context, serial string) error

func (*Client) RunCommand

func (c *Client) RunCommand(ctx context.Context, serial, cmd string) (string, error)

func (*Client) RunCommandAsRoot

func (c *Client) RunCommandAsRoot(ctx context.Context, serial, cmd string) (string, error)

func (*Client) RunInstrumentation

func (c *Client) RunInstrumentation(ctx context.Context, serial, component string, options InstrumentOptions) (*ExecResult, error)

func (*Client) RunMonkey

func (c *Client) RunMonkey(ctx context.Context, serial, pkg string, events int, options MonkeyOptions) (*ExecResult, error)

func (*Client) ScreenOff

func (c *Client) ScreenOff(ctx context.Context, serial string) error

ScreenOff turns off the device screen.

func (*Client) ScreenOn

func (c *Client) ScreenOn(ctx context.Context, serial string) error

ScreenOn wakes the device screen.

func (*Client) ScreenRecord

func (c *Client) ScreenRecord(ctx context.Context, serial, path string, options ScreenRecordOptions) (*exec.Cmd, error)

func (*Client) Screenshot

func (c *Client) Screenshot(ctx context.Context, serial, path string) error

func (*Client) SendBroadcast

func (c *Client) SendBroadcast(ctx context.Context, serial string, intent Intent) error

func (*Client) SetAirplaneMode

func (c *Client) SetAirplaneMode(ctx context.Context, serial string, enabled bool) error

SetAirplaneMode enables or disables airplane mode.

func (*Client) SetAutoRotation

func (c *Client) SetAutoRotation(ctx context.Context, serial string, enabled bool) error

SetAutoRotation enables or disables auto-rotation.

func (*Client) SetBatteryLevel

func (c *Client) SetBatteryLevel(ctx context.Context, serial string, level int) error

func (*Client) SetBatteryPlugged

func (c *Client) SetBatteryPlugged(ctx context.Context, serial string, plugType int) error

func (*Client) SetBatteryStatus

func (c *Client) SetBatteryStatus(ctx context.Context, serial string, status int) error

func (*Client) SetBrightness

func (c *Client) SetBrightness(ctx context.Context, serial string, level int) error

SetBrightness sets the screen brightness (0-255).

func (*Client) SetClipboard

func (c *Client) SetClipboard(ctx context.Context, serial string, text string) error

func (*Client) SetDensity

func (c *Client) SetDensity(ctx context.Context, serial string, dpi int) error

func (*Client) SetDisplaySize

func (c *Client) SetDisplaySize(ctx context.Context, serial string, w, h int) error

func (*Client) SetFontScale

func (c *Client) SetFontScale(ctx context.Context, serial string, scale float64) error

func (*Client) SetProp

func (c *Client) SetProp(ctx context.Context, serial, key, value string) error

func (*Client) SetRotation

func (c *Client) SetRotation(ctx context.Context, serial string, rotation int) error

SetRotation sets the screen rotation. Values: 0=natural, 1=90°, 2=180°, 3=270°.

func (*Client) SetSELinux

func (c *Client) SetSELinux(ctx context.Context, serial, mode string) error

func (*Client) Shell

func (c *Client) Shell(ctx context.Context, serial string, command string) (*ExecResult, error)

func (*Client) ShellArgs

func (c *Client) ShellArgs(ctx context.Context, serial string, args ...string) (*ExecResult, error)

func (*Client) Sideload

func (c *Client) Sideload(ctx context.Context, serial, otaPath string) error

func (*Client) SimulateBatteryUnplug

func (c *Client) SimulateBatteryUnplug(ctx context.Context, serial string) error

func (*Client) StartActivity

func (c *Client) StartActivity(ctx context.Context, serial string, intent Intent) error

func (*Client) StartServer

func (c *Client) StartServer(ctx context.Context) error

func (*Client) StartService

func (c *Client) StartService(ctx context.Context, serial string, intent Intent) error

func (*Client) Stat

func (c *Client) Stat(ctx context.Context, serial, path string) (*FileInfo, error)

func (*Client) Swipe

func (c *Client) Swipe(ctx context.Context, serial string, x1, y1, x2, y2, durationMs int) error

func (*Client) Tap

func (c *Client) Tap(ctx context.Context, serial string, x, y int) error

func (*Client) TcpIp

func (c *Client) TcpIp(ctx context.Context, serial string, port int) error

func (*Client) Text

func (c *Client) Text(ctx context.Context, serial, text string) error

func (*Client) UninstallPackage

func (c *Client) UninstallPackage(ctx context.Context, serial, pkg string, keepData bool) error

func (*Client) Unroot

func (c *Client) Unroot(ctx context.Context) error

func (*Client) UnrootDevice

func (c *Client) UnrootDevice(ctx context.Context, serial string) error

func (*Client) Usb

func (c *Client) Usb(ctx context.Context, serial string) error

func (*Client) Version

func (c *Client) Version(ctx context.Context) (string, error)

func (*Client) VolumeDown

func (c *Client) VolumeDown(ctx context.Context, serial string) error

VolumeDown decreases the media volume by one step.

func (*Client) VolumeMute

func (c *Client) VolumeMute(ctx context.Context, serial string) error

VolumeMute toggles the mute state.

func (*Client) VolumeUp

func (c *Client) VolumeUp(ctx context.Context, serial string) error

VolumeUp increases the media volume by one step.

func (*Client) WaitForDevice

func (c *Client) WaitForDevice(ctx context.Context, serial string) error

func (*Client) WaitForElement

func (c *Client) WaitForElement(ctx context.Context, serial, text, resourceID string, timeoutMs int) (*UIElement, error)

WaitForElement polls the UI hierarchy until an element matching text or resourceID appears.

func (*Client) WriteFile

func (c *Client) WriteFile(ctx context.Context, serial, path, content string) error

WriteFile writes text content to a file on the device.

type Device

type Device struct {
	Serial      string
	State       DeviceState
	Product     string
	Model       string
	Device      string
	TransportID string
}

type DeviceInfo

type DeviceInfo struct {
	AndroidVersion   string
	SDKVersion       string
	BuildNumber      string
	Brand            string
	Manufacturer     string
	Model            string
	Product          string
	Hardware         string
	Serial           string
	ABIs             []string
	DisplaySize      string
	DisplayDensity   string
	IPAddress        string
	MacAddress       string
	BatteryLevel     string
	BatteryStatus    string
	TotalRAM         string
	AvailableRAM     string
	TotalStorage     string
	AvailableStorage string
	Uptime           string
	CPUInfo          string
}

type DeviceState

type DeviceState string
const (
	StateDevice       DeviceState = "device"
	StateOffline      DeviceState = "offline"
	StateUnauthorized DeviceState = "unauthorized"
	StateNoDevice     DeviceState = "no device"
)

type DiskUsage

type DiskUsage struct {
	Filesystem string
	Size       string
	Used       string
	Available  string
	UsePercent string
	MountPoint string
}

type DisplayInfo

type DisplayInfo struct {
	Width   int
	Height  int
	Density int
	FPS     float64
}

type ExecResult

type ExecResult struct {
	Output   string
	ExitCode int
	Duration time.Duration
}

type FileInfo

type FileInfo struct {
	Name        string
	Size        int64
	Permissions string
	ModTime     time.Time
	IsDir       bool
	IsLink      bool
	LinkTarget  string
}

type ForwardRule

type ForwardRule struct {
	Serial string
	Local  string
	Remote string
}

type GestureDef

type GestureDef struct {
	Name   string
	Params GestureParams
}

GestureDef is a named gesture preset.

type GestureParams

type GestureParams struct {
	StartXFrac, StartYFrac float64
	EndXFrac, EndYFrac     float64
	DurationMs             int
}

GestureParams defines a swipe gesture using fractional screen coordinates (0.0–1.0).

type InstallOptions

type InstallOptions struct {
	Reinstall        bool
	AllowDowngrade   bool
	GrantPermissions bool
}

type InstrumentOptions

type InstrumentOptions struct {
	Runner            string
	Arguments         map[string]string
	RawOutput         bool
	NoWindowAnimation bool
}

type Intent

type Intent struct {
	Action    string
	Data      string
	Type      string
	Component string
	Category  string
	Extras    map[string]string
	Flags     []string
}

func (Intent) Args

func (i Intent) Args() []string

Args returns the intent as a list of arguments safe for ShellArgs.

type ListOptions

type ListOptions struct {
	ShowSystem     bool
	ShowThirdParty bool
	ShowDisabled   bool
	ShowEnabled    bool
	Filter         string
}

type LogEntry

type LogEntry struct {
	Timestamp time.Time
	PID       string
	TID       string
	Level     LogLevel
	Tag       string
	Message   string
}

type LogLevel

type LogLevel string
const (
	LogVerbose LogLevel = "V"
	LogDebug   LogLevel = "D"
	LogInfo    LogLevel = "I"
	LogWarn    LogLevel = "W"
	LogError   LogLevel = "E"
	LogFatal   LogLevel = "F"
)

type LogcatOptions

type LogcatOptions struct {
	Filter string
	Format string
	Buffer string
	Since  string
	Count  int
}

type MemInfo

type MemInfo struct {
	Total     int64
	Free      int64
	Available int64
	Buffers   int64
	Cached    int64
	SwapTotal int64
	SwapFree  int64
}

type MonkeyOptions

type MonkeyOptions struct {
	Seed                     int64
	Throttle                 int
	IgnoreCrashes            bool
	IgnoreTimeouts           bool
	IgnoreSecurityExceptions bool
}

type NetConnection

type NetConnection struct {
	Protocol   string
	LocalAddr  string
	RemoteAddr string
	State      string
	PID        string
	Program    string
}

type NetworkInfo

type NetworkInfo struct {
	Interfaces []NetworkInterface
}

type NetworkInterface

type NetworkInterface struct {
	Name      string
	IPAddress string
	Mask      string
	Flags     string
}

type NotificationInfo

type NotificationInfo struct {
	Key     string
	Package string
	Title   string
	Text    string
	Time    string
}

type PackageDetail

type PackageDetail struct {
	PackageInfo
	Permissions []string
	Activities  []string
	Services    []string
	Receivers   []string
	DataDir     string
	APKPath     string
}

type PackageInfo

type PackageInfo struct {
	Name         string
	VersionCode  string
	VersionName  string
	Installer    string
	UID          string
	FirstInstall string
	LastUpdate   string
	Enabled      bool
	System       bool
}

type PermissionInfo

type PermissionInfo struct {
	Name    string
	Granted bool
}

type PingResult

type PingResult struct {
	Transmitted int
	Received    int
	LossPercent float64
	AvgRTT      float64
}

type ProcessInfo

type ProcessInfo struct {
	PID  int
	User string
	CPU  float64
	MEM  float64
	Name string
}

type Rect

type Rect struct {
	Left, Top, Right, Bottom int
}

Rect holds parsed bounds.

func ParseBounds

func ParseBounds(s string) (Rect, bool)

ParseBounds parses a bounds string like "[0,0][1080,1920]".

func (Rect) Center

func (r Rect) Center() (int, int)

Center returns the center point of the rectangle.

type ScreenRecordOptions

type ScreenRecordOptions struct {
	TimeLimit int
	BitRate   int
	Size      string
}

type SettingNamespace

type SettingNamespace string
const (
	NamespaceSystem SettingNamespace = "system"
	NamespaceSecure SettingNamespace = "secure"
	NamespaceGlobal SettingNamespace = "global"
)

type UIElement

type UIElement struct {
	Text               string `json:"text,omitempty"`
	ResourceID         string `json:"resource_id,omitempty"`
	Class              string `json:"class,omitempty"`
	Package            string `json:"package,omitempty"`
	ContentDescription string `json:"content_desc,omitempty"`
	Clickable          bool   `json:"clickable"`
	Enabled            bool   `json:"enabled"`
	Checked            bool   `json:"checked"`
	Focused            bool   `json:"focused"`
	Selected           bool   `json:"selected"`
	Scrollable         bool   `json:"scrollable"`
	Bounds             Rect   `json:"bounds"`
}

UIElement is a flattened representation of a UI node with its bounds.

func FindElements

func FindElements(elements []UIElement, text, resourceID, className string) []UIElement

FindElements searches the UI hierarchy for elements matching the given criteria. Matching is case-insensitive substring for text and content_desc, exact match for resource_id. Results are sorted by position (top-to-bottom, then left-to-right) for stable indexing.

func FlattenNodes

func FlattenNodes(nodes []UINode) []UIElement

FlattenNodes walks the UI tree and returns all nodes as a flat list.

type UIHierarchy

type UIHierarchy struct {
	XMLName  xml.Name `xml:"hierarchy"`
	Rotation int      `xml:"rotation,attr"`
	Nodes    []UINode `xml:"node"`
}

UIHierarchy is the root of a uiautomator dump.

func ParseUIHierarchy

func ParseUIHierarchy(xmlData string) (*UIHierarchy, error)

ParseUIHierarchy parses XML from uiautomator dump into a structured tree.

type UINode

type UINode struct {
	Index              int      `xml:"index,attr"`
	Text               string   `xml:"text,attr"`
	ResourceID         string   `xml:"resource-id,attr"`
	Class              string   `xml:"class,attr"`
	Package            string   `xml:"package,attr"`
	ContentDescription string   `xml:"content-desc,attr"`
	Checkable          bool     `xml:"checkable,attr"`
	Checked            bool     `xml:"checked,attr"`
	Clickable          bool     `xml:"clickable,attr"`
	Enabled            bool     `xml:"enabled,attr"`
	Focusable          bool     `xml:"focusable,attr"`
	Focused            bool     `xml:"focused,attr"`
	Scrollable         bool     `xml:"scrollable,attr"`
	LongClickable      bool     `xml:"long-clickable,attr"`
	Password           bool     `xml:"password,attr"`
	Selected           bool     `xml:"selected,attr"`
	Bounds             string   `xml:"bounds,attr"`
	Children           []UINode `xml:"node"`
}

UINode represents a single node in the Android UI hierarchy.

Jump to

Keyboard shortcuts

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