MCPcopy Index your code
hub / github.com/callstack/agent-device / listAndroidDevices

Function listAndroidDevices

src/platforms/android/devices.ts:224–260  ·  view source on GitHub ↗
(
  options: AndroidDeviceDiscoveryOptions = {},
)

Source from the content-addressed store, hash-verified

222}
223
224export async function listAndroidDevices(
225 options: AndroidDeviceDiscoveryOptions = {},
226): Promise<DeviceInfo[]> {
227 await ensureAndroidSdkPathConfigured();
228 const adbAvailable = await whichCmd('adb');
229 if (!adbAvailable) {
230 throw new AppError('TOOL_MISSING', 'adb not found in PATH');
231 }
232 const serialAllowlist = options.serialAllowlist ?? resolveAndroidSerialAllowlist(undefined);
233
234 const entries = await listAndroidDeviceEntries();
235 const filteredEntries = entries.filter(
236 (entry) => !serialAllowlist || serialAllowlist.has(entry.serial),
237 );
238
239 const devices = await mapWithConcurrency(
240 filteredEntries,
241 ANDROID_DISCOVERY_CONCURRENCY,
242 async ({ serial, rawModel }) => {
243 const [name, booted, target] = await Promise.all([
244 resolveAndroidDeviceName(serial, rawModel),
245 isAndroidBooted(serial),
246 resolveAndroidTarget(serial),
247 ]);
248 return {
249 platform: 'android',
250 id: serial,
251 name,
252 kind: isEmulatorSerial(serial) ? 'emulator' : 'device',
253 target,
254 booted,
255 } satisfies DeviceInfo;
256 },
257 );
258
259 return [...devices, ...(await listStoppedAndroidAvdDevices(devices))];
260}
261
262type AndroidDeviceEntry = {
263 serial: string;

Callers 4

devices.test.tsFile · 0.90
listLocalDeviceInventoryFunction · 0.85

Calls 10

whichCmdFunction · 0.90
listAndroidDeviceEntriesFunction · 0.85
mapWithConcurrencyFunction · 0.85
resolveAndroidDeviceNameFunction · 0.85
isAndroidBootedFunction · 0.85
resolveAndroidTargetFunction · 0.85
isEmulatorSerialFunction · 0.85

Tested by

no test coverage detected