fix: ComposeTrace host test 降级(Trace API 未 stub 时静默忽略)

androidHostTest 中 android.os.Trace 未提供 stub,调用会抛 RuntimeException。
包装在 try-catch 中,使 host test 能正常执行涉及 trace 的代码路径。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
xfy 2026-05-19 11:47:16 +08:00
parent d3befaabec
commit 49487a00e8

View File

@ -2,6 +2,18 @@ package plus.rua.project
import android.os.Trace
actual fun composeTraceBeginSection(name: String) = Trace.beginSection(name)
actual fun composeTraceBeginSection(name: String) {
try {
Trace.beginSection(name)
} catch (_: RuntimeException) {
// Trace API 在 host test 中未 stub忽略
}
}
actual fun composeTraceEndSection() = Trace.endSection()
actual fun composeTraceEndSection() {
try {
Trace.endSection()
} catch (_: RuntimeException) {
// Trace API 在 host test 中未 stub忽略
}
}