mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-16 22:37:17 +02:00
add support YouTube v18.19.36, v18.20.39, v18.21.35, v18.22.37
This commit is contained in:
parent
aceaf2dade
commit
8f11b4e327
@ -6,12 +6,10 @@ import app.revanced.patcher.annotation.Package
|
||||
@Compatibility(
|
||||
[Package(
|
||||
"com.google.android.youtube", arrayOf(
|
||||
"18.12.35",
|
||||
"18.13.38",
|
||||
"18.14.41",
|
||||
"18.15.40",
|
||||
"18.16.39",
|
||||
"18.17.43"
|
||||
"18.19.36",
|
||||
"18.20.39",
|
||||
"18.21.35",
|
||||
"18.22.37"
|
||||
)
|
||||
)]
|
||||
)
|
||||
|
@ -0,0 +1,14 @@
|
||||
package app.revanced.patches.youtube.misc.layoutswitch.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object ClientFormFactorWalkerFingerprint : MethodFingerprint(
|
||||
returnType = "L",
|
||||
parameters = listOf(),
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.RETURN_OBJECT
|
||||
)
|
||||
)
|
@ -5,6 +5,7 @@ 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.data.toMethodWalker
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
@ -14,12 +15,16 @@ 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.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.patches.shared.fingerprints.LayoutSwitchFingerprint
|
||||
import app.revanced.patches.youtube.misc.layoutswitch.fingerprints.*
|
||||
import app.revanced.patches.youtube.misc.layoutswitch.fingerprints.ClientFormFactorFingerprint
|
||||
import app.revanced.patches.youtube.misc.layoutswitch.fingerprints.ClientFormFactorParentFingerprint
|
||||
import app.revanced.patches.youtube.misc.layoutswitch.fingerprints.ClientFormFactorWalkerFingerprint
|
||||
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.integrations.Constants.MISC_PATH
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
@Patch
|
||||
@Name("layout-switch")
|
||||
@ -35,19 +40,36 @@ class LayoutSwitchPatch : BytecodePatch(
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
||||
ClientFormFactorParentFingerprint.result?.let { parentResult ->
|
||||
ClientFormFactorFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val jumpIndex = it.scanResult.patternScanResult!!.startIndex + 1
|
||||
fun MutableMethod.injectTabletLayout(jumpIndex: Int) {
|
||||
addInstructionsWithLabels(
|
||||
1, """
|
||||
0, """
|
||||
invoke-static {}, $MISC_PATH/LayoutOverridePatch;->enableTabletLayout()Z
|
||||
move-result v2
|
||||
if-nez v2, :tablet_layout
|
||||
move-result v0
|
||||
if-nez v0, :tablet_layout
|
||||
""", ExternalLabel("tablet_layout", getInstruction(jumpIndex))
|
||||
)
|
||||
}
|
||||
} ?: return ClientFormFactorFingerprint.toErrorResult()
|
||||
|
||||
ClientFormFactorParentFingerprint.result?.classDef?.let { classDef ->
|
||||
try {
|
||||
ClientFormFactorFingerprint.also { it.resolve(context, classDef) }.result!!.apply {
|
||||
mutableMethod.injectTabletLayout(scanResult.patternScanResult!!.startIndex + 1)
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
ClientFormFactorWalkerFingerprint.also { it.resolve(context, classDef) }.result?.let {
|
||||
(context
|
||||
.toMethodWalker(it.method)
|
||||
.nextMethod(it.scanResult.patternScanResult!!.startIndex, true)
|
||||
.getMethod() as MutableMethod).apply {
|
||||
|
||||
val jumpIndex = implementation!!.instructions.indexOfFirst { instruction ->
|
||||
instruction.opcode == Opcode.RETURN_OBJECT
|
||||
} - 1
|
||||
|
||||
injectTabletLayout(jumpIndex)
|
||||
}
|
||||
} ?: return ClientFormFactorWalkerFingerprint.toErrorResult()
|
||||
}
|
||||
} ?: return ClientFormFactorParentFingerprint.toErrorResult()
|
||||
|
||||
LayoutSwitchFingerprint.result?.mutableMethod?.addInstructions(
|
||||
@ -57,7 +79,7 @@ class LayoutSwitchPatch : BytecodePatch(
|
||||
"""
|
||||
) ?: return LayoutSwitchFingerprint.toErrorResult()
|
||||
|
||||
/*(
|
||||
/**
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
|
Loading…
x
Reference in New Issue
Block a user