mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-11 02:51:10 +00:00
fix(hud): show the GPU clock in the Steam overlay on Adreno without root (#2059)
This commit is contained in:
4 files changed
+74
-1
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() }
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.io.File
|
||||
|
||||
object OverlayShown {
|
||||
fun check(root: File): Boolean {
|
||||
val config = File(root, "tmp").listFiles { f -> f.name.startsWith("mangohud.") }
|
||||
val config = File(root, "tmp").listFiles { f -> f.name.startsWith("mangohud.") || f.name == "droiddeck-mangohud.conf" }
|
||||
?.maxByOrNull { it.lastModified() } ?: return false
|
||||
return runCatching { !config.readText().contains("no_display") }.getOrDefault(false)
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import java.io.File
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TemporaryFolder
|
||||
|
||||
class OverlayShownTest {
|
||||
@get:Rule val tmp = TemporaryFolder()
|
||||
|
||||
private fun config(name: String, text: String, modified: Long) =
|
||||
File(tmp.root, "tmp").apply { mkdirs() }.resolve(name).apply { writeText(text); setLastModified(modified) }
|
||||
|
||||
@Test fun noConfigIsHidden() {
|
||||
assertFalse(OverlayShown.check(tmp.root))
|
||||
}
|
||||
|
||||
@Test fun mangohudConfigFollowsNoDisplay() {
|
||||
val f = config("mangohud.abcdefgh", "no_display\n", 1_000_000L)
|
||||
assertFalse(OverlayShown.check(tmp.root))
|
||||
f.writeText("preset=3\n")
|
||||
assertTrue(OverlayShown.check(tmp.root))
|
||||
}
|
||||
|
||||
@Test fun steamSessionConfigFollowsNoDisplay() {
|
||||
val f = config("droiddeck-mangohud.conf", "no_display\n", 1_000_000L)
|
||||
assertFalse(OverlayShown.check(tmp.root))
|
||||
f.writeText("preset=3\n")
|
||||
assertTrue(OverlayShown.check(tmp.root))
|
||||
}
|
||||
|
||||
@Test fun newestConfigWins() {
|
||||
config("mangohud.abcdefgh", "no_display\n", 1_000_000L)
|
||||
config("droiddeck-mangohud.conf", "preset=3\n", 2_000_000L)
|
||||
assertTrue(OverlayShown.check(tmp.root))
|
||||
config("mangohud.abcdefgh", "no_display\n", 3_000_000L)
|
||||
assertFalse(OverlayShown.check(tmp.root))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user