diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt index a38f3bd..570549a 100644 --- a/src/main/kotlin/Main.kt +++ b/src/main/kotlin/Main.kt @@ -167,8 +167,8 @@ class USBVirusScanner { } SystemState.SAMBA -> { - blinkLed(greenLed, 1000) - blinkLed(yellowLed, 1000) + blinkLed(greenLed, 200) + blinkLed(yellowLed, 200) redLed.setValue(0) } } @@ -228,6 +228,7 @@ class USBVirusScanner { if (result.infectedFiles.size > 10) { println(if (isDebug) " ... и ещё ${result.infectedFiles.size - 10} файлов" else "") } + unmount() } else if (result.error != null) { println(if (isDebug) "❌ Ошибка сканирования: ${result.error}" else "") } else { @@ -259,7 +260,16 @@ class USBVirusScanner { currentState = SystemState.SAMBA sambaStartSharing() - while (isUsbSharing()) {} + val buttonListener = ButtonListener() + var isEventHappened = false + + buttonListener.addLongPressListener { event -> + isEventHappened = true + } + buttonListener.startListening() + while (!isEventHappened) { + delay(500.milliseconds) + } } currentState = SystemState.IDLE @@ -453,12 +463,6 @@ class USBVirusScanner { } } - fun isUsbSharing(isActive: Boolean): Boolean { - var defaultState: Boolean = false - defaultState = isActive - return defaultState - } - suspend fun sambaStartSharing() { try { currentState = SystemState.SAMBA