mirror of
https://github.com/taigrr/adb.git
synced 2026-04-02 02:58:42 -07:00
add USB conn support explicitly
This commit is contained in:
10
adb.go
10
adb.go
@@ -97,6 +97,7 @@ func Devices(ctx context.Context) ([]Device, error) {
|
|||||||
return parseDevices(stdout)
|
return parseDevices(stdout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO add support for connected network devices
|
||||||
func parseDevices(stdout string) ([]Device, error) {
|
func parseDevices(stdout string) ([]Device, error) {
|
||||||
devs := []Device{}
|
devs := []Device{}
|
||||||
lines := strings.Split(stdout, "\n")
|
lines := strings.Split(stdout, "\n")
|
||||||
@@ -119,7 +120,11 @@ func parseDevices(stdout string) ([]Device, error) {
|
|||||||
//
|
//
|
||||||
// If a device is already disconnected or otherwise not found, returns an error.
|
// If a device is already disconnected or otherwise not found, returns an error.
|
||||||
func (d Device) Disconnect(ctx context.Context) error {
|
func (d Device) Disconnect(ctx context.Context) error {
|
||||||
return nil
|
if d.ConnType != Network {
|
||||||
|
return ErrConnUSB
|
||||||
|
}
|
||||||
|
_, _, _, err := execute(ctx, []string{"-s", d.ConnString(), "disconnect"})
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kill the ADB Server
|
// Kill the ADB Server
|
||||||
@@ -131,7 +136,8 @@ func (d Device) Disconnect(ctx context.Context) error {
|
|||||||
// refuse following connection attempts if you don't disconnect from them before
|
// refuse following connection attempts if you don't disconnect from them before
|
||||||
// calling this function.
|
// calling this function.
|
||||||
func KillServer(ctx context.Context) error {
|
func KillServer(ctx context.Context) error {
|
||||||
return nil
|
_, _, _, err := execute(ctx, []string{"kill-server"})
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Push a file to a Device.
|
// Push a file to a Device.
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ var (
|
|||||||
ErrStdoutEmpty = errors.New("stdout expected to contain data but was empty")
|
ErrStdoutEmpty = errors.New("stdout expected to contain data but was empty")
|
||||||
ErrNotInstalled = errors.New("adb is not installed or not in PATH")
|
ErrNotInstalled = errors.New("adb is not installed or not in PATH")
|
||||||
ErrCoordinatesNotFound = errors.New("coordinates for an input event are missing")
|
ErrCoordinatesNotFound = errors.New("coordinates for an input event are missing")
|
||||||
ErrConnUSB = errors.New("cannot call connect to device using USB")
|
ErrConnUSB = errors.New("cannot call connect/disconnect to device using USB")
|
||||||
ErrResolutionParseFail = errors.New("failed to parse screen size from input text")
|
ErrResolutionParseFail = errors.New("failed to parse screen size from input text")
|
||||||
ErrUnspecified = errors.New("an unknown error has occurred, please open an issue on GitHub")
|
ErrUnspecified = errors.New("an unknown error has occurred, please open an issue on GitHub")
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user