properly implement new resource mapping patch apis

This commit is contained in:
oSumAtrIX
2026-01-23 17:24:46 +01:00
parent 4950ac412f
commit ef3272bf90
36 changed files with 342 additions and 397 deletions

View File

@@ -11,7 +11,6 @@ import app.revanced.patches.music.misc.settings.PreferenceScreen
import app.revanced.patches.shared.layout.branding.EXTENSION_CLASS_DESCRIPTOR
import app.revanced.patches.shared.layout.branding.baseCustomBrandingPatch
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.getResourceId
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
@@ -34,11 +33,11 @@ private val disableSplashAnimationPatch = bytecodePatch {
// barely shown. Instead turn off the animation entirely (app will also launch a little faster).
cairoSplashAnimationConfigMethod.apply {
val literalIndex = indexOfFirstLiteralInstructionOrThrow(
getResourceId(ResourceType.LAYOUT, "main_activity_launch_animation")
ResourceType.LAYOUT["main_activity_launch_animation"],
)
val checkCastIndex = indexOfFirstInstructionOrThrow(literalIndex) {
opcode == Opcode.CHECK_CAST &&
getReference<TypeReference>()?.type == "Lcom/airbnb/lottie/LottieAnimationView;"
getReference<TypeReference>()?.type == "Lcom/airbnb/lottie/LottieAnimationView;"
}
val register = getInstruction<OneRegisterInstruction>(checkCastIndex).registerA
@@ -48,7 +47,7 @@ private val disableSplashAnimationPatch = bytecodePatch {
"""
invoke-static { v$register }, $EXTENSION_CLASS_DESCRIPTOR->getLottieViewOrNull(Landroid/view/View;)Landroid/view/View;
move-result-object v$register
"""
""",
)
}
}
@@ -73,8 +72,8 @@ val customBrandingPatch = baseCustomBrandingPatch(
compatibleWith(
"com.google.android.apps.youtube.music"(
"7.29.52",
"8.10.52"
)
"8.10.52",
),
)
}
},
)

View File

@@ -10,7 +10,6 @@ import app.revanced.patches.music.misc.extension.sharedExtensionPatch
import app.revanced.patches.music.misc.settings.PreferenceScreen
import app.revanced.patches.music.misc.settings.settingsPatch
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.getResourceId
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
import app.revanced.util.indexOfFirstInstructionOrThrow
@@ -35,28 +34,28 @@ private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/music/pa
@Suppress("unused")
val hideButtons = bytecodePatch(
name = "Hide buttons",
description = "Adds options to hide the cast, history, notification, and search buttons."
description = "Adds options to hide the cast, history, notification, and search buttons.",
) {
dependsOn(
sharedExtensionPatch,
settingsPatch,
addResourcesPatch,
resourceMappingPatch
resourceMappingPatch,
)
compatibleWith(
"com.google.android.apps.youtube.music"(
"7.29.52",
"8.10.52"
)
"8.10.52",
),
)
apply {
playerOverlayChip = getResourceId(ResourceType.ID, "player_overlay_chip")
historyMenuItem = getResourceId(ResourceType.ID, "history_menu_item")
offlineSettingsMenuItem = getResourceId(ResourceType.ID, "offline_settings_menu_item")
searchButton = getResourceId(ResourceType.LAYOUT, "search_button")
topBarMenuItemImageView = getResourceId(ResourceType.ID, "top_bar_menu_item_image_view")
playerOverlayChip = ResourceType.ID["player_overlay_chip"]
historyMenuItem = ResourceType.ID["history_menu_item"]
offlineSettingsMenuItem = ResourceType.ID["offline_settings_menu_item"]
searchButton = ResourceType.LAYOUT["search_button"]
topBarMenuItemImageView = ResourceType.ID["top_bar_menu_item_image_view"]
addResources("music", "layout.buttons.hideButtons")
@@ -64,13 +63,13 @@ val hideButtons = bytecodePatch(
SwitchPreference("revanced_music_hide_cast_button"),
SwitchPreference("revanced_music_hide_history_button"),
SwitchPreference("revanced_music_hide_notification_button"),
SwitchPreference("revanced_music_hide_search_button")
SwitchPreference("revanced_music_hide_search_button"),
)
// Region for hide history button in the top bar.
arrayOf(
historyMenuItemFingerprint,
historyMenuItemOfflineTabFingerprint
historyMenuItemOfflineTabFingerprint,
).forEach { fingerprint ->
fingerprint.method.apply {
val targetIndex = fingerprint.patternMatch.startIndex
@@ -81,7 +80,7 @@ val hideButtons = bytecodePatch(
"""
invoke-static { v$targetRegister }, $EXTENSION_CLASS_DESCRIPTOR->hideHistoryButton(Z)Z
move-result v$targetRegister
"""
""",
)
}
}
@@ -90,19 +89,20 @@ val hideButtons = bytecodePatch(
arrayOf(
Triple(playerOverlayChipFingerprint, playerOverlayChip, "hideCastButton"),
Triple(searchActionViewFingerprint, searchButton, "hideSearchButton"),
Triple(topBarMenuItemImageViewFingerprint, topBarMenuItemImageView, "hideNotificationButton")
Triple(topBarMenuItemImageViewFingerprint, topBarMenuItemImageView, "hideNotificationButton"),
).forEach { (fingerprint, resourceIdLiteral, methodName) ->
fingerprint.method.apply {
val resourceIndex = indexOfFirstLiteralInstructionOrThrow(resourceIdLiteral)
val targetIndex = indexOfFirstInstructionOrThrow(
resourceIndex, Opcode.MOVE_RESULT_OBJECT
resourceIndex,
Opcode.MOVE_RESULT_OBJECT,
)
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
addInstruction(
targetIndex + 1,
"invoke-static { v$targetRegister }, " +
"$EXTENSION_CLASS_DESCRIPTOR->$methodName(Landroid/view/View;)V"
"$EXTENSION_CLASS_DESCRIPTOR->$methodName(Landroid/view/View;)V",
)
}
}
@@ -115,7 +115,7 @@ val hideButtons = bytecodePatch(
"""
invoke-static { p1 }, $EXTENSION_CLASS_DESCRIPTOR->hideCastButton(I)I
move-result p1
"""
""",
)
}
}

View File

@@ -9,7 +9,6 @@ import app.revanced.patches.music.misc.extension.sharedExtensionPatch
import app.revanced.patches.music.misc.settings.PreferenceScreen
import app.revanced.patches.music.misc.settings.settingsPatch
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.getResourceId
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@@ -21,7 +20,7 @@ private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/music/pa
@Suppress("unused")
val hideCategoryBar = bytecodePatch(
name = "Hide category bar",
description = "Adds an option to hide the category bar at the top of the homepage."
description = "Adds an option to hide the category bar at the top of the homepage.",
) {
dependsOn(
sharedExtensionPatch,
@@ -32,8 +31,8 @@ val hideCategoryBar = bytecodePatch(
compatibleWith(
"com.google.android.apps.youtube.music"(
"7.29.52",
"8.10.52"
)
"8.10.52",
),
)
apply {
@@ -43,7 +42,7 @@ val hideCategoryBar = bytecodePatch(
SwitchPreference("revanced_music_hide_category_bar"),
)
chipCloud = getResourceId(ResourceType.LAYOUT, "chip_cloud")
chipCloud = ResourceType.LAYOUT["chip_cloud"]
chipCloudFingerprint.method.apply {
val targetIndex = chipCloudFingerprint.patternMatch.endIndex
@@ -51,7 +50,7 @@ val hideCategoryBar = bytecodePatch(
addInstruction(
targetIndex + 1,
"invoke-static { v$targetRegister }, $EXTENSION_CLASS_DESCRIPTOR->hideCategoryBar(Landroid/view/View;)V"
"invoke-static { v$targetRegister }, $EXTENSION_CLASS_DESCRIPTOR->hideCategoryBar(Landroid/view/View;)V",
)
}
}

View File

@@ -2,14 +2,13 @@ package app.revanced.patches.music.layout.miniplayercolor
import app.revanced.patcher.fingerprint
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.resourceLiteral
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
internal val miniPlayerConstructorFingerprint = fingerprint {
returns("V")
instructions(
resourceLiteral(ResourceType.ID, "mpp_player_bottom_sheet")
ResourceType.ID("mpp_player_bottom_sheet"),
)
strings("sharedToggleMenuItemMutations")
}
@@ -25,6 +24,6 @@ internal val switchToggleColorFingerprint = fingerprint {
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.CHECK_CAST,
Opcode.IGET
Opcode.IGET,
)
}

View File

@@ -11,7 +11,6 @@ import app.revanced.patches.music.misc.extension.sharedExtensionPatch
import app.revanced.patches.music.misc.settings.PreferenceScreen
import app.revanced.patches.music.misc.settings.settingsPatch
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.getResourceId
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPreference
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
@@ -30,7 +29,7 @@ private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/music/pa
@Suppress("unused")
val navigationBarPatch = bytecodePatch(
name = "Navigation bar",
description = "Adds options to hide navigation bar, labels and buttons."
description = "Adds options to hide navigation bar, labels and buttons.",
) {
dependsOn(
resourceMappingPatch,
@@ -52,18 +51,18 @@ val navigationBarPatch = bytecodePatch(
}
}
}
}
},
)
compatibleWith(
"com.google.android.apps.youtube.music"(
"7.29.52",
"8.10.52"
)
"8.10.52",
),
)
apply {
text1 = getResourceId(ResourceType.ID, "text1")
text1 = ResourceType.ID["text1"]
addResources("music", "layout.navigationbar.navigationBarPatch")
@@ -80,8 +79,8 @@ val navigationBarPatch = bytecodePatch(
SwitchPreference("revanced_music_hide_navigation_bar"),
SwitchPreference("revanced_music_hide_navigation_bar_labels"),
)
)
),
),
)
tabLayoutTextFingerprint.method.apply {
@@ -91,12 +90,13 @@ val navigationBarPatch = bytecodePatch(
val targetParameter = getInstruction<ReferenceInstruction>(targetIndex).reference
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
if (!targetParameter.toString().endsWith("Landroid/widget/TextView;"))
if (!targetParameter.toString().endsWith("Landroid/widget/TextView;")) {
throw PatchException("Method signature parameter did not match: $targetParameter")
}
addInstruction(
targetIndex + 1,
"invoke-static { v$targetRegister }, $EXTENSION_CLASS_DESCRIPTOR->hideNavigationLabel(Landroid/widget/TextView;)V"
"invoke-static { v$targetRegister }, $EXTENSION_CLASS_DESCRIPTOR->hideNavigationLabel(Landroid/widget/TextView;)V",
)
// Set navigation enum and hide navigation buttons.
@@ -109,12 +109,12 @@ val navigationBarPatch = bytecodePatch(
addInstruction(
pivotTabIndex,
"invoke-static { v$pivotTabRegister }, $EXTENSION_CLASS_DESCRIPTOR->hideNavigationButton(Landroid/view/View;)V"
"invoke-static { v$pivotTabRegister }, $EXTENSION_CLASS_DESCRIPTOR->hideNavigationButton(Landroid/view/View;)V",
)
addInstruction(
insertEnumIndex,
"invoke-static { v$enumRegister }, $EXTENSION_CLASS_DESCRIPTOR->setLastAppNavigationEnum(Ljava/lang/Enum;)V"
"invoke-static { v$enumRegister }, $EXTENSION_CLASS_DESCRIPTOR->setLastAppNavigationEnum(Ljava/lang/Enum;)V",
)
}
}

View File

@@ -2,12 +2,10 @@ package app.revanced.patches.shared.misc.mapping
import app.revanced.patcher.Predicate
import app.revanced.patcher.extensions.wideLiteral
import app.revanced.patcher.literal
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.resourcePatch
import com.android.tools.smali.dexlib2.iface.instruction.Instruction
import org.w3c.dom.Element
import java.util.*
enum class ResourceType(val value: String) {
ANIM("anim"),
@@ -37,9 +35,18 @@ enum class ResourceType(val value: String) {
XML("xml"),
;
val id = getResourceId(this, name)
operator fun invoke(name: String): Predicate<Instruction> {
val id = getResourceId(this, name)
operator fun invoke(name: String): Predicate<Instruction> = { wideLiteral == id }
return { wideLiteral == id }
}
/**
* @return A resource id of the given resource type and name.
* @throws PatchException if the resource is not found.
*/
operator fun get(name: String) = resourceMappings[value + name]?.id
?: throw PatchException("Could not find resource type: $this name: $name")
companion object {
private val VALUE_MAP: Map<String, ResourceType> = entries.associateBy { it.value }
@@ -53,10 +60,6 @@ data class ResourceElement(val type: ResourceType, val name: String, val id: Lon
private lateinit var resourceMappings: MutableMap<String, ResourceElement>
private fun setResourceId(type: ResourceType, name: String, id: Long) {
resourceMappings[type.value + name] = ResourceElement(type, name, id)
}
/**
* @return A resource id of the given resource type and name.
* @throws PatchException if the resource is not found.
@@ -64,36 +67,14 @@ private fun setResourceId(type: ResourceType, name: String, id: Long) {
fun getResourceId(type: ResourceType, name: String) = resourceMappings[type.value + name]?.id
?: throw PatchException("Could not find resource type: $type name: $name")
/**
* @return All resource elements. If a single resource id is needed instead use [getResourceId].
*/
fun getResourceElements() = Collections.unmodifiableCollection(resourceMappings.values)
/**
* @return If the resource exists.
*/
fun hasResourceId(type: ResourceType, name: String) = resourceMappings[type.value + name] != null
/**
* Identical to [LiteralFilter] except uses a decoded resource literal value.
*
* Any patch with fingerprints of this filter must
* also declare [resourceMappingPatch] as a dependency.
*/
fun resourceLiteral(
type: ResourceType,
name: String,
location: InstructionLocation = InstructionLocation.MatchAfterAnywhere(),
) = literal({ getResourceId(type, name) }, null, location)
val resourceMappingPatch = resourcePatch {
apply {
// Use a stream of the file, since no modifications are done
// and using a File parameter causes the file to be re-wrote when closed.
// and using a File parameter causes the file to be re-written when closed.
document(get("res/values/public.xml").inputStream()).use { document ->
val resources = document.documentElement.childNodes
val resourcesLength = resources.length
resourceMappings = HashMap<String, ResourceElement>(2 * resourcesLength)
resourceMappings = HashMap(2 * resourcesLength)
for (i in 0 until resourcesLength) {
val node = resources.item(i) as? Element ?: continue
@@ -105,7 +86,9 @@ val resourceMappingPatch = resourcePatch {
val typeAttribute = node.getAttribute("type")
val id = node.getAttribute("id").substring(2).toLong(16)
setResourceId(ResourceType.fromValue(typeAttribute), nameAttribute, id)
val type = ResourceType.fromValue(typeAttribute)
resourceMappings[type.value + nameAttribute] = ResourceElement(type, nameAttribute, id)
}
}
}

View File

@@ -10,7 +10,6 @@ import app.revanced.patches.all.misc.resources.addResources
import app.revanced.patches.all.misc.resources.addResourcesPatch
import app.revanced.patches.shared.misc.fix.verticalscroll.verticalScrollPatch
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.getResourceId
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
import app.revanced.patches.youtube.ad.getpremium.hideGetPremiumPatch
@@ -57,8 +56,8 @@ private val hideAdsResourcePatch = resourcePatch {
addLithoFilter("Lapp/revanced/extension/youtube/patches/components/AdsFilter;")
adAttributionId = getResourceId(ResourceType.ID, "ad_attribution")
fullScreenEngagementAdContainer = getResourceId(ResourceType.ID, "fullscreen_engagement_ad_container")
adAttributionId = ResourceType.ID["ad_attribution"]
fullScreenEngagementAdContainer = ResourceType.ID["fullscreen_engagement_ad_container"]
}
}
@@ -80,7 +79,7 @@ val hideAdsPatch = bytecodePatch(
"20.14.43",
"20.21.37",
"20.31.40",
)
),
)
apply {
@@ -95,7 +94,7 @@ val hideAdsPatch = bytecodePatch(
replaceInstruction(
addListIndex,
"invoke-static { v$listRegister, v$objectRegister }, $EXTENSION_CLASS_DESCRIPTOR" +
"->hideEndScreenStoreBanner(Ljava/util/List;Ljava/lang/Object;)V"
"->hideEndScreenStoreBanner(Ljava/util/List;Ljava/lang/Object;)V",
)
}
@@ -105,7 +104,6 @@ val hideAdsPatch = bytecodePatch(
if (instruction.opcode != Opcode.CONST) return@forEachInstructionAsSequence
if (instruction.wideLiteral != adAttributionId) return@forEachInstructionAsSequence
val insertIndex = index + 1
// Call to get the view with the id adAttribution,

View File

@@ -12,7 +12,6 @@ import app.revanced.patches.all.misc.resources.addResources
import app.revanced.patches.all.misc.resources.addResourcesPatch
import app.revanced.patches.shared.layout.branding.addBrandLicensePatch
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.getResourceId
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
import app.revanced.patches.shared.misc.settings.preference.ListPreference
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
@@ -30,7 +29,7 @@ private val targetResourceDirectoryNames = mapOf(
"drawable-hdpi" to "194x72 px",
"drawable-xhdpi" to "258x96 px",
"drawable-xxhdpi" to "387x144 px",
"drawable-xxxhdpi" to "512x192 px"
"drawable-xxxhdpi" to "512x192 px",
)
/**
@@ -58,25 +57,25 @@ private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/
private val changeHeaderBytecodePatch = bytecodePatch {
dependsOn(
resourceMappingPatch,
addBrandLicensePatch
addBrandLicensePatch,
)
apply {
// Verify images exist. Resources are not used during patching but extension code does.
arrayOf(
"yt_ringo2_wordmark_header",
"yt_ringo2_premium_wordmark_header"
"yt_ringo2_premium_wordmark_header",
).forEach { resource ->
variants.forEach { theme ->
getResourceId(ResourceType.DRAWABLE, resource + "_" + theme)
ResourceType.DRAWABLE[resource + "_" + theme]
}
}
arrayOf(
"ytWordmarkHeader",
"ytPremiumWordmarkHeader"
"ytPremiumWordmarkHeader",
).forEach { resourceName ->
val id = getResourceId(ResourceType.ATTR, resourceName)
val id = ResourceType.ATTR[resourceName]
forEachInstructionAsSequence { _, method, i, instruction ->
if (instruction.wideLiteral != id) return@forEachInstructionAsSequence
@@ -87,7 +86,7 @@ private val changeHeaderBytecodePatch = bytecodePatch {
"""
invoke-static { v$register }, $EXTENSION_CLASS_DESCRIPTOR->getHeaderAttributeId(I)I
move-result v$register
"""
""",
)
}
}
@@ -107,7 +106,7 @@ val changeHeaderPatch = resourcePatch(
"20.14.43",
"20.21.37",
"20.31.40",
)
),
)
val custom by stringOption(
@@ -123,7 +122,7 @@ val changeHeaderPatch = resourcePatch(
The image dimensions must be as follows:
${targetResourceDirectoryNames.map { (dpi, dim) -> "- $dpi: $dim" }.joinToString("\n")}
""".trimIndentMultiline()
""".trimIndentMultiline(),
)
apply {
@@ -136,9 +135,9 @@ val changeHeaderPatch = resourcePatch(
ListPreference(
key = "revanced_header_logo",
entriesKey = "revanced_header_logo_custom_entries",
entryValuesKey = "revanced_header_logo_custom_entry_values"
entryValuesKey = "revanced_header_logo_custom_entry_values",
)
}
},
)
logoResourceNames.forEach { logo ->
@@ -147,8 +146,8 @@ val changeHeaderPatch = resourcePatch(
"change-header",
ResourceGroup(
"drawable",
logo + "_" + variant + ".xml"
)
logo + "_" + variant + ".xml",
),
)
}
}
@@ -161,8 +160,8 @@ val changeHeaderPatch = resourcePatch(
"change-header",
ResourceGroup(
dpi,
*customHeaderResourceFileNames
)
*customHeaderResourceFileNames,
),
)
}
}
@@ -191,10 +190,11 @@ val changeHeaderPatch = resourcePatch(
"Base.Theme.YouTube.Light" to "light",
"Base.Theme.YouTube.Dark" to "dark",
"CairoLightThemeRingo2Updates" to "light",
"CairoDarkThemeRingo2Updates" to "dark"
"CairoDarkThemeRingo2Updates" to "dark",
).forEach { (style, mode) ->
val styleElement = document.childNodes.findElementByAttributeValueOrThrow(
"name", style
"name",
style,
)
fun addDrawableElement(document: Document, logoName: String, mode: String) {
@@ -218,14 +218,14 @@ val changeHeaderPatch = resourcePatch(
if (!customFile.exists()) {
throw PatchException(
"The custom header path cannot be found: " +
customFile.absolutePath
customFile.absolutePath,
)
}
if (!customFile.isDirectory) {
throw PatchException(
"The custom header path must be a folder: "
+ customFile.absolutePath
"The custom header path must be a folder: " +
customFile.absolutePath,
)
}
@@ -248,7 +248,8 @@ val changeHeaderPatch = resourcePatch(
if (customFiles.isNotEmpty() && customFiles.size != variants.size) {
throw PatchException(
"Both light/dark mode images " +
"must be specified but only found: " + customFiles.map { it.name })
"must be specified but only found: " + customFiles.map { it.name },
)
}
customFiles.forEach { imgSourceFile ->
@@ -261,9 +262,9 @@ val changeHeaderPatch = resourcePatch(
if (!copiedFiles) {
throw PatchException(
"Expected to find directories and files: "
+ customHeaderResourceFileNames.contentToString()
+ "\nBut none were found in the provided option file path: " + customFile.absolutePath
"Expected to find directories and files: " +
customHeaderResourceFileNames.contentToString() +
"\nBut none were found in the provided option file path: " + customFile.absolutePath,
)
}
}

View File

@@ -4,7 +4,6 @@ import app.revanced.patcher.fingerprint
import app.revanced.patcher.literal
import app.revanced.patcher.methodCall
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.resourceLiteral
import com.android.tools.smali.dexlib2.AccessFlags
internal val mediaRouteButtonFingerprint = fingerprint {
@@ -17,14 +16,14 @@ internal val mediaRouteButtonFingerprint = fingerprint {
internal val castButtonPlayerFeatureFlagFingerprint = fingerprint {
returns("Z")
instructions(
literal(45690091)
literal(45690091),
)
}
internal val castButtonActionFeatureFlagFingerprint = fingerprint {
returns("Z")
instructions(
literal(45690090)
literal(45690090),
)
}
@@ -33,7 +32,7 @@ internal val inflateControlsGroupLayoutStubFingerprint = fingerprint {
parameters()
returns("V")
instructions(
resourceLiteral(ResourceType.ID, "youtube_controls_button_group_layout_stub"),
methodCall(name = "inflate")
ResourceType.ID("youtube_controls_button_group_layout_stub"),
methodCall(name = "inflate"),
)
}

View File

@@ -8,7 +8,6 @@ import app.revanced.patcher.patch.resourcePatch
import app.revanced.patches.all.misc.resources.addResources
import app.revanced.patches.all.misc.resources.addResourcesPatch
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.getResourceId
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
@@ -39,7 +38,7 @@ private val hideEndScreenCardsResourcePatch = resourcePatch {
SwitchPreference("revanced_hide_endscreen_cards"),
)
fun idOf(name: String) = getResourceId(ResourceType.LAYOUT, "endscreen_element_layout_$name")
fun idOf(name: String) = ResourceType.LAYOUT["endscreen_element_layout_$name"]
layoutCircle = idOf("circle")
layoutIcon = idOf("icon")
@@ -58,7 +57,7 @@ val hideEndScreenCardsPatch = bytecodePatch(
dependsOn(
sharedExtensionPatch,
hideEndScreenCardsResourcePatch,
versionCheckPatch
versionCheckPatch,
)
compatibleWith(
@@ -67,7 +66,7 @@ val hideEndScreenCardsPatch = bytecodePatch(
"20.14.43",
"20.21.37",
"20.31.40",
)
),
)
apply {
@@ -83,7 +82,7 @@ val hideEndScreenCardsPatch = bytecodePatch(
addInstruction(
insertIndex,
"invoke-static { v$viewRegister }, " +
"$EXTENSION_CLASS_DESCRIPTOR->hideEndScreenCardView(Landroid/view/View;)V",
"$EXTENSION_CLASS_DESCRIPTOR->hideEndScreenCardView(Landroid/view/View;)V",
)
}
}
@@ -98,7 +97,7 @@ val hideEndScreenCardsPatch = bytecodePatch(
return-void
:show
nop
"""
""",
)
}
}

View File

@@ -2,13 +2,12 @@ package app.revanced.patches.youtube.layout.hide.general
import app.revanced.patcher.InstructionLocation.*
import app.revanced.patcher.StringComparisonType
import app.revanced.patcher.addString
import app.revanced.patcher.checkCast
import app.revanced.patcher.fingerprint
import app.revanced.patcher.methodCall
import app.revanced.patcher.opcode
import app.revanced.patcher.addString
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.resourceLiteral
import app.revanced.patches.youtube.layout.searchbar.wideSearchbarLayoutFingerprint
import app.revanced.util.literal
import com.android.tools.smali.dexlib2.AccessFlags
@@ -22,18 +21,18 @@ internal val hideShowMoreButtonFingerprint = fingerprint {
returns("V")
parameters("L", "Ljava/lang/Object;")
instructions(
resourceLiteral(ResourceType.LAYOUT, "expand_button_down"),
ResourceType.LAYOUT("expand_button_down"),
methodCall(smali = "Landroid/view/LayoutInflater;->inflate(ILandroid/view/ViewGroup;Z)Landroid/view/View;"),
opcode(Opcode.MOVE_RESULT_OBJECT, location = MatchAfterImmediately())
opcode(Opcode.MOVE_RESULT_OBJECT, location = MatchAfterImmediately()),
)
}
internal val hideShowMoreLegacyButtonFingerprint = fingerprint {
accessFlags(AccessFlags.PUBLIC, AccessFlags.CONSTRUCTOR)
instructions(
resourceLiteral(ResourceType.LAYOUT, "expand_button_down"),
ResourceType.LAYOUT("expand_button_down"),
methodCall(smali = "Landroid/view/View;->inflate(Landroid/content/Context;ILandroid/view/ViewGroup;)Landroid/view/View;"),
opcode(Opcode.MOVE_RESULT_OBJECT)
opcode(Opcode.MOVE_RESULT_OBJECT),
)
}
@@ -45,7 +44,7 @@ internal val parseElementFromBufferFingerprint = fingerprint {
opcode(Opcode.INVOKE_INTERFACE, location = MatchAfterWithin(1)),
opcode(Opcode.MOVE_RESULT_OBJECT, location = MatchAfterImmediately()),
addString("Failed to parse Element", comparison = StringComparisonType.STARTS_WITH)
addString("Failed to parse Element", comparison = StringComparisonType.STARTS_WITH),
)
}
@@ -53,7 +52,7 @@ internal val playerOverlayFingerprint = fingerprint {
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
returns("L")
instructions(
addString("player_overlay_in_video_programming")
addString("player_overlay_in_video_programming"),
)
}
@@ -71,7 +70,7 @@ internal val yoodlesImageViewFingerprint = fingerprint {
returns("Landroid/view/View;")
parameters("L", "L")
instructions(
resourceLiteral(ResourceType.ID, "youtube_logo")
ResourceType.ID("youtube_logo"),
)
}
@@ -136,9 +135,9 @@ internal val showFloatingMicrophoneButtonFingerprint = fingerprint {
returns("V")
parameters()
instructions(
resourceLiteral(ResourceType.ID, "fab"),
ResourceType.ID("fab"),
checkCast("/FloatingActionButton;", location = MatchAfterWithin(10)),
opcode(Opcode.IGET_BOOLEAN, location = MatchAfterWithin(15))
opcode(Opcode.IGET_BOOLEAN, location = MatchAfterWithin(15)),
)
}
@@ -154,4 +153,4 @@ internal val hideViewCountFingerprint = fingerprint {
strings(
"Has attachmentRuns but drawableRequester is missing.",
)
}
}

View File

@@ -8,7 +8,6 @@ import app.revanced.patcher.patch.resourcePatch
import app.revanced.patches.all.misc.resources.addResources
import app.revanced.patches.all.misc.resources.addResourcesPatch
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.getResourceId
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
import app.revanced.patches.shared.misc.settings.preference.*
import app.revanced.patches.youtube.misc.litho.filter.addLithoFilter
@@ -94,7 +93,7 @@ val hideLayoutComponentsPatch = bytecodePatch(
hideLayoutComponentsResourcePatch,
navigationBarHookPatch,
versionCheckPatch,
resourceMappingPatch
resourceMappingPatch,
)
compatibleWith(
@@ -103,7 +102,7 @@ val hideLayoutComponentsPatch = bytecodePatch(
"20.14.43",
"20.21.37",
"20.31.40",
)
),
)
apply {
@@ -168,7 +167,7 @@ val hideLayoutComponentsPatch = bytecodePatch(
TextPreference("revanced_hide_keyword_content_phrases", inputType = InputType.TEXT_MULTI_LINE),
NonInteractivePreference(
key = "revanced_hide_keyword_content_about",
tag = "app.revanced.extension.shared.settings.preference.BulletPointPreference"
tag = "app.revanced.extension.shared.settings.preference.BulletPointPreference",
),
NonInteractivePreference(
key = "revanced_hide_keyword_content_about_whole_words",
@@ -206,7 +205,7 @@ val hideLayoutComponentsPatch = bytecodePatch(
SwitchPreference("revanced_hide_floating_microphone_button"),
SwitchPreference(
key = "revanced_hide_horizontal_shelves",
tag = "app.revanced.extension.shared.settings.preference.BulletPointSwitchPreference"
tag = "app.revanced.extension.shared.settings.preference.BulletPointSwitchPreference",
),
SwitchPreference("revanced_hide_image_shelf"),
SwitchPreference("revanced_hide_latest_posts"),
@@ -300,7 +299,7 @@ val hideLayoutComponentsPatch = bytecodePatch(
addInstruction(
insertIndex,
"invoke-static { v$viewRegister }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR" +
"->hideShowMoreButton(Landroid/view/View;)V",
"->hideShowMoreButton(Landroid/view/View;)V",
)
}
}
@@ -372,14 +371,13 @@ val hideLayoutComponentsPatch = bytecodePatch(
replaceInstruction(
insertIndex,
"invoke-static { v$imageViewRegister, v$drawableRegister }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->" +
"setDoodleDrawable(Landroid/widget/ImageView;Landroid/graphics/drawable/Drawable;)V"
"setDoodleDrawable(Landroid/widget/ImageView;Landroid/graphics/drawable/Drawable;)V",
)
}
}
// endregion
// region hide view count
hideViewCountFingerprint.method.apply {
@@ -390,15 +388,15 @@ val hideLayoutComponentsPatch = bytecodePatch(
val applyDimensionIndex = indexOfFirstInstructionReversedOrThrow {
val reference = getReference<MethodReference>()
opcode == Opcode.INVOKE_STATIC &&
reference?.definingClass == "Landroid/util/TypedValue;" &&
reference.returnType == "F" &&
reference.name == "applyDimension" &&
reference.parameterTypes == listOf("I", "F", "Landroid/util/DisplayMetrics;")
reference?.definingClass == "Landroid/util/TypedValue;" &&
reference.returnType == "F" &&
reference.name == "applyDimension" &&
reference.parameterTypes == listOf("I", "F", "Landroid/util/DisplayMetrics;")
}
// A float value is passed which is used to determine subtitle text size.
val floatDimensionRegister = getInstruction<OneRegisterInstruction>(
applyDimensionIndex + 1
applyDimensionIndex + 1,
).registerA
addInstructions(
@@ -406,7 +404,7 @@ val hideLayoutComponentsPatch = bytecodePatch(
"""
invoke-static { v$returnStringRegister, v$floatDimensionRegister }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->modifyFeedSubtitleSpan(Landroid/text/SpannableString;F)Landroid/text/SpannableString;
move-result-object v$returnStringRegister
"""
""",
)
}

View File

@@ -1,15 +1,14 @@
package app.revanced.patches.youtube.layout.hide.infocards
import app.revanced.patcher.extensions.ExternalLabel
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patcher.patch.resourcePatch
import app.revanced.patcher.extensions.ExternalLabel
import app.revanced.patches.all.misc.resources.addResources
import app.revanced.patches.all.misc.resources.addResourcesPatch
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.getResourceId
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
@@ -54,7 +53,7 @@ val hideInfoCardsPatch = bytecodePatch(
"20.14.43",
"20.21.37",
"20.31.40",
)
),
)
apply {
@@ -94,7 +93,7 @@ val hideInfoCardsPatch = bytecodePatch(
ExternalLabel(
"hide_info_cards",
getInstruction(invokeInterfaceIndex + 1),
)
),
)
}
}

View File

@@ -2,12 +2,11 @@ package app.revanced.patches.youtube.layout.hide.relatedvideooverlay
import app.revanced.patcher.fingerprint
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.resourceLiteral
internal val relatedEndScreenResultsParentFingerprint = fingerprint {
returns("V")
instructions(
resourceLiteral(ResourceType.LAYOUT, "app_related_endscreen_results")
ResourceType.LAYOUT("app_related_endscreen_results"),
)
}

View File

@@ -1,13 +1,12 @@
package app.revanced.patches.youtube.layout.hide.shorts
import app.revanced.patcher.InstructionLocation.*
import app.revanced.patcher.addString
import app.revanced.patcher.fingerprint
import app.revanced.patcher.literal
import app.revanced.patcher.methodCall
import app.revanced.patcher.opcode
import app.revanced.patcher.addString
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.resourceLiteral
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
@@ -17,9 +16,9 @@ internal val shortsBottomBarContainerFingerprint = fingerprint {
parameters("Landroid/view/View;", "Landroid/os/Bundle;")
instructions(
addString("r_pfvc"),
resourceLiteral(ResourceType.ID, "bottom_bar_container"),
ResourceType.ID("bottom_bar_container"),
methodCall(name = "getHeight"),
opcode(Opcode.MOVE_RESULT)
opcode(Opcode.MOVE_RESULT),
)
}
@@ -57,7 +56,7 @@ internal val legacyRenderBottomNavigationBarLegacyParentFingerprint = fingerprin
"L",
)
instructions(
addString("aa")
addString("aa"),
)
}
@@ -77,7 +76,7 @@ internal val renderBottomNavigationBarLegacy1941ParentFingerprint = fingerprint
"L",
)
instructions(
addString("aa")
addString("aa"),
)
}
@@ -87,10 +86,10 @@ internal val renderBottomNavigationBarParentFingerprint = fingerprint {
parameters(
"Ljava/lang/Class;",
"Ljava/lang/Object;",
"I"
"I",
)
instructions(
addString("RPCAC")
addString("RPCAC"),
)
}
@@ -107,7 +106,7 @@ internal val setPivotBarVisibilityFingerprint = fingerprint {
internal val setPivotBarVisibilityParentFingerprint = fingerprint {
parameters("Z")
instructions(
addString("FEnotifications_inbox")
addString("FEnotifications_inbox"),
)
}
@@ -116,7 +115,7 @@ internal val shortsExperimentalPlayerFeatureFlagFingerprint = fingerprint {
returns("Z")
parameters()
instructions(
literal(45677719L)
literal(45677719L),
)
}
@@ -125,6 +124,6 @@ internal val renderNextUIFeatureFlagFingerprint = fingerprint {
returns("Z")
parameters()
instructions(
literal(45649743L)
literal(45649743L),
)
}

View File

@@ -10,7 +10,6 @@ import app.revanced.patcher.patch.resourcePatch
import app.revanced.patches.all.misc.resources.addResources
import app.revanced.patches.all.misc.resources.addResourcesPatch
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.getResourceId
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPreference
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
@@ -66,9 +65,9 @@ private val hideShortsComponentsResourcePatch = resourcePatch {
// FIXME: The buffer is very different for 20.22+ and these current cannot be hidden.
Logger.getLogger(this::class.java.name).warning(
"\n!!!" +
"\n!!! Shorts action buttons currently cannot be set hidden when patching 20.22+" +
"\n!!! Patch 20.21.37 or lower if you want to hide Shorts action buttons" +
"\n!!!"
"\n!!! Shorts action buttons currently cannot be set hidden when patching 20.22+" +
"\n!!! Patch 20.21.37 or lower if you want to hide Shorts action buttons" +
"\n!!!",
)
} else {
preferences.addAll(
@@ -76,8 +75,8 @@ private val hideShortsComponentsResourcePatch = resourcePatch {
SwitchPreference("revanced_hide_shorts_comments_button"),
SwitchPreference("revanced_hide_shorts_share_button"),
SwitchPreference("revanced_hide_shorts_remix_button"),
SwitchPreference("revanced_hide_shorts_sound_button")
)
SwitchPreference("revanced_hide_shorts_sound_button"),
),
)
}
@@ -97,7 +96,7 @@ private val hideShortsComponentsResourcePatch = resourcePatch {
SwitchPreference("revanced_hide_shorts_effect_button"),
SwitchPreference("revanced_hide_shorts_green_screen_button"),
SwitchPreference("revanced_hide_shorts_hashtag_button"),
SwitchPreference("revanced_hide_shorts_live_preview"),SwitchPreference("revanced_hide_shorts_new_posts_button"),
SwitchPreference("revanced_hide_shorts_live_preview"), SwitchPreference("revanced_hide_shorts_new_posts_button"),
SwitchPreference("revanced_hide_shorts_shop_button"),
SwitchPreference("revanced_hide_shorts_tagged_products"),
SwitchPreference("revanced_hide_shorts_search_suggestions"),
@@ -105,14 +104,14 @@ private val hideShortsComponentsResourcePatch = resourcePatch {
SwitchPreference("revanced_hide_shorts_stickers"),
// Bottom of the screen.
SwitchPreference("revanced_hide_shorts_auto_dubbed_label"),SwitchPreference("revanced_hide_shorts_location_label"),
SwitchPreference("revanced_hide_shorts_auto_dubbed_label"), SwitchPreference("revanced_hide_shorts_location_label"),
SwitchPreference("revanced_hide_shorts_channel_bar"),
SwitchPreference("revanced_hide_shorts_info_panel"),
SwitchPreference("revanced_hide_shorts_full_video_link_label"),
SwitchPreference("revanced_hide_shorts_video_title"),
SwitchPreference("revanced_hide_shorts_sound_metadata_label"),
SwitchPreference("revanced_hide_shorts_navigation_bar"),
)
),
)
PreferenceScreen.SHORTS.addPreferences(
@@ -125,7 +124,7 @@ private val hideShortsComponentsResourcePatch = resourcePatch {
key = "revanced_shorts_player_screen",
sorting = PreferenceScreenPreference.Sorting.UNSORTED,
preferences = preferences,
)
),
)
// Verify the file has the expected node, even if the patch option is off.
@@ -175,7 +174,7 @@ val hideShortsComponentsPatch = bytecodePatch(
"20.14.43",
"20.21.37",
// 20.22+ does not yet support hiding Shorts action buttons.
)
),
)
hideShortsAppShortcutOption()
@@ -184,7 +183,7 @@ val hideShortsComponentsPatch = bytecodePatch(
apply {
addLithoFilter(FILTER_CLASS_DESCRIPTOR)
val id = getResourceId(ResourceType.DIMEN, "reel_player_right_pivot_v2_size")
val id = ResourceType.DIMEN["reel_player_right_pivot_v2_size"]
forEachInstructionAsSequence { _, method, i, instruction ->
if (instruction.wideLiteral != id) return@forEachInstructionAsSequence
@@ -200,11 +199,10 @@ val hideShortsComponentsPatch = bytecodePatch(
"""
invoke-static { v$sizeRegister }, $FILTER_CLASS_DESCRIPTOR->getSoundButtonSize(I)I
move-result v$sizeRegister
"""
""",
)
}
// endregion
// region Hide the navigation bar.
@@ -219,20 +217,22 @@ val hideShortsComponentsPatch = bytecodePatch(
addInstruction(
insertIndex,
"invoke-static {v$viewRegister}," +
" $FILTER_CLASS_DESCRIPTOR->setNavigationBar(Lcom/google/android/libraries/youtube/rendering/ui/pivotbar/PivotBar;)V",
" $FILTER_CLASS_DESCRIPTOR->setNavigationBar(Lcom/google/android/libraries/youtube/rendering/ui/pivotbar/PivotBar;)V",
)
}
}
// Hook to hide the shared navigation bar when the Shorts player is opened.
renderBottomNavigationBarFingerprint.match(
(if (is_20_45_or_greater) {
renderBottomNavigationBarParentFingerprint
} else if (is_19_41_or_greater) {
renderBottomNavigationBarLegacy1941ParentFingerprint
} else {
legacyRenderBottomNavigationBarLegacyParentFingerprint
}).originalClassDef
(
if (is_20_45_or_greater) {
renderBottomNavigationBarParentFingerprint
} else if (is_19_41_or_greater) {
renderBottomNavigationBarLegacy1941ParentFingerprint
} else {
legacyRenderBottomNavigationBarLegacyParentFingerprint
}
).originalClassDef,
).method.addInstruction(
0,
"invoke-static { p1 }, $FILTER_CLASS_DESCRIPTOR->hideNavigationBar(Ljava/lang/String;)V",
@@ -249,14 +249,13 @@ val hideShortsComponentsPatch = bytecodePatch(
"""
invoke-static { v$heightRegister }, $FILTER_CLASS_DESCRIPTOR->getNavigationBarHeight(I)I
move-result v$heightRegister
"""
""",
)
}
}
// endregion
// region Disable experimental Shorts flags.
// Flags might be present in earlier targets, but they are not found in 19.47.53.

View File

@@ -2,7 +2,6 @@ package app.revanced.patches.youtube.layout.hide.signintotvpopup
import app.revanced.patcher.fingerprint
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.resourceLiteral
internal val signInToTvPopupFingerprint = fingerprint {
returns("Z")
@@ -10,7 +9,7 @@ internal val signInToTvPopupFingerprint = fingerprint {
instructions(
resourceLiteral(
ResourceType.STRING,
"mdx_seamless_tv_sign_in_drawer_fragment_title"
)
"mdx_seamless_tv_sign_in_drawer_fragment_title",
),
)
}
}

View File

@@ -3,18 +3,18 @@
package app.revanced.patches.youtube.layout.miniplayer
import app.revanced.patcher.InstructionLocation.MatchAfterWithin
import app.revanced.patcher.addString
import app.revanced.patcher.checkCast
import app.revanced.patcher.fingerprint
import app.revanced.patcher.literal
import app.revanced.patcher.methodCall
import app.revanced.patcher.opcode
import app.revanced.patcher.addString
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.resourceLiteral
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
internal const val MINIPLAYER_MODERN_FEATURE_KEY = 45622882L
// In later targets this feature flag does nothing and is dead code.
internal const val MINIPLAYER_MODERN_FEATURE_LEGACY_KEY = 45630429L
internal const val MINIPLAYER_DOUBLE_TAP_FEATURE_KEY = 45628823L
@@ -28,7 +28,7 @@ internal const val MINIPLAYER_ANIMATED_EXPAND_FEATURE_KEY = 45644360L
internal val miniplayerModernConstructorFingerprint = fingerprint {
accessFlags(AccessFlags.PUBLIC, AccessFlags.CONSTRUCTOR)
instructions(
literal(45623000L) // Magic number found in the constructor.
literal(45623000L), // Magic number found in the constructor.
)
}
@@ -37,7 +37,7 @@ internal val miniplayerDimensionsCalculatorParentFingerprint = fingerprint {
returns("V")
parameters("L")
instructions(
resourceLiteral(ResourceType.DIMEN, "floaty_bar_button_top_margin")
ResourceType.DIMEN("floaty_bar_button_top_margin"),
)
}
@@ -46,7 +46,7 @@ internal val miniplayerModernViewParentFingerprint = fingerprint {
returns("Ljava/lang/String;")
parameters()
instructions(
addString("player_overlay_modern_mini_player_controls")
addString("player_overlay_modern_mini_player_controls"),
)
}
@@ -67,8 +67,8 @@ internal val miniplayerModernCloseButtonFingerprint = fingerprint {
returns("L")
parameters()
instructions(
resourceLiteral(ResourceType.ID, "modern_miniplayer_close"),
checkCast("Landroid/widget/ImageView;")
ResourceType.ID("modern_miniplayer_close"),
checkCast("Landroid/widget/ImageView;"),
)
}
@@ -80,8 +80,8 @@ internal val miniplayerModernExpandButtonFingerprint = fingerprint {
returns("L")
parameters()
instructions(
resourceLiteral(ResourceType.ID, "modern_miniplayer_expand"),
checkCast("Landroid/widget/ImageView;")
ResourceType.ID("modern_miniplayer_expand"),
checkCast("Landroid/widget/ImageView;"),
)
}
@@ -93,7 +93,7 @@ internal val miniplayerModernExpandCloseDrawablesFingerprint = fingerprint {
returns("V")
parameters("L")
instructions(
literal(ytOutlinePictureInPictureWhite24)
literal(ytOutlinePictureInPictureWhite24),
)
}
@@ -105,8 +105,8 @@ internal val miniplayerModernForwardButtonFingerprint = fingerprint {
returns("L")
parameters()
instructions(
resourceLiteral(ResourceType.ID, "modern_miniplayer_forward_button"),
opcode(Opcode.MOVE_RESULT_OBJECT, MatchAfterWithin(5))
ResourceType.ID("modern_miniplayer_forward_button"),
opcode(Opcode.MOVE_RESULT_OBJECT, MatchAfterWithin(5)),
)
}
@@ -114,8 +114,8 @@ internal val miniplayerModernOverlayViewFingerprint = fingerprint {
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
parameters()
instructions(
resourceLiteral(ResourceType.ID, "scrim_overlay"),
opcode(Opcode.MOVE_RESULT_OBJECT, MatchAfterWithin(5))
ResourceType.ID("scrim_overlay"),
opcode(Opcode.MOVE_RESULT_OBJECT, MatchAfterWithin(5)),
)
}
@@ -127,8 +127,8 @@ internal val miniplayerModernRewindButtonFingerprint = fingerprint {
returns("L")
parameters()
instructions(
resourceLiteral(ResourceType.ID, "modern_miniplayer_rewind_button"),
opcode(Opcode.MOVE_RESULT_OBJECT, MatchAfterWithin(5))
ResourceType.ID("modern_miniplayer_rewind_button"),
opcode(Opcode.MOVE_RESULT_OBJECT, MatchAfterWithin(5)),
)
}
@@ -140,17 +140,17 @@ internal val miniplayerModernActionButtonFingerprint = fingerprint {
returns("L")
parameters()
instructions(
resourceLiteral(ResourceType.ID, "modern_miniplayer_overlay_action_button"),
opcode(Opcode.MOVE_RESULT_OBJECT, MatchAfterWithin(5))
ResourceType.ID("modern_miniplayer_overlay_action_button"),
opcode(Opcode.MOVE_RESULT_OBJECT, MatchAfterWithin(5)),
)
}
internal val miniplayerMinimumSizeFingerprint = fingerprint {
accessFlags(AccessFlags.PUBLIC, AccessFlags.CONSTRUCTOR)
instructions(
resourceLiteral(ResourceType.DIMEN, "miniplayer_max_size"),
ResourceType.DIMEN("miniplayer_max_size"),
literal(192), // Default miniplayer width constant.
literal(128) // Default miniplayer height constant.
literal(128), // Default miniplayer height constant.
)
}
@@ -162,8 +162,8 @@ internal val miniplayerOverrideFingerprint = fingerprint {
methodCall(
parameters = listOf("Landroid/content/Context;"),
returnType = "Z",
location = MatchAfterWithin(10)
)
location = MatchAfterWithin(10),
),
)
}
@@ -171,7 +171,7 @@ internal val miniplayerOverrideNoContextFingerprint = fingerprint {
accessFlags(AccessFlags.PRIVATE, AccessFlags.FINAL)
returns("Z")
instructions(
opcode(Opcode.IGET_BOOLEAN) // Anchor to insert the instruction.
opcode(Opcode.IGET_BOOLEAN), // Anchor to insert the instruction.
)
}
@@ -196,7 +196,7 @@ internal val miniplayerOnCloseHandlerFingerprint = fingerprint {
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
returns("Z")
instructions(
literal(MINIPLAYER_DISABLED_FEATURE_KEY)
literal(MINIPLAYER_DISABLED_FEATURE_KEY),
)
}
@@ -213,7 +213,7 @@ internal val miniplayerSetIconsFingerprint = fingerprint {
returns("V")
parameters("I", "Ljava/lang/Runnable;")
instructions(
resourceLiteral(ResourceType.DRAWABLE, "yt_fill_pause_white_36"),
resourceLiteral(ResourceType.DRAWABLE, "yt_fill_pause_black_36")
ResourceType.DRAWABLE("yt_fill_pause_white_36"),
ResourceType.DRAWABLE("yt_fill_pause_black_36"),
)
}

View File

@@ -9,12 +9,9 @@ import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.replaceInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patcher.patch.resourcePatch
import com.android.tools.smali.dexlib2.mutable.MutableMethod
import com.android.tools.smali.dexlib2.mutable.MutableMethod.Companion.toMutable
import app.revanced.patches.all.misc.resources.addResources
import app.revanced.patches.all.misc.resources.addResourcesPatch
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.getResourceId
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
import app.revanced.patches.shared.misc.settings.preference.*
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
@@ -32,6 +29,8 @@ import com.android.tools.smali.dexlib2.iface.reference.FieldReference
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
import com.android.tools.smali.dexlib2.immutable.ImmutableMethodParameter
import com.android.tools.smali.dexlib2.mutable.MutableMethod
import com.android.tools.smali.dexlib2.mutable.MutableMethod.Companion.toMutable
// Only available in 19.15 and upwards.
internal var ytOutlineXWhite24 = -1L
@@ -73,7 +72,7 @@ private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/
@Suppress("unused")
val miniplayerPatch = bytecodePatch(
name = "Miniplayer",
description = "Adds options to change the in-app minimized player."
description = "Adds options to change the in-app minimized player.",
) {
dependsOn(
sharedExtensionPatch,
@@ -88,7 +87,7 @@ val miniplayerPatch = bytecodePatch(
"20.14.43",
"20.21.37",
"20.31.40",
)
),
)
apply {
@@ -96,7 +95,6 @@ val miniplayerPatch = bytecodePatch(
val preferences = mutableSetOf<BasePreference>()
preferences +=
if (is_20_37_or_greater) {
ListPreference("revanced_miniplayer_type")
@@ -104,19 +102,19 @@ val miniplayerPatch = bytecodePatch(
ListPreference(
key = "revanced_miniplayer_type",
entriesKey = "revanced_miniplayer_type_legacy_20_03_entries",
entryValuesKey = "revanced_miniplayer_type_legacy_20_03_entry_values"
entryValuesKey = "revanced_miniplayer_type_legacy_20_03_entry_values",
)
} else if (is_19_43_or_greater) {
ListPreference(
key = "revanced_miniplayer_type",
entriesKey = "revanced_miniplayer_type_legacy_19_43_entries",
entryValuesKey = "revanced_miniplayer_type_legacy_19_43_entry_values"
entryValuesKey = "revanced_miniplayer_type_legacy_19_43_entry_values",
)
} else {
ListPreference(
key = "revanced_miniplayer_type",
entriesKey = "revanced_miniplayer_type_legacy_19_16_entries",
entryValuesKey = "revanced_miniplayer_type_legacy_19_16_entry_values"
entryValuesKey = "revanced_miniplayer_type_legacy_19_16_entry_values",
)
}
@@ -173,7 +171,7 @@ val miniplayerPatch = bytecodePatch(
"""
invoke-static {v$register}, $EXTENSION_CLASS_DESCRIPTOR->$methodName(Z)Z
move-result v$register
"""
""",
)
}
@@ -198,7 +196,7 @@ val miniplayerPatch = bytecodePatch(
extensionMethod: String,
) = method.insertLiteralOverride(
literal,
"$EXTENSION_CLASS_DESCRIPTOR->$extensionMethod(Z)Z"
"$EXTENSION_CLASS_DESCRIPTOR->$extensionMethod(Z)Z",
)
fun Fingerprint.insertMiniplayerFeatureFlagFloatOverride(
@@ -215,7 +213,7 @@ val miniplayerPatch = bytecodePatch(
"""
invoke-static { v$register }, $EXTENSION_CLASS_DESCRIPTOR->$extensionMethod(F)F
move-result v$register
"""
""",
)
}
}
@@ -231,7 +229,7 @@ val miniplayerPatch = bytecodePatch(
"""
invoke-static { v$register }, $EXTENSION_CLASS_DESCRIPTOR->getModernMiniplayerOverrideType(I)I
move-result v$register
"""
""",
)
}
@@ -244,7 +242,7 @@ val miniplayerPatch = bytecodePatch(
).method.apply {
findReturnIndicesReversed().forEach { index ->
insertLegacyTabletMiniplayerOverride(
index
index,
)
}
}
@@ -257,7 +255,7 @@ val miniplayerPatch = bytecodePatch(
navigate(it.originalMethod).to(appNameStringIndex).stop().apply {
findReturnIndicesReversed().forEach { index ->
insertLegacyTabletMiniplayerOverride(
index
index,
)
}
}
@@ -323,7 +321,7 @@ val miniplayerPatch = bytecodePatch(
"""
invoke-static { v$register }, $EXTENSION_CLASS_DESCRIPTOR->getMiniplayerDefaultSize(I)I
move-result v$register
"""
""",
)
}
@@ -351,7 +349,7 @@ val miniplayerPatch = bytecodePatch(
if (is_19_43_or_greater) {
miniplayerOnCloseHandlerFingerprint.insertMiniplayerFeatureFlagBooleanOverride(
MINIPLAYER_DISABLED_FEATURE_KEY,
"getMiniplayerOnCloseHandler"
"getMiniplayerOnCloseHandler",
)
miniplayerModernConstructorFingerprint.insertMiniplayerFeatureFlagBooleanOverride(
@@ -394,8 +392,8 @@ val miniplayerPatch = bytecodePatch(
miniplayerSetIconsFingerprint.method.apply {
findInstructionIndicesReversedOrThrow {
val reference = getReference<MethodReference>()
opcode == Opcode.INVOKE_INTERFACE
&& reference?.returnType == "Z" && reference.parameterTypes.isEmpty()
opcode == Opcode.INVOKE_INTERFACE &&
reference?.returnType == "Z" && reference.parameterTypes.isEmpty()
}.forEach { index ->
val register = getInstruction<OneRegisterInstruction>(index + 1).registerA
@@ -404,7 +402,7 @@ val miniplayerPatch = bytecodePatch(
"""
invoke-static { v$register }, $EXTENSION_CLASS_DESCRIPTOR->allowBoldIcons(Z)Z
move-result v$register
"""
""",
)
}
}
@@ -420,7 +418,7 @@ val miniplayerPatch = bytecodePatch(
miniplayerModernActionButtonFingerprint to "hideMiniplayerActionButton",
miniplayerModernRewindButtonFingerprint to "hideMiniplayerRewindForward",
miniplayerModernForwardButtonFingerprint to "hideMiniplayerRewindForward",
miniplayerModernOverlayViewFingerprint to "adjustMiniplayerOpacity"
miniplayerModernOverlayViewFingerprint to "adjustMiniplayerOpacity",
).forEach { (fingerprint, methodName) ->
fingerprint.match(
miniplayerModernViewParentFingerprint.classDef,
@@ -462,7 +460,7 @@ val miniplayerPatch = bytecodePatch(
ImmutableMethodParameter(
"Landroid/view/ViewGroup\$LayoutParams;",
null,
null
null,
),
),
"V",
@@ -476,9 +474,9 @@ val miniplayerPatch = bytecodePatch(
invoke-super { p0, p1, p2, p3 }, Landroid/view/ViewGroup;->addView(Landroid/view/View;ILandroid/view/ViewGroup${'$'}LayoutParams;)V
invoke-static { p1 }, $EXTENSION_CLASS_DESCRIPTOR->playerOverlayGroupCreated(Landroid/view/View;)V
return-void
"""
""",
)
}
},
)
}

View File

@@ -4,12 +4,11 @@ import app.revanced.patcher.InstructionLocation.MatchAfterWithin
import app.revanced.patcher.checkCast
import app.revanced.patcher.fingerprint
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.resourceLiteral
internal val createPlayerOverviewFingerprint = fingerprint {
returns("V")
instructions(
resourceLiteral(ResourceType.ID, "scrim_overlay"),
checkCast("Landroid/widget/ImageView;", location = MatchAfterWithin(10))
ResourceType.ID("scrim_overlay"),
checkCast("Landroid/widget/ImageView;", location = MatchAfterWithin(10)),
)
}

View File

@@ -2,7 +2,6 @@ package app.revanced.patches.youtube.layout.searchbar
import app.revanced.patcher.fingerprint
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.resourceLiteral
import app.revanced.patches.youtube.layout.hide.general.yoodlesImageViewFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
@@ -11,8 +10,8 @@ internal val setWordmarkHeaderFingerprint = fingerprint {
returns("V")
parameters("Landroid/widget/ImageView;")
instructions(
resourceLiteral(ResourceType.ATTR, "ytPremiumWordmarkHeader"),
resourceLiteral(ResourceType.ATTR, "ytWordmarkHeader")
ResourceType.ATTR("ytPremiumWordmarkHeader"),
ResourceType.ATTR("ytWordmarkHeader"),
)
}
@@ -24,6 +23,6 @@ internal val wideSearchbarLayoutFingerprint = fingerprint {
returns("Landroid/view/View;")
parameters("L", "L")
instructions(
resourceLiteral(ResourceType.LAYOUT, "action_bar_ringo"),
ResourceType.LAYOUT("action_bar_ringo"),
)
}

View File

@@ -2,14 +2,13 @@ package app.revanced.patches.youtube.layout.seekbar
import app.revanced.patcher.InstructionLocation.MatchAfterImmediately
import app.revanced.patcher.InstructionLocation.MatchAfterWithin
import app.revanced.patcher.addString
import app.revanced.patcher.anyInstruction
import app.revanced.patcher.fingerprint
import app.revanced.patcher.literal
import app.revanced.patcher.methodCall
import app.revanced.patcher.opcode
import app.revanced.patcher.addString
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.resourceLiteral
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
@@ -18,15 +17,15 @@ internal val fullscreenSeekbarThumbnailsFingerprint = fingerprint {
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
parameters()
instructions(
literal(45398577)
literal(45398577),
)
}
internal val playerSeekbarColorFingerprint = fingerprint {
accessFlags(AccessFlags.PUBLIC, AccessFlags.CONSTRUCTOR)
instructions(
resourceLiteral(ResourceType.COLOR, "inline_time_bar_played_not_highlighted_color"),
resourceLiteral(ResourceType.COLOR, "inline_time_bar_colorized_bar_played_color_dark")
ResourceType.COLOR("inline_time_bar_played_not_highlighted_color"),
ResourceType.COLOR("inline_time_bar_colorized_bar_played_color_dark"),
)
}
@@ -39,15 +38,15 @@ internal val setSeekbarClickedColorFingerprint = fingerprint {
internal val shortsSeekbarColorFingerprint = fingerprint {
accessFlags(AccessFlags.PUBLIC, AccessFlags.CONSTRUCTOR)
instructions(
resourceLiteral(ResourceType.COLOR, "reel_time_bar_played_color")
ResourceType.COLOR("reel_time_bar_played_color"),
)
}
internal val playerSeekbarHandle1ColorFingerprint = fingerprint {
accessFlags(AccessFlags.PUBLIC, AccessFlags.CONSTRUCTOR)
instructions(
resourceLiteral(ResourceType.COLOR, "inline_time_bar_live_seekable_range"),
resourceLiteral(ResourceType.ATTR, "ytStaticBrandRed"),
ResourceType.COLOR("inline_time_bar_live_seekable_range"),
ResourceType.ATTR("ytStaticBrandRed"),
)
}
@@ -55,8 +54,8 @@ internal val playerSeekbarHandle2ColorFingerprint = fingerprint {
accessFlags(AccessFlags.PUBLIC, AccessFlags.CONSTRUCTOR)
parameters("Landroid/content/Context;")
instructions(
resourceLiteral(ResourceType.ATTR, "ytTextSecondary"),
resourceLiteral(ResourceType.ATTR, "ytStaticBrandRed"),
ResourceType.ATTR("ytTextSecondary"),
ResourceType.ATTR("ytStaticBrandRed"),
)
}
@@ -67,7 +66,7 @@ internal val watchHistoryMenuUseProgressDrawableFingerprint = fingerprint {
instructions(
methodCall("Landroid/widget/ProgressBar;", "setMax"),
opcode(Opcode.MOVE_RESULT),
literal(-1712394514)
literal(-1712394514),
)
}
@@ -85,10 +84,10 @@ internal val playerLinearGradientFingerprint = fingerprint {
parameters("I", "I", "I", "I", "Landroid/content/Context;", "I")
returns("Landroid/graphics/LinearGradient;")
instructions(
resourceLiteral(ResourceType.COLOR, "yt_youtube_magenta"),
ResourceType.COLOR("yt_youtube_magenta"),
opcode(Opcode.FILLED_NEW_ARRAY, location = MatchAfterWithin(5)),
opcode(Opcode.MOVE_RESULT_OBJECT, location = MatchAfterImmediately())
opcode(Opcode.MOVE_RESULT_OBJECT, location = MatchAfterImmediately()),
)
}
@@ -98,7 +97,7 @@ internal val playerLinearGradientFingerprint = fingerprint {
internal val playerLinearGradientLegacyFingerprint = fingerprint {
returns("V")
instructions(
resourceLiteral(ResourceType.COLOR, "yt_youtube_magenta"),
ResourceType.COLOR("yt_youtube_magenta"),
opcode(Opcode.FILLED_NEW_ARRAY),
opcode(Opcode.MOVE_RESULT_OBJECT, MatchAfterImmediately()),
@@ -112,7 +111,7 @@ internal val lottieAnimationViewSetAnimationIntFingerprint = fingerprint {
parameters("I")
returns("V")
instructions(
methodCall("this", "isInEditMode")
methodCall("this", "isInEditMode"),
)
custom { _, classDef ->
classDef.type == LOTTIE_ANIMATION_VIEW_CLASS_TYPE
@@ -125,7 +124,7 @@ internal val lottieCompositionFactoryZipFingerprint = fingerprint {
returns("L")
instructions(
addString("Unable to parse composition"),
addString(" however it was not found in the animation.")
addString(" however it was not found in the animation."),
)
}
@@ -139,7 +138,6 @@ internal val lottieCompositionFactoryFromJsonInputStreamFingerprint = fingerprin
parameters("Ljava/io/InputStream;", "Ljava/lang/String;")
returns("L")
instructions(
anyInstruction(literal(2), literal(3))
anyInstruction(literal(2), literal(3)),
)
}

View File

@@ -1,13 +1,12 @@
package app.revanced.patches.youtube.layout.shortsplayer
import app.revanced.patcher.addString
import app.revanced.patcher.checkCast
import app.revanced.patcher.fieldAccess
import app.revanced.patcher.fingerprint
import app.revanced.patcher.literal
import app.revanced.patcher.methodCall
import app.revanced.patcher.addString
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.resourceLiteral
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
@@ -24,9 +23,9 @@ internal val playbackStartFeatureFlagFingerprint = fingerprint {
instructions(
methodCall(
definingClass = "Lcom/google/android/libraries/youtube/player/model/PlaybackStartDescriptor;",
returnType = "Ljava/lang/String;"
returnType = "Ljava/lang/String;",
),
literal(45380134L)
literal(45380134L),
)
}
@@ -41,21 +40,20 @@ internal val watchPanelVideoIdFingerprint = fingerprint {
instructions(
fieldAccess(
opcode = Opcode.IGET_OBJECT,
type = "Lcom/google/android/apps/youtube/app/common/player/queue/WatchPanelId;"
type = "Lcom/google/android/apps/youtube/app/common/player/queue/WatchPanelId;",
),
checkCast("Lcom/google/android/apps/youtube/app/common/player/queue/DefaultWatchPanelId;"),
methodCall(
definingClass = "Lcom/google/android/apps/youtube/app/common/player/queue/DefaultWatchPanelId;",
returnType = "Lcom/google/android/libraries/youtube/player/model/PlaybackStartDescriptor;"
returnType = "Lcom/google/android/libraries/youtube/player/model/PlaybackStartDescriptor;",
),
methodCall(
definingClass = "Lcom/google/android/libraries/youtube/player/model/PlaybackStartDescriptor;",
returnType = "Ljava/lang/String;"
)
returnType = "Ljava/lang/String;",
),
)
}
// Pre 19.25
internal val shortsPlaybackIntentLegacyFingerprint = fingerprint {
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
@@ -66,14 +64,14 @@ internal val shortsPlaybackIntentLegacyFingerprint = fingerprint {
"J",
"Ljava/lang/String;",
"Z",
"Ljava/util/Map;"
"Ljava/util/Map;",
)
instructions(
methodCall(returnType = "Lcom/google/android/libraries/youtube/player/model/PlaybackStartDescriptor;"),
// None of these strings are unique.
addString("com.google.android.apps.youtube.app.endpoint.flags"),
addString("ReelWatchFragmentArgs"),
addString("reels_fragment_descriptor")
addString("reels_fragment_descriptor"),
)
}
@@ -84,13 +82,13 @@ internal val shortsPlaybackIntentFingerprint = fingerprint {
"Lcom/google/android/libraries/youtube/player/model/PlaybackStartDescriptor;",
"Ljava/util/Map;",
"J",
"Ljava/lang/String;"
"Ljava/lang/String;",
)
instructions(
// None of these strings are unique.
addString("com.google.android.apps.youtube.app.endpoint.flags"),
addString("ReelWatchFragmentArgs"),
addString("reels_fragment_descriptor")
addString("reels_fragment_descriptor"),
)
}
@@ -98,6 +96,6 @@ internal val exitVideoPlayerFingerprint = fingerprint {
returns("V")
parameters()
instructions(
resourceLiteral(ResourceType.ID, "mdx_drawer_layout")
ResourceType.ID("mdx_drawer_layout"),
)
}
}

View File

@@ -6,7 +6,6 @@ import app.revanced.patcher.fingerprint
import app.revanced.patcher.methodCall
import app.revanced.patcher.opcode
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.resourceLiteral
import app.revanced.patches.youtube.shared.seekbarFingerprint
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionReversed
@@ -20,10 +19,10 @@ internal val appendTimeFingerprint = fingerprint {
returns("V")
parameters("Ljava/lang/CharSequence;", "Ljava/lang/CharSequence;", "Ljava/lang/CharSequence;")
instructions(
resourceLiteral(ResourceType.STRING, "total_time"),
ResourceType.STRING("total_time"),
methodCall(smali = "Landroid/content/res/Resources;->getString(I[Ljava/lang/Object;)Ljava/lang/String;"),
opcode(Opcode.MOVE_RESULT_OBJECT, MatchAfterImmediately())
opcode(Opcode.MOVE_RESULT_OBJECT, MatchAfterImmediately()),
)
}
@@ -31,8 +30,8 @@ internal val controlsOverlayFingerprint = fingerprint {
returns("V")
parameters()
instructions(
resourceLiteral(ResourceType.ID, "inset_overlay_view_layout"),
checkCast("Landroid/widget/FrameLayout;", MatchAfterWithin(20))
ResourceType.ID("inset_overlay_view_layout"),
checkCast("Landroid/widget/FrameLayout;", MatchAfterWithin(20)),
)
}
@@ -43,7 +42,7 @@ internal val rectangleFieldInvalidatorFingerprint = fingerprint {
returns("V")
parameters()
instructions(
methodCall(name = "invalidate")
methodCall(name = "invalidate"),
)
}
@@ -56,11 +55,9 @@ internal val adProgressTextViewVisibilityFingerprint = fingerprint {
}
}
internal fun indexOfAdProgressTextViewVisibilityInstruction(method: Method) =
method.indexOfFirstInstructionReversed {
val reference = getReference<MethodReference>()
reference?.definingClass ==
"Lcom/google/android/libraries/youtube/ads/player/ui/AdProgressTextView;"
&& reference.name =="setVisibility"
}
internal fun indexOfAdProgressTextViewVisibilityInstruction(method: Method) = method.indexOfFirstInstructionReversed {
val reference = getReference<MethodReference>()
reference?.definingClass ==
"Lcom/google/android/libraries/youtube/ads/player/ui/AdProgressTextView;" &&
reference.name == "setVisibility"
}

View File

@@ -6,7 +6,6 @@ import app.revanced.patcher.fingerprint
import app.revanced.patcher.methodCall
import app.revanced.patcher.opcode
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.resourceLiteral
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
@@ -14,18 +13,18 @@ internal val toolBarButtonFingerprint = fingerprint {
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
returns("V")
instructions(
resourceLiteral(ResourceType.ID, "menu_item_view"),
ResourceType.ID("menu_item_view"),
methodCall(returnType = "I", opcode = Opcode.INVOKE_INTERFACE),
opcode(Opcode.MOVE_RESULT, MatchAfterImmediately()),
fieldAccess(type = "Landroid/widget/ImageView;", opcode = Opcode.IGET_OBJECT, location = MatchAfterWithin(6)),
methodCall("Landroid/content/res/Resources;", "getDrawable", location = MatchAfterWithin(8)),
methodCall("Landroid/widget/ImageView;", "setImageDrawable", location = MatchAfterWithin(4))
methodCall("Landroid/widget/ImageView;", "setImageDrawable", location = MatchAfterWithin(4)),
)
custom { method, _ ->
// 20.37+ has second parameter of "Landroid/content/Context;"
val parameterCount = method.parameterTypes.count()
(parameterCount == 1 || parameterCount == 2)
&& method.parameterTypes.firstOrNull() == "Landroid/view/MenuItem;"
(parameterCount == 1 || parameterCount == 2) &&
method.parameterTypes.firstOrNull() == "Landroid/view/MenuItem;"
}
}

View File

@@ -6,7 +6,6 @@ import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.all.misc.resources.addResources
import app.revanced.patches.all.misc.resources.addResourcesPatch
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.getResourceId
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
@@ -38,7 +37,7 @@ val backgroundPlaybackPatch = bytecodePatch(
playerTypeHookPatch,
videoInformationPatch,
settingsPatch,
versionCheckPatch
versionCheckPatch,
)
compatibleWith(
@@ -47,19 +46,19 @@ val backgroundPlaybackPatch = bytecodePatch(
"20.14.43",
"20.21.37",
"20.31.40",
)
),
)
apply {
addResources("youtube", "misc.backgroundplayback.backgroundPlaybackPatch")
PreferenceScreen.SHORTS.addPreferences(
SwitchPreference("revanced_shorts_disable_background_playback")
SwitchPreference("revanced_shorts_disable_background_playback"),
)
prefBackgroundAndOfflineCategoryId = getResourceId(
ResourceType.STRING,
"pref_background_and_offline_category"
"pref_background_and_offline_category",
)
arrayOf(
@@ -105,7 +104,7 @@ val backgroundPlaybackPatch = bytecodePatch(
pipInputConsumerFeatureFlagFingerprint.let {
it.method.insertLiteralOverride(
it.instructionMatches.first().index,
false
false,
)
}
}

View File

@@ -5,7 +5,6 @@ import app.revanced.patcher.fingerprint
import app.revanced.patcher.methodCall
import app.revanced.patcher.opcode
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.resourceLiteral
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
@@ -14,10 +13,10 @@ internal val specificNetworkErrorViewControllerFingerprint = fingerprint {
returns("V")
parameters()
instructions(
resourceLiteral(ResourceType.DRAWABLE, "ic_offline_no_content_upside_down"),
resourceLiteral(ResourceType.STRING, "offline_no_content_body_text_not_offline_eligible"),
ResourceType.DRAWABLE("ic_offline_no_content_upside_down"),
ResourceType.STRING("offline_no_content_body_text_not_offline_eligible"),
methodCall(name = "getString", returnType = "Ljava/lang/String;"),
opcode(Opcode.MOVE_RESULT_OBJECT, location = MatchAfterImmediately())
opcode(Opcode.MOVE_RESULT_OBJECT, location = MatchAfterImmediately()),
)
}
@@ -28,9 +27,9 @@ internal val loadingFrameLayoutControllerFingerprint = fingerprint {
returns("V")
parameters("L")
instructions(
resourceLiteral(ResourceType.DRAWABLE, "ic_offline_no_content_upside_down"),
resourceLiteral(ResourceType.STRING, "offline_no_content_body_text_not_offline_eligible"),
ResourceType.DRAWABLE("ic_offline_no_content_upside_down"),
ResourceType.STRING("offline_no_content_body_text_not_offline_eligible"),
methodCall(name = "getString", returnType = "Ljava/lang/String;"),
opcode(Opcode.MOVE_RESULT_OBJECT, MatchAfterImmediately())
opcode(Opcode.MOVE_RESULT_OBJECT, MatchAfterImmediately()),
)
}
}

View File

@@ -4,7 +4,6 @@ import app.revanced.patcher.*
import app.revanced.patcher.InstructionLocation.MatchAfterImmediately
import app.revanced.patcher.InstructionLocation.MatchAfterWithin
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.resourceLiteral
import app.revanced.patches.youtube.layout.buttons.navigation.navigationButtonsPatch
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
@@ -13,16 +12,16 @@ internal val actionBarSearchResultsFingerprint = fingerprint {
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
returns("Landroid/view/View;")
instructions(
resourceLiteral(ResourceType.LAYOUT, "action_bar_search_results_view_mic"),
methodCall(name = "setLayoutDirection")
ResourceType.LAYOUT("action_bar_search_results_view_mic"),
methodCall(name = "setLayoutDirection"),
)
}
internal val toolbarLayoutFingerprint = fingerprint {
accessFlags(AccessFlags.PROTECTED, AccessFlags.CONSTRUCTOR)
instructions(
resourceLiteral(ResourceType.ID, "toolbar_container"),
checkCast("Lcom/google/android/apps/youtube/app/ui/actionbar/MainCollapsingToolbarLayout;")
ResourceType.ID("toolbar_container"),
checkCast("Lcom/google/android/apps/youtube/app/ui/actionbar/MainCollapsingToolbarLayout;"),
)
}
@@ -45,7 +44,7 @@ internal val initializeButtonsFingerprint = fingerprint {
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
returns("V")
instructions(
resourceLiteral(ResourceType.LAYOUT, "image_only_tab")
ResourceType.LAYOUT("image_only_tab"),
)
}
@@ -59,7 +58,7 @@ internal val navigationBarHookCallbackFingerprint = fingerprint {
parameters(EXTENSION_NAVIGATION_BUTTON_DESCRIPTOR, "Landroid/view/View;")
custom { method, _ ->
method.name == "navigationTabCreatedCallback" &&
method.definingClass == EXTENSION_CLASS_DESCRIPTOR
method.definingClass == EXTENSION_CLASS_DESCRIPTOR
}
}
@@ -76,7 +75,7 @@ internal val navigationEnumFingerprint = fingerprint {
"TAB_ACTIVITY",
"VIDEO_LIBRARY_WHITE",
"INCOGNITO_CIRCLE",
"UNKNOWN" // Required to distinguish from patch extension class.
"UNKNOWN", // Required to distinguish from patch extension class.
)
}
@@ -85,8 +84,8 @@ internal val pivotBarButtonsCreateDrawableViewFingerprint = fingerprint {
returns("Landroid/view/View;")
custom { method, _ ->
method.definingClass == "Lcom/google/android/libraries/youtube/rendering/ui/pivotbar/PivotBar;" &&
// Only one view creation method has a Drawable parameter.
method.parameterTypes.firstOrNull() == "Landroid/graphics/drawable/Drawable;"
// Only one view creation method has a Drawable parameter.
method.parameterTypes.firstOrNull() == "Landroid/graphics/drawable/Drawable;"
}
}
@@ -107,8 +106,8 @@ internal val pivotBarButtonsCreateResourceIntViewFingerprint = fingerprint {
returns("Landroid/view/View;")
custom { method, _ ->
method.definingClass == "Lcom/google/android/libraries/youtube/rendering/ui/pivotbar/PivotBar;" &&
// Only one view creation method has an int first parameter.
method.parameterTypes.firstOrNull() == "I"
// Only one view creation method has an int first parameter.
method.parameterTypes.firstOrNull() == "I"
}
}
@@ -117,7 +116,7 @@ internal val pivotBarButtonsViewSetSelectedFingerprint = fingerprint {
returns("V")
parameters("I", "Z")
instructions(
methodCall(name = "setSelected")
methodCall(name = "setSelected"),
)
custom { method, _ ->
method.definingClass == "Lcom/google/android/libraries/youtube/rendering/ui/pivotbar/PivotBar;"
@@ -136,17 +135,17 @@ internal val imageEnumConstructorFingerprint = fingerprint {
instructions(
addString("TAB_ACTIVITY_CAIRO"),
opcode(Opcode.INVOKE_DIRECT, location = MatchAfterImmediately()),
opcode(Opcode.SPUT_OBJECT, location = MatchAfterImmediately())
opcode(Opcode.SPUT_OBJECT, location = MatchAfterImmediately()),
)
}
internal val setEnumMapFingerprint = fingerprint {
instructions(
resourceLiteral(ResourceType.DRAWABLE, "yt_fill_bell_black_24"),
ResourceType.DRAWABLE("yt_fill_bell_black_24"),
methodCall(smali = "Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;", location = MatchAfterWithin(10)),
methodCall(
smali = "Ljava/util/EnumMap;->put(Ljava/lang/Enum;Ljava/lang/Object;)Ljava/lang/Object;",
location = MatchAfterWithin(10)
)
location = MatchAfterWithin(10),
),
)
}

View File

@@ -7,7 +7,6 @@ import app.revanced.patcher.literal
import app.revanced.patcher.methodCall
import app.revanced.patcher.opcode
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.resourceLiteral
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
@@ -17,7 +16,7 @@ internal val playerControlsVisibilityEntityModelFingerprint = fingerprint {
parameters()
opcodes(
Opcode.IGET,
Opcode.INVOKE_STATIC
Opcode.INVOKE_STATIC,
)
custom { method, _ ->
method.name == "getPlayerControlsVisibility"
@@ -29,8 +28,8 @@ internal val youtubeControlsOverlayFingerprint = fingerprint {
parameters()
instructions(
methodCall(name = "setFocusableInTouchMode"),
resourceLiteral(ResourceType.ID, "inset_overlay_view_layout"),
resourceLiteral(ResourceType.ID, "scrim_overlay"),
ResourceType.ID("inset_overlay_view_layout"),
ResourceType.ID("scrim_overlay"),
)
}
@@ -38,7 +37,7 @@ internal val motionEventFingerprint = fingerprint {
returns("V")
parameters("Landroid/view/MotionEvent;")
instructions(
methodCall(name = "setTranslationY")
methodCall(name = "setTranslationY"),
)
}
@@ -48,7 +47,7 @@ internal val playerControlsExtensionHookListenersExistFingerprint = fingerprint
parameters()
custom { methodDef, classDef ->
methodDef.name == "fullscreenButtonVisibilityCallbacksExist" &&
classDef.type == EXTENSION_CLASS_DESCRIPTOR
classDef.type == EXTENSION_CLASS_DESCRIPTOR
}
}
@@ -67,9 +66,9 @@ internal val playerTopControlsInflateFingerprint = fingerprint {
returns("V")
parameters()
instructions(
resourceLiteral(ResourceType.ID, "controls_layout_stub"),
ResourceType.ID("controls_layout_stub"),
methodCall("Landroid/view/ViewStub;", "inflate"),
opcode(Opcode.MOVE_RESULT_OBJECT, MatchAfterImmediately())
opcode(Opcode.MOVE_RESULT_OBJECT, MatchAfterImmediately()),
)
}
@@ -77,9 +76,9 @@ internal val playerBottomControlsInflateFingerprint = fingerprint {
returns("Ljava/lang/Object;")
parameters()
instructions(
resourceLiteral(ResourceType.ID, "bottom_ui_container_stub"),
ResourceType.ID("bottom_ui_container_stub"),
methodCall("Landroid/view/ViewStub;", "inflate"),
opcode(Opcode.MOVE_RESULT_OBJECT, MatchAfterImmediately())
opcode(Opcode.MOVE_RESULT_OBJECT, MatchAfterImmediately()),
)
}
@@ -88,9 +87,9 @@ internal val overlayViewInflateFingerprint = fingerprint {
returns("V")
parameters("Landroid/view/View;")
instructions(
resourceLiteral(ResourceType.ID, "heatseeker_viewstub"),
resourceLiteral(ResourceType.ID, "fullscreen_button"),
checkCast("Landroid/widget/ImageView;")
ResourceType.ID("heatseeker_viewstub"),
ResourceType.ID("fullscreen_button"),
checkCast("Landroid/widget/ImageView;"),
)
}
@@ -108,7 +107,7 @@ internal val playerBottomControlsExploderFeatureFlagFingerprint = fingerprint {
returns("Z")
parameters()
instructions(
literal(45643739L)
literal(45643739L),
)
}
@@ -117,7 +116,7 @@ internal val playerTopControlsExperimentalLayoutFeatureFlagFingerprint = fingerp
returns("I")
parameters()
instructions(
literal(45629424L)
literal(45629424L),
)
}
@@ -126,7 +125,7 @@ internal val playerControlsLargeOverlayButtonsFeatureFlagFingerprint = fingerpri
returns("Z")
parameters()
instructions(
literal(45709810L)
literal(45709810L),
)
}
@@ -135,7 +134,7 @@ internal val playerControlsFullscreenLargeButtonsFeatureFlagFingerprint = finger
returns("Z")
parameters()
instructions(
literal(45686474L)
literal(45686474L),
)
}
@@ -144,6 +143,6 @@ internal val playerControlsButtonStrokeFeatureFlagFingerprint = fingerprint {
returns("Z")
parameters()
instructions(
literal(45713296)
literal(45713296),
)
}
}

