Skip to content

Commit b70fc03

Browse files
brossshAxelen123
andauthored
fix: Allow different app version when downloading via plugin if setting is off (#2579)
Co-authored-by: Ax333l <[email protected]>
1 parent 81a4ebd commit b70fc03

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

app/src/main/java/app/revanced/manager/domain/repository/DownloadedAppRepository.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class DownloadedAppRepository(
4040
data: Parcelable,
4141
expectedPackageName: String,
4242
expectedVersion: String?,
43+
appCompatibilityCheck: Boolean,
44+
patchesCompatibilityCheck: Boolean,
4345
onDownload: suspend (downloadProgress: Pair<Long, Long?>) -> Unit,
4446
): File {
4547
// Converted integers cannot contain / or .. unlike the package name or version, so they are safer to use here.
@@ -96,7 +98,12 @@ class DownloadedAppRepository(
9698
val pkgInfo =
9799
pm.getPackageInfo(targetFile.toFile()) ?: error("Downloaded APK file is invalid")
98100
if (pkgInfo.packageName != expectedPackageName) error("Downloaded APK has the wrong package name. Expected: $expectedPackageName, Actual: ${pkgInfo.packageName}")
99-
if (expectedVersion != null && pkgInfo.versionName != expectedVersion) error("Downloaded APK has the wrong version. Expected: $expectedVersion, Actual: ${pkgInfo.versionName}")
101+
expectedVersion?.let {
102+
if (
103+
pkgInfo.versionName != expectedVersion &&
104+
(appCompatibilityCheck || patchesCompatibilityCheck)
105+
) error("The selected app version ($pkgInfo.versionName) doesn't match the suggested version. Please use the suggested version ($expectedVersion), or adjust your settings by disabling \"Require suggested app version\" and enabling \"Disable version compatibility check\".")
106+
}
100107

101108
// Delete the previous copy (if present).
102109
dao.get(pkgInfo.packageName, pkgInfo.versionName!!)?.directory?.let {

app/src/main/java/app/revanced/manager/patcher/worker/PatcherWorker.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ class PatcherWorker(
158158
data,
159159
args.packageName,
160160
args.input.version,
161+
prefs.suggestedVersionSafeguard.get(),
162+
!prefs.disablePatchVersionCompatCheck.get(),
161163
onDownload = args.onDownloadProgress
162164
).also {
163165
args.setInputFile(it)

0 commit comments

Comments
 (0)