mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-22 14:52:45 +01:00
Merge pull request #11773 from t895/manager-fix
android: Fix incorrect assumption for driver installation validation
This commit is contained in:
commit
4a9240599a
1 changed files with 13 additions and 12 deletions
|
@ -26,6 +26,7 @@ import org.yuzu.yuzu_emu.model.DriverViewModel
|
||||||
import org.yuzu.yuzu_emu.model.HomeViewModel
|
import org.yuzu.yuzu_emu.model.HomeViewModel
|
||||||
import org.yuzu.yuzu_emu.utils.FileUtil
|
import org.yuzu.yuzu_emu.utils.FileUtil
|
||||||
import org.yuzu.yuzu_emu.utils.GpuDriverHelper
|
import org.yuzu.yuzu_emu.utils.GpuDriverHelper
|
||||||
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
class DriverManagerFragment : Fragment() {
|
class DriverManagerFragment : Fragment() {
|
||||||
|
@ -154,29 +155,29 @@ class DriverManagerFragment : Fragment() {
|
||||||
R.string.installing_driver,
|
R.string.installing_driver,
|
||||||
false
|
false
|
||||||
) {
|
) {
|
||||||
|
val driverPath =
|
||||||
|
"${GpuDriverHelper.driverStoragePath}/${FileUtil.getFilename(result)}"
|
||||||
|
val driverFile = File(driverPath)
|
||||||
|
|
||||||
// Ignore file exceptions when a user selects an invalid zip
|
// Ignore file exceptions when a user selects an invalid zip
|
||||||
try {
|
try {
|
||||||
GpuDriverHelper.copyDriverToInternalStorage(result)
|
if (!GpuDriverHelper.copyDriverToInternalStorage(result)) {
|
||||||
|
throw IOException("Driver failed validation!")
|
||||||
|
}
|
||||||
} catch (_: IOException) {
|
} catch (_: IOException) {
|
||||||
|
if (driverFile.exists()) {
|
||||||
|
driverFile.delete()
|
||||||
|
}
|
||||||
return@newInstance getString(R.string.select_gpu_driver_error)
|
return@newInstance getString(R.string.select_gpu_driver_error)
|
||||||
}
|
}
|
||||||
|
|
||||||
val driverData = GpuDriverHelper.customDriverData
|
val driverData = GpuDriverHelper.getMetadataFromZip(driverFile)
|
||||||
if (driverData.name == null) {
|
|
||||||
return@newInstance getString(R.string.select_gpu_driver_error)
|
|
||||||
}
|
|
||||||
|
|
||||||
val driverInList =
|
val driverInList =
|
||||||
driverViewModel.driverList.value.firstOrNull { it.second == driverData }
|
driverViewModel.driverList.value.firstOrNull { it.second == driverData }
|
||||||
if (driverInList != null) {
|
if (driverInList != null) {
|
||||||
return@newInstance getString(R.string.driver_already_installed)
|
return@newInstance getString(R.string.driver_already_installed)
|
||||||
} else {
|
} else {
|
||||||
driverViewModel.addDriver(
|
driverViewModel.addDriver(Pair(driverPath, driverData))
|
||||||
Pair(
|
|
||||||
"${GpuDriverHelper.driverStoragePath}/${FileUtil.getFilename(result)}",
|
|
||||||
driverData
|
|
||||||
)
|
|
||||||
)
|
|
||||||
driverViewModel.setNewDriverInstalled(true)
|
driverViewModel.setNewDriverInstalled(true)
|
||||||
}
|
}
|
||||||
return@newInstance Any()
|
return@newInstance Any()
|
||||||
|
|
Loading…
Reference in a new issue