ROMs folder and Storage in the session's home, the app's own file picker, logs finished on a crash, a two-column menu

A program's file dialog inside the session never showed the phone: internal storage was bound
at its own path, but proot binds do not appear in /proc/mounts and nothing under home pointed at
it. Every session now binds internal storage at /root/Storage and the folder chosen with the new
ROMs folder tile at /root/ROMs - a bind, so a folder on an SD card works the same.

Folder and file choosing is the app's own picker (files/), Bannerlator's File Manager pick mode
carried over: StorageRoots verbatim for the drive menu, the same intent API (InAppFilePicker),
folders first, an up-arrow floored at the volume root, the last folder remembered. Both driver
imports use it instead of the system document picker.

A session folder is finished whichever way the session ends: SessionArtifacts is shared by the
ordinary stop, an uncaught-exception handler (App/CrashHandler, writes crash-app.txt and finishes
the folder before the process dies) and a sweep at the next app start for a folder without its
.complete marker (a kill or a native crash), which gets ended-without-teardown.txt and the crash
buffer. A Session logs tile turns the folder off: it then lives in the cache and is deleted at
the end.

The main menu is two columns of tiles, each with its setting's value under its title.
This commit is contained in:
The412Banner committed 2026-09-21 22:43:56 -04:00
1 parent 3aa0162055
commit cb5a1b5a31
15 files changed
+1066 -91

No files matched your search

