mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-01 07:04:30 +02:00
add lift-vertical-video-restriction
patch (Experimental Flags)
This commit is contained in:
parent
714d79f597
commit
ecbedb79bd
@ -0,0 +1,15 @@
|
||||
package app.revanced.patches.youtube.video.restrictions.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object VideoCapabilitiesFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
opcodes = listOf(
|
||||
Opcode.IPUT,
|
||||
Opcode.IPUT,
|
||||
Opcode.IPUT,
|
||||
Opcode.IPUT
|
||||
),
|
||||
customFingerprint = { it.name == "<init>" }
|
||||
)
|
@ -0,0 +1,8 @@
|
||||
package app.revanced.patches.youtube.video.restrictions.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
|
||||
object VideoCapabilitiesParentFingerprint : MethodFingerprint(
|
||||
returnType = "L",
|
||||
strings = listOf("minh.", ";maxh.")
|
||||
)
|
@ -0,0 +1,85 @@
|
||||
package app.revanced.patches.youtube.video.restrictions.patch
|
||||
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.patcher.annotation.Description
|
||||
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.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.patches.youtube.video.restrictions.fingerprints.*
|
||||
import app.revanced.util.integrations.Constants.VIDEO_PATH
|
||||
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
|
||||
@Patch
|
||||
@Name("lift-vertical-video-restriction")
|
||||
@Description("Lift 4K resolution restrictions on vertical video.")
|
||||
@DependsOn([SettingsPatch::class])
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class VideoRestrictionPatch : BytecodePatch(
|
||||
listOf(
|
||||
VideoCapabilitiesParentFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
||||
VideoCapabilitiesParentFingerprint.result?.let { parentResult ->
|
||||
VideoCapabilitiesFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let {
|
||||
val startIndex = it.scanResult.patternScanResult!!.startIndex
|
||||
val endIndex = it.scanResult.patternScanResult!!.endIndex
|
||||
|
||||
for (index in endIndex downTo startIndex)
|
||||
it.mutableMethod.hookOverride(index)
|
||||
} ?: return VideoCapabilitiesFingerprint.toErrorResult()
|
||||
} ?: return VideoCapabilitiesParentFingerprint.toErrorResult()
|
||||
|
||||
/*
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"SETTINGS: VERTICAL_VIDEO_RESTRICTIONS"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("lift-vertical-video-restriction")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
||||
"$VIDEO_PATH/VideoRestrictionPatch;"
|
||||
|
||||
const val INTEGRATIONS_CLASS_METHOD_LOWER_REFERENCE =
|
||||
"$INTEGRATIONS_CLASS_DESCRIPTOR->overrideLowerRange(I)I"
|
||||
|
||||
const val INTEGRATIONS_CLASS_METHOD_UPPER_REFERENCE =
|
||||
"$INTEGRATIONS_CLASS_DESCRIPTOR->overrideUpperRange(I)I"
|
||||
|
||||
fun MutableMethod.hookOverride(index: Int) {
|
||||
val register = (instruction(index) as TwoRegisterInstruction).registerA
|
||||
val descriptor =
|
||||
if (index % 2 == 0) INTEGRATIONS_CLASS_METHOD_UPPER_REFERENCE
|
||||
else INTEGRATIONS_CLASS_METHOD_LOWER_REFERENCE
|
||||
|
||||
addInstructions(
|
||||
index, """
|
||||
invoke-static {v$register}, $descriptor
|
||||
move-result v$register
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -529,6 +529,8 @@ Since these setting is quite outdated, it may not be valid"</string>
|
||||
<string name="revanced_switching_create_notification_summary_on">Create button and notification button are switched</string>
|
||||
<string name="revanced_switching_create_notification_title">Switching the create button and notification button</string>
|
||||
<string name="revanced_tool_used">Tool used</string>
|
||||
<string name="revanced_vertical_video_restrictions_summary">Spoofing device information to lift the resolution restrictions for vertical video</string>
|
||||
<string name="revanced_vertical_video_restrictions_title">Lift resolution restrictions on vertical video</string>
|
||||
<string name="revanced_video">Video</string>
|
||||
<string name="revanced_video_ads_removal_summary_off">Video ads are shown</string>
|
||||
<string name="revanced_video_ads_removal_summary_on">Video ads are hidden</string>
|
||||
|
@ -345,6 +345,10 @@
|
||||
<!-- SETTINGS: CUSTOM_VIDEO_SPEED
|
||||
<SwitchPreference android:title="@string/revanced_enable_custom_video_speed_title" android:key="revanced_enable_custom_video_speed" android:defaultValue="false" android:summaryOn="@string/revanced_enable_custom_video_speed_summary_on" android:summaryOff="@string/revanced_enable_custom_video_speed_summary_off" />SETTINGS: CUSTOM_VIDEO_SPEED -->
|
||||
|
||||
<!-- SETTINGS: VERTICAL_VIDEO_RESTRICTIONS
|
||||
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_experimental_flag" />
|
||||
<SwitchPreference android:title="@string/revanced_vertical_video_restrictions_title" android:key="revanced_vertical_video_restrictions" android:defaultValue="false" android:summary="@string/revanced_vertical_video_restrictions_summary" />SETTINGS: VERTICAL_VIDEO_RESTRICTIONS -->
|
||||
|
||||
<!-- PREFERENCE: VIDEO_SETTINGS
|
||||
</PreferenceScreen>PREFERENCE: VIDEO_SETTINGS -->
|
||||
|
||||
@ -459,6 +463,7 @@
|
||||
<Preference android:title="default-video-quality" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="default-video-speed" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="custom-video-speed" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="lift-vertical-video-restriction" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
|
||||
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_misc" />
|
||||
<Preference android:title="enable-external-browser" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user