mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-02 07:34:31 +02:00
refactor(enable-old-layout
): no longer changes the version shown in app settings
This commit is contained in:
parent
d6f7d4d94b
commit
e5c112a94b
@ -0,0 +1,15 @@
|
|||||||
|
package app.revanced.patches.shared.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 ClientInfoFingerprint : 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.shared.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
|
||||||
|
object ClientInfoParentFingerprint : MethodFingerprint(
|
||||||
|
returnType = "V",
|
||||||
|
strings = listOf("Android Wear")
|
||||||
|
)
|
@ -24,7 +24,7 @@ class PatchOptions : ResourcePatch {
|
|||||||
|
|
||||||
companion object : OptionsContainer() {
|
companion object : OptionsContainer() {
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Custom Branding Name
|
* Custom Branding Name
|
||||||
*/
|
*/
|
||||||
internal var YouTubeAppName: String? by option(
|
internal var YouTubeAppName: String? by option(
|
||||||
@ -36,7 +36,7 @@ class PatchOptions : ResourcePatch {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Custom Package Name (YouTube)
|
* Custom Package Name (YouTube)
|
||||||
*/
|
*/
|
||||||
internal var YouTubePackageName: String? by option(
|
internal var YouTubePackageName: String? by option(
|
||||||
@ -48,7 +48,7 @@ class PatchOptions : ResourcePatch {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Custom Package Name (YouTube Music)
|
* Custom Package Name (YouTube Music)
|
||||||
*/
|
*/
|
||||||
internal var MusicPackageName: String? by option(
|
internal var MusicPackageName: String? by option(
|
||||||
@ -60,7 +60,7 @@ class PatchOptions : ResourcePatch {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Custom Speed Values
|
* Custom Speed Values
|
||||||
*/
|
*/
|
||||||
internal var CustomSpeedArrays: String? by option(
|
internal var CustomSpeedArrays: String? by option(
|
||||||
@ -72,7 +72,7 @@ class PatchOptions : ResourcePatch {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Overlay Buttons Icon
|
* Overlay Buttons Icon
|
||||||
*/
|
*/
|
||||||
internal var OverlayButtonsIcon: String? by option(
|
internal var OverlayButtonsIcon: String? by option(
|
||||||
@ -84,7 +84,7 @@ class PatchOptions : ResourcePatch {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Theme
|
* Theme
|
||||||
*/
|
*/
|
||||||
internal var darkThemeBackgroundColor: String? by option(
|
internal var darkThemeBackgroundColor: String? by option(
|
||||||
@ -96,5 +96,16 @@ class PatchOptions : ResourcePatch {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Client Spoofing Version
|
||||||
|
*/
|
||||||
|
internal var clientSpoofVersion: String? by option(
|
||||||
|
PatchOption.StringOption(
|
||||||
|
key = "clientSpoofVersion",
|
||||||
|
default = "17.28.35",
|
||||||
|
title = "Old YouTube version to override",
|
||||||
|
description = "Type the client version to spoof when Old Layout is enabled"
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,69 @@
|
|||||||
|
package app.revanced.patches.shared.patch.versionspoof
|
||||||
|
|
||||||
|
import app.revanced.extensions.toErrorResult
|
||||||
|
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.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.util.proxy.mutableTypes.MutableMethod
|
||||||
|
import app.revanced.patches.shared.fingerprints.ClientInfoFingerprint
|
||||||
|
import app.revanced.patches.shared.fingerprints.ClientInfoParentFingerprint
|
||||||
|
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
|
||||||
|
import kotlin.properties.Delegates
|
||||||
|
|
||||||
|
@Name("general-version-spoof")
|
||||||
|
@Version("0.0.1")
|
||||||
|
class GeneralVersionSpoofPatch : BytecodePatch(
|
||||||
|
listOf(
|
||||||
|
ClientInfoParentFingerprint
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
|
|
||||||
|
ClientInfoParentFingerprint.result?.let { parentResult ->
|
||||||
|
ClientInfoFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.let {
|
||||||
|
val insertInstructions = it.implementation!!.instructions
|
||||||
|
val targetString = "Landroid/os/Build\$VERSION;->RELEASE: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
|
||||||
|
|
||||||
|
insertMethod = it
|
||||||
|
insertIndex = index - 1
|
||||||
|
targetRegister = (instruction as OneRegisterInstruction).registerA
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if (insertIndex <= 0) return ClientInfoFingerprint.toErrorResult()
|
||||||
|
} ?: return ClientInfoFingerprint.toErrorResult()
|
||||||
|
} ?: return ClientInfoParentFingerprint.toErrorResult()
|
||||||
|
|
||||||
|
return PatchResultSuccess()
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private var insertIndex by Delegates.notNull<Int>()
|
||||||
|
private var targetRegister by Delegates.notNull<Int>()
|
||||||
|
private lateinit var insertMethod: MutableMethod
|
||||||
|
|
||||||
|
|
||||||
|
fun injectSpoof(methodDescriptor: String) {
|
||||||
|
insertMethod.addInstructions(
|
||||||
|
insertIndex, """
|
||||||
|
invoke-static {v$targetRegister}, $methodDescriptor
|
||||||
|
move-result-object v$targetRegister
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,18 +0,0 @@
|
|||||||
package app.revanced.patches.youtube.misc.oldlayout.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 OldLayoutFingerprint : MethodFingerprint(
|
|
||||||
returnType = "L",
|
|
||||||
access = AccessFlags.PUBLIC or AccessFlags.STATIC,
|
|
||||||
parameters = listOf("L"),
|
|
||||||
opcodes = listOf(
|
|
||||||
Opcode.IGET_OBJECT,
|
|
||||||
Opcode.GOTO,
|
|
||||||
Opcode.CONST_STRING,
|
|
||||||
),
|
|
||||||
strings = listOf("Unset")
|
|
||||||
)
|
|
@ -0,0 +1,14 @@
|
|||||||
|
package app.revanced.patches.youtube.misc.oldlayout.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
|
object VersionOverrideFingerprint : MethodFingerprint(
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.IF_EQZ,
|
||||||
|
Opcode.CONST_STRING
|
||||||
|
),
|
||||||
|
customFingerprint = {
|
||||||
|
it.definingClass.endsWith("VersionOverridePatch;") && it.name == "getVersionOverride"
|
||||||
|
}
|
||||||
|
)
|
@ -5,44 +5,48 @@ import app.revanced.patcher.annotation.Description
|
|||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.extensions.addInstructions
|
import app.revanced.patcher.extensions.replaceInstruction
|
||||||
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.patcher.patch.annotations.DependsOn
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
import app.revanced.patcher.patch.annotations.Patch
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
||||||
import app.revanced.patches.youtube.misc.oldlayout.fingerprints.OldLayoutFingerprint
|
import app.revanced.patches.shared.patch.options.PatchOptions
|
||||||
|
import app.revanced.patches.shared.patch.versionspoof.GeneralVersionSpoofPatch
|
||||||
|
import app.revanced.patches.youtube.misc.oldlayout.fingerprints.VersionOverrideFingerprint
|
||||||
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
|
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
|
||||||
import app.revanced.util.integrations.Constants.MISC_PATH
|
import app.revanced.util.integrations.Constants.MISC_PATH
|
||||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
|
||||||
|
|
||||||
@Patch
|
@Patch
|
||||||
@Name("enable-old-layout")
|
@Name("enable-old-layout")
|
||||||
@Description("Spoof the YouTube client version to use the old layout.")
|
@Description("Spoof the YouTube client version to use the old layout.")
|
||||||
@DependsOn([SettingsPatch::class])
|
@DependsOn(
|
||||||
|
[
|
||||||
|
GeneralVersionSpoofPatch::class,
|
||||||
|
PatchOptions::class,
|
||||||
|
SettingsPatch::class
|
||||||
|
]
|
||||||
|
)
|
||||||
@YouTubeCompatibility
|
@YouTubeCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class OldLayoutPatch : BytecodePatch(
|
class OldLayoutPatch : BytecodePatch(
|
||||||
listOf(
|
listOf(
|
||||||
OldLayoutFingerprint
|
VersionOverrideFingerprint
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
|
|
||||||
OldLayoutFingerprint.result?.let {
|
GeneralVersionSpoofPatch.injectSpoof("$MISC_PATH/VersionOverridePatch;->getVersionOverride(Ljava/lang/String;)Ljava/lang/String;")
|
||||||
val insertIndex = it.scanResult.patternScanResult!!.startIndex
|
|
||||||
|
|
||||||
with (it.mutableMethod) {
|
val clientSpoofVersion = PatchOptions.clientSpoofVersion!!
|
||||||
val register = (this.implementation!!.instructions[insertIndex] as OneRegisterInstruction).registerA
|
|
||||||
addInstructions(
|
VersionOverrideFingerprint.result?.let {
|
||||||
insertIndex + 1, """
|
val insertIndex = it.scanResult.patternScanResult!!.endIndex
|
||||||
invoke-static {v$register}, $MISC_PATH/VersionOverridePatch;->getVersionOverride(Ljava/lang/String;)Ljava/lang/String;
|
|
||||||
move-result-object v$register
|
it.mutableMethod.replaceInstruction(insertIndex, "const-string p0, \"$clientSpoofVersion\"")
|
||||||
"""
|
|
||||||
)
|
} ?: return VersionOverrideFingerprint.toErrorResult()
|
||||||
}
|
|
||||||
} ?: return OldLayoutFingerprint.toErrorResult()
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add settings
|
* Add settings
|
||||||
|
@ -485,9 +485,6 @@ Is it ready to submit?"</string>
|
|||||||
<string name="revanced_player_layout">Player layout</string>
|
<string name="revanced_player_layout">Player layout</string>
|
||||||
<string name="revanced_reboot_warning_general">"As this is still an experimental feature, there may be other unknown issues.
|
<string name="revanced_reboot_warning_general">"As this is still an experimental feature, there may be other unknown issues.
|
||||||
Are you sure you want to continue though?"</string>
|
Are you sure you want to continue though?"</string>
|
||||||
<string name="revanced_reboot_warning_oldlayout">"Tricks the YouTube client version to v17.28.35 to load the old layout
|
|
||||||
|
|
||||||
In the app settings, the YouTube version may be marked as v17.28.35"</string>
|
|
||||||
<string name="revanced_reboot_warning_phone">"Tricks the dpi to change some layouts to phone layouts.
|
<string name="revanced_reboot_warning_phone">"Tricks the dpi to change some layouts to phone layouts.
|
||||||
|
|
||||||
If you enable this setting, the following features are available:
|
If you enable this setting, the following features are available:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user