mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 05:16:01 +00:00
fix: new Steam installs start with shader pre-caching off (#1861)
This commit is contained in:
1 parent
fa4a54f64a
commit
c8c5e22a34
3 files changed
+46
-4
No files matched your search
@@ -760,7 +760,7 @@ jobs:
|
||||
checks:
|
||||
name: Compile and test APK
|
||||
needs: [build, python-tests]
|
||||
if: ${{ always() && (github.event_name != 'pull_request' || !github.event.pull_request.draft) }}
|
||||
if: ${{ !cancelled() && (github.event_name != 'pull_request' || !github.event.pull_request.draft) }}
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
|
||||
@@ -442,11 +442,15 @@ object SessionPrefs {
|
||||
|
||||
/**
|
||||
* Shader pre-caching as the launcher last set it, until a session reports it written into the
|
||||
* client's config.vdf; after that the client's own toggle is the user's again.
|
||||
* client's config.vdf; after that the client's own toggle is the user's again. A client that
|
||||
* has never written a config.vdf starts with pre-caching off.
|
||||
*/
|
||||
fun pendingShaderPrecache(context: Context): Boolean? {
|
||||
val prefs = prefs(context)
|
||||
if (!prefs.contains("shaderPrecache")) return null
|
||||
if (!prefs.contains("shaderPrecache")) {
|
||||
if (steamConfig(context).exists()) return null
|
||||
prefs.edit().putBoolean("shaderPrecache", false).apply()
|
||||
}
|
||||
val on = prefs.getBoolean("shaderPrecache", true)
|
||||
val applied = shaderPrecacheApplied(context)
|
||||
val written = runCatching { applied.readText().trim() }.getOrNull() ?: return on
|
||||
@@ -461,9 +465,12 @@ object SessionPrefs {
|
||||
prefs(context).edit().putBoolean("shaderPrecache", on).apply()
|
||||
}
|
||||
|
||||
private fun steamConfig(context: Context) =
|
||||
java.io.File(steamRoot(context, steamClientArch(context)), "config/config.vdf")
|
||||
|
||||
fun shaderPrecache(context: Context): Boolean = pendingShaderPrecache(context)
|
||||
?: runCatching { com.droiddeck.launcher.storage.SteamStorage.shaderPrecache(
|
||||
java.io.File(steamRoot(context, steamClientArch(context)), "config/config.vdf").readText()) }.getOrDefault(true)
|
||||
steamConfig(context).readText()) }.getOrDefault(true)
|
||||
|
||||
fun stretch16x9(context: Context): Boolean = prefs(context).getBoolean("stretch16x9", false)
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import android.content.Context
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28], manifest = Config.NONE)
|
||||
class ShaderPrecachePrefsTest {
|
||||
private val context: Context get() = RuntimeEnvironment.getApplication()
|
||||
|
||||
@Before fun reset() {
|
||||
context.getSharedPreferences("session", Context.MODE_PRIVATE).edit().clear().commit()
|
||||
SessionPrefs.steamRoot(context, SessionPrefs.steamClientArch(context)).deleteRecursively()
|
||||
}
|
||||
|
||||
@Test fun clientWithoutConfigStartsWithPrecachingOff() {
|
||||
assertEquals(false, SessionPrefs.pendingShaderPrecache(context))
|
||||
assertEquals(false, SessionPrefs.shaderPrecache(context))
|
||||
}
|
||||
|
||||
@Test fun existingConfigKeepsTheClientsChoice() {
|
||||
val config = SessionPrefs.steamRoot(context, SessionPrefs.steamClientArch(context)).resolve("config/config.vdf")
|
||||
config.parentFile!!.mkdirs()
|
||||
config.writeText("\"InstallConfigStore\" {}")
|
||||
assertNull(SessionPrefs.pendingShaderPrecache(context))
|
||||
assertEquals(true, SessionPrefs.shaderPrecache(context))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user