mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 13:55:58 +00:00
feat: add build watermark toggle for Lab, test, and local builds (#2488)
This commit is contained in:
1 parent
02a5be62da
commit
7da27d4ff4
41 files changed
+281
-16
No files matched your search
@@ -0,0 +1,44 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.util.AtomicFile
|
||||
import java.io.File
|
||||
|
||||
internal object BuildWatermarkSetting {
|
||||
const val CHANGED = "com.droiddeck.launcher.BUILD_WATERMARK_CHANGED"
|
||||
|
||||
private fun file(context: Context) = AtomicFile(File(context.filesDir, "build-watermark"))
|
||||
|
||||
private val processLock = Any()
|
||||
|
||||
private fun <T> locked(context: Context, action: () -> T): T = synchronized(processLock) {
|
||||
File(context.filesDir, "build-watermark.lock").outputStream().channel.use { channel ->
|
||||
channel.lock().use { action() }
|
||||
}
|
||||
}
|
||||
|
||||
fun enabled(context: Context): Boolean = try {
|
||||
locked(context) {
|
||||
// SharedPreferences caches are process-local; read the shared file on every refresh.
|
||||
file(context).readFully().decodeToString() != "off"
|
||||
}
|
||||
} catch (_: java.io.IOException) {
|
||||
context.getSharedPreferences("session", Context.MODE_PRIVATE).getBoolean("buildWatermark", true)
|
||||
}
|
||||
|
||||
fun setEnabled(context: Context, on: Boolean) {
|
||||
locked(context) {
|
||||
val target = file(context)
|
||||
val stream = target.startWrite()
|
||||
try {
|
||||
stream.write((if (on) "on" else "off").toByteArray())
|
||||
target.finishWrite(stream)
|
||||
} catch (error: Throwable) {
|
||||
target.failWrite(stream)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
context.sendBroadcast(Intent(CHANGED).setPackage(context.packageName))
|
||||
}
|
||||
}
|
||||
@@ -1048,6 +1048,13 @@ object SessionPrefs {
|
||||
prefs(context).edit().putBoolean("vac_diagnostics", on).apply()
|
||||
}
|
||||
|
||||
fun buildWatermarkEnabled(context: Context): Boolean =
|
||||
BuildWatermarkSetting.enabled(context)
|
||||
|
||||
fun setBuildWatermarkEnabled(context: Context, on: Boolean) {
|
||||
BuildWatermarkSetting.setEnabled(context, on)
|
||||
}
|
||||
|
||||
private fun resolutionCap(context: Context, mode: String): Int = prefs(context).getInt("resolutionCap.$mode", 720)
|
||||
|
||||
fun resolutionChosen(context: Context, mode: String): Boolean =
|
||||
|
||||
@@ -23,7 +23,7 @@ object SettingsReset {
|
||||
"tuSysmem", "glThread", "noGlError", "zinkLazy", "mangoapp", "gpuClockPin", "gamescopeRealtime", "ramCapMb", "vramCapMb", "zramClient",
|
||||
"directAudio", "mic", "wifiDiscovery", "clientCpusOverride", "clientCpus", "gameCpus",
|
||||
"noXalia", "fastSync", "fsyncFirst", "syncFallback", "prootNoSeccomp", "prootFastPath", "nativeUserland", "cursorComposite",
|
||||
"guestHostname", "fexPreset", "forceSsbs", "logs", "gameDebugLogsEnabled", "enhancedDiagnosticsNext", "storageDiagnostics",
|
||||
"guestHostname", "fexPreset", "forceSsbs", "logs", "gameDebugLogsEnabled", "enhancedDiagnosticsNext", "storageDiagnostics", "buildWatermark",
|
||||
"upscaler", "upscaleSharpness", "screenEffects", "textureAnisotropy", "textureLodBias",
|
||||
"steamDownloadsInBackground", "steam_offline", "bootMovie", "bootMovieSound", "bootMovieVolume", "bootMovieSeconds",
|
||||
"bootMovieApplyNext", "bootMovieSteamSeen",
|
||||
@@ -43,6 +43,7 @@ object SettingsReset {
|
||||
var ok = true
|
||||
val session = context.getSharedPreferences("session", Context.MODE_PRIVATE)
|
||||
session.edit().apply { session.all.keys.filter { isSessionSetting(it) }.forEach { remove(it) } }.commit()
|
||||
BuildWatermarkSetting.setEnabled(context, true)
|
||||
ControllerPrefs.resetAll(context)
|
||||
InputProfiles.resetAll(context)
|
||||
context.getSharedPreferences("app-ui", Context.MODE_PRIVATE).edit().clear().commit()
|
||||
|
||||
Reference in new issue
Block a user