use correct version in root installs

This commit is contained in:
Ax333l 2024-12-10 17:47:38 +01:00
parent a85ad4ea0e
commit fd013ab5d7
No known key found for this signature in database
GPG Key ID: D2B4D85271127D23

View File

@ -76,7 +76,8 @@ class PatcherViewModel(
private val installedAppRepository: InstalledAppRepository by inject()
private val rootInstaller: RootInstaller by inject()
val installerStatusDialogModel : InstallerStatusDialogModel = object : InstallerStatusDialogModel {
val installerStatusDialogModel: InstallerStatusDialogModel =
object : InstallerStatusDialogModel {
override var packageInstallerStatus: Int? by mutableStateOf(null)
override fun reinstall() {
@ -341,7 +342,8 @@ class PatcherViewModel(
// Check if the app version is less than the installed version
if (pm.getVersionCode(currentPackageInfo) < pm.getVersionCode(existingPackageInfo)) {
// Exit if the selected app version is less than the installed version
installerStatusDialogModel.packageInstallerStatus = PackageInstaller.STATUS_FAILURE_CONFLICT
installerStatusDialogModel.packageInstallerStatus =
PackageInstaller.STATUS_FAILURE_CONFLICT
return@launch
}
}
@ -377,20 +379,23 @@ class PatcherViewModel(
}
}
val inputVersion = input.selectedApp.version
?: inputFile?.let(pm::getPackageInfo)?.versionName
?: throw Exception("Failed to determine input APK version")
// Install as root
rootInstaller.install(
outputFile,
inputFile,
packageName,
// input.selectedApp.version?
packageInfo.versionName!!,
inputVersion,
label
)
installedAppRepository.addOrUpdate(
packageInfo.packageName,
packageName,
packageInfo.versionName!!,
inputVersion,
InstallType.MOUNT,
input.selectedPatches
)
@ -410,7 +415,7 @@ class PatcherViewModel(
}
}
}
} catch(e: Exception) {
} catch (e: Exception) {
Log.e(tag, "Failed to install", e)
app.toast(app.getString(R.string.install_app_fail, e.simpleMessage()))
} finally {