Cover all added games in storage access diagnostics

This commit is contained in:
Kurt Himebauch committed 2026-12-05 14:15:22 -05:00
1 parent 9946b6d678
commit 4b119b548c
3 files changed
+18 -13

No files matched your search

@@ -20,7 +20,7 @@ object AllFilesAccess {
else -> "missing"
}
fun hidesFilesIn(path: String, sdk: Int = Build.VERSION.SDK_INT, granted: () -> Boolean = { Environment.isExternalStorageManager() }): Boolean =
fun mayHideFilesIn(path: String, sdk: Int = Build.VERSION.SDK_INT, granted: () -> Boolean = { Environment.isExternalStorageManager() }): Boolean =
covers(path) && missing(sdk, granted)
/** Whether reading [path] takes all-files access: shared storage, outside the per-app folders directly under a volume's root, which Android always lets the app use. */
@@ -1355,10 +1355,17 @@ class SessionService : Service() {
if (controllersOn) components.add(RumbleComponent().also { it.attach(this) })
val home = File(LinuxRuntime.rootDir(this), "root")
File(home, "Storage").mkdirs()
val addedExeFolders = com.droiddeck.launcher.frontend.AddedExes.list(this).map { File(it.folder) }.distinctBy { it.path }
val addedGameRoots = com.droiddeck.launcher.frontend.AddedGames.roots(this)
val addedFolders = (addedExeFolders + addedGameRoots.map { it.host }).distinctBy { it.path }
for (folder in addedFolders) {
if (com.droiddeck.launcher.files.AllFilesAccess.mayHideFilesIn(folder.path))
Log.w(TAG, "added games: Android may hide .exe files in $folder because All files access is missing")
}
if (sharedStorage != null) {
binds.add(sharedStorage.path + ":/root/Storage")
} else {
for (folder in com.droiddeck.launcher.frontend.AddedExes.list(this).map { File(it.folder) }.distinctBy { it.path }) {
for (folder in addedExeFolders) {
val guest = com.droiddeck.launcher.frontend.AddedGames.guestPath(this, folder) ?: continue
if (!guest.startsWith("/root/Storage/") || !folder.isDirectory) continue
File(LinuxRuntime.rootDir(this), guest.removePrefix("/")).mkdirs()
@@ -1409,13 +1416,11 @@ class SessionService : Service() {
Log.w(TAG, "storage diagnostics: selected library could not be identified; metadata snapshot only")
}
}
for (root in com.droiddeck.launcher.frontend.AddedGames.roots(this)) {
for (root in addedGameRoots) {
if (root.host.isDirectory && root.host.canRead()) {
File(LinuxRuntime.rootDir(this), root.guest.removePrefix("/")).mkdirs()
binds.add(root.host.path + ":" + root.guest)
Log.i(TAG, "added games: ${root.host} -> ${root.guest}")
if (com.droiddeck.launcher.files.AllFilesAccess.hidesFilesIn(root.host.path))
Log.w(TAG, "added games: ${root.host} needs All files access; without it Android hides its .exe files from the session")
} else {
Log.w(TAG, "added games: ${root.host} is not a readable folder this session")
}
@@ -47,17 +47,17 @@ class AllFilesAccessTest {
}
@Test
fun sharedStorageHidesFilesOnlyWithoutAccess() {
assertTrue(AllFilesAccess.hidesFilesIn("/storage/emulated/0", sdk = 34) { false })
assertTrue(AllFilesAccess.hidesFilesIn("/storage/1A2B-3C4D/Games", sdk = 34) { false })
assertFalse(AllFilesAccess.hidesFilesIn("/storage/emulated/0", sdk = 34) { true })
assertFalse(AllFilesAccess.hidesFilesIn("/storage/emulated/0", sdk = 29) { false })
fun sharedStorageMayHideFilesOnlyWithoutAccess() {
assertTrue(AllFilesAccess.mayHideFilesIn("/storage/emulated/0", sdk = 34) { false })
assertTrue(AllFilesAccess.mayHideFilesIn("/storage/1A2B-3C4D/Games", sdk = 34) { false })
assertFalse(AllFilesAccess.mayHideFilesIn("/storage/emulated/0", sdk = 34) { true })
assertFalse(AllFilesAccess.mayHideFilesIn("/storage/emulated/0", sdk = 29) { false })
}
@Test
fun appFoldersAndPrivateStorageNeverHideFiles() {
assertFalse(AllFilesAccess.hidesFilesIn("/storage/emulated/0/Android/data/com.droiddeck.launcher/files", sdk = 34) { false })
assertFalse(AllFilesAccess.hidesFilesIn("/data/user/0/com.droiddeck.launcher/files/Games", sdk = 34) { false })
assertFalse(AllFilesAccess.hidesFilesIn("/mnt/media_rw/1A2B-3C4D", sdk = 34) { false })
assertFalse(AllFilesAccess.mayHideFilesIn("/storage/emulated/0/Android/data/com.droiddeck.launcher/files", sdk = 34) { false })
assertFalse(AllFilesAccess.mayHideFilesIn("/data/user/0/com.droiddeck.launcher/files/Games", sdk = 34) { false })
assertFalse(AllFilesAccess.mayHideFilesIn("/mnt/media_rw/1A2B-3C4D", sdk = 34) { false })
}
}