adb

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2025 License: BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsLevelInScope

func IsLevelInScope(entryLevel string, wantedLevel string) bool

Checks if the level is higher or the same as the wanted one

Types

type AdbLineEntry

type AdbLineEntry struct {
	Date    string
	Time    string
	Level   string
	Tag     string
	PID     string
	TID     string
	Message string
}

The struct to represent a logcat line

func ParseLogcatLine

func ParseLogcatLine(line string) (entry AdbLineEntry, err error)

Parses a logcat line into a LogcatEntry struct

func (AdbLineEntry) EqualTimePidLevel

func (entry AdbLineEntry) EqualTimePidLevel(e2 *AdbLineEntry) bool

type Client

type Client struct {
	ADBPath       string   // Path to the ADB binary like /path/to/adb
	BaseCmd       []string // Base command like /path/to/adb -d
	BaseCmdLogcat []string // Base logcat command like /path/to/adb -d logcat
}

func NewClient

func NewClient(binPath string, connectionStr []string) (client *Client, err error)

Creates a new ADB client with the passed binPath like '/path/to/adb' and the connectionStr like '-d'

func (*Client) CheckConn added in v0.1.2

func (client *Client) CheckConn() (err error)

Runs 'adb shell ps' to check conectivity with device

func (*Client) ClearLogcatOutput

func (client *Client) ClearLogcatOutput() (err error)

Clears the logcat output via 'logcat -c'

func (*Client) GetCurrentApp

func (client *Client) GetCurrentApp() (slug string, err error)

Returns the slug (com.example.app) of the app in the foreground via 'adb shell dumsys'

func (*Client) GetPID

func (client *Client) GetPID(slug string) (pid string, err error)

Returns the PID of the passed app identified by its slug (com.example.app)

If no process is matched, an error is returned

func (*Client) GetProcesses

func (client *Client) GetProcesses() (processes []*Process, err error)

Runs 'adb shell ps' and parses the output into a custom struct

func (*Client) ListAllPackages

func (client *Client) ListAllPackages() (packages []string, err error)

Returns a list of all packages installed on the device via 'adb shell pm list packages'

func (*Client) ListDevices added in v0.1.2

func (client *Client) ListDevices() (devices []string, err error)

Returns a list of all packages installed on the device via 'adb shell pm list packages'

func (*Client) ListThirdPartyPackages

func (client *Client) ListThirdPartyPackages() (packages []string, err error)

Returns a list of all third party packages installed on the device via 'adb shell pm list packages -3'

func (*Client) Run

func (client *Client) Run(timeoutSeconds int, args ...string) (string, error)

Runs an adb command with the passed timeout and arguments. Returns the output of the command

type LogcatOptions

type LogcatOptions struct {
	Packages []string // The packages to filter for
	MinLevel string   // The minimum log level to show
}

type Process

type Process struct {
	USER  string
	PID   string
	PPID  string
	VSZ   string
	RSS   string
	WCHAN string
	ADDR  string
	LEVEL string
	NAME  string
}

One line of the output from 'adb shell ps'

Jump to

Keyboard shortcuts

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