feat: discover ADB devices from agent management

This commit is contained in:
tongtong committed 2026-11-12 22:30:05 +08:00
1 parent 8ecfe880cc
commit 3a7bb071f0
12 files changed
+132 -5

No files matched your search

+20
View File
@@ -24,6 +24,25 @@ class AgentModel extends ChangeNotifier {
configPath = '',
configText = '',
logText = '';
List<JsonMap> discoveredDevices = [];
Future<void> discoverDevices() => run(() async {
final rows = await _call({'op': 'devices_discover'});
discoveredDevices = (rows! as List<Object?>)
.map((v) => Map<String, Object?>.from(v! as Map))
.toList();
notice =
'发现 ${discoveredDevices.length} 台 ADB 设备;选择后确认添加。USB 接入仍须启用 TCP adbd。';
});
void chooseDiscovered(JsonMap row) {
final serial = row['serial']! as String;
final tcp = RegExp(r'^.+:\d+$').hasMatch(serial);
target = tcp ? serial : '';
adbSerial = tcp ? '' : serial;
deviceId = 'phone-${DateTime.now().microsecondsSinceEpoch}';
notice = '已填入添加表单,请确认设备 ID 后添加手机。';
_notify();
}
String deviceId = '', target = '', adbSerial = '', adbServer = '';
String notice = '远程管理需要独立管理员凭据;也可选择管理本机 Agent。';
Timer? _timer;
@@ -105,6 +124,7 @@ class AgentModel extends ChangeNotifier {
void select(String? id) {
if (id != selectedId) {
discoveredDevices = [];
selectedId = id;
_cursor = 0;
_instance = '';