View File

@@ -1,11 +1,10 @@
package app.revanced.patches.youtube.misc.playertype
import app.revanced.patcher.InstructionLocation.MatchAfterWithin
import app.revanced.patcher.addString
import app.revanced.patcher.fingerprint
import app.revanced.patcher.opcode
import app.revanced.patcher.addString
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.resourceLiteral
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
@@ -30,8 +29,8 @@ internal val reelWatchPagerFingerprint = fingerprint {
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
returns("Landroid/view/View;")
instructions(
resourceLiteral(ResourceType.ID, "reel_watch_player"),
opcode(Opcode.MOVE_RESULT_OBJECT, location = MatchAfterWithin(10))
ResourceType.ID("reel_watch_player"),
opcode(Opcode.MOVE_RESULT_OBJECT, location = MatchAfterWithin(10)),
)
}
@@ -44,7 +43,7 @@ internal val videoStateEnumFingerprint = fingerprint {
"PAUSED",
"RECOVERABLE_ERROR",
"UNRECOVERABLE_ERROR",
"ENDED"
"ENDED",
)
}
@@ -55,6 +54,6 @@ internal val controlsStateToStringFingerprint = fingerprint {
returns("Ljava/lang/String;")
instructions(
addString("videoState"),
addString("isBuffering")
addString("isBuffering"),
)
}

