Skip to content

Commit

Permalink
fix(YouTube/Integrations): skip patches even in versions where finger…
Browse files Browse the repository at this point in the history
…prints are still used
  • Loading branch information
inotia00 committed Sep 27, 2024
1 parent 96dc5cf commit 79bfd1e
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import app.revanced.patcher.fingerprint.MethodFingerprint
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patches.shared.integrations.BaseIntegrationsPatch.IntegrationsFingerprint.IRegisterResolver
import app.revanced.patches.shared.integrations.Constants.INTEGRATIONS_UTILS_CLASS_DESCRIPTOR
import app.revanced.util.exception
import app.revanced.util.findMethodOrThrow
import app.revanced.util.isDeprecated
import app.revanced.util.resultOrThrow
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 Expand Up @@ -50,18 +50,21 @@ abstract class BaseIntegrationsPatch(
) {

fun invoke(integrationsDescriptor: String) {
if (isDeprecated()) return
val method = result?.mutableMethod
?: if (!isDeprecated()) {
throw exception
} else {
return
}

resultOrThrow().mutableMethod.let { method ->
val insertIndex = insertIndexResolver(method)
val contextRegister = contextRegisterResolver(method)
val insertIndex = insertIndexResolver(method)
val contextRegister = contextRegisterResolver(method)

method.addInstruction(
insertIndex,
"invoke-static/range { $contextRegister .. $contextRegister }, " +
"$integrationsDescriptor->setContext(Landroid/content/Context;)V",
)
}
method.addInstruction(
insertIndex,
"invoke-static/range { $contextRegister .. $contextRegister }, " +
"$integrationsDescriptor->setContext(Landroid/content/Context;)V",
)
}

interface IHookInsertIndexResolver : (Method) -> Int {
Expand Down

0 comments on commit 79bfd1e

Please sign in to comment.