feat(YouTube): add support version 19.25.39, drop support version 19.23.40

This commit is contained in:
inotia00
2024-07-05 15:14:14 +09:00
parent 4866308321
commit 00cc6d0945
20 changed files with 152 additions and 121 deletions

View File

@ -16,7 +16,7 @@ import app.revanced.patches.youtube.player.buttons.fingerprints.YouTubeControlsO
import app.revanced.patches.youtube.utils.castbutton.CastButtonPatch
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.youtube.utils.fingerprints.LayoutConstructorFingerprint
import app.revanced.patches.youtube.utils.fix.fullscreen.FullscreenButtonViewStubPatch
import app.revanced.patches.youtube.utils.fix.bottomui.CfBottomUIPatch
import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.AutoNavToggle
@ -39,7 +39,7 @@ object PlayerButtonsPatch : BaseBytecodePatch(
description = "Adds options to hide buttons in the video player.",
dependencies = setOf(
CastButtonPatch::class,
FullscreenButtonViewStubPatch::class,
CfBottomUIPatch::class,
SettingsPatch::class,
SharedResourceIdPatch::class
),

View File

@ -243,7 +243,7 @@ object PlayerComponentsPatch : BaseBytecodePatch(
addLiteralValues(insertIndex, jumpIndex - 1)
addInstructionsWithLabels(
insertIndex + 1, """
insertIndex + 1, literalComponent + """
const v$constRegister, $FadeDurationFast
invoke-static {}, $PLAYER_CLASS_DESCRIPTOR->hideFilmstripOverlay()Z
move-result v${replaceInstruction.registerA}
@ -379,31 +379,16 @@ object PlayerComponentsPatch : BaseBytecodePatch(
) {
for (index in startIndex..endIndex) {
val opcode = getInstruction(index).opcode
if (opcode != Opcode.CONST_16 && opcode != Opcode.CONST_4 && opcode != Opcode.CONST)
if (opcode != Opcode.CONST_16 && opcode != Opcode.CONST_4)
continue
val register = getInstruction<OneRegisterInstruction>(index).registerA
val value = getInstruction<WideLiteralInstruction>(index).wideLiteral.toInt()
val line =
when (opcode) {
Opcode.CONST_16 -> """
const/16 v$register, $value
""".trimIndent()
Opcode.CONST_4 -> """
const/4 v$register, $value
""".trimIndent()
Opcode.CONST -> """
const v$register, $value
""".trimIndent()
else -> ""
}
val line = """
const/16 v$register, $value
""".trimIndent()
literalComponent += line
}

View File

@ -13,9 +13,6 @@ import app.revanced.patches.youtube.player.fullscreen.fingerprints.BroadcastRece
import app.revanced.patches.youtube.player.fullscreen.fingerprints.ClientSettingEndpointFingerprint
import app.revanced.patches.youtube.player.fullscreen.fingerprints.EngagementPanelFingerprint
import app.revanced.patches.youtube.player.fullscreen.fingerprints.LandScapeModeConfigFingerprint
import app.revanced.patches.youtube.player.fullscreen.fingerprints.OrientationParentFingerprint
import app.revanced.patches.youtube.player.fullscreen.fingerprints.OrientationPrimaryFingerprint
import app.revanced.patches.youtube.player.fullscreen.fingerprints.OrientationSecondaryFingerprint
import app.revanced.patches.youtube.player.fullscreen.fingerprints.PlayerTitleViewFingerprint
import app.revanced.patches.youtube.player.fullscreen.fingerprints.QuickActionsElementFingerprint
import app.revanced.patches.youtube.player.fullscreen.fingerprints.RelatedEndScreenResultsFingerprint
@ -26,16 +23,19 @@ import app.revanced.patches.youtube.utils.fingerprints.YouTubeControlsOverlayFin
import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH
import app.revanced.patches.youtube.utils.integrations.Constants.PATCH_STATUS_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.mainactivity.MainActivityResolvePatch
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.AutoNavPreviewStub
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.FullScreenEngagementPanel
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.QuickActionsElementContainer
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.getReference
import app.revanced.util.getStringInstructionIndex
import app.revanced.util.getTargetIndexOrThrow
import app.revanced.util.getTargetIndexWithMethodReferenceNameOrThrow
import app.revanced.util.getWalkerMethod
import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.indexOfFirstInstructionOrThrow
import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow
import app.revanced.util.updatePatchStatus
@ -45,6 +45,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.WideLiteralInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
@Suppress("unused")
object FullscreenComponentsPatch : BaseBytecodePatch(
@ -52,6 +53,7 @@ object FullscreenComponentsPatch : BaseBytecodePatch(
description = "Adds options to hide or change components related to fullscreen.",
dependencies = setOf(
LithoFilterPatch::class,
MainActivityResolvePatch::class,
SettingsPatch::class,
SharedResourceIdPatch::class
),
@ -62,7 +64,6 @@ object FullscreenComponentsPatch : BaseBytecodePatch(
EngagementPanelFingerprint,
LandScapeModeConfigFingerprint,
LayoutConstructorFingerprint,
OrientationParentFingerprint,
PlayerTitleViewFingerprint,
QuickActionsElementFingerprint,
RelatedEndScreenResultsFingerprint,
@ -265,25 +266,42 @@ object FullscreenComponentsPatch : BaseBytecodePatch(
// region patch for disable landscape mode
OrientationParentFingerprint.resultOrThrow().classDef.let { classDef ->
MainActivityResolvePatch.onConfigurationChangedMethod.apply {
val walkerIndex = indexOfFirstInstructionOrThrow {
val reference = getReference<MethodReference>()
reference?.parameterTypes == listOf("Landroid/content/res/Configuration;")
&& reference.returnType == "V"
&& reference.name != "onConfigurationChanged"
}
val walkerMethod = getWalkerMethod(context, walkerIndex)
val targetClass =
context.findClass(walkerMethod.definingClass)!!.mutableClass
val constructorMethod = targetClass
.methods
.find { method ->
method.name == "<init>"
&& method.parameterTypes == listOf("Landroid/app/Activity;")
} ?: throw PatchException("Constructor method not found!")
arrayOf(
OrientationPrimaryFingerprint,
OrientationSecondaryFingerprint
).forEach { fingerprint ->
fingerprint.resolve(context, classDef)
walkerMethod,
constructorMethod
).forEach { method ->
method.apply {
val index = indexOfFirstInstructionOrThrow {
val reference = getReference<MethodReference>()
reference?.parameterTypes == listOf("Landroid/content/Context;")
&& reference.returnType == "Z"
} + 1
val register = getInstruction<OneRegisterInstruction>(index).registerA
fingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val index = it.scanResult.patternScanResult!!.endIndex
val register = getInstruction<OneRegisterInstruction>(index).registerA
addInstructions(
index + 1, """
invoke-static {v$register}, $PLAYER_CLASS_DESCRIPTOR->disableLandScapeMode(Z)Z
move-result v$register
"""
)
}
addInstructions(
index + 1, """
invoke-static {v$register}, $PLAYER_CLASS_DESCRIPTOR->disableLandScapeMode(Z)Z
move-result v$register
"""
)
}
}
}

View File

@ -1,8 +0,0 @@
package app.revanced.patches.youtube.player.fullscreen.fingerprints
import app.revanced.patcher.fingerprint.MethodFingerprint
internal object OrientationParentFingerprint : MethodFingerprint(
returnType = "Z",
strings = listOf("NoClassDefFoundError thrown while verifying stack trace.")
)

View File

@ -1,17 +0,0 @@
package app.revanced.patches.youtube.player.fullscreen.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
internal object OrientationPrimaryFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
parameters = listOf("L"),
opcodes = listOf(
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT
),
customFingerprint = { methodDef, _ -> methodDef.name == "<init>" }
)

View File

@ -1,16 +0,0 @@
package app.revanced.patches.youtube.player.fullscreen.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
internal object OrientationSecondaryFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("L"),
opcodes = listOf(
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT
)
)

View File

@ -19,6 +19,7 @@ import app.revanced.patches.youtube.video.information.VideoInformationPatch
import app.revanced.util.addFieldAndInstructions
import app.revanced.util.getReference
import app.revanced.util.getTargetIndexWithReferenceOrThrow
import app.revanced.util.indexOfFirstInstruction
import app.revanced.util.indexOfFirstInstructionOrThrow
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
@ -84,11 +85,22 @@ object OverlayButtonsBytecodePatch : BytecodePatch(
PlayerButtonConstructorFingerprint.resultOrThrow().mutableMethod.apply {
val registerResolver = implementation!!.registerCount - parameters.size - 1 + 6 // p6
val invokerObjectIndex = indexOfFirstInstructionOrThrow {
var invokerObjectIndex = indexOfFirstInstruction {
opcode == Opcode.IPUT_OBJECT
&& getReference<FieldReference>()?.definingClass == definingClass
&& (this as TwoRegisterInstruction).registerA == registerResolver
}
if (invokerObjectIndex < 0) {
val moveObjectIndex = indexOfFirstInstructionOrThrow {
(this as? TwoRegisterInstruction)?.registerB == registerResolver
}
val moveObjectRegister = getInstruction<TwoRegisterInstruction>(moveObjectIndex).registerA
invokerObjectIndex = indexOfFirstInstructionOrThrow(moveObjectIndex) {
opcode == Opcode.IPUT_OBJECT
&& getReference<FieldReference>()?.definingClass == definingClass
&& (this as TwoRegisterInstruction).registerA == moveObjectRegister
}
}
val invokerObjectReference =
getInstruction<ReferenceInstruction>(invokerObjectIndex).reference

View File

@ -3,7 +3,7 @@ package app.revanced.patches.youtube.player.overlaybuttons
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.stringPatchOption
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.youtube.utils.fix.fullscreen.FullscreenButtonViewStubPatch
import app.revanced.patches.youtube.utils.fix.bottomui.CfBottomUIPatch
import app.revanced.patches.youtube.utils.integrations.Constants.OVERLAY_BUTTONS_PATH
import app.revanced.patches.youtube.utils.playercontrols.PlayerControlsPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch
@ -27,7 +27,7 @@ object OverlayButtonsPatch : BaseResourcePatch(
name = "Overlay buttons",
description = "Adds options to display overlay buttons in the video player.",
dependencies = setOf(
FullscreenButtonViewStubPatch::class,
CfBottomUIPatch::class,
PlayerControlsPatch::class,
SettingsPatch::class,
OverlayButtonsBytecodePatch::class,