mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2026-01-25 19:51:03 +00:00
refactor(boostforreddit): FixRedgifsApiPatch
This commit is contained in:
@@ -1,20 +1,30 @@
|
||||
package app.revanced.patches.reddit.customclients.boostforreddit.fix.redgifs
|
||||
|
||||
import app.revanced.patcher.fingerprint
|
||||
import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively
|
||||
import app.revanced.patcher.accessFlags
|
||||
import app.revanced.patcher.classDef
|
||||
import app.revanced.patcher.custom
|
||||
import app.revanced.patcher.instructions
|
||||
import app.revanced.patcher.invoke
|
||||
import app.revanced.patcher.patch.BytecodePatchContext
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.Method
|
||||
|
||||
internal val createOkHttpClientFingerprint = fingerprint {
|
||||
internal val BytecodePatchContext.createOkHttpClientMethod by gettingFirstMutableMethodDeclaratively {
|
||||
accessFlags(AccessFlags.PRIVATE)
|
||||
opcodes(
|
||||
Opcode.NEW_INSTANCE,
|
||||
Opcode.INVOKE_DIRECT,
|
||||
Opcode.NEW_INSTANCE,
|
||||
Opcode.INVOKE_DIRECT,
|
||||
Opcode.NEW_INSTANCE,
|
||||
Opcode.INVOKE_DIRECT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_OBJECT
|
||||
instructions(
|
||||
Opcode.NEW_INSTANCE(),
|
||||
Opcode.INVOKE_DIRECT(),
|
||||
Opcode.NEW_INSTANCE(),
|
||||
Opcode.INVOKE_DIRECT(),
|
||||
Opcode.NEW_INSTANCE(),
|
||||
Opcode.INVOKE_DIRECT(),
|
||||
Opcode.INVOKE_VIRTUAL(),
|
||||
Opcode.MOVE_RESULT_OBJECT()
|
||||
)
|
||||
custom { _, classDef -> classDef.sourceFile == "RedGifsAPIv2.java" }
|
||||
|
||||
// Helper to capture the BytecodePatchContext for classDef access
|
||||
fun Method.isTargetSourceFile() = classDef.sourceFile == "RedGifsAPIv2.java"
|
||||
custom { isTargetSourceFile() }
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ val fixRedgifsApi = fixRedgifsApiPatch(
|
||||
apply {
|
||||
// region Patch Redgifs OkHttp3 client.
|
||||
|
||||
createOkHttpClientFingerprint.method.apply {
|
||||
createOkHttpClientMethod.apply {
|
||||
val index = indexOfFirstInstructionOrThrow {
|
||||
val reference = getReference<MethodReference>()
|
||||
reference?.name == "build" && reference.definingClass == "Lokhttp3/OkHttpClient\$Builder;"
|
||||
|
||||
Reference in New Issue
Block a user