mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 05:37:40 +02:00
fix(youtube/default-video-quality): fix default video quality/speed being applied when resuming app
This commit is contained in:
@ -57,7 +57,7 @@ class MainstreamVideoIdPatch : BytecodePatch(
|
||||
playerInitMethod = parentResult.mutableClass.methods.first { MethodUtil.isConstructor(it) }
|
||||
|
||||
// hook the player controller for use through integrations
|
||||
onCreateHook(INTEGRATIONS_CLASS_DESCRIPTOR, "playerController_onCreateHook")
|
||||
onCreateHook(INTEGRATIONS_CLASS_DESCRIPTOR, "initialize")
|
||||
|
||||
SeekFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let {
|
||||
val resultMethod = it.method
|
||||
@ -157,6 +157,9 @@ class MainstreamVideoIdPatch : BytecodePatch(
|
||||
internal var reactReference: String? = null
|
||||
|
||||
private var offset = 0
|
||||
private var playerInitInsertIndex = 4
|
||||
private var timeInitInsertIndex = 2
|
||||
private var highPrecisionInsertIndex = 0
|
||||
|
||||
private var insertIndex: Int = 0
|
||||
private var videoIdRegister: Int = 0
|
||||
@ -178,21 +181,24 @@ class MainstreamVideoIdPatch : BytecodePatch(
|
||||
)
|
||||
}
|
||||
|
||||
private fun MutableMethod.insert(insert: InsertIndex, register: String, descriptor: String) =
|
||||
addInstruction(insert.index, "invoke-static { $register }, $descriptor")
|
||||
private fun MutableMethod.insert(insertIndex: Int, register: String, descriptor: String) =
|
||||
addInstruction(insertIndex, "invoke-static { $register }, $descriptor")
|
||||
|
||||
private fun MutableMethod.insertTimeHook(insert: InsertIndex, descriptor: String) =
|
||||
insert(insert, "p1, p2", descriptor)
|
||||
private fun MutableMethod.insertTimeHook(insertIndex: Int, descriptor: String) =
|
||||
insert(insertIndex, "p1, p2", descriptor)
|
||||
|
||||
/**
|
||||
* Hook the player controller.
|
||||
* Hook the player controller. Called when a video is opened or the current video is changed.
|
||||
*
|
||||
* Note: This hook is called very early and is called before the video id, video time, video length,
|
||||
* and many other data fields are set.
|
||||
*
|
||||
* @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(
|
||||
InsertIndex.CREATE,
|
||||
playerInitInsertIndex++,
|
||||
"v0",
|
||||
"$targetMethodClass->$targetMethodName(Ljava/lang/Object;)V"
|
||||
)
|
||||
@ -206,7 +212,7 @@ class MainstreamVideoIdPatch : BytecodePatch(
|
||||
*/
|
||||
internal fun videoTimeHook(targetMethodClass: String, targetMethodName: String) =
|
||||
timeMethod.insertTimeHook(
|
||||
InsertIndex.TIME,
|
||||
timeInitInsertIndex++,
|
||||
"$targetMethodClass->$targetMethodName(J)V"
|
||||
)
|
||||
|
||||
@ -220,15 +226,9 @@ class MainstreamVideoIdPatch : BytecodePatch(
|
||||
*/
|
||||
internal fun highPrecisionTimeHook(targetMethodClass: String, targetMethodName: String) =
|
||||
highPrecisionTimeMethod.insertTimeHook(
|
||||
InsertIndex.HIGH_PRECISION_TIME,
|
||||
highPrecisionInsertIndex++,
|
||||
"$targetMethodClass->$targetMethodName(J)V"
|
||||
)
|
||||
|
||||
enum class InsertIndex(internal val index: Int) {
|
||||
CREATE(4),
|
||||
TIME(2),
|
||||
HIGH_PRECISION_TIME(0),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user