#2: Добавлено отслеживение длины нажатий кнопки. Это нужно для отключения самбы и размонтирования флешки. (спустя два часа страданий)
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user