Skip to content

Commit d18941c

Browse files
committed
Squash
fix(Prime Video): Update `Skip ads` patch Truncating class names in fingerprints PR comments fix(Prime Video): Update `Skip ads` patch Truncating class names in fingerprints Typo PR comments
1 parent fff2954 commit d18941c

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

patches/src/main/kotlin/app/revanced/patches/primevideo/ads/Fingerprints.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,11 @@ package app.revanced.patches.primevideo.ads
22

33
import app.revanced.patcher.fingerprint
44
import com.android.tools.smali.dexlib2.AccessFlags
5-
import com.android.tools.smali.dexlib2.Opcode
65

76
internal val enterServerInsertedAdBreakStateFingerprint = fingerprint {
87
accessFlags(AccessFlags.PUBLIC)
98
parameters("Lcom/amazon/avod/fsm/Trigger;")
109
returns("V")
11-
opcodes(
12-
Opcode.INVOKE_VIRTUAL,
13-
Opcode.MOVE_RESULT_OBJECT,
14-
Opcode.CONST_4,
15-
Opcode.CONST_4
16-
)
1710
custom { method, classDef ->
1811
method.name == "enter" && classDef.type == "Lcom/amazon/avod/media/ads/internal/state/ServerInsertedAdBreakState;"
1912
}
@@ -22,12 +15,19 @@ internal val enterServerInsertedAdBreakStateFingerprint = fingerprint {
2215
internal val doTriggerFingerprint = fingerprint {
2316
accessFlags(AccessFlags.PROTECTED)
2417
returns("V")
25-
opcodes(
26-
Opcode.IGET_OBJECT,
27-
Opcode.INVOKE_INTERFACE,
28-
Opcode.RETURN_VOID
29-
)
3018
custom { method, classDef ->
3119
method.name == "doTrigger" && classDef.type == "Lcom/amazon/avod/fsm/StateBase;"
3220
}
21+
}
22+
23+
internal val onSeekPastUnwatchedAdFingerprint = fingerprint {
24+
custom {method, classDef ->
25+
method.name == "onSeekPastUnwatchedAd" && classDef.endsWith("SeekbarControllerImpl;")
26+
}
27+
}
28+
29+
internal val onSeekBehindUnwatchedAdFingerprint = fingerprint {
30+
custom {method, classDef ->
31+
method.name == "onSeekBehindUnwatchedAd" && classDef.endsWith("SeekbarControllerImpl;")
32+
}
3333
}

patches/src/main/kotlin/app/revanced/patches/primevideo/ads/SkipAdsPatch.kt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
44
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
55
import app.revanced.patcher.patch.bytecodePatch
66
import app.revanced.patches.primevideo.misc.extension.sharedExtensionPatch
7+
import app.revanced.util.*
78
import com.android.tools.smali.dexlib2.AccessFlags
9+
import com.android.tools.smali.dexlib2.Opcode
810
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
11+
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
912

1013
@Suppress("unused")
1114
val skipAdsPatch = bytecodePatch(
1215
name = "Skip ads",
1316
description = "Automatically skips video stream ads.",
1417
) {
15-
compatibleWith("com.amazon.avod.thirdpartyclient"("3.0.412.2947"))
18+
compatibleWith("com.amazon.avod.thirdpartyclient"("3.0.430.1747"))
1619

1720
dependsOn(sharedExtensionPatch)
1821

@@ -22,24 +25,30 @@ val skipAdsPatch = bytecodePatch(
2225
// Force doTrigger() access to public so we can call it from our extension.
2326
doTriggerFingerprint.method.accessFlags = AccessFlags.PUBLIC.value;
2427

25-
val getPlayerIndex = enterServerInsertedAdBreakStateFingerprint.patternMatch!!.startIndex
2628
enterServerInsertedAdBreakStateFingerprint.method.apply {
2729
// Get register that stores VideoPlayer:
2830
// invoke-virtual ->getPrimaryPlayer()
2931
// move-result-object { playerRegister }
30-
val playerRegister = getInstruction<OneRegisterInstruction>(getPlayerIndex + 1).registerA
32+
val playerIndex = indexOfFirstInstructionOrThrow() {
33+
opcode == Opcode.INVOKE_VIRTUAL && getReference<MethodReference>()?.name == "getPrimaryPlayer"
34+
}
35+
val playerRegister = getInstruction<OneRegisterInstruction>(playerIndex + 1).registerA
3136

3237
// Reuse the params from the original method:
3338
// p0 = ServerInsertedAdBreakState
3439
// p1 = AdBreakTrigger
3540
addInstructions(
36-
getPlayerIndex + 2,
41+
playerIndex + 2,
3742
"""
3843
invoke-static { p0, p1, v$playerRegister }, Lapp/revanced/extension/primevideo/ads/SkipAdsPatch;->enterServerInsertedAdBreakState(Lcom/amazon/avod/media/ads/internal/state/ServerInsertedAdBreakState;Lcom/amazon/avod/media/ads/internal/state/AdBreakTrigger;Lcom/amazon/avod/media/playback/VideoPlayer;)V
3944
return-void
4045
"""
4146
)
4247
}
48+
49+
// Return early from these callbacks to prevent unwanted overlays from ad breaks.
50+
onSeekBehindUnwatchedAdFingerprint.method.returnEarly()
51+
onSeekPastUnwatchedAdFingerprint.method.returnEarly()
4352
}
4453
}
4554

0 commit comments

Comments
 (0)