mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 13:17:46 +02:00
fix(YouTube Music/SponsorBlock): when the app is in the background, segments are not fetched
This commit is contained in:
@ -14,6 +14,7 @@ import app.revanced.patches.music.utils.fingerprints.SeekBarConstructorFingerpri
|
||||
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.patches.music.video.information.fingerprints.PlayerControllerSetTimeReferenceFingerprint
|
||||
import app.revanced.patches.music.video.information.fingerprints.VideoEndFingerprint
|
||||
import app.revanced.patches.music.video.information.fingerprints.VideoIdFingerprint
|
||||
import app.revanced.patches.music.video.information.fingerprints.VideoIdParentFingerprint
|
||||
import app.revanced.patches.music.video.information.fingerprints.VideoLengthFingerprint
|
||||
import app.revanced.util.integrations.Constants.MUSIC_VIDEO_PATH
|
||||
@ -183,37 +184,22 @@ object VideoInformationPatch : BytecodePatch(
|
||||
/**
|
||||
* Inject call for video id
|
||||
*/
|
||||
VideoIdParentFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = it.scanResult.patternScanResult!!.endIndex
|
||||
|
||||
val targetReference = getInstruction<ReferenceInstruction>(targetIndex).reference
|
||||
val targetClass = (targetReference as FieldReference).type
|
||||
|
||||
videoIdMethod = context
|
||||
.findClass(targetClass)!!
|
||||
.mutableClass.methods.first { method ->
|
||||
method.name == "handleVideoStageEvent"
|
||||
}
|
||||
}
|
||||
VideoIdParentFingerprint.result?.let { parentResult ->
|
||||
VideoIdFingerprint.also {
|
||||
it.resolve(
|
||||
context,
|
||||
parentResult.classDef
|
||||
)
|
||||
}.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
videoIdMethod = this
|
||||
videoIdIndex = it.scanResult.patternScanResult!!.endIndex
|
||||
videoIdRegister = getInstruction<OneRegisterInstruction>(videoIdIndex).registerA
|
||||
}
|
||||
offset++ // offset so setVideoId is called before any injected call
|
||||
} ?: throw VideoIdFingerprint.exception
|
||||
} ?: throw VideoIdParentFingerprint.exception
|
||||
|
||||
videoIdMethod.apply {
|
||||
for (index in implementation!!.instructions.size - 1 downTo 0) {
|
||||
if (getInstruction(index).opcode != Opcode.INVOKE_INTERFACE) continue
|
||||
|
||||
val targetReference = getInstruction<ReferenceInstruction>(index).reference
|
||||
|
||||
if (!targetReference.toString().endsWith("Ljava/lang/String;")) continue
|
||||
|
||||
videoIdIndex = index + 1
|
||||
videoIdRegister = getInstruction<OneRegisterInstruction>(videoIdIndex).registerA
|
||||
|
||||
break
|
||||
}
|
||||
offset++ // offset so setVideoId is called before any injected call
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set current video id
|
||||
|
@ -0,0 +1,16 @@
|
||||
package app.revanced.patches.music.video.information.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
object VideoIdFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
parameters = listOf("L", "L", "L"),
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_INTERFACE,
|
||||
Opcode.MOVE_RESULT_OBJECT
|
||||
)
|
||||
)
|
@ -3,18 +3,10 @@ package app.revanced.patches.music.video.information.fingerprints
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
object VideoIdParentFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
parameters = emptyList(),
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_SUPER,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.CONST_4,
|
||||
Opcode.IPUT_OBJECT,
|
||||
Opcode.IGET_OBJECT
|
||||
),
|
||||
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/WatchFragment;") && methodDef.name == "onDestroyView" }
|
||||
strings = listOf("currentWatchNextResponse")
|
||||
)
|
||||
|
Reference in New Issue
Block a user