mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-05-01 06:24:26 +02:00
use correct version in root installs
This commit is contained in:
parent
a85ad4ea0e
commit
fd013ab5d7
@ -76,19 +76,20 @@ 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 =
|
||||||
override var packageInstallerStatus: Int? by mutableStateOf(null)
|
object : InstallerStatusDialogModel {
|
||||||
|
override var packageInstallerStatus: Int? by mutableStateOf(null)
|
||||||
|
|
||||||
override fun reinstall() {
|
override fun reinstall() {
|
||||||
this@PatcherViewModel.reinstall()
|
this@PatcherViewModel.reinstall()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun install() {
|
override fun install() {
|
||||||
// Since this is a package installer status dialog,
|
// Since this is a package installer status dialog,
|
||||||
// InstallType.MOUNT is never used here.
|
// InstallType.MOUNT is never used here.
|
||||||
install(InstallType.DEFAULT)
|
install(InstallType.DEFAULT)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private var installedApp: InstalledApp? = null
|
private var installedApp: InstalledApp? = null
|
||||||
val packageName: String = input.selectedApp.packageName
|
val packageName: String = input.selectedApp.packageName
|
||||||
@ -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
|
||||||
)
|
)
|
||||||
@ -410,7 +415,7 @@ class PatcherViewModel(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e(tag, "Failed to install", e)
|
Log.e(tag, "Failed to install", e)
|
||||||
app.toast(app.getString(R.string.install_app_fail, e.simpleMessage()))
|
app.toast(app.getString(R.string.install_app_fail, e.simpleMessage()))
|
||||||
} finally {
|
} finally {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user