mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-06 17:44:36 +02:00
feat(YouTube/Enable minimized playback): checks whether Shorts is attached to Windows instead of checking PlayerType
This commit is contained in:
parent
e1fd3c8586
commit
fa71b9ba3e
@ -10,7 +10,6 @@ import app.revanced.patcher.patch.annotation.Patch
|
|||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
import app.revanced.patches.youtube.utils.fingerprints.InitializeButtonsFingerprint
|
import app.revanced.patches.youtube.utils.fingerprints.InitializeButtonsFingerprint
|
||||||
import app.revanced.patches.youtube.utils.integrations.Constants.SHARED_PATH
|
import app.revanced.patches.youtube.utils.integrations.Constants.SHARED_PATH
|
||||||
import app.revanced.patches.youtube.utils.navigation.fingerprints.ActionBarSearchResultsFingerprint
|
|
||||||
import app.revanced.patches.youtube.utils.navigation.fingerprints.NavigationEnumFingerprint
|
import app.revanced.patches.youtube.utils.navigation.fingerprints.NavigationEnumFingerprint
|
||||||
import app.revanced.patches.youtube.utils.navigation.fingerprints.PivotBarButtonsCreateDrawableViewFingerprint
|
import app.revanced.patches.youtube.utils.navigation.fingerprints.PivotBarButtonsCreateDrawableViewFingerprint
|
||||||
import app.revanced.patches.youtube.utils.navigation.fingerprints.PivotBarButtonsCreateResourceViewFingerprint
|
import app.revanced.patches.youtube.utils.navigation.fingerprints.PivotBarButtonsCreateResourceViewFingerprint
|
||||||
@ -18,10 +17,8 @@ import app.revanced.patches.youtube.utils.navigation.fingerprints.PivotBarConstr
|
|||||||
import app.revanced.patches.youtube.utils.playertype.PlayerTypeHookPatch
|
import app.revanced.patches.youtube.utils.playertype.PlayerTypeHookPatch
|
||||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||||
import app.revanced.util.getReference
|
import app.revanced.util.getReference
|
||||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
|
||||||
import app.revanced.util.resultOrThrow
|
import app.revanced.util.resultOrThrow
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.Instruction
|
import com.android.tools.smali.dexlib2.iface.instruction.Instruction
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||||
@ -37,7 +34,6 @@ import com.android.tools.smali.dexlib2.util.MethodUtil
|
|||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
object NavigationBarHookPatch : BytecodePatch(
|
object NavigationBarHookPatch : BytecodePatch(
|
||||||
setOf(
|
setOf(
|
||||||
ActionBarSearchResultsFingerprint,
|
|
||||||
NavigationEnumFingerprint,
|
NavigationEnumFingerprint,
|
||||||
PivotBarButtonsCreateDrawableViewFingerprint,
|
PivotBarButtonsCreateDrawableViewFingerprint,
|
||||||
PivotBarButtonsCreateResourceViewFingerprint,
|
PivotBarButtonsCreateResourceViewFingerprint,
|
||||||
@ -96,22 +92,6 @@ object NavigationBarHookPatch : BytecodePatch(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hook the search bar.
|
|
||||||
|
|
||||||
// Two different layouts are used at the hooked code.
|
|
||||||
// Insert before the first ViewGroup method call after inflating,
|
|
||||||
// so this works regardless which layout is used.
|
|
||||||
ActionBarSearchResultsFingerprint.resultOrThrow().mutableMethod.apply {
|
|
||||||
val instructionIndex = getTargetIndexWithMethodReferenceName("setLayoutDirection")
|
|
||||||
val viewRegister = getInstruction<FiveRegisterInstruction>(instructionIndex).registerC
|
|
||||||
|
|
||||||
addInstruction(
|
|
||||||
instructionIndex,
|
|
||||||
"invoke-static { v$viewRegister }, " +
|
|
||||||
"$INTEGRATIONS_CLASS_DESCRIPTOR->searchBarResultsViewLoaded(Landroid/view/View;)V",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
navigationTabCreatedCallback = context.findClass(INTEGRATIONS_CLASS_DESCRIPTOR)?.mutableClass?.methods?.first { method ->
|
navigationTabCreatedCallback = context.findClass(INTEGRATIONS_CLASS_DESCRIPTOR)?.mutableClass?.methods?.first { method ->
|
||||||
method.name == "navigationTabCreatedCallback"
|
method.name == "navigationTabCreatedCallback"
|
||||||
} ?: throw PatchException("Could not find navigationTabCreatedCallback method")
|
} ?: throw PatchException("Could not find navigationTabCreatedCallback method")
|
||||||
|
@ -7,54 +7,96 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
|||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.annotation.Patch
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
import app.revanced.patches.youtube.utils.fingerprints.YouTubeControlsOverlayFingerprint
|
import app.revanced.patches.youtube.utils.fingerprints.YouTubeControlsOverlayFingerprint
|
||||||
|
import app.revanced.patches.youtube.utils.integrations.Constants.SHARED_PATH
|
||||||
import app.revanced.patches.youtube.utils.integrations.Constants.UTILS_PATH
|
import app.revanced.patches.youtube.utils.integrations.Constants.UTILS_PATH
|
||||||
|
import app.revanced.patches.youtube.utils.playertype.fingerprint.ActionBarSearchResultsFingerprint
|
||||||
import app.revanced.patches.youtube.utils.playertype.fingerprint.PlayerTypeFingerprint
|
import app.revanced.patches.youtube.utils.playertype.fingerprint.PlayerTypeFingerprint
|
||||||
|
import app.revanced.patches.youtube.utils.playertype.fingerprint.ReelWatchPagerFingerprint
|
||||||
import app.revanced.patches.youtube.utils.playertype.fingerprint.VideoStateFingerprint
|
import app.revanced.patches.youtube.utils.playertype.fingerprint.VideoStateFingerprint
|
||||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||||
|
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelWatchPlayer
|
||||||
|
import app.revanced.util.getTargetIndex
|
||||||
|
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||||
|
import app.revanced.util.getWideLiteralInstructionIndex
|
||||||
import app.revanced.util.resultOrThrow
|
import app.revanced.util.resultOrThrow
|
||||||
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||||
|
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.ReferenceInstruction
|
||||||
|
|
||||||
@Patch(dependencies = [SharedResourceIdPatch::class])
|
@Patch(dependencies = [SharedResourceIdPatch::class])
|
||||||
object PlayerTypeHookPatch : BytecodePatch(
|
object PlayerTypeHookPatch : BytecodePatch(
|
||||||
setOf(
|
setOf(
|
||||||
|
ActionBarSearchResultsFingerprint,
|
||||||
PlayerTypeFingerprint,
|
PlayerTypeFingerprint,
|
||||||
|
ReelWatchPagerFingerprint,
|
||||||
YouTubeControlsOverlayFingerprint
|
YouTubeControlsOverlayFingerprint
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
private const val INTEGRATIONS_PLAYER_TYPE_HOOK_CLASS_DESCRIPTOR =
|
||||||
"$UTILS_PATH/PlayerTypeHookPatch;"
|
"$UTILS_PATH/PlayerTypeHookPatch;"
|
||||||
|
|
||||||
|
private const val INTEGRATIONS_ROOT_VIEW_HOOK_CLASS_DESCRIPTOR =
|
||||||
|
"$SHARED_PATH/RootView;"
|
||||||
|
|
||||||
override fun execute(context: BytecodeContext) {
|
override fun execute(context: BytecodeContext) {
|
||||||
|
|
||||||
PlayerTypeFingerprint.resultOrThrow().let {
|
PlayerTypeFingerprint.resultOrThrow().let {
|
||||||
it.mutableMethod.apply {
|
it.mutableMethod.apply {
|
||||||
addInstruction(
|
addInstruction(
|
||||||
0,
|
0,
|
||||||
"invoke-static {p1}, $INTEGRATIONS_CLASS_DESCRIPTOR->setPlayerType(Ljava/lang/Enum;)V"
|
"invoke-static {p1}, " +
|
||||||
|
"$INTEGRATIONS_PLAYER_TYPE_HOOK_CLASS_DESCRIPTOR->setPlayerType(Ljava/lang/Enum;)V"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
YouTubeControlsOverlayFingerprint.resultOrThrow().let { parentResult ->
|
YouTubeControlsOverlayFingerprint.resultOrThrow().let { parentResult ->
|
||||||
VideoStateFingerprint.also {
|
VideoStateFingerprint.also { it.resolve(context, parentResult.classDef)
|
||||||
it.resolve(
|
|
||||||
context,
|
|
||||||
parentResult.classDef
|
|
||||||
)
|
|
||||||
}.resultOrThrow().let {
|
}.resultOrThrow().let {
|
||||||
it.mutableMethod.apply {
|
it.mutableMethod.apply {
|
||||||
val endIndex = it.scanResult.patternScanResult!!.endIndex
|
val endIndex = it.scanResult.patternScanResult!!.endIndex
|
||||||
val videoStateFieldName =
|
val videoStateFieldName =
|
||||||
getInstruction<ReferenceInstruction>(endIndex).reference
|
getInstruction<ReferenceInstruction>(endIndex).reference
|
||||||
|
|
||||||
addInstructions(
|
addInstructions(
|
||||||
0, """
|
0, """
|
||||||
iget-object v0, p1, $videoStateFieldName # copy VideoState parameter field
|
iget-object v0, p1, $videoStateFieldName # copy VideoState parameter field
|
||||||
invoke-static {v0}, $INTEGRATIONS_CLASS_DESCRIPTOR->setVideoState(Ljava/lang/Enum;)V
|
invoke-static {v0}, $INTEGRATIONS_PLAYER_TYPE_HOOK_CLASS_DESCRIPTOR->setVideoState(Ljava/lang/Enum;)V
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReelWatchPagerFingerprint.resultOrThrow().let {
|
||||||
|
it.mutableMethod.apply {
|
||||||
|
val constIndex = getWideLiteralInstructionIndex(ReelWatchPlayer)
|
||||||
|
val targetIndex = getTargetIndex(constIndex, Opcode.MOVE_RESULT_OBJECT)
|
||||||
|
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||||
|
|
||||||
|
addInstruction(
|
||||||
|
targetIndex + 1,
|
||||||
|
"invoke-static {v$targetRegister}, " +
|
||||||
|
"$INTEGRATIONS_ROOT_VIEW_HOOK_CLASS_DESCRIPTOR->onShortsCreate(Landroid/view/View;)V"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hook the search bar.
|
||||||
|
|
||||||
|
// Two different layouts are used at the hooked code.
|
||||||
|
// Insert before the first ViewGroup method call after inflating,
|
||||||
|
// so this works regardless which layout is used.
|
||||||
|
ActionBarSearchResultsFingerprint.resultOrThrow().mutableMethod.apply {
|
||||||
|
val instructionIndex = getTargetIndexWithMethodReferenceName("setLayoutDirection")
|
||||||
|
val viewRegister = getInstruction<FiveRegisterInstruction>(instructionIndex).registerC
|
||||||
|
|
||||||
|
addInstruction(
|
||||||
|
instructionIndex,
|
||||||
|
"invoke-static { v$viewRegister }, " +
|
||||||
|
"$INTEGRATIONS_ROOT_VIEW_HOOK_CLASS_DESCRIPTOR->searchBarResultsViewLoaded(Landroid/view/View;)V",
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patches.youtube.utils.navigation.fingerprints
|
package app.revanced.patches.youtube.utils.playertype.fingerprint
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.or
|
import app.revanced.patcher.extensions.or
|
||||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ActionBarSearchResultsViewMic
|
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ActionBarSearchResultsViewMic
|
@ -13,5 +13,7 @@ internal object PlayerTypeFingerprint : MethodFingerprint(
|
|||||||
Opcode.IF_NE,
|
Opcode.IF_NE,
|
||||||
Opcode.RETURN_VOID
|
Opcode.RETURN_VOID
|
||||||
),
|
),
|
||||||
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/YouTubePlayerOverlaysLayout;") }
|
customFingerprint = { methodDef, _ ->
|
||||||
|
methodDef.definingClass.endsWith("/YouTubePlayerOverlaysLayout;")
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
package app.revanced.patches.youtube.utils.playertype.fingerprint
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelWatchPlayer
|
||||||
|
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||||
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
|
||||||
|
internal object ReelWatchPagerFingerprint : LiteralValueFingerprint(
|
||||||
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
|
returnType = "Landroid/view/View;",
|
||||||
|
literalSupplier = { ReelWatchPlayer }
|
||||||
|
)
|
@ -72,6 +72,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
|||||||
var ReelRightDislikeIcon = -1L
|
var ReelRightDislikeIcon = -1L
|
||||||
var ReelRightLikeIcon = -1L
|
var ReelRightLikeIcon = -1L
|
||||||
var ReelTimeBarPlayedColor = -1L
|
var ReelTimeBarPlayedColor = -1L
|
||||||
|
var ReelWatchPlayer = -1L
|
||||||
var RelatedChipCloudMargin = -1L
|
var RelatedChipCloudMargin = -1L
|
||||||
var RightComment = -1L
|
var RightComment = -1L
|
||||||
var ScrimOverlay = -1L
|
var ScrimOverlay = -1L
|
||||||
@ -145,6 +146,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
|||||||
ReelPlayerPausedStateButton = getId(ID, "reel_player_paused_state_buttons")
|
ReelPlayerPausedStateButton = getId(ID, "reel_player_paused_state_buttons")
|
||||||
ReelRightDislikeIcon = getId(DRAWABLE, "reel_right_dislike_icon")
|
ReelRightDislikeIcon = getId(DRAWABLE, "reel_right_dislike_icon")
|
||||||
ReelRightLikeIcon = getId(DRAWABLE, "reel_right_like_icon")
|
ReelRightLikeIcon = getId(DRAWABLE, "reel_right_like_icon")
|
||||||
|
ReelWatchPlayer = getId(ID, "reel_watch_player")
|
||||||
ReelTimeBarPlayedColor = getId(COLOR, "reel_time_bar_played_color")
|
ReelTimeBarPlayedColor = getId(COLOR, "reel_time_bar_played_color")
|
||||||
RelatedChipCloudMargin = getId(LAYOUT, "related_chip_cloud_reduced_margins")
|
RelatedChipCloudMargin = getId(LAYOUT, "related_chip_cloud_reduced_margins")
|
||||||
RightComment = getId(DRAWABLE, "ic_right_comment_32c")
|
RightComment = getId(DRAWABLE, "ic_right_comment_32c")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user