fix(youtube/hide-flyout-panel): quality and captions footers are not hidden in the old player flyout panel

This commit is contained in:
inotia00 2023-09-28 23:03:03 +09:00
parent 80c81d46ba
commit 4faea22fb0
6 changed files with 110 additions and 7 deletions

View File

@ -9,7 +9,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.flyoutpanel.oldqualitylayout.fingerprints.QualityMenuViewInflateFingerprint
import app.revanced.patches.youtube.utils.fingerprints.QualityMenuViewInflateFingerprint
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.fingerprints.RecyclerViewTreeObserverFingerprint
import app.revanced.patches.youtube.utils.litho.patch.LithoFilterPatch

View File

@ -0,0 +1,41 @@
package app.revanced.patches.youtube.flyoutpanel.player.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.VideoQualityBottomSheet
import app.revanced.util.bytecode.isWideLiteralExists
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
object AdvancedQualityBottomSheetFingerprint : MethodFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("L", "L", "L"),
returnType = "L",
opcodes = listOf(
Opcode.IGET_OBJECT,
Opcode.INVOKE_STATIC,
Opcode.CONST,
Opcode.CONST_4,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.CONST,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.CONST_16,
Opcode.INVOKE_VIRTUAL,
Opcode.CONST,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.CHECK_CAST,
Opcode.CONST,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.IGET_OBJECT,
Opcode.IGET_OBJECT,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.IGET_OBJECT,
Opcode.CONST_STRING
),
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(VideoQualityBottomSheet) }
)

View File

@ -0,0 +1,16 @@
package app.revanced.patches.youtube.flyoutpanel.player.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.BottomSheetFooterText
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.SubtitleMenuSettingsFooterInfo
import app.revanced.util.bytecode.isWideLiteralExists
import com.android.tools.smali.dexlib2.AccessFlags
object CaptionsBottomSheetFingerprint : MethodFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
customFingerprint = { methodDef, _ ->
methodDef.isWideLiteralExists(BottomSheetFooterText)
&& methodDef.isWideLiteralExists(SubtitleMenuSettingsFooterInfo)
}
)

View File

@ -1,15 +1,27 @@
package app.revanced.patches.youtube.flyoutpanel.player.patch
import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.utils.fingerprints.QualityMenuViewInflateFingerprint
import app.revanced.patches.youtube.flyoutpanel.player.fingerprints.AdvancedQualityBottomSheetFingerprint
import app.revanced.patches.youtube.flyoutpanel.player.fingerprints.CaptionsBottomSheetFingerprint
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.litho.patch.LithoFilterPatch
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.BottomSheetFooterText
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
import app.revanced.util.bytecode.getWideLiteralIndex
import app.revanced.util.integrations.Constants.FLYOUT_PANEL
import app.revanced.util.integrations.Constants.PATCHES_PATH
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Patch
@Name("Hide player flyout panel")
@ -17,12 +29,27 @@ import app.revanced.util.integrations.Constants.PATCHES_PATH
@DependsOn(
[
LithoFilterPatch::class,
SettingsPatch::class
SettingsPatch::class,
SharedResourceIdPatch::class
]
)
@YouTubeCompatibility
class PlayerFlyoutPanelPatch : ResourcePatch {
override fun execute(context: ResourceContext) {
class PlayerFlyoutPanelPatch : BytecodePatch(
listOf(
AdvancedQualityBottomSheetFingerprint,
CaptionsBottomSheetFingerprint,
QualityMenuViewInflateFingerprint
)
) {
override fun execute(context: BytecodeContext) {
arrayOf(
AdvancedQualityBottomSheetFingerprint to "hideFooterQuality",
CaptionsBottomSheetFingerprint to "hideFooterCaptions",
QualityMenuViewInflateFingerprint to "hideFooterQuality"
).map { (fingerprint, name) ->
fingerprint.injectCall(name)
}
LithoFilterPatch.addFilter("$PATCHES_PATH/ads/PlayerFlyoutPanelsFilter;")
LithoFilterPatch.addFilter("$PATCHES_PATH/ads/PlayerFlyoutPanelsFooterFilter;")
@ -40,4 +67,19 @@ class PlayerFlyoutPanelPatch : ResourcePatch {
SettingsPatch.updatePatchStatus("hide-player-flyout-panel")
}
private companion object {
fun MethodFingerprint.injectCall(descriptor: String) {
result?.let {
it.mutableMethod.apply {
val insertIndex = getWideLiteralIndex(BottomSheetFooterText) + 3
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
addInstruction(
insertIndex,
"invoke-static {v$insertRegister}, $FLYOUT_PANEL->$descriptor(Landroid/view/View;)V"
)
}
} ?: throw exception
}
}
}

View File

@ -1,4 +1,4 @@
package app.revanced.patches.youtube.flyoutpanel.oldqualitylayout.fingerprints
package app.revanced.patches.youtube.utils.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint

View File

@ -28,6 +28,7 @@ class SharedResourceIdPatch : ResourcePatch {
var Bar: Long = -1
var BarContainerHeight: Long = -1
var BottomPanelOverlayText: Long = -1
var BottomSheetFooterText: Long = -1
var BottomUiContainerStub: Long = -1
var ChannelListSubMenu: Long = -1
var CompactLink: Long = -1
@ -70,6 +71,7 @@ class SharedResourceIdPatch : ResourcePatch {
var ScrimOverlay: Long = -1
var Scrubbing: Long = -1
var SettingsBooleanTimeRangeDialog: Long = -1
var SubtitleMenuSettingsFooterInfo: Long = -1
var SuggestedAction: Long = -1
var ToolBarPaddingHome: Long = -1
var ToolTipContentView: Long = -1
@ -103,6 +105,7 @@ class SharedResourceIdPatch : ResourcePatch {
Bar = find(LAYOUT, "bar")
BarContainerHeight = find(DIMEN, "bar_container_height")
BottomPanelOverlayText = find(ID, "bottom_panel_overlay_text")
BottomSheetFooterText = find(ID, "bottom_sheet_footer_text")
BottomUiContainerStub = find(ID, "bottom_ui_container_stub")
ChannelListSubMenu = find(LAYOUT, "channel_list_sub_menu")
CompactLink = find(LAYOUT, "compact_link")
@ -147,6 +150,7 @@ class SharedResourceIdPatch : ResourcePatch {
ScrimOverlay = find(ID, "scrim_overlay")
Scrubbing = find(DIMEN, "vertical_touch_offset_to_enter_fine_scrubbing")
SettingsBooleanTimeRangeDialog = find(LAYOUT, "setting_boolean_time_range_dialog")
SubtitleMenuSettingsFooterInfo = find(STRING, "subtitle_menu_settings_footer_info")
SuggestedAction = find(LAYOUT, "suggested_action")
ToolBarPaddingHome = find(DIMEN, "toolbar_padding_home_action_up")
ToolTipContentView = find(LAYOUT, "tooltip_content_view")