mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-14 21:37:17 +02:00
fix(youtube/default-video-quality): fix default video quality/speed being applied when resuming app
This commit is contained in:
parent
afdbee756a
commit
6cf28cd949
@ -57,7 +57,7 @@ class MainstreamVideoIdPatch : BytecodePatch(
|
|||||||
playerInitMethod = parentResult.mutableClass.methods.first { MethodUtil.isConstructor(it) }
|
playerInitMethod = parentResult.mutableClass.methods.first { MethodUtil.isConstructor(it) }
|
||||||
|
|
||||||
// hook the player controller for use through integrations
|
// 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 {
|
SeekFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let {
|
||||||
val resultMethod = it.method
|
val resultMethod = it.method
|
||||||
@ -157,6 +157,9 @@ class MainstreamVideoIdPatch : BytecodePatch(
|
|||||||
internal var reactReference: String? = null
|
internal var reactReference: String? = null
|
||||||
|
|
||||||
private var offset = 0
|
private var offset = 0
|
||||||
|
private var playerInitInsertIndex = 4
|
||||||
|
private var timeInitInsertIndex = 2
|
||||||
|
private var highPrecisionInsertIndex = 0
|
||||||
|
|
||||||
private var insertIndex: Int = 0
|
private var insertIndex: Int = 0
|
||||||
private var videoIdRegister: Int = 0
|
private var videoIdRegister: Int = 0
|
||||||
@ -178,21 +181,24 @@ class MainstreamVideoIdPatch : BytecodePatch(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun MutableMethod.insert(insert: InsertIndex, register: String, descriptor: String) =
|
private fun MutableMethod.insert(insertIndex: Int, register: String, descriptor: String) =
|
||||||
addInstruction(insert.index, "invoke-static { $register }, $descriptor")
|
addInstruction(insertIndex, "invoke-static { $register }, $descriptor")
|
||||||
|
|
||||||
private fun MutableMethod.insertTimeHook(insert: InsertIndex, descriptor: String) =
|
private fun MutableMethod.insertTimeHook(insertIndex: Int, descriptor: String) =
|
||||||
insert(insert, "p1, p2", descriptor)
|
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 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.
|
* @param targetMethodName The name of the static method to invoke when the player controller is created.
|
||||||
*/
|
*/
|
||||||
internal fun onCreateHook(targetMethodClass: String, targetMethodName: String) =
|
internal fun onCreateHook(targetMethodClass: String, targetMethodName: String) =
|
||||||
playerInitMethod.insert(
|
playerInitMethod.insert(
|
||||||
InsertIndex.CREATE,
|
playerInitInsertIndex++,
|
||||||
"v0",
|
"v0",
|
||||||
"$targetMethodClass->$targetMethodName(Ljava/lang/Object;)V"
|
"$targetMethodClass->$targetMethodName(Ljava/lang/Object;)V"
|
||||||
)
|
)
|
||||||
@ -206,7 +212,7 @@ class MainstreamVideoIdPatch : BytecodePatch(
|
|||||||
*/
|
*/
|
||||||
internal fun videoTimeHook(targetMethodClass: String, targetMethodName: String) =
|
internal fun videoTimeHook(targetMethodClass: String, targetMethodName: String) =
|
||||||
timeMethod.insertTimeHook(
|
timeMethod.insertTimeHook(
|
||||||
InsertIndex.TIME,
|
timeInitInsertIndex++,
|
||||||
"$targetMethodClass->$targetMethodName(J)V"
|
"$targetMethodClass->$targetMethodName(J)V"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -220,15 +226,9 @@ class MainstreamVideoIdPatch : BytecodePatch(
|
|||||||
*/
|
*/
|
||||||
internal fun highPrecisionTimeHook(targetMethodClass: String, targetMethodName: String) =
|
internal fun highPrecisionTimeHook(targetMethodClass: String, targetMethodName: String) =
|
||||||
highPrecisionTimeMethod.insertTimeHook(
|
highPrecisionTimeMethod.insertTimeHook(
|
||||||
InsertIndex.HIGH_PRECISION_TIME,
|
highPrecisionInsertIndex++,
|
||||||
"$targetMethodClass->$targetMethodName(J)V"
|
"$targetMethodClass->$targetMethodName(J)V"
|
||||||
)
|
)
|
||||||
|
|
||||||
enum class InsertIndex(internal val index: Int) {
|
|
||||||
CREATE(4),
|
|
||||||
TIME(2),
|
|
||||||
HIGH_PRECISION_TIME(0),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,14 +12,14 @@ import app.revanced.patcher.patch.PatchResult
|
|||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
||||||
import app.revanced.patches.youtube.misc.videoid.legacy.patch.LegacyVideoIdPatch
|
import app.revanced.patches.youtube.misc.videoid.mainstream.patch.MainstreamVideoIdPatch
|
||||||
import app.revanced.patches.youtube.video.quality.bytecode.fingerprints.*
|
import app.revanced.patches.youtube.video.quality.bytecode.fingerprints.*
|
||||||
import app.revanced.util.integrations.Constants.VIDEO_PATH
|
import app.revanced.util.integrations.Constants.VIDEO_PATH
|
||||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
import org.jf.dexlib2.iface.reference.FieldReference
|
import org.jf.dexlib2.iface.reference.FieldReference
|
||||||
|
|
||||||
@Name("default-video-quality-bytecode-patch")
|
@Name("default-video-quality-bytecode-patch")
|
||||||
@DependsOn([LegacyVideoIdPatch::class])
|
@DependsOn([MainstreamVideoIdPatch::class])
|
||||||
@YouTubeCompatibility
|
@YouTubeCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class VideoQualityBytecodePatch : BytecodePatch(
|
class VideoQualityBytecodePatch : BytecodePatch(
|
||||||
@ -62,7 +62,7 @@ class VideoQualityBytecodePatch : BytecodePatch(
|
|||||||
)
|
)
|
||||||
} ?: return VideoQualitySettingsParentFingerprint.toErrorResult()
|
} ?: return VideoQualitySettingsParentFingerprint.toErrorResult()
|
||||||
|
|
||||||
LegacyVideoIdPatch.injectCall("$INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR->newVideoStarted(Ljava/lang/String;)V")
|
MainstreamVideoIdPatch.onCreateHook(INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR, "newVideoStarted")
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
|
@ -13,17 +13,16 @@ import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
|||||||
import app.revanced.patches.youtube.misc.overridespeed.bytecode.fingerprints.VideoSpeedSettingsFingerprint
|
import app.revanced.patches.youtube.misc.overridespeed.bytecode.fingerprints.VideoSpeedSettingsFingerprint
|
||||||
import app.revanced.patches.youtube.misc.overridespeed.bytecode.patch.OverrideSpeedHookPatch
|
import app.revanced.patches.youtube.misc.overridespeed.bytecode.patch.OverrideSpeedHookPatch
|
||||||
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
|
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
|
||||||
import app.revanced.patches.youtube.misc.videoid.legacy.patch.LegacyVideoIdPatch
|
import app.revanced.patches.youtube.misc.videoid.mainstream.patch.MainstreamVideoIdPatch
|
||||||
import app.revanced.patches.youtube.video.livestream.patch.LiveStreamPatch
|
import app.revanced.patches.youtube.video.livestream.patch.LiveStreamPatch
|
||||||
import app.revanced.patches.youtube.video.speed.bytecode.fingerprints.*
|
|
||||||
import app.revanced.util.integrations.Constants.VIDEO_PATH
|
import app.revanced.util.integrations.Constants.VIDEO_PATH
|
||||||
import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction
|
import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||||
|
|
||||||
@Name("default-video-speed-bytecode-patch")
|
@Name("default-video-speed-bytecode-patch")
|
||||||
@DependsOn(
|
@DependsOn(
|
||||||
[
|
[
|
||||||
LegacyVideoIdPatch::class,
|
|
||||||
LiveStreamPatch::class,
|
LiveStreamPatch::class,
|
||||||
|
MainstreamVideoIdPatch::class,
|
||||||
OverrideSpeedHookPatch::class,
|
OverrideSpeedHookPatch::class,
|
||||||
SharedResourceIdPatch::class
|
SharedResourceIdPatch::class
|
||||||
]
|
]
|
||||||
@ -55,7 +54,7 @@ class VideoSpeedBytecodePatch : BytecodePatch(
|
|||||||
"invoke-static {}, $INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR->setDefaultSpeed()V"
|
"invoke-static {}, $INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR->setDefaultSpeed()V"
|
||||||
) ?: return VideoSpeedSettingsFingerprint.toErrorResult()
|
) ?: return VideoSpeedSettingsFingerprint.toErrorResult()
|
||||||
|
|
||||||
LegacyVideoIdPatch.injectCall("$INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR->newVideoStarted(Ljava/lang/String;)V")
|
MainstreamVideoIdPatch.onCreateHook(INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR, "newVideoStarted")
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user