diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/connectivity/telephony/sim/spoof/SpoofSimCountryPatch.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/connectivity/telephony/sim/spoof/SpoofSimCountryPatch.kt deleted file mode 100644 index 432b52b95d..0000000000 --- a/patches/src/main/kotlin/app/revanced/patches/all/misc/connectivity/telephony/sim/spoof/SpoofSimCountryPatch.kt +++ /dev/null @@ -1,9 +0,0 @@ -package app.revanced.patches.all.misc.connectivity.telephony.sim.spoof - -import app.revanced.patcher.patch.bytecodePatch - -@Deprecated("Patch was renamed", ReplaceWith("SpoofSIMProviderPatch")) -@Suppress("unused") -val spoofSimCountryPatch = bytecodePatch { - dependsOn(spoofSIMProviderPatch) -} diff --git a/patches/src/main/kotlin/app/revanced/patches/idaustria/detection/root/RootDetectionPatch.kt b/patches/src/main/kotlin/app/revanced/patches/idaustria/detection/root/RootDetectionPatch.kt deleted file mode 100644 index cfb7e8d686..0000000000 --- a/patches/src/main/kotlin/app/revanced/patches/idaustria/detection/root/RootDetectionPatch.kt +++ /dev/null @@ -1,10 +0,0 @@ -package app.revanced.patches.idaustria.detection.root - -import app.revanced.patcher.patch.bytecodePatch -import app.revanced.patches.idaustria.detection.deviceintegrity.removeDeviceIntegrityChecksPatch - -@Deprecated("Patch was superseded", ReplaceWith("removeDeviceIntegrityChecksPatch")) -@Suppress("unused") -val rootDetectionPatch = bytecodePatch { - dependsOn(removeDeviceIntegrityChecksPatch) -} diff --git a/patches/src/main/kotlin/app/revanced/patches/music/misc/androidauto/BypassCertificateChecksPatch.kt b/patches/src/main/kotlin/app/revanced/patches/music/misc/androidauto/BypassCertificateChecksPatch.kt deleted file mode 100644 index 26d2de4fb5..0000000000 --- a/patches/src/main/kotlin/app/revanced/patches/music/misc/androidauto/BypassCertificateChecksPatch.kt +++ /dev/null @@ -1,11 +0,0 @@ -package app.revanced.patches.music.misc.androidauto - -import app.revanced.patcher.patch.bytecodePatch - -@Deprecated("This patch is useless by itself and has been merged into another patch.", ReplaceWith("unlockAndroidAutoMediaBrowserPatch")) -@Suppress("unused") -val bypassCertificateChecksPatch = bytecodePatch( - description = "Bypasses certificate checks which prevent YouTube Music from working on Android Auto.", -) { - dependsOn(unlockAndroidAutoMediaBrowserPatch) -} diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/misc/hex/HexPatchBuilder.kt b/patches/src/main/kotlin/app/revanced/patches/shared/misc/hex/HexPatchBuilder.kt index c49e0e96c7..3610e3a8ed 100644 --- a/patches/src/main/kotlin/app/revanced/patches/shared/misc/hex/HexPatchBuilder.kt +++ b/patches/src/main/kotlin/app/revanced/patches/shared/misc/hex/HexPatchBuilder.kt @@ -1,13 +1,31 @@ package app.revanced.patches.shared.misc.hex +import app.revanced.patcher.patch.Patch import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.rawResourcePatch import kotlin.collections.component1 import kotlin.collections.component2 import kotlin.math.max -fun hexPatch(ignoreMissingTargetFiles: Boolean = false, block: HexPatchBuilder.() -> Unit) = - hexPatch(ignoreMissingTargetFiles, fun(): Set = HexPatchBuilder().apply(block)) +fun hexPatch(ignoreMissingTargetFiles: Boolean = false, block: HexPatchBuilder.() -> Unit): Patch { + val replacementsSupplier = HexPatchBuilder().apply(block) + + return rawResourcePatch { + apply { + replacementsSupplier.apply(block).groupBy { it.targetFilePath } + .forEach { (targetFilePath, replacements) -> + val targetFile = get(targetFilePath, true) + if (ignoreMissingTargetFiles && !targetFile.exists()) return@forEach + + // TODO: Use a file channel to read and write the file instead of reading the whole file into memory, + // in order to reduce memory usage. + val targetFileBytes = targetFile.readBytes() + replacements.forEach { it.replacePattern(targetFileBytes) } + targetFile.writeBytes(targetFileBytes) + } + } + } +} @Suppress("JavaDefaultMethodsNotOverriddenByDelegation") class HexPatchBuilder internal constructor( @@ -35,28 +53,6 @@ class HexPatchBuilder internal constructor( } } -// The replacements being passed using a function is intended. -// Previously the replacements were a property of the patch. Getter were being delegated to that property. -// This late evaluation was being leveraged in app.revanced.patches.all.misc.hex.HexPatch. -// Without the function, the replacements would be evaluated at the time of patch creation. -// This isn't possible because the delegated property is not accessible at that time. -@Deprecated("Use the hexPatch function with the builder parameter instead.") -fun hexPatch(ignoreMissingTargetFiles: Boolean = false, replacementsSupplier: () -> Set) = - rawResourcePatch { - apply { - replacementsSupplier().groupBy { it.targetFilePath }.forEach { (targetFilePath, replacements) -> - val targetFile = get(targetFilePath, true) - if (ignoreMissingTargetFiles && !targetFile.exists()) return@forEach - - // TODO: Use a file channel to read and write the file instead of reading the whole file into memory, - // in order to reduce memory usage. - val targetFileBytes = targetFile.readBytes() - replacements.forEach { it.replacePattern(targetFileBytes) } - targetFile.writeBytes(targetFileBytes) - } - } - } - /** * Represents a pattern to search for and its replacement pattern in a file. * @@ -71,17 +67,6 @@ class Replacement( ) { val replacementBytesPadded = replacementBytes + ByteArray(bytes.size - replacementBytes.size) - @Deprecated("Use the constructor with ByteArray parameters instead.") - constructor( - pattern: String, - replacementPattern: String, - targetFilePath: String, - ) : this( - byteArrayOf(pattern), - byteArrayOf(replacementPattern), - targetFilePath - ) - /** * Replaces the [bytes] with the [replacementBytes] in the [targetFileBytes]. * diff --git a/patches/src/main/kotlin/app/revanced/patches/strava/upselling/DisableSubscriptionSuggestionsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/strava/upselling/DisableSubscriptionSuggestionsPatch.kt deleted file mode 100644 index d0f3420d40..0000000000 --- a/patches/src/main/kotlin/app/revanced/patches/strava/upselling/DisableSubscriptionSuggestionsPatch.kt +++ /dev/null @@ -1,24 +0,0 @@ -package app.revanced.patches.strava.upselling - -import app.revanced.patcher.patch.bytecodePatch -import app.revanced.patches.strava.distractions.hideDistractionsPatch - -@Suppress("unused") -@Deprecated("Superseded by \"Hide distractions\" patch", ReplaceWith("hideDistractionsPatch")) -val disableSubscriptionSuggestionsPatch = bytecodePatch( - name = "Disable subscription suggestions", -) { - compatibleWith("com.strava") - - dependsOn( - hideDistractionsPatch.apply { - options["Upselling"] = true - options["Promotions"] = false - options["Who to Follow"] = false - options["Suggested Challenges"] = false - options["Join Challenge"] = false - options["Joined a club"] = false - options["Your activity from X years ago"] = false - }, - ) -}