-
Notifications
You must be signed in to change notification settings - Fork 1
/
adbette.go
52 lines (47 loc) · 2.17 KB
/
adbette.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
© 2022–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/)
ISC License
*/
package parl
import (
"context"
"io"
)
// Adbetter is a factory instance for connections featuring Adbette
type Adbetter interface {
NewConnection(address string, ctx context.Context) (conn Adbette, err error)
}
type AdbRequest string
// Adbette is a minimal implementation of the adb Android debug bridge protocol
// Adbette include both adb server and Android device functions
type Adbette interface {
// SendReadOkay sends a request to a remote adb endpoint.
// if anything else than OKAY is received back from the
// remote endpoint, err is non-nil.
SendReadOkay(request AdbRequest) (err error)
// ReadString reads utf-8 text up to 64 KiB-1 in length
ReadString() (s string, err error)
// ConnectToDevice sends a forwarding request to an adb
// server to connect to one of its devices
ConnectToDevice(serial AndroidSerial) (err error)
// Shell executes a shell command on a device connected to the adb server
Shell(command string, reader func(conn io.ReadWriteCloser) (err error)) (out string, err error)
// TrackDevices orders a server to emit serial number as they become available
TrackDevices() (err error)
// Devices lists the currently online serials
Devices() (serials []AndroidSerial, err error)
// DeviceStati returns all available serials and their status
// The two slices correspond and are of the same length
DeviceStati() (serials []AndroidSerial, stati []AndroidStatus, err error)
// Closer closes an adb connection, meant to be a deferred function
Closer(errp *error)
// SetSync chnages the protocol mode of an adb connection to sync
SetSync() (err error)
// LIST is a sync request that lists the entriues in a directory of an adb device
LIST(remoteDir string, dentReceiver func(mode uint32, size uint32, time uint32, byts []byte) (err error)) (err error)
// RECV fetches the contents of a file located on an adb device
RECV(remotePath string, blobReceiver func(data []byte) (err error)) (err error)
// CancelError is a value that a LIST or RECV callback routines can return to
// cancel further invocations
CancelError() (cancelError error)
}