mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 12:35:42 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1566c5abd8 |
No files matched your search
@@ -186,6 +186,7 @@ object DeviceReport {
|
|||||||
val fs = StatFs(Environment.getExternalStorageDirectory().path)
|
val fs = StatFs(Environment.getExternalStorageDirectory().path)
|
||||||
k("Shared storage free", FileUtils.sizeToString(fs.availableBlocksLong * fs.blockSizeLong))
|
k("Shared storage free", FileUtils.sizeToString(fs.availableBlocksLong * fs.blockSizeLong))
|
||||||
}
|
}
|
||||||
|
k("All files access", runCatching { com.droiddeck.launcher.files.AllFilesAccess.state() }.getOrNull())
|
||||||
|
|
||||||
h("GPU")
|
h("GPU")
|
||||||
k("KGSL gpu_model", readSys("/sys/class/kgsl/kgsl-3d0/gpu_model"))
|
k("KGSL gpu_model", readSys("/sys/class/kgsl/kgsl-3d0/gpu_model"))
|
||||||
|
|||||||
@@ -14,6 +14,15 @@ object AllFilesAccess {
|
|||||||
fun missing(sdk: Int = Build.VERSION.SDK_INT, granted: () -> Boolean = { Environment.isExternalStorageManager() }): Boolean =
|
fun missing(sdk: Int = Build.VERSION.SDK_INT, granted: () -> Boolean = { Environment.isExternalStorageManager() }): Boolean =
|
||||||
sdk >= Build.VERSION_CODES.R && !granted()
|
sdk >= Build.VERSION_CODES.R && !granted()
|
||||||
|
|
||||||
|
fun state(sdk: Int = Build.VERSION.SDK_INT, granted: () -> Boolean = { Environment.isExternalStorageManager() }): String = when {
|
||||||
|
sdk < Build.VERSION_CODES.R -> "not needed"
|
||||||
|
granted() -> "granted"
|
||||||
|
else -> "missing"
|
||||||
|
}
|
||||||
|
|
||||||
|
fun hidesFilesIn(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. */
|
/** 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. */
|
||||||
fun covers(path: String): Boolean {
|
fun covers(path: String): Boolean {
|
||||||
val inside = VOLUME.matchEntire(path)?.groupValues?.get(2) ?: return false
|
val inside = VOLUME.matchEntire(path)?.groupValues?.get(2) ?: return false
|
||||||
|
|||||||
@@ -1361,6 +1361,8 @@ class SessionService : Service() {
|
|||||||
File(LinuxRuntime.rootDir(this), root.guest.removePrefix("/")).mkdirs()
|
File(LinuxRuntime.rootDir(this), root.guest.removePrefix("/")).mkdirs()
|
||||||
binds.add(root.host.path + ":" + root.guest)
|
binds.add(root.host.path + ":" + root.guest)
|
||||||
Log.i(TAG, "added games: ${root.host} -> ${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 {
|
} else {
|
||||||
Log.w(TAG, "added games: ${root.host} is not a readable folder this session")
|
Log.w(TAG, "added games: ${root.host} is not a readable folder this session")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.droiddeck.launcher.files
|
package com.droiddeck.launcher.files
|
||||||
|
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Assert.assertFalse
|
import org.junit.Assert.assertFalse
|
||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
@@ -37,4 +38,26 @@ class AllFilesAccessTest {
|
|||||||
assertFalse(AllFilesAccess.covers("/storage/1A2B-3C4D/Android/obb/com.droiddeck.launcher"))
|
assertFalse(AllFilesAccess.covers("/storage/1A2B-3C4D/Android/obb/com.droiddeck.launcher"))
|
||||||
assertFalse(AllFilesAccess.covers("/data/user/0/com.droiddeck.launcher/files"))
|
assertFalse(AllFilesAccess.covers("/data/user/0/com.droiddeck.launcher/files"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun stateNamesWhatTheReportShows() {
|
||||||
|
assertEquals("not needed", AllFilesAccess.state(sdk = 29) { false })
|
||||||
|
assertEquals("missing", AllFilesAccess.state(sdk = 34) { false })
|
||||||
|
assertEquals("granted", AllFilesAccess.state(sdk = 34) { true })
|
||||||
|
}
|
||||||
|
|
||||||
|
@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 })
|
||||||
|
}
|
||||||
|
|
||||||
|
@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 })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user