fix(cw): persist decoder failures to files for adb-less diagnostics

在服务器上完整复现了手机端流程 (真实 20s 含噪音频 -> 重采样 -> 频谱 ->
ONNX -> 贪心 CTC), 解码逐字符正确:
  decoded: [CQ CQ DE BG7NTA BG7NTA K 5NN TU 73]   (与参考完全一致)
整条链路逻辑无问题, 闪退属环境/平台层。

应用内已有全局崩溃捕获器 (MainApplication.installCrashHandler) 会把堆栈
写入 files/crash_log.txt —— 无需 adb 即可取到崩溃原因。

本提交为加载与推理两处异常补充落盘:
- 模型加载失败 -> files/deepcw_load_error.txt
- 推理异常 -> files/deepcw_infer_error.txt

用户可在文件管理器按
Android/data/com.rtbishop.look4sat.bg7nta/files/ 路径取回这些日志。

验证: :core:data:compileDebugKotlin => BUILD SUCCESSFUL
This commit is contained in:
mckero committed 2026-08-12 16:43:52 +00:00
1 parent 5f297f9233
commit cf49dcfa01
1 file changed
+13
@@ -130,6 +130,13 @@ class CwDeepDecoder(context: Context) : ICwDecoder {
Log.e(TAG, "DeepCW model failed to load", t) Log.e(TAG, "DeepCW model failed to load", t)
_errorMessage.value = _errorMessage.value =
"CW model failed to load: ${t.message ?: t.javaClass.simpleName}" "CW model failed to load: ${t.message ?: t.javaClass.simpleName}"
// Persist the failure for devices without logcat access.
runCatching {
val sw = java.io.StringWriter()
t.printStackTrace(java.io.PrintWriter(sw))
java.io.File(appContext.filesDir, "deepcw_load_error.txt")
.writeText("${t.javaClass.name}: ${t.message}\n${sw}\n")
}
return false return false
} }
} }
@@ -154,6 +161,12 @@ class CwDeepDecoder(context: Context) : ICwDecoder {
} catch (t: Throwable) { } catch (t: Throwable) {
Log.e(TAG, "inference failed", t) Log.e(TAG, "inference failed", t)
_errorMessage.value = "CW decode failed: ${t.message ?: t.javaClass.simpleName}" _errorMessage.value = "CW decode failed: ${t.message ?: t.javaClass.simpleName}"
runCatching {
val sw = java.io.StringWriter()
t.printStackTrace(java.io.PrintWriter(sw))
java.io.File(appContext.filesDir, "deepcw_infer_error.txt")
.writeText("${t.javaClass.name}: ${t.message}\n${sw}\n")
}
} finally { } finally {
inferenceLock.unlock() inferenceLock.unlock()
} }