fix error & update to latest patcher

This commit is contained in:
oSumAtrIX
2026-01-28 20:10:53 +01:00
parent 7d891afd2e
commit e928128a94
34 changed files with 114 additions and 118 deletions

View File

@@ -13,14 +13,14 @@ import com.android.tools.smali.dexlib2.util.MethodUtil
private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/all/misc/hide/adb/HideAdbPatch;"
private val SETTINGS_GLOBAL_GET_INT_OR_THROW_METHOD_REFERENCE = ImmutableMethodReference(
"Landroid/provider/Settings\$Global;",
$$"Landroid/provider/Settings$Global;",
"getInt",
listOf("Landroid/content/ContentResolver;", "Ljava/lang/String;"),
"I",
)
private val SETTINGS_GLOBAL_GET_INT_OR_DEFAULT_METHOD_REFERENCE = ImmutableMethodReference(
"Landroid/provider/Settings\$Global;",
$$"Landroid/provider/Settings$Global;",
"getInt",
listOf("Landroid/content/ContentResolver;", "Ljava/lang/String;", "I"),
"I",

View File

@@ -1,5 +1,6 @@
package app.revanced.patches.all.misc.connectivity.telephony.sim.spoof
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.replaceInstruction
import app.revanced.patcher.patch.bytecodePatch
@@ -10,7 +11,6 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
import com.android.tools.smali.dexlib2.immutable.reference.ImmutableMethodReference
import com.android.tools.smali.dexlib2.mutable.MutableMethod
import com.android.tools.smali.dexlib2.util.MethodUtil
import java.util.*

View File

@@ -1,7 +1,7 @@
package app.revanced.patches.all.misc.transformation
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.patcher.extensions.replaceInstruction
import com.android.tools.smali.dexlib2.mutable.MutableMethod
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.ClassDef
import com.android.tools.smali.dexlib2.iface.instruction.Instruction

View File

@@ -1,6 +1,6 @@
package app.revanced.patches.all.misc.transformation
import com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.util.forEachInstructionAsSequence
import com.android.tools.smali.dexlib2.iface.ClassDef

View File

@@ -1,5 +1,6 @@
package app.revanced.patches.facebook.ads.mainfeed
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod.Companion.toMutable
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.addInstructionsWithLabels
import app.revanced.patcher.patch.bytecodePatch
@@ -8,7 +9,6 @@ import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction31i
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
import com.android.tools.smali.dexlib2.immutable.ImmutableMethodParameter
import com.android.tools.smali.dexlib2.mutable.MutableMethod.Companion.toMutable
@Suppress("unused")
val hideSponsoredStoriesPatch = bytecodePatch("Hide 'Sponsored Stories'") {

View File

@@ -1,8 +1,8 @@
package app.revanced.patches.facebook.ads.story
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.util.returnEarly
import com.android.tools.smali.dexlib2.mutable.MutableMethod
@Suppress("unused")
val hideStoryAdsPatch = bytecodePatch(

View File

@@ -1,11 +1,11 @@
package app.revanced.patches.instagram.misc.share
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.patch.BytecodePatchContext
import app.revanced.util.indexOfFirstInstruction
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import com.android.tools.smali.dexlib2.mutable.MutableMethod
internal fun BytecodePatchContext.editShareLinksPatch(block: MutableMethod.(index: Int, register: Int) -> Unit) {
val methodsToPatch = arrayOf(

View File

@@ -4,6 +4,7 @@ import app.revanced.patcher.*
import com.android.tools.smali.dexlib2.Opcode
internal val getMobileConfigBoolMethodMatch = firstMethodComposite {
parameterTypes("J")
returnType("Z")
opcodes(Opcode.RETURN)
custom { "Lcom/facebook/mobileconfig/factory/MobileConfigUnsafeContext;" in immutableClassDef.interfaces }

View File

@@ -1,12 +1,12 @@
package app.revanced.patches.reddit.customclients.infinityforreddit.api
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod.Companion.toMutable
import app.revanced.patcher.classDef
import app.revanced.patcher.extensions.toInstructions
import app.revanced.patches.reddit.customclients.spoofClientPatch
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
import com.android.tools.smali.dexlib2.immutable.ImmutableMethodImplementation
import com.android.tools.smali.dexlib2.mutable.MutableMethod.Companion.toMutable
val spoofClientPatch = spoofClientPatch(redirectUri = "infinity://localhost") { clientIdOption ->
compatibleWith(

View File

@@ -1,5 +1,6 @@
package app.revanced.patches.shared.layout.branding
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.patch.*
@@ -15,7 +16,6 @@ import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
import com.android.tools.smali.dexlib2.iface.reference.TypeReference
import com.android.tools.smali.dexlib2.mutable.MutableMethod
import org.w3c.dom.Element
import org.w3c.dom.NodeList
import java.io.File

View File

@@ -1,5 +1,8 @@
package app.revanced.patches.shared.misc.audio
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableField.Companion.toMutable
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod.Companion.toMutable
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.addInstructionsWithLabels
@@ -21,9 +24,6 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.immutable.ImmutableField
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
import com.android.tools.smali.dexlib2.immutable.ImmutableMethodParameter
import com.android.tools.smali.dexlib2.mutable.MutableField.Companion.toMutable
import com.android.tools.smali.dexlib2.mutable.MutableMethod
import com.android.tools.smali.dexlib2.mutable.MutableMethod.Companion.toMutable
private const val EXTENSION_CLASS_DESCRIPTOR =
"Lapp/revanced/extension/shared/patches/ForceOriginalAudioPatch;"
@@ -37,12 +37,11 @@ internal fun forceOriginalAudioPatch(
fixUseLocalizedAudioTrackFlag: BytecodePatchContext.() -> Boolean,
getMainActivityOnCreateMethod: BytecodePatchContext.() -> MutableMethod,
subclassExtensionClassDescriptor: String,
preferenceScreen: BasePreferenceScreen.Screen
preferenceScreen: BasePreferenceScreen.Screen,
) = bytecodePatch(
name = "Force original audio", // TODO
description = "Adds an option to always use the original audio track.",
) {
block()
dependsOn(addResourcesPatch)
@@ -53,13 +52,13 @@ internal fun forceOriginalAudioPatch(
preferenceScreen.addPreferences(
SwitchPreference(
key = "revanced_force_original_audio",
tag = "app.revanced.extension.shared.settings.preference.ForceOriginalAudioSwitchPreference"
)
tag = "app.revanced.extension.shared.settings.preference.ForceOriginalAudioSwitchPreference",
),
)
getMainActivityOnCreateMethod().addInstruction(
0,
"invoke-static { }, $subclassExtensionClassDescriptor->setEnabled()V"
"invoke-static { }, $subclassExtensionClassDescriptor->setEnabled()V",
)
// Disable feature flag that ignores the default track flag
@@ -67,7 +66,7 @@ internal fun forceOriginalAudioPatch(
if (fixUseLocalizedAudioTrackFlag()) {
selectAudioStreamMethodMatch.method.insertLiteralOverride(
selectAudioStreamMethodMatch.indices.first(),
"$EXTENSION_CLASS_DESCRIPTOR->ignoreDefaultAudioStream(Z)Z"
"$EXTENSION_CLASS_DESCRIPTOR->ignoreDefaultAudioStream(Z)Z",
)
}
@@ -93,8 +92,8 @@ internal fun forceOriginalAudioPatch(
AccessFlags.PRIVATE.value or AccessFlags.VOLATILE.value,
null,
null,
null
).toMutable()
null,
).toMutable(),
)
// Add a helper method because the isDefaultAudioTrack() has only 2 registers and 3 are needed.
@@ -133,7 +132,7 @@ internal fun forceOriginalAudioPatch(
move-result-object v0
iput-object v0, p0, $helperMethodClass->$helperFieldName:Ljava/lang/Boolean;
return v3
"""
""",
)
}
methods.add(helperMethod)
@@ -148,7 +147,7 @@ internal fun forceOriginalAudioPatch(
"""
invoke-direct { p0, v$register }, $helperMethodClass->$helperMethodName(Z)Z
move-result v$register
"""
""",
)
}
}

View File

@@ -1,19 +1,19 @@
package app.revanced.patches.shared.misc.checks
import android.os.Build.*
import app.revanced.com.android.tools.smali.dexlib2.iface.value.MutableEncodedValue
import app.revanced.com.android.tools.smali.dexlib2.iface.value.MutableLongEncodedValue
import app.revanced.com.android.tools.smali.dexlib2.iface.value.MutableStringEncodedValue
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableClassDef
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.patch.BytecodePatchContext
import app.revanced.patcher.patch.Patch
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.all.misc.resources.addResources
import app.revanced.patches.all.misc.resources.addResourcesPatch
import com.android.tools.smali.dexlib2.iface.value.MutableEncodedValue
import com.android.tools.smali.dexlib2.iface.value.MutableLongEncodedValue
import com.android.tools.smali.dexlib2.iface.value.MutableStringEncodedValue
import com.android.tools.smali.dexlib2.immutable.value.ImmutableLongEncodedValue
import com.android.tools.smali.dexlib2.immutable.value.ImmutableStringEncodedValue
import com.android.tools.smali.dexlib2.mutable.MutableClassDef
import com.android.tools.smali.dexlib2.mutable.MutableMethod
import java.nio.charset.StandardCharsets
import java.security.MessageDigest
import kotlin.io.encoding.Base64

View File

@@ -1,11 +1,11 @@
package app.revanced.patches.shared.misc.dns
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.patch.BytecodePatchBuilder
import app.revanced.patcher.patch.BytecodePatchContext
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.all.misc.resources.addResources
import com.android.tools.smali.dexlib2.mutable.MutableMethod
private const val EXTENSION_CLASS_DESCRIPTOR =
"Lapp/revanced/extension/shared/patches/CheckWatchHistoryDomainNameResolutionPatch;"
@@ -16,7 +16,7 @@ private const val EXTENSION_CLASS_DESCRIPTOR =
internal fun checkWatchHistoryDomainNameResolutionPatch(
block: BytecodePatchBuilder.() -> Unit = {},
executeBlock: BytecodePatchContext.() -> Unit = {},
getMainActivityMethod: BytecodePatchContext.() -> MutableMethod
getMainActivityMethod: BytecodePatchContext.() -> MutableMethod,
) = bytecodePatch(
name = "Check watch history domain name resolution", // TODO
description = "Checks if the device DNS server is preventing user watch history from being saved.",

View File

@@ -1,5 +1,6 @@
package app.revanced.patches.shared.misc.gms
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.instructions
import app.revanced.patcher.extensions.replaceInstruction
@@ -19,7 +20,6 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction21c
import com.android.tools.smali.dexlib2.iface.reference.StringReference
import com.android.tools.smali.dexlib2.immutable.reference.ImmutableStringReference
import com.android.tools.smali.dexlib2.mutable.MutableMethod
import com.android.tools.smali.dexlib2.util.MethodUtil
import org.w3c.dom.Element
import org.w3c.dom.Node

View File

@@ -1,5 +1,7 @@
package app.revanced.patches.shared.misc.spoof
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod.Companion.toMutable
import app.revanced.patcher.custom
import app.revanced.patcher.extensions.*
import app.revanced.patcher.firstMutableMethodDeclaratively
@@ -21,8 +23,6 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
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
internal const val EXTENSION_CLASS_DESCRIPTOR =
"Lapp/revanced/extension/shared/spoof/SpoofVideoStreamsPatch;"
@@ -128,7 +128,7 @@ internal fun spoofVideoStreamsPatch(
addInstruction(
videoDetailsIndex + 1,
"invoke-direct { p0, v$videoDetailsRegister }, " +
"$resultMethodType->$setStreamDataMethodName($videoDetailsClass)V",
"$resultMethodType->$setStreamDataMethodName($videoDetailsClass)V",
)
val protobufClass = protobufClassParseByteBufferMethod.definingClass
@@ -275,7 +275,7 @@ internal fun spoofVideoStreamsPatch(
val mediaFetchEnumClass = definingClass
val sabrFieldIndex = indexOfFirstInstructionOrThrow(disabledBySABRStreamingUrlString) {
opcode == Opcode.SPUT_OBJECT &&
getReference<FieldReference>()?.type == mediaFetchEnumClass
getReference<FieldReference>()?.type == mediaFetchEnumClass
}
Pair(

View File

@@ -1,5 +1,6 @@
package app.revanced.patches.spotify.misc.lyrics
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.patcher.classDef
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.getInstruction
@@ -19,7 +20,6 @@ import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction35c
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
import com.android.tools.smali.dexlib2.immutable.reference.ImmutableMethodReference
import com.android.tools.smali.dexlib2.mutable.MutableMethod
import java.net.InetAddress
import java.net.URI
import java.net.URISyntaxException

View File

@@ -1,12 +1,12 @@
package app.revanced.patches.strava.upselling
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod.Companion.toMutable
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.removeInstruction
import app.revanced.patcher.patch.bytecodePatch
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
import com.android.tools.smali.dexlib2.mutable.MutableMethod.Companion.toMutable
@Suppress("unused")
val disableSubscriptionSuggestionsPatch = bytecodePatch("Disable subscription suggestions") {

View File

@@ -1,8 +1,8 @@
package app.revanced.patches.tiktok.misc.login.fixgoogle
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.util.returnEarly
import com.android.tools.smali.dexlib2.mutable.MutableMethod
@Suppress("unused")
val fixGoogleLoginPatch = bytecodePatch(

View File

@@ -1,8 +1,8 @@
package app.revanced.patches.trakt
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.patch.bytecodePatch
import com.android.tools.smali.dexlib2.mutable.MutableMethod
@Suppress("unused")
val unlockProPatch = bytecodePatch("Unlock pro") {

View File

@@ -1,5 +1,6 @@
package app.revanced.patches.tumblr.featureflags
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod.Companion.toMutable
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.addInstructionsWithLabels
import app.revanced.patcher.patch.bytecodePatch
@@ -7,7 +8,6 @@ import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
import com.android.tools.smali.dexlib2.immutable.ImmutableMethodParameter
import com.android.tools.smali.dexlib2.mutable.MutableMethod.Companion.toMutable
/**
* Override a feature flag with a value.
@@ -73,7 +73,7 @@ val overrideFeatureFlagsPatch = bytecodePatch(
val getFeatureIndex = match.indices.first()
match.method.addInstructionsWithLabels(
getFeatureIndex,
"""
"""
# Call the Helper Method with the Feature
invoke-virtual {p0, p1}, $configurationClass->getValueOverride($featureClass)Ljava/lang/String;
move-result-object v0

View File

@@ -1,5 +1,7 @@
package app.revanced.patches.twitch.misc.settings
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableField.Companion.toMutable
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.patcher.classDef
import app.revanced.patcher.extensions.ExternalLabel
import app.revanced.patcher.extensions.addInstructions
@@ -14,8 +16,6 @@ import app.revanced.patches.shared.misc.settings.settingsPatch
import app.revanced.patches.twitch.misc.extension.sharedExtensionPatch
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.immutable.ImmutableField
import com.android.tools.smali.dexlib2.mutable.MutableField.Companion.toMutable
import com.android.tools.smali.dexlib2.mutable.MutableMethod
private const val REVANCED_SETTINGS_MENU_ITEM_NAME = "RevancedSettings"
private const val REVANCED_SETTINGS_MENU_ITEM_ID = 0x7

View File

@@ -1,5 +1,6 @@
package app.revanced.patches.youtube.interaction.swipecontrols
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod.Companion.toMutable
import app.revanced.patcher.classDef
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patcher.patch.resourcePatch
@@ -21,7 +22,6 @@ import app.revanced.patches.youtube.shared.mainActivityConstructorMethod
import app.revanced.util.*
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
import com.android.tools.smali.dexlib2.mutable.MutableMethod.Companion.toMutable
internal const val EXTENSION_CLASS_DESCRIPTOR =
"Lapp/revanced/extension/youtube/swipecontrols/SwipeControlsHostActivity;"

View File

@@ -2,6 +2,8 @@
package app.revanced.patches.youtube.layout.miniplayer
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod.Companion.toMutable
import app.revanced.patcher.classDef
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.addInstructions
@@ -30,8 +32,6 @@ 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

View File

@@ -1,5 +1,7 @@
package app.revanced.patches.youtube.layout.seekbar
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod.Companion.toMutable
import app.revanced.patcher.*
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.getInstruction
@@ -25,8 +27,6 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
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
private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/theme/SeekbarColorPatch;"

View File

@@ -1,5 +1,6 @@
package app.revanced.patches.youtube.layout.shortsautoplay
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod.Companion.toMutable
import app.revanced.patcher.classDef
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.addInstructions
@@ -30,7 +31,6 @@ 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.Companion.toMutable
private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/ShortsAutoplayPatch;"

View File

@@ -1,5 +1,7 @@
package app.revanced.patches.youtube.misc.imageurlhook
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod.Companion.toMutable
import app.revanced.patcher.classDef
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.addInstructions
@@ -14,8 +16,6 @@ import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
import com.android.tools.smali.dexlib2.mutable.MutableMethod
import com.android.tools.smali.dexlib2.mutable.MutableMethod.Companion.toMutable
private lateinit var loadImageUrlMethod: MutableMethod
private var loadImageUrlIndex = 0

View File

@@ -1,5 +1,7 @@
package app.revanced.patches.youtube.misc.navigation
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod.Companion.toMutable
import app.revanced.patcher.classDef
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.addInstructions
@@ -28,8 +30,6 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
import com.android.tools.smali.dexlib2.mutable.MutableMethod
import com.android.tools.smali.dexlib2.mutable.MutableMethod.Companion.toMutable
import com.android.tools.smali.dexlib2.util.MethodUtil
import java.util.logging.Logger
@@ -73,7 +73,7 @@ val navigationBarHookPatch = bytecodePatch(description = "Hooks the active navig
addInstruction(
insertIndex,
"invoke-static { v$register }, " +
"$EXTENSION_CLASS_DESCRIPTOR->${hook.methodName}(${hook.parameters})V",
"$EXTENSION_CLASS_DESCRIPTOR->${hook.methodName}(${hook.parameters})V",
)
}
}
@@ -83,7 +83,7 @@ val navigationBarHookPatch = bytecodePatch(description = "Hooks the active navig
val navigationEnumClassName = navigationEnumMethod.classDef.type
addHook(NavigationHook.SET_LAST_APP_NAVIGATION_ENUM) {
opcode == Opcode.INVOKE_STATIC &&
getReference<MethodReference>()?.definingClass == navigationEnumClassName
getReference<MethodReference>()?.definingClass == navigationEnumClassName
}
// Hook the creation of navigation tab views.
@@ -121,7 +121,7 @@ val navigationBarHookPatch = bytecodePatch(description = "Hooks the active navig
addInstruction(
index + 1,
"invoke-static { v$viewRegister, v$isSelectedRegister }, " +
"$EXTENSION_CLASS_DESCRIPTOR->navigationTabSelected(Landroid/view/View;Z)V",
"$EXTENSION_CLASS_DESCRIPTOR->navigationTabSelected(Landroid/view/View;Z)V",
)
}
@@ -145,7 +145,7 @@ val navigationBarHookPatch = bytecodePatch(description = "Hooks the active navig
addInstruction(
instructionIndex,
"invoke-static { v$viewRegister }, " +
"$EXTENSION_CLASS_DESCRIPTOR->searchBarResultsViewLoaded(Landroid/view/View;)V",
"$EXTENSION_CLASS_DESCRIPTOR->searchBarResultsViewLoaded(Landroid/view/View;)V",
)
}
}
@@ -199,7 +199,7 @@ val navigationBarHookPatch = bytecodePatch(description = "Hooks the active navig
navigationBarHookCallbackMethod.addInstruction(
0,
"invoke-static { p0, p1 }, $extensionClassDescriptor->navigationTabCreated" +
"(${EXTENSION_NAVIGATION_BUTTON_DESCRIPTOR}Landroid/view/View;)V",
"(${EXTENSION_NAVIGATION_BUTTON_DESCRIPTOR}Landroid/view/View;)V",
)
}

View File

@@ -1,5 +1,6 @@
package app.revanced.patches.youtube.misc.playercontrols
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.immutableClassDef
@@ -13,7 +14,6 @@ import app.revanced.patches.youtube.misc.playservice.*
import app.revanced.util.*
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.mutable.MutableMethod
import org.w3c.dom.Node
/**

View File

@@ -1,5 +1,8 @@
package app.revanced.patches.youtube.misc.settings
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableClassDef
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod.Companion.toMutable
import app.revanced.patcher.classDef
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.getInstruction
@@ -27,9 +30,6 @@ import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
import com.android.tools.smali.dexlib2.immutable.ImmutableMethodParameter
import com.android.tools.smali.dexlib2.mutable.MutableClassDef
import com.android.tools.smali.dexlib2.mutable.MutableMethod
import com.android.tools.smali.dexlib2.mutable.MutableMethod.Companion.toMutable
import com.android.tools.smali.dexlib2.util.MethodUtil
private const val BASE_ACTIVITY_HOOK_CLASS_DESCRIPTOR =

View File

@@ -1,5 +1,8 @@
package app.revanced.patches.youtube.video.information
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableClassDef
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod.Companion.toMutable
import app.revanced.patcher.classDef
import app.revanced.patcher.extensions.*
import app.revanced.patcher.firstMutableClassDef
@@ -34,9 +37,6 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
import com.android.tools.smali.dexlib2.immutable.ImmutableMethodImplementation
import com.android.tools.smali.dexlib2.immutable.ImmutableMethodParameter
import com.android.tools.smali.dexlib2.mutable.MutableClassDef
import com.android.tools.smali.dexlib2.mutable.MutableMethod
import com.android.tools.smali.dexlib2.mutable.MutableMethod.Companion.toMutable
import com.android.tools.smali.dexlib2.util.MethodUtil
private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/VideoInformation;"
@@ -106,7 +106,7 @@ val videoInformationPatch = bytecodePatch(
addSeekInterfaceMethods(
playVideoCheckVideoStreamingDataResponseMethod.classDef,
classDef.getSeekMethod(),
classDef.getSeekRelativeMethod()
classDef.getSeekRelativeMethod(),
)
}
@@ -125,7 +125,7 @@ val videoInformationPatch = bytecodePatch(
addSeekInterfaceMethods(
classDef,
classDef.getMdxSeekMethod(),
classDef.getMdxSeekRelativeMethod()
classDef.getMdxSeekRelativeMethod(),
)
}
@@ -140,7 +140,7 @@ val videoInformationPatch = bytecodePatch(
addInstruction(
videoLengthMethodMatch.indices.last(),
"invoke-static {v$videoLengthRegister, v$dummyRegisterForLong}, " +
"$EXTENSION_CLASS_DESCRIPTOR->setVideoLength(J)V",
"$EXTENSION_CLASS_DESCRIPTOR->setVideoLength(J)V",
)
}
}
@@ -162,7 +162,7 @@ val videoInformationPatch = bytecodePatch(
addPlayerResponseMethodHook(
Hook.ProtoBufferParameterBeforeVideoId(
"$EXTENSION_CLASS_DESCRIPTOR->" +
"newPlayerResponseSignature(Ljava/lang/String;Ljava/lang/String;Z)Ljava/lang/String;",
"newPlayerResponseSignature(Ljava/lang/String;Ljava/lang/String;Z)Ljava/lang/String;",
),
)
@@ -232,9 +232,11 @@ val videoInformationPatch = bytecodePatch(
:ignore
return-void
""".toInstructions(), null, null
)
).toMutable()
""".toInstructions(),
null,
null,
),
).toMutable(),
)
}
@@ -246,7 +248,7 @@ val videoInformationPatch = bytecodePatch(
// Set playback speed class.
addInstructionsAtControlFlowLabel(
index,
"sput-object v$register, $EXTENSION_CLASS_DESCRIPTOR->playbackSpeedClass:$playbackSpeedClass"
"sput-object v$register, $EXTENSION_CLASS_DESCRIPTOR->playbackSpeedClass:$playbackSpeedClass",
)
val smaliInstructions =
@@ -263,7 +265,7 @@ val videoInformationPatch = bytecodePatch(
"overridePlaybackSpeed",
"playbackSpeedClass",
playbackSpeedClass,
smaliInstructions
smaliInstructions,
)
}
@@ -286,7 +288,7 @@ val videoInformationPatch = bytecodePatch(
"""
invoke-static { $nameRegister, p1 }, $EXTENSION_CLASS_DESCRIPTOR->fixVideoQualityResolution(Ljava/lang/String;I)I
move-result p1
"""
""",
)
// Add methods to access obfuscated quality fields.
@@ -312,9 +314,9 @@ val videoInformationPatch = bytecodePatch(
"""
iget-object v0, p0, $qualityNameField
return-object v0
"""
""",
)
}
},
)
methods.add(
@@ -337,9 +339,9 @@ val videoInformationPatch = bytecodePatch(
"""
iget v0, p0, $resolutionField
return v0
"""
""",
)
}
},
)
}
}
@@ -360,7 +362,7 @@ val videoInformationPatch = bytecodePatch(
type,
"patch_setQuality",
listOf(
ImmutableMethodParameter(YOUTUBE_VIDEO_QUALITY_CLASS_TYPE, null, null)
ImmutableMethodParameter(YOUTUBE_VIDEO_QUALITY_CLASS_TYPE, null, null),
),
"V",
AccessFlags.PUBLIC.value or AccessFlags.FINAL.value,
@@ -377,9 +379,9 @@ val videoInformationPatch = bytecodePatch(
"""
invoke-virtual { p0, p1 }, $setQualityMenuIndexMethod
return-void
"""
""",
)
}
},
)
}
@@ -392,7 +394,7 @@ val videoInformationPatch = bytecodePatch(
invoke-static { p1, v0, p2 }, $EXTENSION_CLASS_DESCRIPTOR->setVideoQuality([$YOUTUBE_VIDEO_QUALITY_CLASS_TYPE${EXTENSION_VIDEO_QUALITY_MENU_INTERFACE}I)I
move-result p2
"""
""",
)
}
@@ -450,11 +452,9 @@ private fun addSeekInterfaceMethods(targetClass: MutableClassDef, seekToMethod:
}
}
private fun MutableMethod.insert(insertIndex: Int, register: String, descriptor: String) =
addInstruction(insertIndex, "invoke-static { $register }, $descriptor")
private fun MutableMethod.insert(insertIndex: Int, register: String, descriptor: String) = addInstruction(insertIndex, "invoke-static { $register }, $descriptor")
private fun MutableMethod.insertTimeHook(insertIndex: Int, descriptor: String) =
insert(insertIndex, "p1, p2", descriptor)
private fun MutableMethod.insertTimeHook(insertIndex: Int, descriptor: String) = insert(insertIndex, "p1, p2", descriptor)
/**
* Hook the player controller. Called when a video is opened or the current video is changed.
@@ -465,12 +465,11 @@ private fun MutableMethod.insertTimeHook(insertIndex: Int, descriptor: String) =
* @param targetMethodClass The descriptor for the class to invoke when the player controller is created.
* @param targetMethodName The name of the static method to invoke when the player controller is created.
*/
internal fun onCreateHook(targetMethodClass: String, targetMethodName: String) =
playerInitMethod.insert(
playerInitInsertIndex++,
"v$playerInitInsertRegister",
"$targetMethodClass->$targetMethodName($EXTENSION_PLAYER_INTERFACE)V",
)
internal fun onCreateHook(targetMethodClass: String, targetMethodName: String) = playerInitMethod.insert(
playerInitInsertIndex++,
"v$playerInitInsertRegister",
"$targetMethodClass->$targetMethodName($EXTENSION_PLAYER_INTERFACE)V",
)
/**
* Hook the MDX player director. Called when playing videos while casting to a big screen device.
@@ -478,12 +477,11 @@ internal fun onCreateHook(targetMethodClass: String, targetMethodName: String) =
* @param targetMethodClass The descriptor for the class to invoke when the player controller is created.
* @param targetMethodName The name of the static method to invoke when the player controller is created.
*/
internal fun onCreateHookMdx(targetMethodClass: String, targetMethodName: String) =
mdxInitMethod.insert(
mdxInitInsertIndex++,
"v$mdxInitInsertRegister",
"$targetMethodClass->$targetMethodName($EXTENSION_PLAYER_INTERFACE)V",
)
internal fun onCreateHookMdx(targetMethodClass: String, targetMethodName: String) = mdxInitMethod.insert(
mdxInitInsertIndex++,
"v$mdxInitInsertRegister",
"$targetMethodClass->$targetMethodName($EXTENSION_PLAYER_INTERFACE)V",
)
/**
* Hook the video time.
@@ -492,20 +490,18 @@ internal fun onCreateHookMdx(targetMethodClass: String, targetMethodName: String
* @param targetMethodClass The descriptor for the static method to invoke when the player controller is created.
* @param targetMethodName The name of the static method to invoke when the player controller is created.
*/
fun videoTimeHook(targetMethodClass: String, targetMethodName: String) =
timeMethod.insertTimeHook(
timeInitInsertIndex++,
"$targetMethodClass->$targetMethodName(J)V",
)
fun videoTimeHook(targetMethodClass: String, targetMethodName: String) = timeMethod.insertTimeHook(
timeInitInsertIndex++,
"$targetMethodClass->$targetMethodName(J)V",
)
/**
* Hook when the video speed is changed for any reason _except when the user manually selects a new speed_.
*/
fun videoSpeedChangedHook(targetMethodClass: String, targetMethodName: String) =
setPlaybackSpeedMethod.addInstruction(
setPlaybackSpeedMethodIndex++,
"invoke-static { p1 }, $targetMethodClass->$targetMethodName(F)V"
)
fun videoSpeedChangedHook(targetMethodClass: String, targetMethodName: String) = setPlaybackSpeedMethod.addInstruction(
setPlaybackSpeedMethodIndex++,
"invoke-static { p1 }, $targetMethodClass->$targetMethodName(F)V",
)
/**
* Hook the video speed selected by the user.
@@ -513,11 +509,11 @@ fun videoSpeedChangedHook(targetMethodClass: String, targetMethodName: String) =
fun userSelectedPlaybackSpeedHook(targetMethodClass: String, targetMethodName: String) {
legacySpeedSelectionInsertMethod.addInstruction(
legacySpeedSelectionInsertIndex++,
"invoke-static { v$legacySpeedSelectionValueRegister }, $targetMethodClass->$targetMethodName(F)V"
"invoke-static { v$legacySpeedSelectionValueRegister }, $targetMethodClass->$targetMethodName(F)V",
)
speedSelectionInsertMethod.addInstruction(
speedSelectionInsertIndex++,
"invoke-static { v$speedSelectionValueRegister }, $targetMethodClass->$targetMethodName(F)V",
)
}
}

View File

@@ -1,5 +1,6 @@
package app.revanced.patches.youtube.video.playerresponse
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.patch.bytecodePatch
@@ -11,7 +12,6 @@ import app.revanced.patches.youtube.misc.playservice.is_20_15_or_greater
import app.revanced.patches.youtube.misc.playservice.is_20_26_or_greater
import app.revanced.patches.youtube.misc.playservice.is_20_46_or_greater
import app.revanced.patches.youtube.misc.playservice.versionCheckPatch
import com.android.tools.smali.dexlib2.mutable.MutableMethod
private val hooks = mutableSetOf<Hook>()

View File

@@ -1,5 +1,6 @@
package app.revanced.patches.youtube.video.speed.custom
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableField.Companion.toMutable
import app.revanced.patcher.classDef
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.addInstructions
@@ -31,7 +32,6 @@ import app.revanced.util.returnEarly
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.immutable.ImmutableField
import com.android.tools.smali.dexlib2.mutable.MutableField.Companion.toMutable
private const val FILTER_CLASS_DESCRIPTOR =
"Lapp/revanced/extension/youtube/patches/components/PlaybackSpeedMenuFilter;"

View File

@@ -1,5 +1,6 @@
package app.revanced.patches.youtube.video.videoid
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.patch.bytecodePatch
@@ -9,7 +10,6 @@ import app.revanced.patches.youtube.video.playerresponse.Hook
import app.revanced.patches.youtube.video.playerresponse.addPlayerResponseMethodHook
import app.revanced.patches.youtube.video.playerresponse.playerResponseMethodHookPatch
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.mutable.MutableMethod
/**
* Hooks the new video id when the video changes.

View File

@@ -1,5 +1,9 @@
package app.revanced.util
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableClassDef
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableField
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableField.Companion.toMutable
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.patcher.*
import app.revanced.patcher.extensions.*
import app.revanced.patcher.patch.BytecodePatchContext
@@ -23,10 +27,6 @@ import com.android.tools.smali.dexlib2.iface.reference.StringReference
import com.android.tools.smali.dexlib2.iface.value.*
import com.android.tools.smali.dexlib2.immutable.ImmutableField
import com.android.tools.smali.dexlib2.immutable.value.*
import com.android.tools.smali.dexlib2.mutable.MutableClassDef
import com.android.tools.smali.dexlib2.mutable.MutableField
import com.android.tools.smali.dexlib2.mutable.MutableField.Companion.toMutable
import com.android.tools.smali.dexlib2.mutable.MutableMethod
import com.android.tools.smali.dexlib2.util.MethodUtil
import java.util.*