From 3ad13b1b66b14b1b1639cb8cb747a7e9815785ea Mon Sep 17 00:00:00 2001 From: angelrenefm <17342133+angelrenefm@users.noreply.github.com> Date: Wed, 4 Nov 2026 00:07:13 +0100 Subject: [PATCH] fix(hud): bind the GPU clock and load nodes even when the HUD starts hidden With the overlay hidden at session start the blocked feeds have no value, so cur_freq and perf_now were never written before the binds were taken and stayed unbound for the whole session. --- .../launcher/session/GpuStatsComponent.kt | 5 ++++ .../launcher/session/GpuStatsBindsTest.kt | 27 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 app/src/test/java/com/droiddeck/launcher/session/GpuStatsBindsTest.kt diff --git a/app/src/main/java/com/droiddeck/launcher/session/GpuStatsComponent.kt b/app/src/main/java/com/droiddeck/launcher/session/GpuStatsComponent.kt index a5ddcb95d7..b0c0b45b2f 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/GpuStatsComponent.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/GpuStatsComponent.kt @@ -54,6 +54,7 @@ class GpuStatsComponent(val dir: File, private val root: File) : SessionPart() { } pick("temp", tempSources(), "%6d\n") { milliCelsius(it) }?.let { feeds.add(it) } refresh() + createMissing(feeds.map { it.file }) describeSources() Log.i(TAG, "hud: kgsl stats from the session's own: $sources") true @@ -354,6 +355,10 @@ class GpuStatsComponent(val dir: File, private val root: File) : SessionPart() { fun guestLoadDir(root: File) = File(root, GUEST_LOAD_DIR.removePrefix("/")) + // A feed with no value yet (the HUD hidden at start) still needs its file, or binds() leaves its node out for + // the whole session. + internal fun createMissing(files: List) = files.forEach { runCatching { it.createNewFile() } } + /** True when this app can see kgsl but none of its GPU load nodes (SELinux-blocked, e.g. the Retroid Pocket Duo). */ fun loadBlocked(): Boolean = File(KGSL).exists() && !File(GPUBUSY).canRead() && LOAD_SOURCES.none { File(it).canRead() } diff --git a/app/src/test/java/com/droiddeck/launcher/session/GpuStatsBindsTest.kt b/app/src/test/java/com/droiddeck/launcher/session/GpuStatsBindsTest.kt new file mode 100644 index 0000000000..4343683f35 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/session/GpuStatsBindsTest.kt @@ -0,0 +1,27 @@ +package com.droiddeck.launcher.session + +import java.io.File +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder + +class GpuStatsBindsTest { + @get:Rule val tmp = TemporaryFolder() + + @Test fun feedsWithNoValueYetAreStillBound() { + val dir = tmp.newFolder("kgsl-3d0") + GpuStatsComponent.createMissing(listOf(File(dir, "perf_now"), File(dir, "cur_freq"))) + val binds = GpuStatsComponent(dir, tmp.root).binds() + assertTrue(binds.contains(File(dir, "perf_now").path + ":" + GpuStatsComponent.MSM_LOAD)) + assertTrue(binds.contains(File(dir, "cur_freq").path + ":" + GpuStatsComponent.MSM_CLOCK)) + } + + @Test fun aWrittenValueIsKept() { + val dir = tmp.newFolder("kgsl-3d0") + File(dir, "cur_freq").writeText("586000000 \n") + GpuStatsComponent.createMissing(listOf(File(dir, "cur_freq"))) + assertEquals("586000000 \n", File(dir, "cur_freq").readText()) + } +}