adb

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	Serial  string
	Wrapper *Wrapper
	// contains filtered or unexported fields
}

Device 表示一个 Android 设备

func NewDevice

func NewDevice(serial string, wrapper *Wrapper) *Device

NewDevice 创建一个新的设备实例

func (*Device) AndroidVersion

func (d *Device) AndroidVersion(ctx context.Context) (string, error)

AndroidVersion 获取 Android 版本

func (*Device) Brand

func (d *Device) Brand(ctx context.Context) (string, error)

Brand 获取设备品牌

func (*Device) GetProperties

func (d *Device) GetProperties(ctx context.Context) (map[string]string, error)

GetProperties 获取设备所有属性

func (*Device) GetProperty

func (d *Device) GetProperty(ctx context.Context, name string) (string, error)

GetProperty 获取设备特定属性

func (*Device) InputText

func (d *Device) InputText(ctx context.Context, text string) error

InputText 输入文本

func (*Device) InstallApp

func (d *Device) InstallApp(ctx context.Context, apkPath string, reinstall, grantPermissions bool) error

InstallApp 安装 APK 应用

func (*Device) ListPackages

func (d *Device) ListPackages(ctx context.Context, includeSystemApps bool) ([]PackageInfo, error)

ListPackages 列出已安装的包

func (*Device) Model

func (d *Device) Model(ctx context.Context) (string, error)

Model 获取设备型号

func (*Device) PressKey

func (d *Device) PressKey(ctx context.Context, keycode int) error

PressKey 按键

func (*Device) SDKLevel

func (d *Device) SDKLevel(ctx context.Context) (string, error)

SDKLevel 获取 SDK 级别

func (*Device) Shell

func (d *Device) Shell(ctx context.Context, command string) (string, error)

Shell 在设备上执行 shell 命令

func (*Device) StartActivity

func (d *Device) StartActivity(ctx context.Context, pkg, activity string, extras map[string]string) error

StartActivity 启动应用活动

func (*Device) StartApp

func (d *Device) StartApp(ctx context.Context, pkg, activity string) error

StartApp 启动应用

func (*Device) Swipe

func (d *Device) Swipe(ctx context.Context, startX, startY, endX, endY, durationMs int) error

Swipe 执行滑动手势

func (*Device) TakeScreenshot

func (d *Device) TakeScreenshot(ctx context.Context, quality int) (string, []byte, error)

TakeScreenshot 截屏

func (*Device) Tap

func (d *Device) Tap(ctx context.Context, x, y int) error

Tap 在指定坐标点击

func (*Device) UninstallApp

func (d *Device) UninstallApp(ctx context.Context, pkg string, keepData bool) error

UninstallApp 卸载应用

type DeviceInfo

type DeviceInfo struct {
	Serial string
	Status string
}

DeviceInfo 设备信息

type Manager

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

Manager 设备管理器

func NewManager

func NewManager(adbPath string) *Manager

NewManager 创建新的设备管理器

func (*Manager) Connect

func (m *Manager) Connect(ctx context.Context, host string, port int) (*Device, error)

Connect 连接到网络设备

func (*Manager) Disconnect

func (m *Manager) Disconnect(ctx context.Context, serial string) error

Disconnect 断开设备连接

func (*Manager) GetDevice

func (m *Manager) GetDevice(ctx context.Context, serial string) (*Device, error)

GetDevice 获取特定设备

func (*Manager) ListDevices

func (m *Manager) ListDevices(ctx context.Context) ([]*Device, error)

ListDevices 列出连接的设备

type PackageInfo

type PackageInfo struct {
	Package string `json:"package"`
	Path    string `json:"path"`
}

PackageInfo 包信息

type Wrapper

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

Wrapper ADB 命令包装器

func NewWrapper

func NewWrapper(adbPath string) *Wrapper

NewWrapper 创建新的 ADB wrapper

func (*Wrapper) Connect

func (w *Wrapper) Connect(ctx context.Context, host string, port int) (string, error)

Connect 连接到网络设备

func (*Wrapper) Disconnect

func (w *Wrapper) Disconnect(ctx context.Context, serial string) error

Disconnect 断开设备连接

func (*Wrapper) GetDevices

func (w *Wrapper) GetDevices(ctx context.Context) ([]DeviceInfo, error)

GetDevices 获取连接的设备列表

func (*Wrapper) GetProperties

func (w *Wrapper) GetProperties(ctx context.Context, serial string) (map[string]string, error)

GetProperties 获取设备属性

func (*Wrapper) PullFile

func (w *Wrapper) PullFile(ctx context.Context, serial, remotePath, localPath string) error

PullFile 从设备拉取文件

func (*Wrapper) PushFile

func (w *Wrapper) PushFile(ctx context.Context, serial, localPath, remotePath string) error

PushFile 推送文件到设备

func (*Wrapper) RunDeviceCommand

func (w *Wrapper) RunDeviceCommand(ctx context.Context, serial string, args []string) (string, string, error)

RunDeviceCommand 运行设备命令

func (*Wrapper) Shell

func (w *Wrapper) Shell(ctx context.Context, serial, command string) (string, error)

Shell 在设备上执行 shell 命令

Jump to

Keyboard shortcuts

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