Add opt-in physical USB device enrollment and remembered choices in 0.2.7

This commit is contained in:
tongtong committed 2026-11-14 04:06:01 +08:00
1 parent dc29a20a41
commit 208d37b7d8
20 files changed
+515 -18

No files matched your search

+34 -1
View File
@@ -44,7 +44,12 @@ class FakeApi implements AgentApi {
'configured': false,
},
],
'config_get' => {'id': agent, 'devices': <Object?>[]},
'config_get' => {
'id': agent,
'devices': <Object?>[],
'ignored_usb_serials': ['USB-A', 'USB-B'],
'usb_device_ids': {'USB-A': 'stable-id'},
},
'logs' => {
'instance': 'i',
'next': 1,
@@ -72,6 +77,34 @@ class FakeApi implements AgentApi {
}
void main() {
test(
'USB policy applies only to selected agent and preserves identity memory',
() async {
final api = FakeApi();
final m = AgentModel(AgentRepository(api));
await m.refresh();
m.select('two');
await m.setAutoUsb(true);
final enabled = api.calls.lastWhere((c) => c['op'] == 'config_set');
expect(enabled['agent'], 'two');
expect((enabled['config'] as Map)['auto_register_usb'], true);
expect((enabled['config'] as Map)['usb_device_ids'], {
'USB-A': 'stable-id',
});
m.adbSerial = 'USB-A';
await m.unignoreUsb();
expect((api.calls.last['config'] as Map)['ignored_usb_serials'], [
'USB-B',
]);
await m.setAutoUsb(false);
expect(
(api.calls.lastWhere((c) => c['op'] == 'config_set')['config']
as Map)['auto_register_usb'],
false,
);
m.dispose();
},
);
test(
'selected agent scopes mutations and log secrets are redacted',
() async {