Make GpuDriverInstallResult PascalCase

This commit is contained in:
lynxnb 2022-11-09 12:48:48 +01:00 committed by Mark Collins
parent 7f1667de82
commit ee8c055641
3 changed files with 20 additions and 21 deletions

View File

@ -59,7 +59,7 @@ class GpuDriverActivity : AppCompatActivity() {
val result = GpuDriverHelper.installDriver(this@GpuDriverActivity, fileStream) val result = GpuDriverHelper.installDriver(this@GpuDriverActivity, fileStream)
runOnUiThread { runOnUiThread {
Snackbar.make(binding.root, resolveInstallResultString(result), Snackbar.LENGTH_LONG).show() Snackbar.make(binding.root, resolveInstallResultString(result), Snackbar.LENGTH_LONG).show()
if (result == GpuDriverInstallResult.SUCCESS) if (result == GpuDriverInstallResult.Success)
populateAdapter() populateAdapter()
} }
} }
@ -185,11 +185,11 @@ class GpuDriverActivity : AppCompatActivity() {
} }
private fun resolveInstallResultString(result : GpuDriverInstallResult) = when (result) { private fun resolveInstallResultString(result : GpuDriverInstallResult) = when (result) {
GpuDriverInstallResult.SUCCESS -> getString(R.string.gpu_driver_install_success) GpuDriverInstallResult.Success -> getString(R.string.gpu_driver_install_success)
GpuDriverInstallResult.INVALID_ARCHIVE -> getString(R.string.gpu_driver_install_invalid_archive) GpuDriverInstallResult.InvalidArchive -> getString(R.string.gpu_driver_install_invalid_archive)
GpuDriverInstallResult.MISSING_METADATA -> getString(R.string.gpu_driver_install_missing_metadata) GpuDriverInstallResult.MissingMetadata -> getString(R.string.gpu_driver_install_missing_metadata)
GpuDriverInstallResult.INVALID_METADATA -> getString(R.string.gpu_driver_install_invalid_metadata) GpuDriverInstallResult.InvalidMetadata -> getString(R.string.gpu_driver_install_invalid_metadata)
GpuDriverInstallResult.UNSUPPORTED_ANDROID_VERSION -> getString(R.string.gpu_driver_install_unsupported_android_version) GpuDriverInstallResult.UnsupportedAndroidVersion -> getString(R.string.gpu_driver_install_unsupported_android_version)
GpuDriverInstallResult.ALREADY_INSTALLED -> getString(R.string.gpu_driver_install_already_installed) GpuDriverInstallResult.AlreadyInstalled -> getString(R.string.gpu_driver_install_already_installed)
} }
} }

View File

@ -104,7 +104,7 @@ interface GpuDriverHelper {
} catch (e : Exception) { } catch (e : Exception) {
e.printStackTrace() e.printStackTrace()
installTempDir.deleteRecursively() installTempDir.deleteRecursively()
return GpuDriverInstallResult.INVALID_ARCHIVE return GpuDriverInstallResult.InvalidArchive
} }
return installUnpackedDriver(context, installTempDir) return installUnpackedDriver(context, installTempDir)
@ -125,7 +125,7 @@ interface GpuDriverHelper {
} catch (e : Exception) { } catch (e : Exception) {
e.printStackTrace() e.printStackTrace()
installTempDir.deleteRecursively() installTempDir.deleteRecursively()
return GpuDriverInstallResult.INVALID_ARCHIVE return GpuDriverInstallResult.InvalidArchive
} }
return installUnpackedDriver(context, installTempDir) return installUnpackedDriver(context, installTempDir)
@ -145,7 +145,7 @@ interface GpuDriverHelper {
val metadataFile = File(unpackDir, GPU_DRIVER_META_FILE) val metadataFile = File(unpackDir, GPU_DRIVER_META_FILE)
if (!metadataFile.isFile) { if (!metadataFile.isFile) {
cleanup() cleanup()
return GpuDriverInstallResult.MISSING_METADATA return GpuDriverInstallResult.MissingMetadata
} }
// Check that the driver metadata is valid // Check that the driver metadata is valid
@ -153,13 +153,13 @@ interface GpuDriverHelper {
GpuDriverMetadata.deserialize(metadataFile) GpuDriverMetadata.deserialize(metadataFile)
} catch (e : SerializationException) { } catch (e : SerializationException) {
cleanup() cleanup()
return GpuDriverInstallResult.INVALID_METADATA return GpuDriverInstallResult.InvalidMetadata
} }
// Check that the device satisfies the driver's minimum Android version requirements // Check that the device satisfies the driver's minimum Android version requirements
if (Build.VERSION.SDK_INT < driverMetadata.minApi) { if (Build.VERSION.SDK_INT < driverMetadata.minApi) {
cleanup() cleanup()
return GpuDriverInstallResult.UNSUPPORTED_ANDROID_VERSION return GpuDriverInstallResult.UnsupportedAndroidVersion
} }
// Check that the driver is not already installed // Check that the driver is not already installed
@ -167,7 +167,7 @@ interface GpuDriverHelper {
val finalInstallDir = File(getDriversDirectory(context), driverMetadata.label) val finalInstallDir = File(getDriversDirectory(context), driverMetadata.label)
if (installedDrivers[finalInstallDir] != null) { if (installedDrivers[finalInstallDir] != null) {
cleanup() cleanup()
return GpuDriverInstallResult.ALREADY_INSTALLED return GpuDriverInstallResult.AlreadyInstalled
} }
// Move the driver files to the final location // Move the driver files to the final location
@ -176,7 +176,7 @@ interface GpuDriverHelper {
throw IOException("Failed to create directory ${finalInstallDir.name}") throw IOException("Failed to create directory ${finalInstallDir.name}")
} }
return GpuDriverInstallResult.SUCCESS return GpuDriverInstallResult.Success
} }
/** /**
@ -216,10 +216,10 @@ interface GpuDriverHelper {
} }
enum class GpuDriverInstallResult { enum class GpuDriverInstallResult {
SUCCESS, Success,
INVALID_ARCHIVE, InvalidArchive,
MISSING_METADATA, MissingMetadata,
INVALID_METADATA, InvalidMetadata,
UNSUPPORTED_ANDROID_VERSION, UnsupportedAndroidVersion,
ALREADY_INSTALLED, AlreadyInstalled,
} }

View File

@ -6,7 +6,6 @@
package emu.skyline.utils package emu.skyline.utils
import java.io.* import java.io.*
import java.lang.reflect.Field
import java.util.zip.ZipEntry import java.util.zip.ZipEntry
import java.util.zip.ZipFile import java.util.zip.ZipFile
import java.util.zip.ZipInputStream import java.util.zip.ZipInputStream