Skip to content

Commit

Permalink
feat: Publish as a library (#3356)
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX authored Dec 2, 2023
1 parent 1f1cae1 commit 4b878ee
Show file tree
Hide file tree
Showing 500 changed files with 2,369 additions and 719 deletions.
1,639 changes: 1,639 additions & 0 deletions api/revanced-patches.api

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import org.gradle.kotlin.dsl.support.listFilesOrdered

plugins {
kotlin("jvm") version "1.9.10"
alias(libs.plugins.binary.compatibility.validator)
`maven-publish`
}

Expand Down
4 changes: 4 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ revanced-patcher = "19.1.0"
smali = "3.0.3"
guava = "32.1.2-jre"
gson = "2.10.1"
binary-compatibility-validator = "0.13.2"

[libraries]
revanced-patcher = { module = "app.revanced:revanced-patcher", version.ref = "revanced-patcher" }
smali = { module = "com.android.tools.smali:smali", version.ref = "smali" }
guava = { module = "com.google.guava:guava", version.ref = "guava" }
gson = { module = "com.google.code.gson:gson", version.ref = "gson" }

[plugins]
binary-compatibility-validator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binary-compatibility-validator" }
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package app.revanced.patches.all.connectivity.wifi.spoof

import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.util.patch.AbstractTransformInstructionsPatch
import app.revanced.util.patch.IMethodCall
import app.revanced.util.patch.Instruction35cInfo
import app.revanced.util.patch.filterMapInstruction35c
import app.revanced.patches.all.misc.transformation.AbstractTransformInstructionsPatch
import app.revanced.patches.all.misc.transformation.IMethodCall
import app.revanced.patches.all.misc.transformation.Instruction35cInfo
import app.revanced.patches.all.misc.transformation.filterMapInstruction35c
import com.android.tools.smali.dexlib2.iface.ClassDef
import com.android.tools.smali.dexlib2.iface.Method
import com.android.tools.smali.dexlib2.iface.instruction.Instruction
Expand Down Expand Up @@ -40,7 +40,7 @@ object SpoofWifiPatch : AbstractTransformInstructionsPatch<Instruction35cInfo>()


// Information about method calls we want to replace
enum class MethodCall(
private enum class MethodCall(
override val definedClassName: String,
override val methodName: String,
override val methodParams: Array<String>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package app.revanced.util.patch
package app.revanced.patches.all.misc.transformation

import app.revanced.extensions.findMutableMethodOf
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.util.findMutableMethodOf
import com.android.tools.smali.dexlib2.iface.ClassDef
import com.android.tools.smali.dexlib2.iface.Method
import com.android.tools.smali.dexlib2.iface.instruction.Instruction

@Suppress("MemberVisibilityCanBePrivate")
abstract class AbstractTransformInstructionsPatch<T> : BytecodePatch() {

abstract fun filterMap(
Expand All @@ -20,7 +21,7 @@ abstract class AbstractTransformInstructionsPatch<T> : BytecodePatch() {
abstract fun transform(mutableMethod: MutableMethod, entry: T)

// Returns the patch indices as a Sequence, which will execute lazily.
private fun findPatchIndices(classDef: ClassDef, method: Method): Sequence<T>? {
fun findPatchIndices(classDef: ClassDef, method: Method): Sequence<T>? {
return method.implementation?.instructions?.asSequence()?.withIndex()?.mapNotNull { (index, instruction) ->
filterMap(classDef, method, instruction, index)
}
Expand All @@ -35,11 +36,7 @@ abstract class AbstractTransformInstructionsPatch<T> : BytecodePatch() {
// Since the Sequence executes lazily,
// using any() results in only calling
// filterMap until the first index has been found.
val patchIndices = findPatchIndices(classDef, method)

if (patchIndices?.any() == true) {
add(method)
}
if (findPatchIndices(classDef, method)?.any() == true) add(method)
}
}

Expand All @@ -55,9 +52,7 @@ abstract class AbstractTransformInstructionsPatch<T> : BytecodePatch() {
val patchIndices = findPatchIndices(mutableClass, mutableMethod)?.toCollection(ArrayDeque())
?: return@methods

while (!patchIndices.isEmpty()) {
transform(mutableMethod, patchIndices.removeLast())
}
while (!patchIndices.isEmpty()) transform(mutableMethod, patchIndices.removeLast())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app.revanced.util.patch
package app.revanced.patches.all.misc.transformation

import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package app.revanced.patches.all.screencapture.removerestriction

import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.util.patch.AbstractTransformInstructionsPatch
import app.revanced.util.patch.IMethodCall
import app.revanced.util.patch.Instruction35cInfo
import app.revanced.util.patch.filterMapInstruction35c
import app.revanced.patches.all.misc.transformation.AbstractTransformInstructionsPatch
import app.revanced.patches.all.misc.transformation.IMethodCall
import app.revanced.patches.all.misc.transformation.Instruction35cInfo
import app.revanced.patches.all.misc.transformation.filterMapInstruction35c
import com.android.tools.smali.dexlib2.iface.ClassDef
import com.android.tools.smali.dexlib2.iface.Method
import com.android.tools.smali.dexlib2.iface.instruction.Instruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.util.patch.AbstractTransformInstructionsPatch
import app.revanced.util.patch.IMethodCall
import app.revanced.util.patch.Instruction35cInfo
import app.revanced.util.patch.filterMapInstruction35c
import app.revanced.patches.all.misc.transformation.AbstractTransformInstructionsPatch
import app.revanced.patches.all.misc.transformation.IMethodCall
import app.revanced.patches.all.misc.transformation.Instruction35cInfo
import app.revanced.patches.all.misc.transformation.filterMapInstruction35c
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.ClassDef
import com.android.tools.smali.dexlib2.iface.Method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patcher.patch.options.PatchOption
import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.stringPatchOption
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.util.patch.AbstractTransformInstructionsPatch
import app.revanced.patches.all.misc.transformation.AbstractTransformInstructionsPatch
import com.android.tools.smali.dexlib2.iface.ClassDef
import com.android.tools.smali.dexlib2.iface.Method
import com.android.tools.smali.dexlib2.iface.instruction.Instruction
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package app.revanced.patches.backdrops.misc.pro

import app.revanced.extensions.exception
import app.revanced.util.exception
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package app.revanced.patches.backdrops.misc.pro.fingerprints
import app.revanced.patcher.fingerprint.MethodFingerprint
import com.android.tools.smali.dexlib2.Opcode

object ProUnlockFingerprint : MethodFingerprint(
internal object ProUnlockFingerprint : MethodFingerprint(
opcodes = listOf(
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package app.revanced.patches.candylinkvpn

import app.revanced.extensions.exception
import app.revanced.util.exception
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package app.revanced.patches.candylinkvpn.fingerprints

import app.revanced.patcher.fingerprint.MethodFingerprint

object IsPremiumPurchasedFingerprint : MethodFingerprint(
internal object IsPremiumPurchasedFingerprint : MethodFingerprint(
customFingerprint = { methodDef, _ ->
methodDef.definingClass.endsWith("PreferenceProvider;") &&
methodDef.name == "isPremiumPurchased"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package app.revanced.patches.cieid.restrictions.root

import app.revanced.extensions.exception
import app.revanced.util.exception
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.patch.BytecodePatch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package app.revanced.patches.cieid.restrictions.root.fingerprints

import app.revanced.patcher.fingerprint.MethodFingerprint

object CheckRootFingerprint : MethodFingerprint(
internal object CheckRootFingerprint : MethodFingerprint(
customFingerprint = { methodDef, _ ->
methodDef.definingClass == "Lit/ipzs/cieid/BaseActivity;" && methodDef.name == "onResume"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package app.revanced.patches.facebook.ads.story

import app.revanced.extensions.exception
import app.revanced.util.exception
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.patch.BytecodePatch
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package app.revanced.patches.facebook.ads.story.fingerprints

object AdsInsertionFingerprint : FieldMethodFingerprint(fieldValue = "AdBucketDataSourceUtil\$attemptAdsInsertion\$1")
internal object AdsInsertionFingerprint : FieldMethodFingerprint(fieldValue = "AdBucketDataSourceUtil\$attemptAdsInsertion\$1")
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package app.revanced.patches.facebook.ads.story.fingerprints

object FetchMoreAdsFingerprint : FieldMethodFingerprint(fieldValue = "AdBucketDataSourceUtil\$attemptFetchMoreAds\$1")
internal object FetchMoreAdsFingerprint : FieldMethodFingerprint(fieldValue = "AdBucketDataSourceUtil\$attemptFetchMoreAds\$1")
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package app.revanced.patches.facebook.ads.story.fingerprints
import app.revanced.patcher.fingerprint.MethodFingerprint
import com.android.tools.smali.dexlib2.iface.value.StringEncodedValue

abstract class FieldMethodFingerprint(fieldValue: String) : MethodFingerprint(
internal abstract class FieldMethodFingerprint(fieldValue: String) : MethodFingerprint(
returnType = "V",
parameters = listOf(),
customFingerprint = { methodDef, classDef ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package app.revanced.patches.finanzonline.detection.bootloader

import app.revanced.extensions.exception
import app.revanced.util.exception
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode

// Located @ at.gv.bmf.bmf2go.taxequalization.tools.utils.AttestationHelper#isBootStateOk (3.0.1)
object BootStateFingerprint : MethodFingerprint(
internal object BootStateFingerprint : MethodFingerprint(
"Z",
accessFlags = AccessFlags.PUBLIC.value,
opcodes = listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import app.revanced.patcher.fingerprint.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags

// Located @ at.gv.bmf.bmf2go.taxequalization.tools.utils.AttestationHelper#createKey (3.0.1)
object CreateKeyFingerprint : MethodFingerprint(
internal object CreateKeyFingerprint : MethodFingerprint(
"Z",
accessFlags = AccessFlags.PUBLIC.value,
strings = listOf("attestation", "SHA-256", "random", "EC", "AndroidKeyStore")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package app.revanced.patches.finanzonline.detection.root

import app.revanced.extensions.exception
import app.revanced.util.exception
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode

// Located @ at.gv.bmf.bmf2go.taxequalization.tools.utils.RootDetection#isRooted (3.0.1)
object RootDetectionFingerprint : MethodFingerprint(
internal object RootDetectionFingerprint : MethodFingerprint(
"L",
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC,
parameters = listOf("L"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package app.revanced.patches.googlerecorder.restrictions

import app.revanced.extensions.exception
import app.revanced.util.exception
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package app.revanced.patches.googlerecorder.restrictions.fingerprints

import app.revanced.patcher.fingerprint.MethodFingerprint

object OnApplicationCreateFingerprint : MethodFingerprint(
internal object OnApplicationCreateFingerprint : MethodFingerprint(
strings = listOf("com.google.android.feature.PIXEL_2017_EXPERIENCE"),
customFingerprint = custom@{ methodDef, classDef ->
if (methodDef.name != "onCreate") return@custom false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package app.revanced.patches.hexeditor.ad

import app.revanced.extensions.exception
import app.revanced.util.exception
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstructions
import app.revanced.patcher.patch.BytecodePatch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package app.revanced.patches.hexeditor.ad.fingerprints

import app.revanced.patcher.fingerprint.MethodFingerprint

object PrimaryAdsFingerprint : MethodFingerprint(
internal object PrimaryAdsFingerprint : MethodFingerprint(
customFingerprint = { methodDef, _ ->
methodDef.definingClass.endsWith("PreferencesHelper;") && methodDef.name == "isAdsDisabled"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package app.revanced.patches.iconpackstudio.misc.pro.fingerprints

import app.revanced.patcher.fingerprint.MethodFingerprint

object CheckProFingerprint : MethodFingerprint(
internal object CheckProFingerprint : MethodFingerprint(
"Z",
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("IPSPurchaseRepository;")}
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.idaustria.detection.root.fingerprints.AttestationSupportedCheckFingerprint
import app.revanced.patches.idaustria.detection.root.fingerprints.BootloaderCheckFingerprint
import app.revanced.patches.idaustria.detection.root.fingerprints.RootCheckFingerprint
import app.revanced.util.Utils.returnEarly
import app.revanced.util.returnEarly

@Patch(
name = "Remove root detection",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package app.revanced.patches.idaustria.detection.root.fingerprints
import app.revanced.patcher.fingerprint.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags

object AttestationSupportedCheckFingerprint : MethodFingerprint(
internal object AttestationSupportedCheckFingerprint : MethodFingerprint(
"V",
accessFlags = AccessFlags.PUBLIC.value,
customFingerprint = { methodDef, _ ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package app.revanced.patches.idaustria.detection.root.fingerprints
import app.revanced.patcher.fingerprint.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags

object BootloaderCheckFingerprint : MethodFingerprint(
internal object BootloaderCheckFingerprint : MethodFingerprint(
"Z",
accessFlags = AccessFlags.PUBLIC.value,
customFingerprint = { methodDef, _ ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package app.revanced.patches.idaustria.detection.root.fingerprints
import app.revanced.patcher.fingerprint.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags

object RootCheckFingerprint : MethodFingerprint(
internal object RootCheckFingerprint : MethodFingerprint(
"V",
accessFlags = AccessFlags.PUBLIC.value,
customFingerprint = { methodDef, _ ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package app.revanced.patches.idaustria.detection.signature.fingerprints
import app.revanced.patcher.fingerprint.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags

object SpoofSignatureFingerprint : MethodFingerprint(
internal object SpoofSignatureFingerprint : MethodFingerprint(
"L",
parameters = listOf("L"),
accessFlags = AccessFlags.PRIVATE.value,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package app.revanced.patches.inshorts.ad

import app.revanced.extensions.exception
import app.revanced.util.exception
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.patch.BytecodePatch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package app.revanced.patches.inshorts.ad.fingerprints

import app.revanced.patcher.fingerprint.MethodFingerprint

object InshortsAdsFingerprint : MethodFingerprint(
internal object InshortsAdsFingerprint : MethodFingerprint(
"V",
strings = listOf("GoogleAdLoader","exception in requestAd"),
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package app.revanced.patches.instagram.patches.ads.timeline

import app.revanced.extensions.exception
import app.revanced.util.exception
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package app.revanced.patches.instagram.patches.ads.timeline.fingerprints

import app.revanced.patcher.fingerprint.MethodFingerprint

object MediaFingerprint : MethodFingerprint(
internal object MediaFingerprint : MethodFingerprint(
strings = listOf("force_overlay", "Media#updateFields", "live_reels_metadata")
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import app.revanced.patcher.fingerprint.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode

object ShowAdFingerprint : MethodFingerprint(
internal object ShowAdFingerprint : MethodFingerprint(
"Z",
AccessFlags.PUBLIC or AccessFlags.STATIC or AccessFlags.FINAL,
listOf("L", "L", "Z", "Z"),
Expand Down
Loading

0 comments on commit 4b878ee

Please sign in to comment.