diff --git a/src/main/kotlin/app/revanced/patches/shared/mainactivity/BaseMainActivityResolvePatch.kt b/src/main/kotlin/app/revanced/patches/shared/mainactivity/BaseMainActivityResolvePatch.kt index bc9d883d3..e6a08478d 100644 --- a/src/main/kotlin/app/revanced/patches/shared/mainactivity/BaseMainActivityResolvePatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/mainactivity/BaseMainActivityResolvePatch.kt @@ -18,6 +18,7 @@ abstract class BaseMainActivityResolvePatch( setOf(mainActivityOnCreateFingerprint) ) { lateinit var mainActivityMutableClass: MutableClass + lateinit var onConfigurationChangedMethod: MutableMethod private lateinit var constructorMethod: MutableMethod private lateinit var onBackPressedMethod: MutableMethod @@ -38,6 +39,9 @@ abstract class BaseMainActivityResolvePatch( // set onBackPressed method onBackPressedMethod = getMethod("onBackPressed") onBackPressedMethodIndex = onBackPressedMethod.getTargetIndexOrThrow(Opcode.RETURN_VOID) + + // set onConfigurationChanged method + onConfigurationChangedMethod = getMethod("onConfigurationChanged") } fun injectConstructorMethodCall(classDescriptor: String, methodDescriptor: String) = diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/miniplayer/MiniplayerPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/miniplayer/MiniplayerPatch.kt index 2aa8ba3b2..fa41caa83 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/miniplayer/MiniplayerPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/miniplayer/MiniplayerPatch.kt @@ -3,16 +3,20 @@ package app.revanced.patches.youtube.general.miniplayer import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable +import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.youtube.general.miniplayer.fingerprints.MiniplayerDimensionsCalculatorParentFingerprint import app.revanced.patches.youtube.general.miniplayer.fingerprints.MiniplayerModernAddViewListenerFingerprint import app.revanced.patches.youtube.general.miniplayer.fingerprints.MiniplayerModernCloseButtonFingerprint import app.revanced.patches.youtube.general.miniplayer.fingerprints.MiniplayerModernConstructorFingerprint +import app.revanced.patches.youtube.general.miniplayer.fingerprints.MiniplayerModernConstructorFingerprint.isMultiConstructorMethod import app.revanced.patches.youtube.general.miniplayer.fingerprints.MiniplayerModernDragAndDropFingerprint +import app.revanced.patches.youtube.general.miniplayer.fingerprints.MiniplayerModernEnabledFingerprint import app.revanced.patches.youtube.general.miniplayer.fingerprints.MiniplayerModernExpandButtonFingerprint import app.revanced.patches.youtube.general.miniplayer.fingerprints.MiniplayerModernExpandCloseDrawablesFingerprint import app.revanced.patches.youtube.general.miniplayer.fingerprints.MiniplayerModernForwardButtonFingerprint @@ -26,7 +30,6 @@ import app.revanced.patches.youtube.general.miniplayer.fingerprints.YouTubePlaye import app.revanced.patches.youtube.general.miniplayer.fingerprints.YouTubePlayerOverlaysLayoutFingerprint.YOUTUBE_PLAYER_OVERLAYS_LAYOUT_CLASS_NAME import app.revanced.patches.youtube.utils.compatibility.Constants import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_PATH -import app.revanced.patches.youtube.utils.integrations.Constants.PATCH_STATUS_CLASS_DESCRIPTOR import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ModernMiniPlayerClose import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ModernMiniPlayerExpand @@ -45,7 +48,6 @@ import app.revanced.util.indexOfWideLiteralInstructionOrThrow import app.revanced.util.literalInstructionBooleanHook import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.resultOrThrow -import app.revanced.util.updatePatchStatus import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation @@ -57,6 +59,7 @@ import com.android.tools.smali.dexlib2.iface.reference.FieldReference import com.android.tools.smali.dexlib2.iface.reference.TypeReference import com.android.tools.smali.dexlib2.immutable.ImmutableMethod import com.android.tools.smali.dexlib2.immutable.ImmutableMethodParameter +import com.android.tools.smali.dexlib2.util.MethodUtil // YT uses "Miniplayer" without a space between 'mini' and 'player: https://support.google.com/youtube/answer/9162927. @Suppress("unused", "SpellCheckingInspection") @@ -75,6 +78,7 @@ object MiniplayerPatch : BaseBytecodePatch( MiniplayerOverrideFingerprint, MiniplayerModernConstructorFingerprint, MiniplayerModernDragAndDropFingerprint, + MiniplayerModernEnabledFingerprint, MiniplayerModernViewParentFingerprint, YouTubePlayerOverlaysLayoutFingerprint, ) @@ -149,13 +153,13 @@ object MiniplayerPatch : BaseBytecodePatch( MiniplayerModernConstructorFingerprint.resultOrThrow().mutableClass.methods.forEach { it.apply { - if (AccessFlags.CONSTRUCTOR.isSet(accessFlags)) { + if (MethodUtil.isConstructor(it)) { val iPutIndex = indexOfFirstInstructionOrThrow { this.opcode == Opcode.IPUT && this.getReference()?.type == "I" } insertModernMiniplayerTypeOverride(iPutIndex) - } else { + } else if (isMultiConstructorMethod()) { findReturnIndicesReversed().forEach { index -> insertModernMiniplayerOverride( index @@ -165,8 +169,17 @@ object MiniplayerPatch : BaseBytecodePatch( } } + if (SettingsPatch.upward1925) { + MiniplayerModernEnabledFingerprint.literalInstructionBooleanHook( + 45622882, + "$INTEGRATIONS_CLASS_DESCRIPTOR->getModernMiniplayerOverride(Z)Z" + ) + } + // endregion + val miniplayerModernViewParentClassDef = MiniplayerModernViewParentFingerprint.resultOrThrow().classDef + // region Fix 19.16 using mixed up drawables for tablet modern. // YT fixed this mistake in 19.17. // Fix this, by swapping the drawable resource values with each other. @@ -174,7 +187,7 @@ object MiniplayerPatch : BaseBytecodePatch( MiniplayerModernExpandCloseDrawablesFingerprint.apply { resolve( context, - MiniplayerModernViewParentFingerprint.resultOrThrow().classDef + miniplayerModernViewParentClassDef ) }.resultOrThrow().mutableMethod.apply { listOf( @@ -220,7 +233,7 @@ object MiniplayerPatch : BaseBytecodePatch( ).forEach { (fingerprint, literalValue, methodName) -> fingerprint.resolve( context, - MiniplayerModernViewParentFingerprint.resultOrThrow().classDef + miniplayerModernViewParentClassDef ) fingerprint.hookInflatedView( @@ -233,13 +246,17 @@ object MiniplayerPatch : BaseBytecodePatch( MiniplayerModernAddViewListenerFingerprint.apply { resolve( context, - MiniplayerModernViewParentFingerprint.resultOrThrow().classDef + miniplayerModernViewParentClassDef ) - }.resultOrThrow().mutableMethod.addInstruction( - 0, - "invoke-static { p1 }, $INTEGRATIONS_CLASS_DESCRIPTOR->" + - "hideMiniplayerSubTexts(Landroid/view/View;)V" - ) + }.resultOrThrow().mutableMethod.apply { + addInstructionsWithLabels( + 0, """ + invoke-static { p1 }, $INTEGRATIONS_CLASS_DESCRIPTOR->hideMiniplayerSubTexts(Landroid/view/View;)Z + move-result v0 + if-nez v0, :hidden + """, ExternalLabel("hidden", getInstruction(implementation!!.instructions.lastIndex)) + ) + } // Modern 2 has a broken overlay subtitle view that is always present. @@ -294,11 +311,6 @@ object MiniplayerPatch : BaseBytecodePatch( // endregion - - if (SettingsPatch.upward1920) { - context.updatePatchStatus(PATCH_STATUS_CLASS_DESCRIPTOR, "MiniplayerType1920") - } - settingArray += "SETTINGS: MINIPLAYER_TYPE_MODERN" SettingsPatch.addPreference(settingArray) diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/miniplayer/fingerprints/MiniplayerModernConstructorFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/miniplayer/fingerprints/MiniplayerModernConstructorFingerprint.kt index e1007e050..560567ed7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/miniplayer/fingerprints/MiniplayerModernConstructorFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/miniplayer/fingerprints/MiniplayerModernConstructorFingerprint.kt @@ -1,12 +1,29 @@ package app.revanced.patches.youtube.general.miniplayer.fingerprints import app.revanced.patcher.extensions.or -import app.revanced.util.fingerprint.LiteralValueFingerprint +import app.revanced.patcher.fingerprint.MethodFingerprint +import app.revanced.patches.youtube.general.miniplayer.fingerprints.MiniplayerModernConstructorFingerprint.constructorMethodCount +import app.revanced.patches.youtube.utils.settings.SettingsPatch +import app.revanced.util.containsWideLiteralInstructionIndex import com.android.tools.smali.dexlib2.AccessFlags +import com.android.tools.smali.dexlib2.util.MethodUtil @Suppress("SpellCheckingInspection") -internal object MiniplayerModernConstructorFingerprint : LiteralValueFingerprint( +internal object MiniplayerModernConstructorFingerprint : MethodFingerprint( accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, parameters = listOf("L"), - literalSupplier = { 45623000 } // Magic number found in the constructor. -) \ No newline at end of file + customFingerprint = custom@{ methodDef, classDef -> + if (!methodDef.containsWideLiteralInstructionIndex(45623000)) // Magic number found in the constructor. + return@custom false + + classDef.methods.forEach { + if (MethodUtil.isConstructor(it)) constructorMethodCount += 1 + } + + constructorMethodCount > 0 + } +) { + private var constructorMethodCount = 0 + + internal fun isMultiConstructorMethod() = constructorMethodCount > 1 +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/miniplayer/fingerprints/MiniplayerModernEnabledFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/miniplayer/fingerprints/MiniplayerModernEnabledFingerprint.kt new file mode 100644 index 000000000..86ab4512c --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/general/miniplayer/fingerprints/MiniplayerModernEnabledFingerprint.kt @@ -0,0 +1,8 @@ +package app.revanced.patches.youtube.general.miniplayer.fingerprints + +import app.revanced.util.fingerprint.LiteralValueFingerprint + +@Suppress("SpellCheckingInspection") +internal object MiniplayerModernEnabledFingerprint : LiteralValueFingerprint( + literalSupplier = { 45622882 } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/buttons/PlayerButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/buttons/PlayerButtonsPatch.kt index 56cf17faf..81888b98b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/buttons/PlayerButtonsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/buttons/PlayerButtonsPatch.kt @@ -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 ), diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/components/PlayerComponentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/components/PlayerComponentsPatch.kt index da19e2a2d..1ad0d5932 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/components/PlayerComponentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/components/PlayerComponentsPatch.kt @@ -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(index).registerA val value = getInstruction(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 } diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/fullscreen/FullscreenComponentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/fullscreen/FullscreenComponentsPatch.kt index 2b2591066..e90ec3c64 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/fullscreen/FullscreenComponentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/fullscreen/FullscreenComponentsPatch.kt @@ -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() + 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 == "" + && 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() + reference?.parameterTypes == listOf("Landroid/content/Context;") + && reference.returnType == "Z" + } + 1 + val register = getInstruction(index).registerA - fingerprint.resultOrThrow().let { - it.mutableMethod.apply { - val index = it.scanResult.patternScanResult!!.endIndex - val register = getInstruction(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 + """ + ) } } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/fullscreen/fingerprints/OrientationParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/fullscreen/fingerprints/OrientationParentFingerprint.kt deleted file mode 100644 index 1eb971bc2..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/player/fullscreen/fingerprints/OrientationParentFingerprint.kt +++ /dev/null @@ -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.") -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/fullscreen/fingerprints/OrientationPrimaryFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/fullscreen/fingerprints/OrientationPrimaryFingerprint.kt deleted file mode 100644 index fbf8b9b9e..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/player/fullscreen/fingerprints/OrientationPrimaryFingerprint.kt +++ /dev/null @@ -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 == "" } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/fullscreen/fingerprints/OrientationSecondaryFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/fullscreen/fingerprints/OrientationSecondaryFingerprint.kt deleted file mode 100644 index bc9735ac5..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/player/fullscreen/fingerprints/OrientationSecondaryFingerprint.kt +++ /dev/null @@ -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 - ) -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/overlaybuttons/OverlayButtonsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/overlaybuttons/OverlayButtonsBytecodePatch.kt index e533feb96..86bbd52fb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/overlaybuttons/OverlayButtonsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/overlaybuttons/OverlayButtonsBytecodePatch.kt @@ -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()?.definingClass == definingClass && (this as TwoRegisterInstruction).registerA == registerResolver } + if (invokerObjectIndex < 0) { + val moveObjectIndex = indexOfFirstInstructionOrThrow { + (this as? TwoRegisterInstruction)?.registerB == registerResolver + } + val moveObjectRegister = getInstruction(moveObjectIndex).registerA + invokerObjectIndex = indexOfFirstInstructionOrThrow(moveObjectIndex) { + opcode == Opcode.IPUT_OBJECT + && getReference()?.definingClass == definingClass + && (this as TwoRegisterInstruction).registerA == moveObjectRegister + } + } val invokerObjectReference = getInstruction(invokerObjectIndex).reference diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/overlaybuttons/OverlayButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/overlaybuttons/OverlayButtonsPatch.kt index af22a97ab..e0300fdb8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/overlaybuttons/OverlayButtonsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/overlaybuttons/OverlayButtonsPatch.kt @@ -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, diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/compatibility/Constants.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/compatibility/Constants.kt index 02359d0f2..4b4ec9305 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/compatibility/Constants.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/compatibility/Constants.kt @@ -13,7 +13,7 @@ object Constants { "18.48.39", // This is the last version that do not use Rolling Number. "19.05.36", // This is the last version with the least YouTube experimental flag. "19.16.39", // This is the last version that supports the 'Restore old seekbar thumbnails' setting. - "19.23.40", // This is the latest version supported by the RVX patch. + "19.25.39", // This is the latest version supported by the RVX patch. ) ) ) diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/fullscreen/FullscreenButtonViewStubPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/bottomui/CfBottomUIPatch.kt similarity index 82% rename from src/main/kotlin/app/revanced/patches/youtube/utils/fix/fullscreen/FullscreenButtonViewStubPatch.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/fix/bottomui/CfBottomUIPatch.kt index fba7caf5f..ab733d352 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/fullscreen/FullscreenButtonViewStubPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/bottomui/CfBottomUIPatch.kt @@ -1,12 +1,11 @@ -package app.revanced.patches.youtube.utils.fix.fullscreen +package app.revanced.patches.youtube.utils.fix.bottomui import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.youtube.utils.fix.fullscreen.fingerprints.FullscreenButtonPositionFingerprint -import app.revanced.patches.youtube.utils.fix.fullscreen.fingerprints.FullscreenButtonViewStubFingerprint +import app.revanced.patches.youtube.utils.fix.bottomui.fingerprints.* import app.revanced.util.getTargetIndexOrThrow import app.revanced.util.getWideLiteralInstructionIndex import com.android.tools.smali.dexlib2.Opcode @@ -15,8 +14,10 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction @Patch( description = "Fixes an issue where overlay button patches were broken by the new layout." ) -object FullscreenButtonViewStubPatch : BytecodePatch( +object CfBottomUIPatch : BytecodePatch( setOf( + BottomUIContainerBooleanFingerprint, + BottomUIContainerIntegerFingerprint, FullscreenButtonPositionFingerprint, FullscreenButtonViewStubFingerprint ) @@ -28,6 +29,8 @@ object FullscreenButtonViewStubPatch : BytecodePatch( * Therefore, this patch only applies to versions that can resolve this fingerprint. */ mapOf( + BottomUIContainerBooleanFingerprint to 45637647, + BottomUIContainerIntegerFingerprint to 45637647, FullscreenButtonViewStubFingerprint to 45617294, FullscreenButtonPositionFingerprint to 45627640 ).forEach { (fingerprint, literalValue) -> diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/bottomui/fingerprints/BottomUIContainerBooleanFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/bottomui/fingerprints/BottomUIContainerBooleanFingerprint.kt new file mode 100644 index 000000000..5ca66ba1e --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/bottomui/fingerprints/BottomUIContainerBooleanFingerprint.kt @@ -0,0 +1,8 @@ +package app.revanced.patches.youtube.utils.fix.bottomui.fingerprints + +import app.revanced.util.fingerprint.LiteralValueFingerprint + +internal object BottomUIContainerBooleanFingerprint : LiteralValueFingerprint( + returnType = "Z", + literalSupplier = { 45637647 } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/bottomui/fingerprints/BottomUIContainerIntegerFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/bottomui/fingerprints/BottomUIContainerIntegerFingerprint.kt new file mode 100644 index 000000000..78c364ebf --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/bottomui/fingerprints/BottomUIContainerIntegerFingerprint.kt @@ -0,0 +1,8 @@ +package app.revanced.patches.youtube.utils.fix.bottomui.fingerprints + +import app.revanced.util.fingerprint.LiteralValueFingerprint + +internal object BottomUIContainerIntegerFingerprint : LiteralValueFingerprint( + returnType = "V", + literalSupplier = { 45637647 } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/fullscreen/fingerprints/FullscreenButtonPositionFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/bottomui/fingerprints/FullscreenButtonPositionFingerprint.kt similarity index 73% rename from src/main/kotlin/app/revanced/patches/youtube/utils/fix/fullscreen/fingerprints/FullscreenButtonPositionFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/fix/bottomui/fingerprints/FullscreenButtonPositionFingerprint.kt index 152b6a6fe..e325d7b02 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/fullscreen/fingerprints/FullscreenButtonPositionFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/bottomui/fingerprints/FullscreenButtonPositionFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.utils.fix.fullscreen.fingerprints +package app.revanced.patches.youtube.utils.fix.bottomui.fingerprints import app.revanced.util.fingerprint.LiteralValueFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/fullscreen/fingerprints/FullscreenButtonViewStubFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/bottomui/fingerprints/FullscreenButtonViewStubFingerprint.kt similarity index 73% rename from src/main/kotlin/app/revanced/patches/youtube/utils/fix/fullscreen/fingerprints/FullscreenButtonViewStubFingerprint.kt rename to src/main/kotlin/app/revanced/patches/youtube/utils/fix/bottomui/fingerprints/FullscreenButtonViewStubFingerprint.kt index 3822ad752..f99b18df6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/fullscreen/fingerprints/FullscreenButtonViewStubFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/bottomui/fingerprints/FullscreenButtonViewStubFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.utils.fix.fullscreen.fingerprints +package app.revanced.patches.youtube.utils.fix.bottomui.fingerprints import app.revanced.util.fingerprint.LiteralValueFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/fingerprints/BottomControlsInflateFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/fingerprints/BottomControlsInflateFingerprint.kt index a9cc717db..5ef4e9224 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/fingerprints/BottomControlsInflateFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/playercontrols/fingerprints/BottomControlsInflateFingerprint.kt @@ -1,14 +1,11 @@ package app.revanced.patches.youtube.utils.playercontrols.fingerprints -import app.revanced.patcher.extensions.or import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.BottomUiContainerStub import app.revanced.util.fingerprint.LiteralValueFingerprint -import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode internal object BottomControlsInflateFingerprint : LiteralValueFingerprint( returnType = "Ljava/lang/Object;", - accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL or AccessFlags.SYNTHETIC, parameters = emptyList(), opcodes = listOf( Opcode.CHECK_CAST, diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/settings/SettingsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/settings/SettingsPatch.kt index bd1c93982..4201b5c22 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/settings/SettingsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/settings/SettingsPatch.kt @@ -97,8 +97,8 @@ object SettingsPatch : BaseResourcePatch( internal var upward1849 = false internal var upward1902 = false internal var upward1912 = false - internal var upward1920 = false internal var upward1923 = false + internal var upward1925 = false override fun execute(context: ResourceContext) { @@ -291,8 +291,8 @@ object SettingsPatch : BaseResourcePatch( upward1849 = 235000000 <= playServicesVersion upward1902 = 240204000 < playServicesVersion upward1912 = 241302000 <= playServicesVersion - upward1920 = 242099000 <= playServicesVersion upward1923 = 242402000 <= playServicesVersion + upward1925 = 242599000 <= playServicesVersion break }