debug: watchdog Thread 매 체크마다 로그 기록 (WATCHDOG_CHECK)

watchdog이 실제로 돌고 있는지, 어디서 멈추는지 진단용.
매 5초: WATCHDOG_CHECK silence=Xms connected=true/false
interrupt 시: WATCHDOG_THREAD interrupted
flag 종료 시: WATCHDOG_THREAD stopped

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-23 14:59:07 +09:00
parent c99eb068a5
commit d3006d91dc
@@ -364,12 +364,22 @@ class BleManager private constructor(private val context: Context) {
debugLogger.info("WATCHDOG_STARTED timeout=${watchdogTimeoutMs}ms")
watchdogJob = Thread({
debugLogger.info("WATCHDOG_THREAD running")
while (watchdogRunning) {
try { Thread.sleep(5000) } catch (_: InterruptedException) { break }
if (!watchdogRunning) break
if (!isConnected.value) continue
try { Thread.sleep(5000) } catch (e: InterruptedException) {
debugLogger.warn("WATCHDOG_THREAD interrupted")
break
}
if (!watchdogRunning) {
debugLogger.info("WATCHDOG_THREAD stopped (flag)")
break
}
val silenceMs = System.currentTimeMillis() - lastRxTimestamp
debugLogger.info("WATCHDOG_CHECK silence=${silenceMs}ms connected=${isConnected.value}")
if (!isConnected.value) continue
if (silenceMs > watchdogTimeoutMs) {
// 직접 로그 기록 (handler 블로킹 무관)
debugLogger.error("WATCHDOG_TIMEOUT silence=${silenceMs}ms — forcing reconnect")