gadb

package
v0.0.0-...-a74421f Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

README

gadb

This module is initially forked from electricbubble/gadb@v0.0.7 and optimized by @appl3s.

  • feat: add reverse forward command
  • feat: add RunShellCommandV2 which supports running nohup
  • feat: add InstallAPK with feature judgment
  • feat: add Uninstall for specified package name

Documentation

Index

Constants

View Source
const (
	AdbServerPort = 5037
	AdbDaemonPort = 5555
)
View Source
const DefaultFileMode = os.FileMode(0o664)

Variables

View Source
var (
	FeatSendrecvV2Brotli          = Feature("sendrecv_v2_brotli")
	FeatRemountShell              = Feature("remount_shell")
	FeatSendrecvV2                = Feature("sendrecv_v2")
	FeatAbbExec                   = Feature("abb_exec")
	FeatFixedPushMkdir            = Feature("fixed_push_mkdir")
	FeatFixedPushSymlinkTimestamp = Feature("fixed_push_symlink_timestamp")
	FeatAbb                       = Feature("abb")
	FeatShellV2                   = Feature("shell_v2")
	FeatCmd                       = Feature("cmd")
	FeatLsV2                      = Feature("ls_v2")
	FeatApex                      = Feature("apex")
	FeatStatV2                    = Feature("stat_v2")
)
View Source
var DefaultAdbReadTimeout time.Duration = 60
View Source
var ErrConnBroken = errors.New("socket connection broken")

Functions

func DisableTimeWait

func DisableTimeWait(conn *net.TCPConn) error

Types

type Client

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

func NewClient

func NewClient() (Client, error)

func NewClientWith

func NewClientWith(host string, port ...int) (adbClient Client, err error)

func NewClientWithoutTransport

func NewClientWithoutTransport(host string, port ...int) (adbClient Client, err error)

func (Client) Connect

func (c Client) Connect(ip string, port ...int) (err error)

func (Client) DeviceList

func (c Client) DeviceList() (devices []*Device, err error)

func (Client) DeviceSerialList

func (c Client) DeviceSerialList() (serials []string, err error)

func (Client) Disconnect

func (c Client) Disconnect(ip string, port ...int) (err error)

func (Client) DisconnectAll

func (c Client) DisconnectAll() (err error)

func (Client) ForwardKillAll

func (c Client) ForwardKillAll() (err error)

func (Client) ForwardList

func (c Client) ForwardList() (deviceForward []DeviceForward, err error)

func (Client) KillServer

func (c Client) KillServer() (err error)

func (Client) ServerVersion

func (c Client) ServerVersion() (version int, err error)

type Device

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

func (*Device) DeviceInfo

func (d *Device) DeviceInfo() map[string]string

func (*Device) DevicePath

func (d *Device) DevicePath() (string, error)

func (*Device) EnableAdbOverTCP

func (d *Device) EnableAdbOverTCP(port ...int) (err error)

func (*Device) Forward

func (d *Device) Forward(localPort int, remoteInterface interface{}, noRebind ...bool) (err error)

func (*Device) ForwardKill

func (d *Device) ForwardKill(localPort int) (err error)

func (*Device) ForwardList

func (d *Device) ForwardList() (deviceForwardList []DeviceForward, err error)

func (*Device) GetFeatures

func (d *Device) GetFeatures() (features Features, err error)

func (*Device) HasFeature

func (d *Device) HasFeature(name Feature) bool

func (*Device) InstallAPK

func (d *Device) InstallAPK(apk io.ReadSeeker) (string, error)

func (*Device) IsUsb

func (d *Device) IsUsb() bool

func (*Device) List

func (d *Device) List(remotePath string) (devFileInfos []DeviceFileInfo, err error)

func (*Device) Model

func (d *Device) Model() string

func (*Device) Product

func (d *Device) Product() string

func (*Device) Pull

func (d *Device) Pull(remotePath string, dest io.Writer) (err error)

func (*Device) Push

func (d *Device) Push(source io.Reader, remotePath string, modification time.Time, mode ...os.FileMode) (err error)

func (*Device) PushFile

func (d *Device) PushFile(local *os.File, remotePath string, modification ...time.Time) (err error)

func (*Device) ReverseForward

func (d *Device) ReverseForward(localPort int, remoteInterface interface{}, noRebind ...bool) (err error)

func (*Device) ReverseForwardKill

func (d *Device) ReverseForwardKill(remoteInterface interface{}) error

func (*Device) ReverseForwardKillAll

func (d *Device) ReverseForwardKillAll() error

func (*Device) ReverseForwardList

func (d *Device) ReverseForwardList() (deviceForwardList []DeviceForward, err error)

func (*Device) RunShellCommand

func (d *Device) RunShellCommand(cmd string, args ...string) (string, error)

func (*Device) RunShellCommandV2

func (d *Device) RunShellCommandV2(cmd string, args ...string) (string, error)

func (*Device) RunShellCommandV2WithBytes

func (d *Device) RunShellCommandV2WithBytes(cmd string, args ...string) ([]byte, error)

RunShellCommandV2WithBytes shell v2, 支持后台运行而不会阻断

func (*Device) RunShellCommandWithBytes

func (d *Device) RunShellCommandWithBytes(cmd string, args ...string) ([]byte, error)

func (*Device) ScreenCap

func (d *Device) ScreenCap() ([]byte, error)

func (*Device) Serial

func (d *Device) Serial() string

func (*Device) State

func (d *Device) State() (DeviceState, error)

func (*Device) Uninstall

func (d *Device) Uninstall(packageName string, keepData ...bool) (string, error)

func (*Device) Usb

func (d *Device) Usb() string

type DeviceFileInfo

type DeviceFileInfo struct {
	Name         string
	Mode         os.FileMode
	Size         uint32
	LastModified time.Time
}

func (DeviceFileInfo) IsDir

func (info DeviceFileInfo) IsDir() bool

type DeviceForward

type DeviceForward struct {
	Serial  string
	Local   string
	Remote  string
	Reverse bool
}

type DeviceState

type DeviceState string
const (
	StateUnknown      DeviceState = "UNKNOWN"
	StateOnline       DeviceState = "online"
	StateOffline      DeviceState = "offline"
	StateDisconnected DeviceState = "disconnected"
)

type Feature

type Feature string

type Features

type Features map[Feature]struct{}

func (Features) HasFeature

func (fs Features) HasFeature(name Feature) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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