Overview
Sync command is used to interact with device filesystem.
Sync connection has its own data protocol, so Adb#sync
creates a connection that you can run commands on.
Create a sync connection
- JavaScript
- TypeScript
const sync = await adb.sync();
const sync: AdbSync = await adb.sync();
Concurrency
- Each sync connection can only run one command at a time.
- Calling another command while a command is still running will wait for the previous command to finish.
- Multiple sync connections to the same device can be created to run multiple commands at the same time.
READ ALL STREAMS!
ADB is a multiplexing protocol (multiple logic streams are transferred over one connection), so blocking one stream will block all other streams.
You must continuously read from all sync connections to prevent this from happening.
For example, you can't create another sync connection or call other methods on Adb
when opendir
is still running. Upcoming data for opendir
will block other operations.
Close sync connection
You should close the sync connection when you no longer need it. This closes the underlying socket.
await sync.dispose();
info
Not closing sync connections will cause a small memory leak.
Supported methods
lstat
/stat
: Get file informationisDirectory
: Check if a path is a directoryopendir
/readdir
: List files in a directoryread
: Read file contentwrite
: Write file content