mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 21:27:43 +02:00
add disable-landscape-mode
patch (exclude by default)
This commit is contained in:
@ -0,0 +1,8 @@
|
||||
package app.revanced.patches.youtube.layout.fullscreen.landscapemode.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
|
||||
object OrientationParentFingerprint : MethodFingerprint(
|
||||
returnType = "Z",
|
||||
strings = listOf("NoClassDefFoundError thrown while verifying stack trace.")
|
||||
)
|
@ -0,0 +1,17 @@
|
||||
package app.revanced.patches.youtube.layout.fullscreen.landscapemode.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 OrientationPrimaryFingerprint : MethodFingerprint (
|
||||
returnType = "V",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||
parameters = listOf("L"),
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT
|
||||
),
|
||||
customFingerprint = {it.name == "<init>"}
|
||||
)
|
@ -0,0 +1,16 @@
|
||||
package app.revanced.patches.youtube.layout.fullscreen.landscapemode.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 OrientationSecondaryFingerprint : MethodFingerprint (
|
||||
returnType = "V",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("L"),
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT
|
||||
)
|
||||
)
|
@ -0,0 +1,77 @@
|
||||
package app.revanced.patches.youtube.layout.fullscreen.landscapemode.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.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.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.layout.fullscreen.landscapemode.fingerprints.*
|
||||
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.integrations.Constants.FULLSCREEN
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Patch(false)
|
||||
@Name("diable-landscape-mode")
|
||||
@Description("Disable landscape mode when entering fullscreen.")
|
||||
@DependsOn([SettingsPatch::class])
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class LandScapeModePatch : BytecodePatch(
|
||||
listOf(
|
||||
OrientationParentFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
OrientationParentFingerprint.result?.classDef?.let { classDef ->
|
||||
arrayOf(
|
||||
OrientationPrimaryFingerprint,
|
||||
OrientationSecondaryFingerprint
|
||||
).forEach { fingerprint ->
|
||||
fingerprint.also { it.resolve(context, classDef) }.result?.injectOverride() ?: return fingerprint.toErrorResult()
|
||||
}
|
||||
} ?: return OrientationParentFingerprint.toErrorResult()
|
||||
|
||||
/*
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE: FULLSCREEN_SETTINGS",
|
||||
"SETTINGS: DISABLE_LANDSCAPE_MODE"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("diable-landscape-mode")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
||||
"$FULLSCREEN->disableLandScapeMode(Z)Z"
|
||||
|
||||
fun MethodFingerprintResult.injectOverride() {
|
||||
with (mutableMethod) {
|
||||
val index = scanResult.patternScanResult!!.endIndex
|
||||
val register = (instruction(index) as OneRegisterInstruction).registerA
|
||||
|
||||
addInstructions(
|
||||
index +1, """
|
||||
invoke-static {v$register}, $INTEGRATIONS_CLASS_DESCRIPTOR
|
||||
move-result v$register
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user