mirror of
https://github.com/revanced/revanced-cli.git
synced 2024-12-27 20:45:49 +01:00
feat: Show error about no installation device found at the beginning
This commit is contained in:
parent
ba159a35a9
commit
3300e6b433
@ -245,6 +245,32 @@ internal object PatchCommand : Runnable {
|
|||||||
keyStoreFilePath ?: outputFilePath.parentFile
|
keyStoreFilePath ?: outputFilePath.parentFile
|
||||||
.resolve("${outputFilePath.nameWithoutExtension}.keystore")
|
.resolve("${outputFilePath.nameWithoutExtension}.keystore")
|
||||||
|
|
||||||
|
val installer = if (deviceSerial != null) {
|
||||||
|
try {
|
||||||
|
if (mount) {
|
||||||
|
AdbRootInstaller(deviceSerial)
|
||||||
|
} else {
|
||||||
|
AdbInstaller(deviceSerial)
|
||||||
|
}
|
||||||
|
} catch (e: DeviceNotFoundException) {
|
||||||
|
if (deviceSerial!!.isNotEmpty()) {
|
||||||
|
logger.severe(
|
||||||
|
"Device with serial $deviceSerial not found to install to. " +
|
||||||
|
"Ensure the device is connected and the serial is correct when using the --install option.",
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
logger.severe(
|
||||||
|
"No device has been found to install to. " +
|
||||||
|
"Ensure a device is connected when using the --install option.",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
// region Load patches
|
// region Load patches
|
||||||
@ -332,13 +358,7 @@ internal object PatchCommand : Runnable {
|
|||||||
val deviceSerial = it.ifEmpty { null }
|
val deviceSerial = it.ifEmpty { null }
|
||||||
|
|
||||||
runBlocking {
|
runBlocking {
|
||||||
val result = if (mount) {
|
when (val result = installer!!.install(Installer.Apk(outputFilePath, packageName))) {
|
||||||
AdbRootInstaller(deviceSerial)
|
|
||||||
} else {
|
|
||||||
AdbInstaller(deviceSerial)
|
|
||||||
}.install(Installer.Apk(outputFilePath, packageName))
|
|
||||||
|
|
||||||
when (result) {
|
|
||||||
RootInstallerResult.FAILURE -> logger.severe("Failed to mount the patched APK file")
|
RootInstallerResult.FAILURE -> logger.severe("Failed to mount the patched APK file")
|
||||||
is AdbInstallerResult.Failure -> logger.severe(result.exception.toString())
|
is AdbInstallerResult.Failure -> logger.severe(result.exception.toString())
|
||||||
else -> logger.info("Installed the patched APK file")
|
else -> logger.info("Installed the patched APK file")
|
||||||
|
Loading…
Reference in New Issue
Block a user