instructionMathes -> indices

This commit is contained in:
oSumAtrIX
2026-01-23 23:45:59 +01:00
parent 6afaf53370
commit 6da8a69f22
34 changed files with 59 additions and 66 deletions

View File

@@ -6,7 +6,6 @@ import app.revanced.patcher.name
import app.revanced.patcher.patch.BytecodePatchContext
import app.revanced.patcher.returnType
internal val BytecodePatchContext.insertionGetPointsMethod by gettingFirstMutableMethodDeclaratively {
name("getPoints")
definingClass("Lcom/dss/sdk/internal/media/Insertion;")
@@ -18,4 +17,3 @@ internal val BytecodePatchContext.insertionGetRangesMethod by gettingFirstMutabl
definingClass("Lcom/dss/sdk/internal/media/Insertion;")
returnType("Ljava/util/List")
}

View File

@@ -16,7 +16,7 @@ private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/music/pa
@Suppress("unused")
val `Permanent repeat` by creatingBytecodePatch(
description = "Adds an option to always repeat even if the playlist ends or another track is played."
description = "Adds an option to always repeat even if the playlist ends or another track is played.",
) {
dependsOn(
sharedExtensionPatch,
@@ -27,8 +27,8 @@ val `Permanent repeat` by creatingBytecodePatch(
compatibleWith(
"com.google.android.apps.youtube.music"(
"7.29.52",
"8.10.52"
)
"8.10.52",
),
)
apply {
@@ -38,7 +38,7 @@ val `Permanent repeat` by creatingBytecodePatch(
SwitchPreference("revanced_music_play_permanent_repeat"),
)
val startIndex = repeatTrackMethod.instructionMatches.last().index // TODO
val startIndex = repeatTrackMethod.indices.last() // TODO
val repeatIndex = startIndex + 1
repeatTrackMethod.apply {

View File

@@ -28,8 +28,8 @@ val `Hide 'Get Music Premium'` by creatingBytecodePatch(
compatibleWith(
"com.google.android.apps.youtube.music"(
"7.29.52",
"8.10.52"
)
"8.10.52",
),
)
apply {
@@ -40,7 +40,7 @@ val `Hide 'Get Music Premium'` by creatingBytecodePatch(
)
hideGetPremiumMethod.apply {
val insertIndex = hideGetPremiumMethod.instructionMatches.last().index // TODO
val insertIndex = hideGetPremiumMethod.indices.last() // TODO
val setVisibilityInstruction = getInstruction<FiveRegisterInstruction>(insertIndex)
val getPremiumViewRegister = setVisibilityInstruction.registerC
@@ -54,7 +54,7 @@ val `Hide 'Get Music Premium'` by creatingBytecodePatch(
addInstruction(
insertIndex + 1,
"invoke-virtual {v$getPremiumViewRegister, v$visibilityRegister}, " +
"Landroid/view/View;->setVisibility(I)V",
"Landroid/view/View;->setVisibility(I)V",
)
}
@@ -68,7 +68,7 @@ val `Hide 'Get Music Premium'` by creatingBytecodePatch(
return-object v0
:show
nop
"""
""",
)
}
}

View File

@@ -1,15 +1,11 @@
package app.revanced.patches.shared.misc.fix.verticalscroll
import app.revanced.patcher.accessFlags
import app.revanced.patcher.gettingFirstMethodDeclaratively
import app.revanced.patcher.opcodes
import app.revanced.patcher.parameterTypes
import app.revanced.patcher.patch.BytecodePatchContext
import app.revanced.patcher.returnType
import app.revanced.patcher.*
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
internal val BytecodePatchContext.canScrollVerticallyMethod by gettingFirstMethodDeclaratively {
internal val canScrollVerticallyMatch = firstMethodComposite {
definingClass("SwipeRefreshLayout;"::endsWith)
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
returnType("Z")
parameterTypes()
@@ -19,5 +15,4 @@ internal val BytecodePatchContext.canScrollVerticallyMethod by gettingFirstMetho
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT,
)
custom { _, classDef -> classDef.endsWith("SwipeRefreshLayout;") }
}

View File

@@ -12,7 +12,7 @@ val verticalScrollPatch = bytecodePatch(
apply {
canScrollVerticallyMethod.let {
it.method.apply {
val moveResultIndex = it.instructionMatches.last().index
val moveResultIndex = it.indices.last()
val moveResultRegister = getInstruction<OneRegisterInstruction>(moveResultIndex).registerA
val insertIndex = moveResultIndex + 1

View File

@@ -20,7 +20,7 @@ val `Fix old versions` by creatingBytecodePatch(
// Remove the live query parameters from the path when it's specified via a @METHOD annotation.
for (liveQueryParameter in liveQueryParameters) {
httpPathParserMethod.addInstructions(
httpPathParserMethod.instructionMatches.last().index + 1,
httpPathParserMethod.indices.last() + 1,
"""
# urlPath = urlPath.replace(liveQueryParameter, "")
const-string p1, "$liveQueryParameter"

View File

@@ -47,7 +47,7 @@ val `Unlock downloads` by creatingBytecodePatch(
const/4 v${checkMediaTypeInstruction.registerB}, 0x2 # GIF
if-eq v${checkMediaTypeInstruction.registerA}, v${checkMediaTypeInstruction.registerB}, :video
""",
ExternalLabel("video", getInstruction(it.instructionMatches.last().index)),
ExternalLabel("video", getInstruction(it.indices.last())),
)
// Remove media.isDownloadable check.

View File

@@ -42,7 +42,7 @@ val `Remove viewer discretion dialog` by creatingBytecodePatch(
createDialogMethod.let {
it.method.apply {
val showDialogIndex = it.instructionMatches.last().index // TODO
val showDialogIndex = it.indices.last() // TODO
val dialogRegister = getInstruction<FiveRegisterInstruction>(showDialogIndex).registerC
replaceInstructions(

View File

@@ -40,12 +40,12 @@ val enableSeekbarTappingPatch = bytecodePatch(
listOf(
getReference(it.instructionMatches.first().index),
getReference(it.instructionMatches.last().index),
getReference(it.indices.last()),
)
}
seekbarTappingMethod.let {
val insertIndex = it.instructionMatches.last().index + 1
val insertIndex = it.indices.last() + 1
it.method.apply {
val thisInstanceRegister = getInstruction<FiveRegisterInstruction>(

View File

@@ -75,7 +75,7 @@ val enableSlideToSeekPatch = bytecodePatch(
if (is_19_17_or_greater) {
disableFastForwardGestureMethod.let {
it.method.apply {
val targetIndex = it.instructionMatches.last().index
val targetIndex = it.indices.last()
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
addInstructions(
@@ -90,7 +90,7 @@ val enableSlideToSeekPatch = bytecodePatch(
} else {
disableFastForwardLegacyMethod.let {
it.method.apply {
val insertIndex = it.instructionMatches.last().index + 1
val insertIndex = it.indices.last() + 1
val targetRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
addInstructions(

View File

@@ -136,7 +136,7 @@ val `Swipe controls` by creatingBytecodePatch(
if (is_19_43_or_greater && !is_20_34_or_greater) {
swipeChangeVideoMethod.let {
it.method.insertLiteralOverride(
it.instructionMatches.last().index, // TODO
it.indices.last(), // TODO
"$EXTENSION_CLASS_DESCRIPTOR->allowSwipeChangeVideo(Z)Z",
)
}

View File

@@ -138,7 +138,7 @@ val `Hide player overlay buttons` by creatingBytecodePatch(
inflateControlsGroupLayoutStubMethodMatch.let {
it.method.apply {
val insertIndex = it.instructionMatches.last().index + 1
val insertIndex = it.indices.last() + 1
val freeRegister = findFreeRegister(insertIndex)
addInstructions(

View File

@@ -64,7 +64,7 @@ val `Change form factor` by creatingBytecodePatch(
createPlayerRequestBodyWithModelFingerprint.let {
it.method.apply {
val index = it.instructionMatches.last().index
val index = it.indices.last()
val register = getInstruction<TwoRegisterInstruction>(index).registerA
addInstructions(

View File

@@ -75,7 +75,7 @@ val `Hide end screen cards` by creatingBytecodePatch(
layoutVideoMethod,
).forEach { fingerprint ->
fingerprint.method.apply {
val insertIndex = fingerprint.instructionMatches.last().index + 1 // TODO
val insertIndex = fingerprint.indices.last() + 1 // TODO
val viewRegister = getInstruction<OneRegisterInstruction>(insertIndex - 1).registerA
addInstruction(

View File

@@ -45,7 +45,7 @@ val `Hide end screen suggested video` by creatingBytecodePatch(
)
removeOnLayoutChangeListenerMethod.let {
val endScreenMethod = navigate(it.originalMethod).to(it.instructionMatches.last().index).stop() // TODO
val endScreenMethod = navigate(it.originalMethod).to(it.indices.last()).stop() // TODO
endScreenMethod.apply {
val autoNavStatusMethodName = autoNavStatusMethod.match(

View File

@@ -289,7 +289,7 @@ val `Hide layout components` by creatingBytecodePatch(
(if (is_20_26_or_greater) hideShowMoreButtonMethod else hideShowMoreLegacyButtonMethod).let {
it.method.apply {
val moveRegisterIndex = it.instructionMatches.last().index
val moveRegisterIndex = it.indices.last()
val viewRegister = getInstruction<OneRegisterInstruction>(moveRegisterIndex).registerA
val insertIndex = moveRegisterIndex + 1
@@ -306,7 +306,7 @@ val `Hide layout components` by creatingBytecodePatch(
// region crowdfunding box
crowdfundingBoxMethod.let {
it.method.apply {
val insertIndex = it.instructionMatches.last().index
val insertIndex = it.indices.last()
val objectRegister = getInstruction<TwoRegisterInstruction>(insertIndex).registerA
addInstruction(
@@ -323,7 +323,7 @@ val `Hide layout components` by creatingBytecodePatch(
albumCardsMethod.let {
it.method.apply {
val checkCastAnchorIndex = it.instructionMatches.last().index
val checkCastAnchorIndex = it.indices.last()
val insertIndex = checkCastAnchorIndex + 1
val register = getInstruction<OneRegisterInstruction>(checkCastAnchorIndex).registerA
@@ -341,7 +341,7 @@ val `Hide layout components` by creatingBytecodePatch(
showFloatingMicrophoneButtonMethod.let {
it.method.apply {
val index = it.instructionMatches.last().index
val index = it.indices.last()
val register = getInstruction<TwoRegisterInstruction>(index).registerA
addInstructions(
@@ -422,7 +422,7 @@ val `Hide layout components` by creatingBytecodePatch(
hookRegisterOffset: Int = 0,
instructions: (Int) -> String,
) = method.apply {
val endIndex = instructionMatches.last().index
val endIndex = indices.last()
val insertIndex = endIndex + insertIndexOffset
val register = getInstruction<RegisterInstruction>(endIndex + hookRegisterOffset).registerA

View File

@@ -78,7 +78,7 @@ val `Hide info cards` by creatingBytecodePatch(
// Edit: This old non litho code may be obsolete and no longer used by any supported versions.
infocardsMethodCallMethod.let {
val invokeInterfaceIndex = it.instructionMatches.last().index
val invokeInterfaceIndex = it.indices.last()
it.method.apply {
val register = implementation!!.registerCount - 1

View File

@@ -46,7 +46,7 @@ val `Disable rolling number animations` by creatingBytecodePatch(
// which prevents the animations from appearing.
rollingNumberTextViewAnimationUpdateMethod.let {
val blockStartIndex = it.instructionMatches.first().index
val blockEndIndex = it.instructionMatches.last().index + 1
val blockEndIndex = it.indices.last() + 1
it.method.apply {
val freeRegister = getInstruction<OneRegisterInstruction>(blockStartIndex).registerA

View File

@@ -210,7 +210,7 @@ val `Hide Shorts componentsby creatingBytecodePatch(
setPivotBarVisibilityParentMethod.originalClassDef,
).let { result ->
result.method.apply {
val insertIndex = result.instructionMatches.last().index
val insertIndex = result.indices.last()
val viewRegister = getInstruction<OneRegisterInstruction>(insertIndex - 1).registerA
addInstruction(
insertIndex,
@@ -239,7 +239,7 @@ val `Hide Shorts componentsby creatingBytecodePatch(
// Hide the bottom bar container of the Shorts player.
shortsBottomBarContainerMethod.let {
it.method.apply {
val targetIndex = it.instructionMatches.last().index
val targetIndex = it.indices.last()
val heightRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
addInstructions(

View File

@@ -249,7 +249,7 @@ val Miniplayer by creatingBytecodePatch(
// region Legacy tablet miniplayer hooks.
miniplayerOverrideMethod.let {
val appNameStringIndex = it.instructionMatches.last().index
val appNameStringIndex = it.indices.last()
navigate(it.originalMethod).to(appNameStringIndex).stop().apply {
findReturnIndicesReversed().forEach { index ->
insertLegacyTabletMiniplayerOverride(
@@ -260,7 +260,7 @@ val Miniplayer by creatingBytecodePatch(
}
miniplayerResponseModelSizeCheckMethod.let {
it.method.insertLegacyTabletMiniplayerOverride(it.instructionMatches.last().index)
it.method.insertLegacyTabletMiniplayerOverride(it.indices.last())
}
}
@@ -421,7 +421,7 @@ val Miniplayer by creatingBytecodePatch(
fingerprint.match(
miniplayerModernViewParentMethod.classDef,
).method.apply {
val index = fingerprint.instructionMatches.last().index
val index = fingerprint.indices.last()
val register = getInstruction<OneRegisterInstruction>(index).registerA
addInstruction(

View File

@@ -36,13 +36,13 @@ internal val openVideosFullscreenHookPatch = bytecodePatch {
// Shorts fullscreen regular player does not use fullscreen
// if the player is minimized and it must be forced using other conditional check.
it.method.insertLiteralOverride(
it.instructionMatches.last().index,
it.indices.last(),
false,
)
}
} else {
fingerprint = openVideosFullscreenPortraitLegacyMethod
insertIndex = fingerprint.instructionMatches.last().index
insertIndex = fingerprint.indices.last()
}
fingerprint.let {

View File

@@ -43,7 +43,7 @@ val `Custom player overlay opacity` by creatingBytecodePatch(
createPlayerOverviewMethod.let {
it.method.apply {
val viewRegisterIndex = it.instructionMatches.last().index
val viewRegisterIndex = it.indices.last()
val viewRegister = getInstruction<OneRegisterInstruction>(viewRegisterIndex).registerA
addInstruction(

View File

@@ -222,7 +222,7 @@ val `Return YouTube Dislike` by creatingBytecodePatch(
rollingNumberSetterMethod.apply {
val insertIndex = 1
val dislikesIndex = rollingNumberSetterMethod.instructionMatches.last().index
val dislikesIndex = rollingNumberSetterMethod.indices.last()
val charSequenceInstanceRegister =
getInstruction<OneRegisterInstruction>(0).registerA
val charSequenceFieldReference =
@@ -248,7 +248,7 @@ val `Return YouTube Dislike` by creatingBytecodePatch(
rollingNumberMeasureAnimatedTextMethod.let {
// Additional check to verify the opcodes are at the start of the method
if (it.instructionMatches.first().index != 0) throw PatchException("Unexpected opcode location")
val endIndex = it.instructionMatches.last().index
val endIndex = it.indices.last()
it.method.apply {
val measuredTextWidthRegister = getInstruction<OneRegisterInstruction>(endIndex).registerA

View File

@@ -49,7 +49,7 @@ val seekbarColorPatch = bytecodePatch(
playerSeekbarColorMethod.let {
it.method.apply {
addColorChangeInstructions(it.instructionMatches.last().index)
addColorChangeInstructions(it.indices.last())
addColorChangeInstructions(it.instructionMatches.first().index)
}
}
@@ -82,7 +82,7 @@ val seekbarColorPatch = bytecodePatch(
handleBarColorFingerprints += playerSeekbarHandle2ColorMethod
}
handleBarColorFingerprints.forEach {
it.method.addColorChangeInstructions(it.instructionMatches.last().index)
it.method.addColorChangeInstructions(it.indices.last())
}
// If hiding feed seekbar thumbnails, then turn off the cairo gradient
@@ -125,7 +125,7 @@ val seekbarColorPatch = bytecodePatch(
playerFingerprint.let {
it.method.apply {
val index = it.instructionMatches.last().index
val index = it.indices.last()
val register = getInstruction<OneRegisterInstruction>(index).registerA
addInstructions(

View File

@@ -76,7 +76,7 @@ val `Shorts autoplay` by creatingBytecodePatch(
reelEnumClass = it.originalClassDef.type
it.method.addInstructions(
it.instructionMatches.last().index,
it.indices.last(),
"""
# Pass the first enum value to extension.
# Any enum value of this type will work.

View File

@@ -83,7 +83,7 @@ val `Spoof app version` by creatingBytecodePatch(
toolBarButtonMethod.apply {
val imageResourceIndex = instructionMatches[2].index
val register = method.getInstruction<OneRegisterInstruction>(imageResourceIndex).registerA
val jumpIndex = instructionMatches.last().index + 1
val jumpIndex = indices.last() + 1
method.addInstructionsWithLabels(
imageResourceIndex + 1,

View File

@@ -18,7 +18,7 @@ internal val fixBackToExitGesturePatch = bytecodePatch(
apply {
recyclerViewTopScrollingMethod.let {
it.method.addInstructionsAtControlFlowLabel(
it.instructionMatches.last().index + 1,
it.indices.last() + 1,
"invoke-static { }, $EXTENSION_CLASS_DESCRIPTOR->onTopView()V",
)
}

View File

@@ -34,7 +34,7 @@ internal val accountCredentialsInvalidTextPatch = bytecodePatch {
loadingFrameLayoutControllerMethod,
).forEach { fingerprint ->
fingerprint.apply {
val index = instructionMatches.last().index
val index = indices.last()
val register = method.getInstruction<OneRegisterInstruction>(index).registerA
method.addInstructions(

View File

@@ -93,7 +93,7 @@ val lithoFilterPatch = bytecodePatch(
protobufBufferReferenceMethod.let {
// Hook the buffer after the call to jniDecode().
it.method.addInstruction(
it.instructionMatches.last().index + 1,
it.indices.last() + 1,
"invoke-static { p1 }, $EXTENSION_CLASS_DESCRIPTOR->setProtoBuffer([B)V",
)
}

View File

@@ -52,7 +52,7 @@ val `Loop video` by creatingBytecodePatch(
invoke-static {}, $EXTENSION_CLASS_DESCRIPTOR->shouldLoopVideo()Z
move-result v0
if-eqz v0, :do_not_loop
invoke-virtual { p0 }, ${videoStartPlaybackFingerprint.method}
invoke-virtual { p0 }, $videoStartPlaybackMethod
return-void
:do_not_loop
nop

View File

@@ -140,7 +140,7 @@ val navigationBarHookPatch = bytecodePatch(description = "Hooks the active navig
// so this works regardless which layout is used.
actionBarSearchResultsMethod.let {
it.method.apply {
val instructionIndex = it.instructionMatches.last().index
val instructionIndex = it.indices.last()
val viewRegister = getInstruction<FiveRegisterInstruction>(instructionIndex).registerC
addInstruction(
@@ -155,7 +155,7 @@ val navigationBarHookPatch = bytecodePatch(description = "Hooks the active navig
toolbarLayoutMethod.let {
it.method.apply {
val index = it.instructionMatches.last().index
val index = it.indices.last()
val register = getInstruction<OneRegisterInstruction>(index).registerA
addInstruction(
@@ -218,7 +218,7 @@ val navigationBarHookPatch = bytecodePatch(description = "Hooks the active navig
.instructionMatches.last().getInstruction<ReferenceInstruction>().reference
setEnumMapMethod.apply {
val setEnumIntegerIndex = setEnumMapMethod.instructionMatches.last().index
val setEnumIntegerIndex = setEnumMapMethod.indices.last()
val enumMapRegister = getInstruction<FiveRegisterInstruction>(setEnumIntegerIndex).registerC
val insertIndex = setEnumIntegerIndex + 1
val freeRegister = findFreeRegister(insertIndex, enumMapRegister)

View File

@@ -248,7 +248,7 @@ val playerControlsPatch = bytecodePatch(
it.method.apply {
inflateBottomControlMethod = this
val inflateReturnObjectIndex = it.instructionMatches.last().index
val inflateReturnObjectIndex = it.indices.last()
inflateBottomControlRegister = getInstruction<OneRegisterInstruction>(inflateReturnObjectIndex).registerA
inflateBottomControlInsertIndex = inflateReturnObjectIndex + 1
}
@@ -258,7 +258,7 @@ val playerControlsPatch = bytecodePatch(
it.method.apply {
inflateTopControlMethod = this
val inflateReturnObjectIndex = it.instructionMatches.last().index
val inflateReturnObjectIndex = it.indices.last()
inflateTopControlRegister = getInstruction<OneRegisterInstruction>(inflateReturnObjectIndex).registerA
inflateTopControlInsertIndex = inflateReturnObjectIndex + 1
}
@@ -272,7 +272,7 @@ val playerControlsPatch = bytecodePatch(
// when seeking and other situations.
overlayViewInflateMethod.let {
it.method.apply {
val index = it.instructionMatches.last().index
val index = it.indices.last()
val register = getInstruction<OneRegisterInstruction>(index).registerA
addInstruction(

View File

@@ -36,7 +36,7 @@ val playerTypeHookPatch = bytecodePatch(
reelWatchPagerMethod.let {
it.method.apply {
val index = it.instructionMatches.last().index
val index = it.indices.last()
val register = getInstruction<OneRegisterInstruction>(index).registerA
addInstruction(

View File

@@ -62,7 +62,7 @@ internal val advancedVideoQualityMenuPatch = bytecodePatch {
// and for the Shorts quality flyout on newer app versions.
videoQualityMenuViewInflateMethod.let {
it.method.apply {
val checkCastIndex = it.instructionMatches.last().index
val checkCastIndex = it.indices.last()
val listViewRegister = getInstruction<OneRegisterInstruction>(checkCastIndex).registerA
addInstruction(