mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 21:27:43 +02:00
chore: remove obsolete code
This commit is contained in:
@ -3,13 +3,13 @@ package app.revanced.patches.youtube.player.ambientmode
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patches.youtube.player.ambientmode.fingerprints.AmbientModeInFullscreenFingerprint
|
||||
import app.revanced.patches.youtube.player.ambientmode.fingerprints.PowerSaveModeBroadcastReceiverFingerprint
|
||||
import app.revanced.patches.youtube.player.ambientmode.fingerprints.PowerSaveModeSyntheticFingerprint
|
||||
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.findMethodOrThrow
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
|
||||
import app.revanced.util.indexOfFirstStringInstructionOrThrow
|
||||
@ -19,7 +19,6 @@ import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
|
||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
|
||||
@Suppress("unused")
|
||||
@ -60,27 +59,30 @@ object AmbientModeSwitchPatch : BaseBytecodePatch(
|
||||
}
|
||||
|
||||
syntheticClassList.distinct().forEach { className ->
|
||||
context.findClass(className)?.mutableClass?.methods?.first { method ->
|
||||
method.name == "accept"
|
||||
}?.apply {
|
||||
for (index in implementation!!.instructions.size - 1 downTo 0) {
|
||||
val instruction = getInstruction(index)
|
||||
if (instruction.opcode != Opcode.INVOKE_VIRTUAL)
|
||||
continue
|
||||
context.findMethodOrThrow(className) {
|
||||
name == "accept"
|
||||
}.apply {
|
||||
implementation!!.instructions
|
||||
.withIndex()
|
||||
.filter { (_, instruction) ->
|
||||
val reference = (instruction as? ReferenceInstruction)?.reference
|
||||
instruction.opcode == Opcode.INVOKE_VIRTUAL &&
|
||||
reference is MethodReference &&
|
||||
reference.name == "isPowerSaveMode"
|
||||
}
|
||||
.map { (index, _) -> index }
|
||||
.reversed()
|
||||
.forEach { index ->
|
||||
val register = getInstruction<OneRegisterInstruction>(index + 1).registerA
|
||||
|
||||
if (((instruction as Instruction35c).reference as MethodReference).name != "isPowerSaveMode")
|
||||
continue
|
||||
|
||||
val register = getInstruction<OneRegisterInstruction>(index + 1).registerA
|
||||
|
||||
addInstructions(
|
||||
index + 2, """
|
||||
invoke-static {v$register}, $PLAYER_CLASS_DESCRIPTOR->bypassAmbientModeRestrictions(Z)Z
|
||||
move-result v$register
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: throw PatchException("Could not find $className")
|
||||
addInstructions(
|
||||
index + 2, """
|
||||
invoke-static {v$register}, $PLAYER_CLASS_DESCRIPTOR->bypassAmbientModeRestrictions(Z)Z
|
||||
move-result v$register
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
@ -48,6 +48,7 @@ import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.TapBl
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.patches.youtube.video.information.VideoInformationPatch
|
||||
import app.revanced.util.REGISTER_TEMPLATE_REPLACEMENT
|
||||
import app.revanced.util.findMethodOrThrow
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
|
||||
@ -146,15 +147,13 @@ object PlayerComponentsPatch : BaseBytecodePatch(
|
||||
hookInitVideoPanel(1)
|
||||
} else {
|
||||
val syntheticIndex =
|
||||
indexOfFirstInstructionOrThrow(opcode = Opcode.NEW_INSTANCE)
|
||||
indexOfFirstInstructionOrThrow(Opcode.NEW_INSTANCE)
|
||||
val syntheticReference =
|
||||
getInstruction<ReferenceInstruction>(syntheticIndex).reference.toString()
|
||||
val syntheticClass =
|
||||
context.findClass(syntheticReference)!!.mutableClass
|
||||
|
||||
syntheticClass.methods.find { method -> method.name == "onClick" }
|
||||
?.hookInitVideoPanel(0)
|
||||
?: throw PatchException("Could not find onClick method in $syntheticReference")
|
||||
context.findMethodOrThrow(syntheticReference) {
|
||||
name == "onClick"
|
||||
}.hookInitVideoPanel(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.AutoN
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.FullScreenEngagementPanel
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.QuickActionsElementContainer
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.findMethodOrThrow
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.getWalkerMethod
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
@ -253,18 +254,16 @@ object FullscreenComponentsPatch : BaseBytecodePatch(
|
||||
val invokeIndex =
|
||||
indexOfFirstInstructionOrThrow(stringIndex, Opcode.INVOKE_INTERFACE)
|
||||
val targetIndex = indexOfFirstInstructionOrThrow(invokeIndex, Opcode.CHECK_CAST)
|
||||
val targetClass = context
|
||||
.findClass(getInstruction<ReferenceInstruction>(targetIndex).reference.toString())!!
|
||||
.mutableClass
|
||||
val targetClass =
|
||||
getInstruction<ReferenceInstruction>(targetIndex).reference.toString()
|
||||
|
||||
// add an instruction to check the vertical video
|
||||
targetClass.methods.find { method -> method.parameters == listOf("I", "I", "Z") }
|
||||
?.apply {
|
||||
addInstruction(
|
||||
1,
|
||||
"invoke-static {p1, p2}, $PLAYER_CLASS_DESCRIPTOR->setVideoPortrait(II)V"
|
||||
)
|
||||
} ?: throw PatchException("Could not find targetMethod")
|
||||
context.findMethodOrThrow(targetClass) {
|
||||
parameters == listOf("I", "I", "Z")
|
||||
}.addInstruction(
|
||||
1,
|
||||
"invoke-static {p1, p2}, $PLAYER_CLASS_DESCRIPTOR->setVideoPortrait(II)V"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -281,14 +280,11 @@ object FullscreenComponentsPatch : BaseBytecodePatch(
|
||||
}
|
||||
|
||||
val walkerMethod = getWalkerMethod(context, walkerIndex)
|
||||
val targetClass =
|
||||
context.findClass(walkerMethod.definingClass)!!.mutableClass
|
||||
val constructorMethod = targetClass
|
||||
.methods
|
||||
.find { method ->
|
||||
method.name == "<init>"
|
||||
&& method.parameterTypes == listOf("Landroid/app/Activity;")
|
||||
} ?: throw PatchException("Constructor method not found!")
|
||||
val constructorMethod =
|
||||
context.findMethodOrThrow(walkerMethod.definingClass) {
|
||||
name == "<init>" &&
|
||||
parameterTypes == listOf("Landroid/app/Activity;")
|
||||
}
|
||||
|
||||
arrayOf(
|
||||
walkerMethod,
|
||||
|
@ -30,6 +30,7 @@ import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelT
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch.contexts
|
||||
import app.revanced.patches.youtube.video.information.VideoInformationPatch
|
||||
import app.revanced.util.findMethodsOrThrow
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.getWalkerMethod
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
@ -38,8 +39,6 @@ import app.revanced.util.injectLiteralInstructionBooleanCall
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction35c
|
||||
import com.android.tools.smali.dexlib2.dexbacked.reference.DexBackedMethodReference
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.NarrowLiteralInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
@ -84,14 +83,15 @@ object SeekbarComponentsPatch : BaseBytecodePatch(
|
||||
SeekbarTappingFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val tapSeekIndex = it.scanResult.patternScanResult!!.startIndex + 1
|
||||
val tapSeekReference = getInstruction<BuilderInstruction35c>(tapSeekIndex).reference
|
||||
val tapSeekClass =
|
||||
context
|
||||
.findClass((tapSeekReference as DexBackedMethodReference).definingClass)!!
|
||||
.mutableClass
|
||||
val tapSeekMethods = mutableMapOf<String, MutableMethod>()
|
||||
val tapSeekClass = getInstruction(tapSeekIndex)
|
||||
.getReference<MethodReference>()!!
|
||||
.definingClass
|
||||
|
||||
for (method in tapSeekClass.methods) {
|
||||
val tapSeekMethods = context.findMethodsOrThrow(tapSeekClass)
|
||||
var pMethodCall = ""
|
||||
var oMethodCall = ""
|
||||
|
||||
for (method in tapSeekMethods) {
|
||||
if (method.implementation == null)
|
||||
continue
|
||||
|
||||
@ -110,15 +110,17 @@ object SeekbarComponentsPatch : BaseBytecodePatch(
|
||||
|
||||
// method founds
|
||||
if (literal == 1)
|
||||
tapSeekMethods["P"] = method
|
||||
pMethodCall = "${method.definingClass}->${method.name}(I)V"
|
||||
else if (literal == 2)
|
||||
tapSeekMethods["O"] = method
|
||||
oMethodCall = "${method.definingClass}->${method.name}(I)V"
|
||||
}
|
||||
|
||||
val pMethod = tapSeekMethods["P"]
|
||||
?: throw PatchException("pMethod not found")
|
||||
val oMethod = tapSeekMethods["O"]
|
||||
?: throw PatchException("oMethod not found")
|
||||
if (pMethodCall.isEmpty()) {
|
||||
throw PatchException("pMethod not found")
|
||||
}
|
||||
if (oMethodCall.isEmpty()) {
|
||||
throw PatchException("oMethod not found")
|
||||
}
|
||||
|
||||
val insertIndex = it.scanResult.patternScanResult!!.startIndex + 2
|
||||
|
||||
@ -127,8 +129,8 @@ object SeekbarComponentsPatch : BaseBytecodePatch(
|
||||
invoke-static {}, $PLAYER_CLASS_DESCRIPTOR->enableSeekbarTapping()Z
|
||||
move-result v0
|
||||
if-eqz v0, :disabled
|
||||
invoke-virtual { p0, v2 }, ${oMethod.definingClass}->${oMethod.name}(I)V
|
||||
invoke-virtual { p0, v2 }, ${pMethod.definingClass}->${pMethod.name}(I)V
|
||||
invoke-virtual { p0, v2 }, $pMethodCall
|
||||
invoke-virtual { p0, v2 }, $oMethodCall
|
||||
""", ExternalLabel("disabled", getInstruction(insertIndex))
|
||||
)
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
@ -20,7 +19,9 @@ import app.revanced.patches.youtube.player.speedoverlay.fingerprints.SpeedOverla
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.util.alsoResolve
|
||||
import app.revanced.util.findMethodOrThrow
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.getWalkerMethod
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
|
||||
import app.revanced.util.injectLiteralInstructionBooleanCall
|
||||
@ -33,7 +34,6 @@ import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
|
||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
import com.android.tools.smali.dexlib2.util.MethodUtil
|
||||
|
||||
@Patch(dependencies = [SharedResourceIdPatch::class])
|
||||
object SpeedOverlayPatch : BytecodePatch(
|
||||
@ -135,16 +135,11 @@ object SpeedOverlayPatch : BytecodePatch(
|
||||
|
||||
hook(insertIndex, insertRegister, jumpIndex)
|
||||
|
||||
val slideToSeekBooleanMethod = context.toMethodWalker(it.mutableMethod)
|
||||
.nextMethod(scanResult.startIndex + 1, true)
|
||||
.getMethod() as MutableMethod
|
||||
val slideToSeekBooleanMethod =
|
||||
getWalkerMethod(context, scanResult.startIndex + 1)
|
||||
|
||||
val slideToSeekConstructorMethod =
|
||||
context.findClass { classDef -> classDef.type == slideToSeekBooleanMethod.definingClass }
|
||||
?.mutableClass
|
||||
?.methods
|
||||
?.find { method -> MethodUtil.isConstructor(method) }
|
||||
?: throw PatchException("Could not find constructor method")
|
||||
context.findMethodOrThrow(slideToSeekBooleanMethod.definingClass)
|
||||
|
||||
val slideToSeekSyntheticIndex = slideToSeekConstructorMethod
|
||||
.indexOfFirstInstructionReversedOrThrow {
|
||||
@ -157,11 +152,9 @@ object SpeedOverlayPatch : BytecodePatch(
|
||||
.toString()
|
||||
|
||||
val slideToSeekSyntheticMethod =
|
||||
context.findClass { classDef -> classDef.type == slideToSeekSyntheticClass }
|
||||
?.mutableClass
|
||||
?.methods
|
||||
?.find { method -> method.name == "run" }
|
||||
?: throw PatchException("Could not find synthetic method")
|
||||
context.findMethodOrThrow(slideToSeekSyntheticClass) {
|
||||
name == "run"
|
||||
}
|
||||
|
||||
Pair(slideToSeekBooleanMethod, slideToSeekSyntheticMethod)
|
||||
}
|
||||
|
Reference in New Issue
Block a user