#2: Добавлено отслеживение длины нажатий кнопки. Это нужно для отключения самбы и размонтирования флешки. (спустя два часа страданий)

This commit is contained in:
2026-04-15 10:35:59 +05:00
parent a655f026b4
commit e622c95666
2 changed files with 106 additions and 24 deletions

View File

@@ -27,7 +27,7 @@ object DebugMode {
// Состояния системы
enum class SystemState {
IDLE, SCANNING, CLEAN, INFECTED, ERROR, INIT
IDLE, SCANNING, CLEAN, INFECTED, ERROR, INIT, SAMBA
}
class USBVirusScanner {
@@ -159,6 +159,11 @@ class USBVirusScanner {
yellowLed.setValue(0)
blinkLed(redLed, 500)
}
SystemState.SAMBA -> {
blinkLed(greenLed, 1000)
blinkLed(yellowLed, 1000)
redLed.setValue(0)
}
}
}
}
@@ -316,7 +321,7 @@ class USBVirusScanner {
try {
// Проверяем установлен ли ClamAV
val checkProcess = ProcessBuilder("which", "clamscan").start()
val checkProcess = ProcessBuilder("which", "clamdscan").start()
val checkExitCode = checkProcess.waitFor()
if (checkExitCode != 0) {
@@ -538,9 +543,20 @@ fun main(args: Array<String>) {
scanner.initialize()
val buttonListener = ButtonListener()
buttonListener.shortPressThresholdMs = 100
buttonListener.longPressThresholdMs = 1000
buttonListener.addClickListener { event ->
scanner.startScan()
}
buttonListener.addLongPressListener { event ->
println(if (isDebug) "ДЛИННОЕ НАЖАТИЕ МЯУ" else "")
println("TODO(\"Добавить отключение samba и размонтирование флешки\")")
}
buttonListener.startListening()
println(if (isDebug) """
@@ -564,4 +580,5 @@ fun main(args: Array<String>) {
scanner.shutdown()
exitProcess(1)
}
}