View File

@@ -7,7 +7,6 @@ import app.revanced.patcher.fieldAccess
import app.revanced.patcher.fingerprint
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.resourceLiteral
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
import com.android.tools.smali.dexlib2.AccessFlags
@@ -43,7 +42,7 @@ val playerTypeHookPatch = bytecodePatch(
addInstruction(
index + 1,
"invoke-static { v$register }, $EXTENSION_CLASS_DESCRIPTOR->onShortsCreate(Landroid/view/View;)V"
"invoke-static { v$register }, $EXTENSION_CLASS_DESCRIPTOR->onShortsCreate(Landroid/view/View;)V",
)
}
}
@@ -58,17 +57,17 @@ val playerTypeHookPatch = bytecodePatch(
// Obfuscated parameter field name.
fieldAccess(
definingClass = controlStateType,
type = videoStateEnumFingerprint.originalClassDef.type
type = videoStateEnumFingerprint.originalClassDef.type,
),
resourceLiteral(ResourceType.STRING, "accessibility_play"),
resourceLiteral(ResourceType.STRING, "accessibility_pause")
ResourceType.STRING("accessibility_play"),
ResourceType.STRING("accessibility_pause"),
)
}
videoStateFingerprint.let {
it.method.apply {
val videoStateFieldName = getInstruction<ReferenceInstruction>(
it.instructionMatches.first().index
it.instructionMatches.first().index,
).reference
addInstructions(
@@ -76,7 +75,7 @@ val playerTypeHookPatch = bytecodePatch(
"""
iget-object v0, p1, $videoStateFieldName # copy VideoState parameter field
invoke-static {v0}, $EXTENSION_CLASS_DESCRIPTOR->setVideoState(Ljava/lang/Enum;)V
"""
""",
)
}
}

View File

@@ -5,7 +5,6 @@ import app.revanced.patcher.fingerprint
import app.revanced.patcher.literal
import app.revanced.patcher.opcode
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.resourceLiteral
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
@@ -23,7 +22,7 @@ internal val setThemeFingerprint = fingerprint {
returns("L")
parameters()
instructions(
resourceLiteral(ResourceType.STRING, "app_theme_appearance_dark"),
ResourceType.STRING("app_theme_appearance_dark"),
)
}
@@ -32,7 +31,7 @@ internal val cairoFragmentConfigFingerprint = fingerprint {
returns("Z")
instructions(
literal(45532100L),
opcode(Opcode.MOVE_RESULT, location = MatchAfterWithin(10))
opcode(Opcode.MOVE_RESULT, location = MatchAfterWithin(10)),
)
}
@@ -43,6 +42,6 @@ internal val boldIconsFeatureFlagFingerprint = fingerprint {
returns("Z")
parameters()
instructions(
literal(45685201L)
literal(45685201L),
)
}

View File

@@ -1,27 +1,26 @@
package app.revanced.patches.youtube.shared
import app.revanced.patcher.gettingFirstMutableMethodDeclaratively
import app.revanced.patcher.InstructionLocation.MatchAfterImmediately
import app.revanced.patcher.accessFlags
import app.revanced.patcher.fingerprint
import app.revanced.patcher.literal
import app.revanced.patcher.methodCall
import app.revanced.patcher.opcode
import app.revanced.patcher.addString
import app.revanced.patcher.after
import app.revanced.patcher.allOf
import app.revanced.patcher.definingClass
import app.revanced.patcher.field
import app.revanced.patcher.fingerprint
import app.revanced.patcher.firstMethodComposite
import app.revanced.patcher.gettingFirstMutableMethodDeclaratively
import app.revanced.patcher.instructions
import app.revanced.patcher.invoke
import app.revanced.patcher.literal
import app.revanced.patcher.methodCall
import app.revanced.patcher.name
import app.revanced.patcher.opcode
import app.revanced.patcher.parameterTypes
import app.revanced.patcher.patch.BytecodePatchContext
import app.revanced.patcher.returnType
import app.revanced.patcher.type
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.resourceLiteral
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
@@ -35,7 +34,7 @@ internal val conversionContextFingerprintToString = fingerprint {
", heightConstraint=",
", templateLoggerFactory=",
", rootDisposableContainer=",
", identifierProperty="
", identifierProperty=",
)
custom { method, _ ->
method.name == "toString"
@@ -47,9 +46,9 @@ internal val layoutConstructorFingerprint = fingerprint {
returns("V")
instructions(
literal(159962),
resourceLiteral(ResourceType.ID, "player_control_previous_button_touch_area"),
resourceLiteral(ResourceType.ID, "player_control_next_button_touch_area"),
methodCall(parameters = listOf("Landroid/view/View;", "I"))
ResourceType.ID("player_control_previous_button_touch_area"),
ResourceType.ID("player_control_next_button_touch_area"),
methodCall(parameters = listOf("Landroid/view/View;", "I")),
)
}
@@ -98,8 +97,8 @@ internal val rollingNumberTextViewAnimationUpdateFingerprint = fingerprint {
)
custom { _, classDef ->
classDef.superclass == "Landroid/support/v7/widget/AppCompatTextView;" ||
classDef.superclass ==
"Lcom/google/android/libraries/youtube/rendering/ui/spec/typography/YouTubeAppCompatTextView;"
classDef.superclass ==
"Lcom/google/android/libraries/youtube/rendering/ui/spec/typography/YouTubeAppCompatTextView;"
}
}
@@ -116,7 +115,7 @@ internal val seekbarFingerprint = fingerprint {
internal val seekbarOnDrawFingerprint = fingerprint {
instructions(
methodCall(smali = "Ljava/lang/Math;->round(F)I"),
opcode(Opcode.MOVE_RESULT, location = MatchAfterImmediately())
opcode(Opcode.MOVE_RESULT, location = MatchAfterImmediately()),
)
custom { method, _ -> method.name == "onDraw" }
}
@@ -126,8 +125,8 @@ internal val subtitleButtonControllerFingerprint = fingerprint {
returns("V")
parameters("Lcom/google/android/libraries/youtube/player/subtitles/model/SubtitleTrack;")
instructions(
resourceLiteral(ResourceType.STRING, "accessibility_captions_unavailable"),
resourceLiteral(ResourceType.STRING, "accessibility_captions_button_name"),
ResourceType.STRING("accessibility_captions_unavailable"),
ResourceType.STRING("accessibility_captions_button_name"),
)
}
@@ -139,6 +138,6 @@ internal val videoQualityChangedMethodMatch = firstMethodComposite {
allOf(Opcode.NEW_INSTANCE(), type("Lcom/google/android/libraries/youtube/innertube/model/media/VideoQuality;")),
Opcode.IGET_OBJECT(),
Opcode.CHECK_CAST(),
after(allOf(Opcode.IGET(), field { type == "I" })) // Video resolution (human-readable).
after(allOf(Opcode.IGET(), field { type == "I" })), // Video resolution (human-readable).
)
}

View File

@@ -8,7 +8,6 @@ import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.all.misc.resources.addResources
import app.revanced.patches.all.misc.resources.addResourcesPatch
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.getResourceId
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
@@ -37,14 +36,14 @@ internal val advancedVideoQualityMenuPatch = bytecodePatch {
addResourcesPatch,
lithoFilterPatch,
recyclerViewTreeHookPatch,
resourceMappingPatch
resourceMappingPatch,
)
apply {
addResources("youtube", "video.quality.advancedVideoQualityMenuPatch")
settingsMenuVideoQualityGroup.add(
SwitchPreference("revanced_advanced_video_quality_menu")
SwitchPreference("revanced_advanced_video_quality_menu"),
)
// Used for the old type of the video quality menu.
@@ -69,7 +68,7 @@ internal val advancedVideoQualityMenuPatch = bytecodePatch {
addInstruction(
checkCastIndex + 1,
"invoke-static { v$listViewRegister }, $EXTENSION_CLASS_DESCRIPTOR->" +
"addVideoQualityListMenuListener(Landroid/widget/ListView;)V",
"addVideoQualityListMenuListener(Landroid/widget/ListView;)V",
)
}
}
@@ -91,7 +90,7 @@ internal val advancedVideoQualityMenuPatch = bytecodePatch {
"""
invoke-static { v$register }, $EXTENSION_CLASS_DESCRIPTOR->forceAdvancedVideoQualityMenuCreation(Z)Z
move-result v$register
"""
""",
)
}
}

View File

@@ -1,18 +1,16 @@
package app.revanced.patches.youtube.video.speed.custom
import app.revanced.patcher.addString
import app.revanced.patcher.fieldAccess
import app.revanced.patcher.fingerprint
import app.revanced.patcher.literal
import app.revanced.patcher.methodCall
import app.revanced.patcher.newInstance
import app.revanced.patcher.opcode
import app.revanced.patcher.addString
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.resourceLiteral
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
internal val getOldPlaybackSpeedsFingerprint = fingerprint {
parameters("[L", "I")
strings("menu_item_playback_speed")
@@ -20,7 +18,7 @@ internal val getOldPlaybackSpeedsFingerprint = fingerprint {
internal val showOldPlaybackSpeedMenuFingerprint = fingerprint {
instructions(
resourceLiteral(ResourceType.STRING, "varispeed_unavailable_message")
ResourceType.STRING("varispeed_unavailable_message"),
)
}
@@ -32,7 +30,7 @@ internal val serverSideMaxSpeedFeatureFlagFingerprint = fingerprint {
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
returns("Z")
instructions(
literal(45719140L)
literal(45719140L),
)
}
@@ -46,7 +44,7 @@ internal val speedArrayGeneratorFingerprint = fingerprint {
addString("0.0#"),
literal(7),
opcode(Opcode.NEW_ARRAY),
fieldAccess(definingClass = "/PlayerConfigModel;", type = "[F")
fieldAccess(definingClass = "/PlayerConfigModel;", type = "[F"),
)
}
@@ -59,7 +57,7 @@ internal val speedLimiterFingerprint = fingerprint {
parameters("F", "Lcom/google/android/libraries/youtube/innertube/model/media/PlayerConfigModel;")
instructions(
literal(0.25f),
literal(4.0f)
literal(4.0f),
)
}

View File

@@ -7,7 +7,6 @@ import app.revanced.patcher.extensions.*
import app.revanced.patcher.patch.BytecodePatchContext
import app.revanced.patcher.patch.PatchException
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.getResourceId
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
import app.revanced.util.InstructionUtils.Companion.branchOpcodes
import app.revanced.util.InstructionUtils.Companion.returnOpcodes
@@ -358,7 +357,7 @@ fun MutableMethod.addInstructionsAtControlFlowLabel(
* @see [indexOfFirstResourceIdOrThrow], [indexOfFirstLiteralInstructionReversed]
*/
fun Method.indexOfFirstResourceId(resourceName: String): Int {
return indexOfFirstLiteralInstruction(getResourceId(ResourceType.ID, resourceName))
return indexOfFirstLiteralInstruction(ResourceType.ID[resourceName)]
}
/**