Overview
Sync command is used to interact with device filesystem.
Socket Pool Architecture
Tango ADB now uses a socket pool to manage sync connections automatically. The adb.sync property provides a high-level API that handles connection pooling internally.
import type { Adb } from "@yume-chan/adb";
import { AdbSync } from "@yume-chan/adb";
declare const adb: Adb;
// adb.sync is a property, not a method
const sync: AdbSync.Service = adb.sync;
Connection Reuse
The socket pool automatically manages sync socket connections:
- Connection reuse: Sockets are pooled and reused across operations
- Automatic lifecycle management: No need to call
dispose()- sockets are managed by the pool - Configurable pooling: Pool size and idle timeout can be configured via
ServiceOptions - Idle timeout: Idle sockets are automatically closed after a configurable timeout (default: 60 seconds)
Advanced Socket Access
For advanced use cases requiring direct socket access, the pool provides methods to acquire and release sockets:
import type { Adb } from "@yume-chan/adb";
declare const adb: Adb;
// Acquire a socket from the pool
const socket = await adb.sync.acquireSocket();
try {
// Use socket directly for custom operations
} finally {
// Return socket to the pool
await adb.sync.releaseSocket(socket);
}
The pool also provides a withSocket() helper for automatic resource management:
import type { Adb } from "@yume-chan/adb";
declare const adb: Adb;
await adb.sync.withSocket(async (socket) => {
// Socket is automatically released after use
});
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