fix(YouTube - Disable haptic feedback): Disable seek haptic feedback doesn't work

This commit is contained in:
inotia00
2024-12-31 20:33:18 +09:00
parent e29a25fac2
commit dd3c889062

View File

@ -10,10 +10,12 @@ import app.revanced.patches.youtube.utils.extension.Constants.PLAYER_CLASS_DESCR
import app.revanced.patches.youtube.utils.patch.PatchList.DISABLE_HAPTIC_FEEDBACK import app.revanced.patches.youtube.utils.patch.PatchList.DISABLE_HAPTIC_FEEDBACK
import app.revanced.patches.youtube.utils.settings.ResourceUtils.addPreference import app.revanced.patches.youtube.utils.settings.ResourceUtils.addPreference
import app.revanced.patches.youtube.utils.settings.settingsPatch import app.revanced.patches.youtube.utils.settings.settingsPatch
import app.revanced.util.fingerprint.methodOrThrow import app.revanced.util.fingerprint.matchOrThrow
import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
@Suppress("unused") @Suppress("unused")
val hapticFeedbackPatch = bytecodePatch( val hapticFeedbackPatch = bytecodePatch(
@ -26,23 +28,29 @@ val hapticFeedbackPatch = bytecodePatch(
execute { execute {
fun Pair<String, Fingerprint>.hookHapticFeedback(methodName: String) = fun Pair<String, Fingerprint>.hookHapticFeedback(methodName: String) =
methodOrThrow().apply { matchOrThrow().let {
var index = 0 it.method.apply {
var register = 0 var index = 0
var register = 0
if (name == "run") { if (name == "run") {
index = indexOfFirstInstructionOrThrow(Opcode.SGET) val stringIndex = it.stringMatches!!.first().index
register = getInstruction<OneRegisterInstruction>(index).registerA index = indexOfFirstInstructionReversedOrThrow(stringIndex) {
} opcode == Opcode.SGET &&
getReference<FieldReference>()?.toString() == "Landroid/os/Build${'$'}VERSION;->SDK_INT:I"
}
register = getInstruction<OneRegisterInstruction>(index).registerA
}
addInstructionsWithLabels( addInstructionsWithLabels(
index, """ index, """
invoke-static {}, $PLAYER_CLASS_DESCRIPTOR->$methodName()Z invoke-static {}, $PLAYER_CLASS_DESCRIPTOR->$methodName()Z
move-result v$register move-result v$register
if-eqz v$register, :vibrate if-eqz v$register, :vibrate
return-void return-void
""", ExternalLabel("vibrate", getInstruction(index)) """, ExternalLabel("vibrate", getInstruction(index))
) )
}
} }
arrayOf( arrayOf(