mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 05:16:01 +00:00
feat: warn when a game library drive is linked at USB 2.0 speed (#1746)
* Warn when a drive used as a game library is linked at USB 2.0 speed Reads the drive's USB link speed from sysfs through its mount, and shows a dismissible warning with the USB generation, link speed and a tip for a faster cable or drive. The warning returns after the drive is plugged in again unless Don't show this again is switched on. * Keep slow USB dismissals per plug-in across restarts and recheck after a dismiss Dismissals are stored with the boot count and the USB bus and device number, so they survive a process restart, end when that drive is plugged in again even while the launcher is stopped, and never clear other drives. A dismiss looks for the next slow drive, stale scans are dropped, and an unknown port speed is no longer treated as a USB 2.0 port. * Drop slow USB scans that a newer library or mount check has superseded * Invalidate pending slow USB scans as soon as a media broadcast arrives * Revalidate an open slow USB warning on every check and match raw mount library paths Every check now rescans, so a warning that is already showing is replaced or cleared when its drive is removed or the library changes. Library paths saved under /mnt/media_rw are treated as their /storage volume. * Keep the Don't show this again choice when a rescan closes the slow USB warning * Save the slow USB opt-out before the launcher activity is torn down
This commit is contained in:
1 parent
2410b8c67c
commit
d1bd23df16
38 files changed
+504
No files matched your search
@@ -213,6 +213,7 @@ class FrontEndActivity : ComponentActivity() {
|
||||
}
|
||||
private val mediaReceiver = object : android.content.BroadcastReceiver() {
|
||||
override fun onReceive(context: android.content.Context?, intent: Intent?) {
|
||||
usbScan++
|
||||
ui.removeCallbacks(mediaRefresh)
|
||||
ui.postDelayed(mediaRefresh, MEDIA_SETTLE_MS)
|
||||
}
|
||||
@@ -472,6 +473,16 @@ class FrontEndActivity : ComponentActivity() {
|
||||
private var oscMode by mutableStateOf(SessionPrefs.OSC_AUTO)
|
||||
private var backActionsInverted by mutableStateOf(false)
|
||||
private var gameStorage by mutableStateOf("")
|
||||
private var slowUsb by mutableStateOf<com.droiddeck.launcher.session.UsbLink.SlowDrive?>(null)
|
||||
private var usbScan = 0
|
||||
private var slowUsbNever by mutableStateOf(false)
|
||||
|
||||
private fun showSlowUsb(drive: com.droiddeck.launcher.session.UsbLink.SlowDrive?) {
|
||||
val off = slowUsbNever
|
||||
if (off) SessionPrefs.setSlowUsbWarningOff(this)
|
||||
slowUsbNever = false
|
||||
slowUsb = drive.takeUnless { off }
|
||||
}
|
||||
private var storageDiagnostics by mutableStateOf(false)
|
||||
private var storageOptions by mutableStateOf<List<GameStorage.Option>>(emptyList())
|
||||
private val pickGameStorage = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { r ->
|
||||
@@ -965,6 +976,13 @@ class FrontEndActivity : ComponentActivity() {
|
||||
if (decky.deckyPendingZip != null) com.droiddeck.launcher.ui.DeckyZipWarningDialog(
|
||||
onConfirm = { decky.confirmPluginZip() }, onCancel = { decky.cancelPluginZip() },
|
||||
)
|
||||
slowUsb?.let { drive ->
|
||||
com.droiddeck.launcher.ui.SlowUsbDialog(drive, slowUsbNever, { slowUsbNever = it }) {
|
||||
com.droiddeck.launcher.session.UsbLink.markShown(this, drive)
|
||||
showSlowUsb(null)
|
||||
checkUsbLink()
|
||||
}
|
||||
}
|
||||
val page: (@Composable () -> Unit)? = when {
|
||||
showPerformance -> { { PerformanceHost() } }
|
||||
showComponents -> { { ComponentsHost() } }
|
||||
@@ -1617,6 +1635,7 @@ class FrontEndActivity : ComponentActivity() {
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
if (slowUsbNever) SessionPrefs.setSlowUsbWarningOff(this)
|
||||
saveCompatLaunch(outState)
|
||||
pendingSwitch?.let { outState.putParcelable(KEY_PENDING_SWITCH, it) }
|
||||
switchingTo?.let {
|
||||
@@ -2198,6 +2217,7 @@ class FrontEndActivity : ComponentActivity() {
|
||||
}
|
||||
|
||||
private fun refreshAddedGames() {
|
||||
checkUsbLink()
|
||||
sgdbKeyKnown()
|
||||
fetchAddedGameArt()
|
||||
}
|
||||
@@ -2302,6 +2322,20 @@ class FrontEndActivity : ComponentActivity() {
|
||||
}
|
||||
SessionPrefs.setGameStorage(this, path, label)
|
||||
gameStorage = path
|
||||
checkUsbLink()
|
||||
}
|
||||
|
||||
private fun checkUsbLink() {
|
||||
if (android.os.Looper.myLooper() != android.os.Looper.getMainLooper()) { ui.post { checkUsbLink() }; return }
|
||||
val scan = ++usbScan
|
||||
Thread({
|
||||
val drive = runCatching { com.droiddeck.launcher.session.UsbLink.slowLibrary(this) }.getOrNull()
|
||||
ui.post {
|
||||
if (scan != usbScan || isFinishing) return@post
|
||||
val due = drive?.takeIf { com.droiddeck.launcher.session.UsbLink.stillDue(this, it) }
|
||||
if (due == null) { if (slowUsb != null) showSlowUsb(null) } else if (slowUsb?.key != due.key) showSlowUsb(due)
|
||||
}
|
||||
}, "usb-link").start()
|
||||
}
|
||||
|
||||
private fun refreshCores() {
|
||||
|
||||
Reference in new issue
Block a user