fix(video-ads): return empty list in correct method

This commit is contained in:
oSumAtrIX 2022-10-10 15:51:20 +02:00
parent 6199e89cbd
commit bbcf0501d4
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
2 changed files with 17 additions and 15 deletions

View File

@ -5,14 +5,15 @@ import app.revanced.patcher.annotation.Version
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.ad.video.annotations.VideoAdsCompatibility
import org.jf.dexlib2.Opcode
@Name("load-ads-fingerprint")
@VideoAdsCompatibility
@Version("0.0.1")
object LoadAdsFingerprint : MethodFingerprint(
strings = listOf("Unexpected playerAd type: "),
opcodes = listOf(Opcode.INVOKE_INTERFACE_RANGE),
customFingerprint = { method ->
method.parameterTypes.size > 0 && method.parameterTypes.first() == "Ljava/lang/String;"
method.parameterTypes.size > 0 && method.parameterTypes.first().endsWith("InstreamAdBreak;")
}
)

View File

@ -41,20 +41,21 @@ class VideoAdsPatch : BytecodePatch(
)
)
LoadAdsFingerprint.result!!.mutableMethod.let { method ->
method.addInstructions(
0,
with(LoadAdsFingerprint.result!!) {
val insertIndex = scanResult.patternScanResult!!.startIndex
with(mutableMethod) {
addInstructions(
insertIndex,
"""
invoke-static { }, Lapp/revanced/integrations/patches/VideoAdsPatch;->shouldShowAds()Z
move-result v1
if-nez v1, :show_video_ads
new-instance v3, Ljava/util/ArrayList;
invoke-direct { v3 }, Ljava/util/ArrayList;-><init>()V
move-result v4
if-nez v4, :show_video_ads
return-object v3
""",
listOf(ExternalLabel("show_video_ads", method.instruction(0)))
listOf(ExternalLabel("show_video_ads", instruction(insertIndex)))
)
}
}
return PatchResultSuccess()
}