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.settings.ResourceUtils.addPreference
import app.revanced.patches.youtube.utils.settings.settingsPatch
import app.revanced.util.fingerprint.methodOrThrow
import app.revanced.util.indexOfFirstInstructionOrThrow
import app.revanced.util.fingerprint.matchOrThrow
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
@Suppress("unused")
val hapticFeedbackPatch = bytecodePatch(
@ -26,12 +28,17 @@ val hapticFeedbackPatch = bytecodePatch(
execute {
fun Pair<String, Fingerprint>.hookHapticFeedback(methodName: String) =
methodOrThrow().apply {
matchOrThrow().let {
it.method.apply {
var index = 0
var register = 0
if (name == "run") {
index = indexOfFirstInstructionOrThrow(Opcode.SGET)
val stringIndex = it.stringMatches!!.first().index
index = indexOfFirstInstructionReversedOrThrow(stringIndex) {
opcode == Opcode.SGET &&
getReference<FieldReference>()?.toString() == "Landroid/os/Build${'$'}VERSION;->SDK_INT:I"
}
register = getInstruction<OneRegisterInstruction>(index).registerA
}
@ -44,6 +51,7 @@ val hapticFeedbackPatch = bytecodePatch(
""", ExternalLabel("vibrate", getInstruction(index))
)
}
}
arrayOf(
seekHapticsFingerprint to "disableSeekVibrate",