mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-03 16:14:28 +02:00
add force-vp9-codec
patch
This commit is contained in:
parent
9785c6ee64
commit
6ae2b86cb1
@ -0,0 +1,16 @@
|
|||||||
|
package app.revanced.patches.youtube.extended.forcevp9.bytecode.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
|
object Vp9PrimaryFingerprint : MethodFingerprint(
|
||||||
|
returnType = "Z",
|
||||||
|
access = AccessFlags.PUBLIC or AccessFlags.STATIC,
|
||||||
|
parameters = listOf("I"),
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.RETURN,
|
||||||
|
Opcode.RETURN
|
||||||
|
)
|
||||||
|
)
|
@ -0,0 +1,15 @@
|
|||||||
|
package app.revanced.patches.youtube.extended.forcevp9.bytecode.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
|
object Vp9PropsFingerprint : MethodFingerprint(
|
||||||
|
returnType = "L",
|
||||||
|
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
|
parameters = listOf(),
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.OR_INT_LIT16
|
||||||
|
)
|
||||||
|
)
|
@ -0,0 +1,8 @@
|
|||||||
|
package app.revanced.patches.youtube.extended.forcevp9.bytecode.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
|
||||||
|
object Vp9PropsParentFingerprint : MethodFingerprint(
|
||||||
|
returnType = "V",
|
||||||
|
strings = listOf("Android Wear")
|
||||||
|
)
|
@ -0,0 +1,17 @@
|
|||||||
|
package app.revanced.patches.youtube.extended.forcevp9.bytecode.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
|
object Vp9SecondaryFingerprint : MethodFingerprint(
|
||||||
|
returnType = "Z",
|
||||||
|
access = AccessFlags.PUBLIC or AccessFlags.STATIC,
|
||||||
|
parameters = listOf("L", "I"),
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.RETURN,
|
||||||
|
Opcode.CONST_4,
|
||||||
|
Opcode.RETURN
|
||||||
|
)
|
||||||
|
)
|
@ -0,0 +1,123 @@
|
|||||||
|
package app.revanced.patches.youtube.extended.forcevp9.bytecode.patch
|
||||||
|
|
||||||
|
import app.revanced.patcher.annotation.Name
|
||||||
|
import app.revanced.patcher.annotation.Version
|
||||||
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
import app.revanced.patcher.extensions.addInstructions
|
||||||
|
import app.revanced.patcher.extensions.instruction
|
||||||
|
import app.revanced.patcher.extensions.removeInstruction
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
|
||||||
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
|
import app.revanced.patcher.patch.PatchResult
|
||||||
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
|
import app.revanced.patches.youtube.extended.forcevp9.bytecode.fingerprints.*
|
||||||
|
import app.revanced.shared.annotation.YouTubeCompatibility
|
||||||
|
import app.revanced.shared.extensions.toErrorResult
|
||||||
|
import app.revanced.shared.fingerprints.LayoutSwitchFingerprint
|
||||||
|
import app.revanced.shared.util.integrations.Constants.EXTENDED_PATH
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
|
import org.jf.dexlib2.dexbacked.reference.DexBackedFieldReference
|
||||||
|
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
|
|
||||||
|
@Name("force-vp9-codec-bytecode-patch")
|
||||||
|
@YouTubeCompatibility
|
||||||
|
@Version("0.0.1")
|
||||||
|
class ForceVP9CodecBytecodePatch : BytecodePatch(
|
||||||
|
listOf(
|
||||||
|
LayoutSwitchFingerprint,
|
||||||
|
Vp9PrimaryFingerprint,
|
||||||
|
Vp9PropsFingerprint,
|
||||||
|
Vp9PropsParentFingerprint,
|
||||||
|
Vp9SecondaryFingerprint
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
|
|
||||||
|
LayoutSwitchFingerprint.result?.let { parentResult ->
|
||||||
|
arrayOf(
|
||||||
|
Vp9PrimaryFingerprint,
|
||||||
|
Vp9SecondaryFingerprint
|
||||||
|
).map {
|
||||||
|
it.also { it.resolve(context, parentResult.classDef) }.result?.injectOverride() ?: return it.toErrorResult()
|
||||||
|
}
|
||||||
|
} ?: return LayoutSwitchFingerprint.toErrorResult()
|
||||||
|
|
||||||
|
Vp9PropsParentFingerprint.result?.let { parentResult ->
|
||||||
|
Vp9PropsFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.let {
|
||||||
|
it.hookProps("MANUFACTURER", "getManufacturer")
|
||||||
|
it.hookProps("BRAND", "getBrand")
|
||||||
|
it.hookProps("MODEL", "getModel")
|
||||||
|
} ?: return Vp9PropsFingerprint.toErrorResult()
|
||||||
|
} ?: return Vp9PropsParentFingerprint.toErrorResult()
|
||||||
|
|
||||||
|
return PatchResultSuccess()
|
||||||
|
}
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
||||||
|
"$EXTENDED_PATH/CodecOverridePatch;"
|
||||||
|
|
||||||
|
const val INTEGRATIONS_CLASS_METHOD_REFERENCE =
|
||||||
|
"$INTEGRATIONS_CLASS_DESCRIPTOR->shouldForceVP9(Z)Z"
|
||||||
|
|
||||||
|
fun MethodFingerprintResult.injectOverride() {
|
||||||
|
with (mutableMethod) {
|
||||||
|
val startIndex = scanResult.patternScanResult!!.startIndex
|
||||||
|
val endIndex = scanResult.patternScanResult!!.endIndex
|
||||||
|
|
||||||
|
val startRegister = (instruction(startIndex) as OneRegisterInstruction).registerA
|
||||||
|
val endRegister = (instruction(endIndex) as OneRegisterInstruction).registerA
|
||||||
|
|
||||||
|
hookOverride(endIndex + 1, endRegister)
|
||||||
|
removeInstruction(endIndex)
|
||||||
|
hookOverride(startIndex + 1, startRegister)
|
||||||
|
removeInstruction(startIndex)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun MutableMethod.hookOverride(
|
||||||
|
index: Int,
|
||||||
|
register: Int
|
||||||
|
) {
|
||||||
|
addInstructions(
|
||||||
|
index, """
|
||||||
|
invoke-static {v$register}, $INTEGRATIONS_CLASS_METHOD_REFERENCE
|
||||||
|
move-result v$register
|
||||||
|
return v$register
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun MutableMethod.hookProps(
|
||||||
|
descriptor: String,
|
||||||
|
fieldName: String
|
||||||
|
) {
|
||||||
|
val insertInstructions = implementation!!.instructions
|
||||||
|
val targetString = "Landroid/os/Build;->" +
|
||||||
|
descriptor +
|
||||||
|
":Ljava/lang/String;"
|
||||||
|
|
||||||
|
for ((index, instruction) in insertInstructions.withIndex()) {
|
||||||
|
if (instruction.opcode != Opcode.SGET_OBJECT) continue
|
||||||
|
|
||||||
|
val indexString = ((instruction as? ReferenceInstruction)?.reference as? DexBackedFieldReference).toString()
|
||||||
|
|
||||||
|
if (indexString != targetString) continue
|
||||||
|
|
||||||
|
val register = (instruction as OneRegisterInstruction).registerA
|
||||||
|
|
||||||
|
addInstructions(
|
||||||
|
index + 1, """
|
||||||
|
invoke-static {v$register}, $INTEGRATIONS_CLASS_DESCRIPTOR->$fieldName(Ljava/lang/String;)Ljava/lang/String;
|
||||||
|
move-result-object v$register
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
package app.revanced.patches.youtube.extended.forcevp9.resource.patch
|
||||||
|
|
||||||
|
import app.revanced.patcher.annotation.Description
|
||||||
|
import app.revanced.patcher.annotation.Name
|
||||||
|
import app.revanced.patcher.annotation.Version
|
||||||
|
import app.revanced.patcher.data.ResourceContext
|
||||||
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
|
import app.revanced.patcher.patch.PatchResult
|
||||||
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
|
import app.revanced.patcher.patch.ResourcePatch
|
||||||
|
import app.revanced.patches.youtube.extended.forcevp9.bytecode.patch.ForceVP9CodecBytecodePatch
|
||||||
|
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
|
||||||
|
import app.revanced.shared.annotation.YouTubeCompatibility
|
||||||
|
import app.revanced.shared.util.resources.ResourceHelper
|
||||||
|
|
||||||
|
@Patch
|
||||||
|
@Name("force-vp9-codec")
|
||||||
|
@Description("Forces the VP9 codec for videos.")
|
||||||
|
@DependsOn(
|
||||||
|
[
|
||||||
|
ForceVP9CodecBytecodePatch::class,
|
||||||
|
SettingsPatch::class
|
||||||
|
]
|
||||||
|
)
|
||||||
|
@YouTubeCompatibility
|
||||||
|
@Version("0.0.1")
|
||||||
|
class ForceVP9CodecPatch : ResourcePatch {
|
||||||
|
override fun execute(context: ResourceContext): PatchResult {
|
||||||
|
|
||||||
|
/*
|
||||||
|
add settings
|
||||||
|
*/
|
||||||
|
ResourceHelper.addSettings2(
|
||||||
|
context,
|
||||||
|
"PREFERENCE_CATEGORY: REVANCED_EXTENDED_SETTINGS",
|
||||||
|
"PREFERENCE: EXTENDED_SETTINGS",
|
||||||
|
"SETTINGS: EXPERIMENTAL_FLAGS",
|
||||||
|
"SETTINGS: ENABLE_VP9_CODEC"
|
||||||
|
)
|
||||||
|
|
||||||
|
ResourceHelper.patchSuccess(
|
||||||
|
context,
|
||||||
|
"force-vp9-codec"
|
||||||
|
)
|
||||||
|
|
||||||
|
return PatchResultSuccess()
|
||||||
|
}
|
||||||
|
}
|
@ -7,9 +7,9 @@ import app.revanced.patcher.extensions.addInstructions
|
|||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
import app.revanced.patches.youtube.extended.layoutswitch.bytecode.fingerprints.LayoutSwitchFingerprint
|
|
||||||
import app.revanced.shared.annotation.YouTubeCompatibility
|
import app.revanced.shared.annotation.YouTubeCompatibility
|
||||||
import app.revanced.shared.extensions.toErrorResult
|
import app.revanced.shared.extensions.toErrorResult
|
||||||
|
import app.revanced.shared.fingerprints.LayoutSwitchFingerprint
|
||||||
import app.revanced.shared.util.integrations.Constants.EXTENDED_PATH
|
import app.revanced.shared.util.integrations.Constants.EXTENDED_PATH
|
||||||
|
|
||||||
@Name("layout-switch-bytecode-patch")
|
@Name("layout-switch-bytecode-patch")
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patches.youtube.extended.layoutswitch.bytecode.fingerprints
|
package app.revanced.shared.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.or
|
import app.revanced.patcher.extensions.or
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
@ -255,6 +255,8 @@ Is it ready to submit?"</string>
|
|||||||
<string name="revanced_enable_wide_searchbar_summary_off">Wide search bar is disabled</string>
|
<string name="revanced_enable_wide_searchbar_summary_off">Wide search bar is disabled</string>
|
||||||
<string name="revanced_enable_wide_searchbar_summary_on">Wide search bar is enabled</string>
|
<string name="revanced_enable_wide_searchbar_summary_on">Wide search bar is enabled</string>
|
||||||
<string name="revanced_enable_wide_searchbar_title">Enable wide search bar</string>
|
<string name="revanced_enable_wide_searchbar_title">Enable wide search bar</string>
|
||||||
|
<string name="revanced_enable_vp9_codec_summary">Spoof device information to enable VP9 codec</string>
|
||||||
|
<string name="revanced_enable_vp9_codec_title">Enable VP9 codec</string>
|
||||||
<string name="revanced_experimental_flag">Experimental Flags</string>
|
<string name="revanced_experimental_flag">Experimental Flags</string>
|
||||||
<string name="revanced_extended_issue_center_summary">Report issues or leave suggestions here</string>
|
<string name="revanced_extended_issue_center_summary">Report issues or leave suggestions here</string>
|
||||||
<string name="revanced_extended_issue_center_title">ReVanced Extended Issue Center</string>
|
<string name="revanced_extended_issue_center_title">ReVanced Extended Issue Center</string>
|
||||||
@ -481,6 +483,9 @@ If you enable this setting, the following features are not available:
|
|||||||
If you enable this setting, the following features are not available:
|
If you enable this setting, the following features are not available:
|
||||||
- Ambient mode
|
- Ambient mode
|
||||||
- Community Posts"</string>
|
- Community Posts"</string>
|
||||||
|
<string name="revanced_reboot_warning_vp9">"Spoofs device information to enable VP9 codec
|
||||||
|
|
||||||
|
Since these setting is quite outdated, it may not be valid"</string>
|
||||||
<string name="revanced_ryd_attribution_summary">Dislike data is provided by the Return YouTube Dislike API. Tap here to learn more.</string>
|
<string name="revanced_ryd_attribution_summary">Dislike data is provided by the Return YouTube Dislike API. Tap here to learn more.</string>
|
||||||
<string name="revanced_ryd_attribution_title">ReturnYouTubeDislike.com</string>
|
<string name="revanced_ryd_attribution_title">ReturnYouTubeDislike.com</string>
|
||||||
<string name="revanced_ryd_dislike_percentage_summary_off">Dislikes shown as number</string>
|
<string name="revanced_ryd_dislike_percentage_summary_off">Dislikes shown as number</string>
|
||||||
|
@ -348,6 +348,8 @@
|
|||||||
<!-- SETTINGS: LAYOUT_SWITCH
|
<!-- SETTINGS: LAYOUT_SWITCH
|
||||||
<SwitchPreference android:title="@string/revanced_enable_tablet_layout_title" android:key="revanced_enable_tablet_layout" android:summary="@string/revanced_enable_tablet_layout_summary" android:defaultValue="false" />
|
<SwitchPreference android:title="@string/revanced_enable_tablet_layout_title" android:key="revanced_enable_tablet_layout" android:summary="@string/revanced_enable_tablet_layout_summary" android:defaultValue="false" />
|
||||||
<SwitchPreference android:title="@string/revanced_enable_phone_layout_title" android:key="revanced_enable_phone_layout" android:summary="@string/revanced_enable_phone_layout_summary" android:defaultValue="false" />SETTINGS: LAYOUT_SWITCH -->
|
<SwitchPreference android:title="@string/revanced_enable_phone_layout_title" android:key="revanced_enable_phone_layout" android:summary="@string/revanced_enable_phone_layout_summary" android:defaultValue="false" />SETTINGS: LAYOUT_SWITCH -->
|
||||||
|
<!-- SETTINGS: ENABLE_VP9_CODEC
|
||||||
|
<SwitchPreference android:title="@string/revanced_enable_vp9_codec_title" android:key="revanced_enable_vp9_codec" android:defaultValue="false" android:summary="@string/revanced_enable_vp9_codec_summary" />SETTINGS: ENABLE_VP9_CODEC -->
|
||||||
|
|
||||||
<!-- SETTINGS: ABOUT
|
<!-- SETTINGS: ABOUT
|
||||||
<Preference android:title=" " android:selectable="false" android:summary="@string/pref_about_category" />
|
<Preference android:title=" " android:selectable="false" android:summary="@string/pref_about_category" />
|
||||||
@ -427,6 +429,7 @@
|
|||||||
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_extended_title" />
|
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_extended_title" />
|
||||||
<Preference android:title="enable-old-layout" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
<Preference android:title="enable-old-layout" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||||
<Preference android:title="layout-switch" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
<Preference android:title="layout-switch" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||||
|
<Preference android:title="force-vp9-codec" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||||
|
|
||||||
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_others_title" />
|
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_others_title" />
|
||||||
<Preference android:title="return-youtube-dislike" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
<Preference android:title="return-youtube-dislike" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user