mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-22 14:26:00 +00:00
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.
This commit is contained in:
1 parent
7901e76561
commit
3ad13b1b66
2 files changed
+32
No files matched your search
@@ -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<File>) = 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() }
|
||||
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user