fix(youtube/spoof-signature-verification): fixed subtitles in wrong location (#1833)

This commit is contained in:
LisoUseInAIKyrios 2023-04-01 17:15:28 +04:00 committed by oSumAtrIX
parent 0a858ecef3
commit 0dbfa6247e
No known key found for this signature in database
GPG key ID: A9B3094ACDB604B4
2 changed files with 32 additions and 0 deletions

View file

@ -0,0 +1,11 @@
package app.revanced.patches.youtube.misc.fix.playback.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object SubtitleWindowSettingsConstructorFingerprint : MethodFingerprint(
parameters = listOf("I", "I", "I", "Z", "Z"),
customFingerprint = { methodDef ->
methodDef.definingClass == "Lcom/google/android/libraries/youtube/player/subtitles/model/SubtitleWindowSettings;"
&& methodDef.name == "<init>"
}
)

View file

@ -19,6 +19,7 @@ import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
import app.revanced.patches.youtube.misc.fix.playback.annotation.ProtobufSpoofCompatibility
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.OpenCronetDataSourceFingerprint
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.ProtobufParameterBuilderFingerprint
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.SubtitleWindowSettingsConstructorFingerprint
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
@ -34,6 +35,7 @@ class SpoofSignatureVerificationPatch : BytecodePatch(
listOf(
ProtobufParameterBuilderFingerprint,
OpenCronetDataSourceFingerprint,
SubtitleWindowSettingsConstructorFingerprint,
)
) {
override fun execute(context: BytecodeContext): PatchResult {
@ -83,6 +85,25 @@ class SpoofSignatureVerificationPatch : BytecodePatch(
} ?: return OpenCronetDataSourceFingerprint.toErrorResult()
// hook override subtitles
SubtitleWindowSettingsConstructorFingerprint.result?.let {
it.mutableMethod.apply {
addInstructions(
0,
"""
invoke-static {p1, p2, p3, p4, p5}, $INTEGRATIONS_CLASS_DESCRIPTOR->getSubtitleWindowSettingsOverride(IIIZZ)[I
move-result-object v0
const/4 v1, 0x0
aget p1, v0, v1 # ap, anchor configuration
const/4 v1, 0x1
aget p2, v0, v1 # ah, horizontal anchor
const/4 v1, 0x2
aget p3, v0, v1 # av, vertical anchor
"""
)
}
} ?: return SubtitleWindowSettingsConstructorFingerprint.toErrorResult()
return PatchResultSuccess()
}