@@ -45,6 +45,10 @@ import com.steamdeck.launcher.ui.FrameGenDialog
import com.steamdeck.launcher.ui.MainScreen
import com.steamdeck.launcher.ui.MainUiState
import com.steamdeck.launcher.ui.SteamDeckTheme
import com.steamdeck.launcher.ui.RomsDialog
import com.steamdeck.launcher.files.InAppFilePicker
import com.steamdeck.launcher.session.SessionArtifacts
import com.steamdeck.launcher.session.SessionState
/**
* The whole app outside a session: is the runtime installed, is there a newer one, frame
@@ -95,14 +99,23 @@ class MainActivity : ComponentActivity() {
private var androidRows by mutableStateOf<List<DriverRow>>(emptyList())
private var androidSelected by mutableStateOf("")
// The system file picker, once per driver list: the two lists validate differently, and the
// reason a zip is refused names the list it belongs in.
private val pickLinuxDriver = registerForActivityResult(ActivityResultContracts.OpenDocument()) { uri ->
if (uri != null) importDriver(uri, linux = true)
// The app's own picker (files/), once per kind of pick: the two driver lists validate
// differently, and the reason a zip is refused names the list it belongs in.
private val pickLinuxDriver = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { r ->
if (r.resultCode == RESULT_OK) InAppFilePicker.pickedUri(r.data)?.let { importDriver(it, linux = true) }
}
private val pickAndroidDriver = registerForActivityResult(ActivityResultContracts.OpenDocument()) { uri ->
if (uri != null) importDriver(uri, linux = false)
private val pickAndroidDriver = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { r ->
if (r.resultCode == RESULT_OK) InAppFilePicker.pickedUri(r.data)?.let { importDriver(it, linux = false) }
}
private val pickRomsDir = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { r ->
if (r.resultCode == RESULT_OK) InAppFilePicker.pickedPath(r.data)?.let { path ->
SessionPrefs.setRomsDir(this, path)
romsDir = path
}
}
private var romsDir by mutableStateOf<String?>(null)
private var logsEnabled by mutableStateOf(true)
private var showRoms by mutableStateOf(false)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -117,6 +130,7 @@ class MainActivity : ComponentActivity() {
frameGenLabel = frameGenLabel,
desktopInstalled = desktopInstalled,
offlineAccount = offlineAccount, offline = offline,
romsDir = romsDir, logsEnabled = logsEnabled,
),
onPlay = { startActivity(Intent(this, SessionActivity::class.java)) },
onDesktop = {
@@ -134,8 +148,22 @@ class MainActivity : ComponentActivity() {
onDrivers = { refreshDrivers(); showDrivers = true },
onAudio = { directAudio = SessionPrefs.directAudio(this); mic = SessionPrefs.micEnabled(this); showAudio = true },
onPerformance = { refreshCores(); showPerformance = true },
onRoms = { showRoms = true },
onLogs = {
SessionPrefs.setLogsEnabled(this, !SessionPrefs.logsEnabled(this))
logsEnabled = SessionPrefs.logsEnabled(this)
},
onCredits = { showCredits = true },
)
if (showRoms) RomsDialog(
path = romsDir,
onChoose = {
showRoms = false
pickRomsDir.launch(InAppFilePicker.buildDirIntent(this, "Choose the ROMs folder", romsDir))
},
onClear = { SessionPrefs.setRomsDir(this, ""); romsDir = null; showRoms = false },
onDismiss = { showRoms = false },
)
if (showApps) DesktopAppsDialog(
rows = packageRows, busyStage = pkgStage, busyPercent = pkgPercent,
onInstall = { id -> installPackage(id) },
@@ -153,10 +181,10 @@ class MainActivity : ComponentActivity() {
linuxRows = linuxRows, linuxSteam = linuxSteam, linuxDesktop = linuxDesktop,
androidRows = androidRows, androidSelected = androidSelected,
onSelectLinux = { mode, id -> SessionPrefs.setLinuxDriver(this, mode, id); refreshDrivers() },
onImportLinux = { pickLinuxDriver.launch(ZIP_TYPES) },
onImportLinux = { pickLinuxDriver.launch(InAppFilePicker.buildIntent(this, ZIP_EXT, "Choose a Linux runtime driver (-Linux zip)")) },
onRemoveLinux = { id -> LinuxVulkanDriverManager(this).removeDriver(id); refreshDrivers() },
onSelectAndroid = { id -> SessionPrefs.setAndroidDriver(this, id); refreshDrivers() },
onImportAndroid = { pickAndroidDriver.launch(ZIP_TYPES) },
onImportAndroid = { pickAndroidDriver.launch(InAppFilePicker.buildIntent(this, ZIP_EXT, "Choose a display driver (AdrenoTools zip)")) },
onRemoveAndroid = { id -> TurnipDriver(this).remove(id); refreshDrivers() },
onDismiss = { showDrivers = false },
)
@@ -221,6 +249,8 @@ class MainActivity : ComponentActivity() {
if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), 1)
}
// A session folder left without its ending - the process was killed - gets it now.
if (!SessionState.running) Thread({ SessionArtifacts.finishAbandoned(this) }, "finish-abandoned").start()
}
override fun onResume() {
@@ -319,7 +349,7 @@ class MainActivity : ComponentActivity() {
}, "import-driver").start()
}
private fun displayNameOf(uri: Uri): String? = try {
private fun displayNameOf(uri: Uri): String? = if (uri.scheme == "file") uri.lastPathSegment else try {
contentResolver.query(uri, arrayOf(OpenableColumns.DISPLAY_NAME), null, null, null)
?.use { c -> if (c.moveToFirst()) c.getString(0) else null }
} catch (e: Exception) {
@@ -359,6 +389,8 @@ class MainActivity : ComponentActivity() {
installed = LinuxRuntimeInstaller.installedVersion(this)
ready = LinuxRuntime.isInstalled(this)
frameGenLabel = FrameGen.label(this)
romsDir = SessionPrefs.romsDir(this).takeIf { it.isNotEmpty() }
logsEnabled = SessionPrefs.logsEnabled(this)
}
private fun onRuntimeButton() {
@@ -402,6 +434,6 @@ class MainActivity : ComponentActivity() {
companion object {
private const val TAG = "MainActivity"
/** What the picker offers for a driver zip; some file apps label a zip as a plain stream. */
private val ZIP_TYPES = arrayOf("application/zip", "application/octet-stream")
private val ZIP_EXT = listOf("zip")
}
}