Skip to content

Commit

Permalink
build: Bump ReVanced Patcher (#3862)
Browse files Browse the repository at this point in the history
Co-authored-by: Ushie <[email protected]>
  • Loading branch information
oSumAtrIX and Ushie authored Nov 5, 2024
1 parent d36ede0 commit 1603ccf
Show file tree
Hide file tree
Showing 230 changed files with 1,068 additions and 1,733 deletions.
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[versions]
revanced-patcher = "20.0.2"
revanced-patcher = "21.0.0"
# Tracking https://github.com/google/smali/issues/64.
#noinspection GradleDependency
smali = "3.0.5"
gson = "2.11.0"
# 8.3.0 causes java verifier error: https://github.com/ReVanced/revanced-patches/issues/2818.
#noinspection GradleDependency
agp = "8.2.2"
annotation = "1.9.0"
annotation = "1.9.1"
appcompat = "1.7.0"
okhttp = "5.0.0-alpha.14"
retrofit = "2.11.0"
Expand Down
24 changes: 6 additions & 18 deletions patches/api/patches.api
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ public final class app/revanced/patches/shared/misc/checks/BaseCheckEnvironmentP

public final class app/revanced/patches/shared/misc/extension/ExtensionHook {
public final fun getFingerprint ()Lapp/revanced/patcher/Fingerprint;
public final fun invoke (Ljava/lang/String;)V
public final fun invoke (Lapp/revanced/patcher/patch/BytecodePatchContext;Ljava/lang/String;)V
}

public final class app/revanced/patches/shared/misc/extension/SharedExtensionPatchKt {
Expand All @@ -551,10 +551,10 @@ public final class app/revanced/patches/shared/misc/gms/FingerprintsKt {
}

public final class app/revanced/patches/shared/misc/gms/GmsCoreSupportPatchKt {
public static final fun gmsCoreSupportPatch (Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patcher/Fingerprint;Ljava/util/Set;Lapp/revanced/patcher/Fingerprint;Lapp/revanced/patcher/patch/Patch;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;)Lapp/revanced/patcher/patch/BytecodePatch;
public static synthetic fun gmsCoreSupportPatch$default (Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patcher/Fingerprint;Ljava/util/Set;Lapp/revanced/patcher/Fingerprint;Lapp/revanced/patcher/patch/Patch;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lapp/revanced/patcher/patch/BytecodePatch;
public static final fun gmsCoreSupportResourcePatch (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patcher/patch/Option;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;)Lapp/revanced/patcher/patch/ResourcePatch;
public static synthetic fun gmsCoreSupportResourcePatch$default (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patcher/patch/Option;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lapp/revanced/patcher/patch/ResourcePatch;
public static final fun gmsCoreSupportPatch (Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patcher/Fingerprint;Ljava/util/Set;Lapp/revanced/patcher/Fingerprint;Lapp/revanced/patcher/patch/Patch;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Lapp/revanced/patcher/patch/BytecodePatch;
public static synthetic fun gmsCoreSupportPatch$default (Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patcher/Fingerprint;Ljava/util/Set;Lapp/revanced/patcher/Fingerprint;Lapp/revanced/patcher/patch/Patch;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lapp/revanced/patcher/patch/BytecodePatch;
public static final fun gmsCoreSupportResourcePatch (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patcher/patch/Option;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Lapp/revanced/patcher/patch/ResourcePatch;
public static synthetic fun gmsCoreSupportResourcePatch$default (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lapp/revanced/patcher/patch/Option;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lapp/revanced/patcher/patch/ResourcePatch;
}

public final class app/revanced/patches/shared/misc/hex/HexPatchKt {
Expand Down Expand Up @@ -979,13 +979,8 @@ public final class app/revanced/patches/twitter/misc/hook/json/JsonHook {
public fun <init> (Lapp/revanced/patcher/patch/BytecodePatchContext;Ljava/lang/String;)V
}

public final class app/revanced/patches/twitter/misc/hook/json/JsonHookPatchHook : java/io/Closeable {
public fun <init> (Lapp/revanced/patcher/Fingerprint;)V
public final fun addHook (Lapp/revanced/patches/twitter/misc/hook/json/JsonHook;)V
public fun close ()V
}

public final class app/revanced/patches/twitter/misc/hook/json/JsonHookPatchKt {
public static final fun addJsonHook (Lapp/revanced/patcher/patch/BytecodePatchContext;Lapp/revanced/patches/twitter/misc/hook/json/JsonHook;)V
public static final fun getJsonHookPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
}

Expand Down Expand Up @@ -1432,16 +1427,13 @@ public final class app/revanced/patches/yuka/misc/unlockpremium/UnlockPremiumPat
}

public final class app/revanced/util/BytecodeUtilsKt {
public static final fun applyMatch (Lapp/revanced/patcher/Fingerprint;Lapp/revanced/patcher/patch/BytecodePatchContext;Lapp/revanced/patcher/Match;)Lapp/revanced/patcher/Match;
public static final fun containsLiteralInstruction (Lcom/android/tools/smali/dexlib2/iface/Method;J)Z
public static final fun findInstructionIndicesReversed (Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/Opcode;)Ljava/util/List;
public static final fun findInstructionIndicesReversed (Lcom/android/tools/smali/dexlib2/iface/Method;Lkotlin/jvm/functions/Function1;)Ljava/util/List;
public static final fun findInstructionIndicesReversedOrThrow (Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/Opcode;)Ljava/util/List;
public static final fun findInstructionIndicesReversedOrThrow (Lcom/android/tools/smali/dexlib2/iface/Method;Lkotlin/jvm/functions/Function1;)Ljava/util/List;
public static final fun findMutableMethodOf (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableClass;Lcom/android/tools/smali/dexlib2/iface/Method;)Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;
public static final fun forEachLiteralValueInstruction (Lapp/revanced/patcher/patch/BytecodePatchContext;JLkotlin/jvm/functions/Function2;)V
public static final fun getException (Lapp/revanced/patcher/Fingerprint;)Lapp/revanced/patcher/patch/PatchException;
public static final fun getMatchOrThrow (Lapp/revanced/patcher/Fingerprint;)Lapp/revanced/patcher/Match;
public static final fun indexOfFirstInstruction (Lcom/android/tools/smali/dexlib2/iface/Method;ILcom/android/tools/smali/dexlib2/Opcode;)I
public static final fun indexOfFirstInstruction (Lcom/android/tools/smali/dexlib2/iface/Method;ILkotlin/jvm/functions/Function1;)I
public static final fun indexOfFirstInstruction (Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/Opcode;)I
Expand All @@ -1468,12 +1460,8 @@ public final class app/revanced/util/BytecodeUtilsKt {
public static final fun indexOfFirstResourceIdOrThrow (Lcom/android/tools/smali/dexlib2/iface/Method;Ljava/lang/String;)I
public static final fun injectHideViewCall (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;IILjava/lang/String;Ljava/lang/String;)V
public static final fun literal (Lapp/revanced/patcher/FingerprintBuilder;Lkotlin/jvm/functions/Function0;)V
public static final fun returnEarly (Lapp/revanced/patcher/Fingerprint;Z)V
public static final fun returnEarly (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;Z)V
public static final fun returnEarly (Ljava/lang/Iterable;Z)V
public static synthetic fun returnEarly$default (Lapp/revanced/patcher/Fingerprint;ZILjava/lang/Object;)V
public static synthetic fun returnEarly$default (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;ZILjava/lang/Object;)V
public static synthetic fun returnEarly$default (Ljava/lang/Iterable;ZILjava/lang/Object;)V
public static final fun transformMethods (Lapp/revanced/patcher/util/proxy/mutableTypes/MutableClass;Lkotlin/jvm/functions/Function1;)V
public static final fun traverseClassHierarchy (Lapp/revanced/patcher/patch/BytecodePatchContext;Lapp/revanced/patcher/util/proxy/mutableTypes/MutableClass;Lkotlin/jvm/functions/Function1;)V
}
Expand Down
6 changes: 6 additions & 0 deletions patches/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ dependencies {
compileOnly(project(":patches:stub"))
}

kotlin {
compilerOptions {
freeCompilerArgs = listOf("-Xcontext-receivers")
}
}

publishing {
repositories {
maven {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ val exportAllActivitiesPatch = resourcePatch(
description = "Makes all app activities exportable.",
use = false,
) {
execute { context ->
execute {
val exportedFlag = "android:exported"

context.document["AndroidManifest.xml"].use { document ->
document("AndroidManifest.xml").use { document ->
val activities = document.getElementsByTagName("activity")

for (i in 0..activities.length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ val enableAndroidDebuggingPatch = resourcePatch(
description = "Enables Android debugging capabilities. This can slow down the app.",
use = false,
) {
execute { context ->
context.document["AndroidManifest.xml"].use { document ->
execute {
document("AndroidManifest.xml").use { document ->
val applicationNode =
document
.getElementsByTagName("application")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ val predictiveBackGesturePatch = resourcePatch(
description = "Enables the predictive back gesture introduced on Android 13.",
use = false,
) {
execute { context ->
execute {
val flag = "android:enableOnBackInvokedCallback"

context.document["AndroidManifest.xml"].use { document ->
document("AndroidManifest.xml").use { document ->
with(document.getElementsByTagName("application").item(0)) {
if (attributes.getNamedItem(flag) != null) return@with

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ val overrideCertificatePinningPatch = resourcePatch(
) {
dependsOn(enableAndroidDebuggingPatch)

execute { context ->
val resXmlDirectory = context["res/xml"]
execute {
val resXmlDirectory = get("res/xml")

// Add android:networkSecurityConfig="@xml/network_security_config" and the "networkSecurityConfig" attribute if it does not exist.
context.document["AndroidManifest.xml"].use { document ->
document("AndroidManifest.xml").use { document ->
val applicationNode = document.getElementsByTagName("application").item(0) as Element

if (!applicationNode.hasAttribute("networkSecurityConfig")) {
Expand Down Expand Up @@ -54,4 +54,4 @@ val overrideCertificatePinningPatch = resourcePatch(
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ val changePackageNamePatch = resourcePatch(
it == "Default" || it!!.matches(Regex("^[a-z]\\w*(\\.[a-z]\\w*)+\$"))
}

finalize { context ->
context.document["AndroidManifest.xml"].use { document ->
finalize {
document("AndroidManifest.xml").use { document ->

val replacementPackageName = packageNameOption.value

Expand All @@ -57,4 +57,4 @@ val changePackageNamePatch = resourcePatch(
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ val addResourcesPatch = resourcePatch(
After all patches that depend on addResourcesPatch have been executed,
addResourcesPatch#finalize is finally called to add all staged resources to the app.
*/
execute { context ->
execute {
stagedResources = buildMap {
/**
* Puts resources under `/resources/addresources/<value>/<resourceKind>.xml` into the map.
Expand All @@ -299,7 +299,7 @@ val addResourcesPatch = resourcePatch(
// instead of overwriting it.
// This covers the example case such as adding strings and arrays of the same value.
getOrPut(destValue, ::mutableMapOf).apply {
context.document[stream].use { document ->
document(stream).use { document ->
document.getElementsByTagName("app").asSequence().forEach { app ->
val appId = app.attributes.getNamedItem("id").textContent

Expand Down Expand Up @@ -343,7 +343,7 @@ val addResourcesPatch = resourcePatch(
* Adds all resources staged in [addResourcesPatch] to the app.
* This is called after all patches that depend on [addResourcesPatch] have been executed.
*/
finalize { context ->
finalize {
operator fun MutableMap<String, Pair<Document, Node>>.invoke(
value: Value,
resource: BaseResource,
Expand All @@ -359,16 +359,15 @@ val addResourcesPatch = resourcePatch(
}

getOrPut(resourceFileName) {
val targetFile =
context["res/$value/$resourceFileName.xml"].also {
it.parentFile?.mkdirs()
val targetFile = this@finalize["res/$value/$resourceFileName.xml"].also {
it.parentFile?.mkdirs()

if (it.createNewFile()) {
it.writeText("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n</resources>")
}
if (it.createNewFile()) {
it.writeText("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n</resources>")
}
}

context.document[targetFile.path].let { document ->
document(targetFile.path).let { document ->

// Save the target node here as well
// in order to avoid having to call document.getNode("resources")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import org.w3c.dom.Element
private val removeCaptureRestrictionResourcePatch = resourcePatch(
description = "Sets allowAudioPlaybackCapture in manifest to true.",
) {
execute { context ->
context.document["AndroidManifest.xml"].use { document ->
execute {
document("AndroidManifest.xml").use { document ->
// Get the application node.
val applicationNode =
document
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ val removeShareTargetsPatch = resourcePatch(
description = "Removes share targets like directly sharing to a frequent contact.",
use = false,
) {
execute { context ->
execute {
try {
context.document["res/xml/shortcuts.xml"]
document("res/xml/shortcuts.xml")
} catch (_: FileNotFoundException) {
return@execute Logger.getLogger(this::class.java.name).warning("The app has no shortcuts")
}.use { document ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ fun <T> transformInstructionsPatch(
transform: (MutableMethod, T) -> Unit,
) = bytecodePatch {
// Returns the patch indices as a Sequence, which will execute lazily.
fun findPatchIndices(classDef: ClassDef, method: Method): Sequence<T>? {
return method.implementation?.instructions?.asSequence()?.withIndex()?.mapNotNull { (index, instruction) ->
filterMap(classDef, method, instruction, index)
}
fun findPatchIndices(classDef: ClassDef, method: Method): Sequence<T>? =
method.implementation?.instructions?.asSequence()?.withIndex()?.mapNotNull { (index, instruction) ->
filterMap(classDef, method, instruction, index)
}

execute { context ->
execute {
// Find all methods to patch
buildMap {
context.classes.forEach { classDef ->
classes.forEach { classDef ->
val methods = buildList {
classDef.methods.forEach { method ->
// Since the Sequence executes lazily,
Expand All @@ -37,7 +36,7 @@ fun <T> transformInstructionsPatch(
}
}.forEach { (classDef, methods) ->
// And finally transform the methods...
val mutableClass = context.proxy(classDef).mutableClass
val mutableClass = proxy(classDef).mutableClass

methods.map(mutableClass::findMutableMethodOf).forEach methods@{ mutableMethod ->
val patchIndices = findPatchIndices(mutableClass, mutableMethod)?.toCollection(ArrayDeque())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ val changeVersionCodePatch = resourcePatch(
required = true,
) { versionCode -> versionCode!! >= 1 }

execute { context ->
context.document["AndroidManifest.xml"].use { document ->
execute {
document("AndroidManifest.xml").use { document ->
val manifestElement = document.getNode("manifest") as Element
manifestElement.setAttribute("android:versionCode", "$versionCode")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ val deepLinkingPatch = bytecodePatch(
) {
compatibleWith("com.amazon.mShop.android.shopping")

val deepLinkingMatch by deepLinkingFingerprint()

execute {
deepLinkingMatch.mutableMethod.addInstructions(
deepLinkingFingerprint.method.addInstructions(
0,
"""
const/4 v0, 0x1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ val proUnlockPatch = bytecodePatch(
) {
compatibleWith("com.backdrops.wallpapers")

val proUnlockMatch by proUnlockFingerprint()

execute {
val registerIndex = proUnlockMatch.patternMatch!!.endIndex - 1
val registerIndex = proUnlockFingerprint.patternMatch!!.endIndex - 1

proUnlockMatch.mutableMethod.apply {
proUnlockFingerprint.method.apply {
val register = getInstruction<OneRegisterInstruction>(registerIndex).registerA
addInstruction(
proUnlockMatch.patternMatch!!.endIndex,
proUnlockFingerprint.patternMatch!!.endIndex,
"const/4 v$register, 0x1",
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ val removePlayLimitsPatch = bytecodePatch(
) {
compatibleWith("com.bandcamp.android")

val handlePlaybackLimitsMatch by handlePlaybackLimitsFingerprint()

execute {
handlePlaybackLimitsMatch.mutableMethod.addInstructions(0, "return-void")
handlePlaybackLimitsFingerprint.method.addInstructions(0, "return-void")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ val bypassRootChecksPatch = bytecodePatch(
) {
compatibleWith("it.ipzs.cieid")

val checkRootMatch by checkRootFingerprint()

execute {
checkRootMatch.mutableMethod.addInstruction(1, "return-void")
checkRootFingerprint.method.addInstruction(1, "return-void")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ val disableAdsPatch = bytecodePatch(
) {
compatibleWith("com.duolingo")

val initializeMonetizationDebugSettingsMatch by initializeMonetizationDebugSettingsFingerprint()

execute {
// Couple approaches to remove ads exist:
//
Expand All @@ -21,8 +19,8 @@ val disableAdsPatch = bytecodePatch(
// SharedPreferences has a debug boolean value with key "disable_ads", which maps to "DebugCategory.DISABLE_ADS".
//
// MonetizationDebugSettings seems to be the most general setting to work fine.
initializeMonetizationDebugSettingsMatch.mutableMethod.apply {
val insertIndex = initializeMonetizationDebugSettingsMatch.patternMatch!!.startIndex
initializeMonetizationDebugSettingsFingerprint.method.apply {
val insertIndex = initializeMonetizationDebugSettingsFingerprint.patternMatch!!.startIndex
val register = getInstruction<TwoRegisterInstruction>(insertIndex).registerA

addInstructions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ val enableDebugMenuPatch = bytecodePatch(
) {
compatibleWith("com.duolingo"("5.158.4"))

val initializeBuildConfigProviderMatch by initializeBuildConfigProviderFingerprint()

execute {
initializeBuildConfigProviderMatch.mutableMethod.apply {
val insertIndex = initializeBuildConfigProviderMatch.patternMatch!!.startIndex
initializeBuildConfigProviderFingerprint.method.apply {
val insertIndex = initializeBuildConfigProviderFingerprint.patternMatch!!.startIndex
val register = getInstruction<TwoRegisterInstruction>(insertIndex).registerA

addInstructions(
Expand Down
Loading

0 comments on commit 1603ccf

Please sign in to comment.