getPhysicalDevices method
Implementation
@override
Future<List<Device>> getPhysicalDevices() async {
try {
final result = await _exec.run(adbPath, arguments: ['devices', '-l']);
if (!result.success) return [];
final stdout = result.stdout;
final rawDevices = stdout
.split('\n')
.skip(1)
.map((l) => l.trim())
.where((l) => l.isNotEmpty && !l.startsWith('emulator-'));
return rawDevices
.map((line) {
final parts = line.split(RegExp(r'\s+'));
final id = parts.isNotEmpty ? parts.first : '';
var name = id;
for (final part in parts) {
if (part.startsWith('model:')) {
name = part.substring(6).replaceAll('_', ' ');
break;
}
}
return Device.android(
id: id,
name: name,
type: DeviceType.physical,
state: DeviceState.booted,
);
})
.where((d) => d.id.isNotEmpty)
.toList();
} catch (e) {
return [];
}
}