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 installedAppRepository: InstalledAppRepository by inject()
private val rootInstaller: RootInstaller 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 var packageInstallerStatus: Int? by mutableStateOf(null)
override fun reinstall() { override fun reinstall() {
@ -341,7 +342,8 @@ class PatcherViewModel(
// Check if the app version is less than the installed version // Check if the app version is less than the installed version
if (pm.getVersionCode(currentPackageInfo) < pm.getVersionCode(existingPackageInfo)) { if (pm.getVersionCode(currentPackageInfo) < pm.getVersionCode(existingPackageInfo)) {
// Exit if the selected app version is less than the installed version // 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 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 // Install as root
rootInstaller.install( rootInstaller.install(
outputFile, outputFile,
inputFile, inputFile,
packageName, packageName,
// input.selectedApp.version? inputVersion,
packageInfo.versionName!!,
label label
) )
installedAppRepository.addOrUpdate( installedAppRepository.addOrUpdate(
packageInfo.packageName, packageInfo.packageName,
packageName, packageName,
packageInfo.versionName!!, inputVersion,
InstallType.MOUNT, InstallType.MOUNT,
input.selectedPatches input.selectedPatches
) )