From 118b845fd93a0153f9f2a977b06a4eb05408e2c3 Mon Sep 17 00:00:00 2001 From: Dain Nilsson Date: Tue, 25 Oct 2022 08:34:22 +0200 Subject: [PATCH] Don't allow turning all capabilities except CCID off. --- lib/management/views/management_screen.dart | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/management/views/management_screen.dart b/lib/management/views/management_screen.dart index 0a7da12e..14c6ad16 100755 --- a/lib/management/views/management_screen.dart +++ b/lib/management/views/management_screen.dart @@ -30,10 +30,9 @@ import '../state.dart'; import 'keys.dart' as management_keys; final _mapEquals = const DeepCollectionEquality().equals; +const _usbCcid = 0x04; -enum _CapabilityType { - usb, nfc -} +enum _CapabilityType { usb, nfc } class _CapabilityForm extends StatelessWidget { final _CapabilityType type; @@ -285,8 +284,10 @@ class _ManagementScreenState extends ConsumerState { ), data: (info) { bool hasConfig = info.version.major > 4; + int usbEnabled = _enabled[Transport.usb] ?? 0; if (hasConfig) { - canSave = _enabled[Transport.usb] != 0 && + // Ignore the _usbCcid bit: + canSave = (usbEnabled & ~_usbCcid) != 0 && !_mapEquals( _enabled, info.config.enabledCapabilities,