2015-04-12 20:34:20 +00:00
|
|
|
package wire
|
|
|
|
|
2020-10-29 02:18:51 +00:00
|
|
|
import "github.com/evrins/goadb/internal/errors"
|
2015-12-28 09:08:51 +00:00
|
|
|
|
2015-04-12 20:34:20 +00:00
|
|
|
const (
|
|
|
|
// Chunks cannot be longer than 64k.
|
2015-12-28 09:08:51 +00:00
|
|
|
SyncMaxChunkSize = 64 * 1024
|
2015-04-12 20:34:20 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
/*
|
|
|
|
SyncConn is a connection to the adb server in sync mode.
|
|
|
|
Assumes the connection has been put into sync mode (by sending "sync" in transport mode).
|
|
|
|
|
|
|
|
The adb sync protocol is defined at
|
|
|
|
https://android.googlesource.com/platform/system/core/+/master/adb/SYNC.TXT.
|
|
|
|
|
|
|
|
Unlike the normal adb protocol (implemented in Conn), the sync protocol is binary.
|
|
|
|
Lengths are binary-encoded (little-endian) instead of hex.
|
|
|
|
|
|
|
|
Notes on Encoding
|
|
|
|
|
|
|
|
Length headers and other integers are encoded in little-endian, with 32 bits.
|
|
|
|
|
|
|
|
File mode seems to be encoded as POSIX file mode.
|
|
|
|
|
|
|
|
Modification time seems to be the Unix timestamp format, i.e. seconds since Epoch UTC.
|
|
|
|
*/
|
|
|
|
type SyncConn struct {
|
|
|
|
SyncScanner
|
|
|
|
SyncSender
|
|
|
|
}
|
2015-12-28 09:08:51 +00:00
|
|
|
|
|
|
|
// Close closes both the sender and the scanner, and returns any errors.
|
|
|
|
func (c SyncConn) Close() error {
|
2016-05-22 17:49:32 +00:00
|
|
|
return errors.CombineErrs("error closing SyncConn", errors.NetworkError,
|
2015-12-28 09:08:51 +00:00
|
|
|
c.SyncScanner.Close(), c.SyncSender.Close())
|
|
|
|
}
|