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

This commit is contained in:
oSumAtrIX 2022-10-10 15:51:20 +02:00
parent 7752b962ef
commit 1159406c05
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.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.ad.video.annotations.VideoAdsCompatibility import app.revanced.patches.youtube.ad.video.annotations.VideoAdsCompatibility
import org.jf.dexlib2.Opcode
@Name("load-ads-fingerprint") @Name("load-ads-fingerprint")
@VideoAdsCompatibility @VideoAdsCompatibility
@Version("0.0.1") @Version("0.0.1")
object LoadAdsFingerprint : MethodFingerprint( object LoadAdsFingerprint : MethodFingerprint(
strings = listOf("Unexpected playerAd type: "), opcodes = listOf(Opcode.INVOKE_INTERFACE_RANGE),
customFingerprint = { method -> customFingerprint = { method ->
method.parameterTypes.size > 0 && method.parameterTypes.first() == "Ljava/lang/String;" method.parameterTypes.size > 0 && method.parameterTypes.first().endsWith("InstreamAdBreak;")
} }
) )

View File

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