feat(youtube): bump patches compatibility to v17.49.37
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
package app.revanced.patches.youtube.misc.settings.bytecode.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
|
||||
object ThemeConstructorFingerprint : MethodFingerprint(
|
||||
"L",
|
||||
AccessFlags.PUBLIC or AccessFlags.STATIC,
|
||||
listOf("L"),
|
||||
strings = listOf("settings.SettingsActivity", ":android:show_fragment", "settings.GeneralPrefsFragment")
|
||||
)
|
||||
+1
-12
@@ -6,18 +6,7 @@ import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object ThemeSetterAppFingerprint : MethodFingerprint(
|
||||
"L", AccessFlags.PUBLIC or AccessFlags.STATIC, listOf("L", "L", "L"), listOf(
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.IF_EQZ,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.IF_EQZ,
|
||||
Opcode.NEW_INSTANCE,
|
||||
Opcode.INVOKE_INTERFACE,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.SGET_OBJECT,
|
||||
Opcode.IF_NE,
|
||||
"L", AccessFlags.PUBLIC or AccessFlags.STATIC, opcodes = listOf(
|
||||
Opcode.CONST, //target reference
|
||||
Opcode.GOTO,
|
||||
Opcode.CONST, //target reference
|
||||
|
||||
+26
-26
@@ -1,11 +1,13 @@
|
||||
package app.revanced.patches.youtube.misc.settings.bytecode.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.addInstruction
|
||||
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
|
||||
@@ -16,6 +18,7 @@ import app.revanced.patches.shared.settings.util.AbstractPreferenceScreen
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.annotations.SettingsCompatibility
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.fingerprints.LicenseActivityFingerprint
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.fingerprints.ThemeConstructorFingerprint
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.fingerprints.ThemeSetterAppFingerprint
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.fingerprints.ThemeSetterSystemFingerprint
|
||||
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsResourcePatch
|
||||
@@ -33,7 +36,7 @@ import org.jf.dexlib2.util.MethodUtil
|
||||
@SettingsCompatibility
|
||||
@Version("0.0.1")
|
||||
class SettingsPatch : BytecodePatch(
|
||||
listOf(LicenseActivityFingerprint, ThemeSetterSystemFingerprint, ThemeSetterAppFingerprint)
|
||||
listOf(LicenseActivityFingerprint, ThemeSetterSystemFingerprint, ThemeConstructorFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
fun buildInvokeInstructionsString(
|
||||
@@ -44,48 +47,47 @@ class SettingsPatch : BytecodePatch(
|
||||
) = "invoke-static {$registers}, $classDescriptor->$methodName($parameters)V"
|
||||
|
||||
// apply the current theme of the settings page
|
||||
with(ThemeSetterSystemFingerprint.result!!) {
|
||||
with(mutableMethod) {
|
||||
val call = buildInvokeInstructionsString()
|
||||
|
||||
ThemeSetterSystemFingerprint.result!!.let { result ->
|
||||
val call = buildInvokeInstructionsString()
|
||||
result.mutableMethod.apply {
|
||||
addInstruction(
|
||||
scanResult.patternScanResult!!.startIndex,
|
||||
call
|
||||
result.scanResult.patternScanResult!!.startIndex, call
|
||||
)
|
||||
|
||||
addInstruction(
|
||||
mutableMethod.implementation!!.instructions.size - 1,
|
||||
call
|
||||
addInstructions(
|
||||
implementation!!.instructions.size - 1, call
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// set the theme based on the preference of the app
|
||||
with(ThemeSetterAppFingerprint.result!!) {
|
||||
with(mutableMethod) {
|
||||
fun buildInstructionsString(theme: Int) = """
|
||||
with((ThemeConstructorFingerprint.result?.let {
|
||||
ThemeSetterAppFingerprint.apply {
|
||||
if (!resolve(context, it.classDef)) return ThemeSetterAppFingerprint.toErrorResult()
|
||||
}
|
||||
} ?: return ThemeConstructorFingerprint.toErrorResult()).result!!) {
|
||||
fun buildInstructionsString(theme: Int) = """
|
||||
const/4 v0, 0x$theme
|
||||
${buildInvokeInstructionsString(parameters = "I")}
|
||||
"""
|
||||
|
||||
val patternScanResult = scanResult.patternScanResult!!
|
||||
|
||||
mutableMethod.apply {
|
||||
addInstructions(
|
||||
scanResult.patternScanResult!!.endIndex + 1,
|
||||
buildInstructionsString(1)
|
||||
patternScanResult.endIndex + 1, buildInstructionsString(1)
|
||||
)
|
||||
addInstructions(
|
||||
scanResult.patternScanResult!!.endIndex - 7,
|
||||
buildInstructionsString(0)
|
||||
patternScanResult.endIndex - 7, buildInstructionsString(0)
|
||||
)
|
||||
|
||||
addInstructions(
|
||||
scanResult.patternScanResult!!.endIndex - 9,
|
||||
buildInstructionsString(1)
|
||||
patternScanResult.endIndex - 9, buildInstructionsString(1)
|
||||
)
|
||||
addInstructions(
|
||||
mutableMethod.implementation!!.instructions.size - 2,
|
||||
buildInstructionsString(0)
|
||||
implementation!!.instructions.size - 2, buildInstructionsString(0)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// set the theme based on the preference of the device
|
||||
@@ -100,8 +102,7 @@ class SettingsPatch : BytecodePatch(
|
||||
|
||||
// initialize the settings
|
||||
addInstructions(
|
||||
1,
|
||||
"""
|
||||
1, """
|
||||
${buildSettingsActivityInvokeString()}
|
||||
return-void
|
||||
"""
|
||||
@@ -134,8 +135,7 @@ class SettingsPatch : BytecodePatch(
|
||||
fun addPreferenceScreen(preferenceScreen: app.revanced.patches.shared.settings.preference.impl.PreferenceScreen) =
|
||||
SettingsResourcePatch.addPreferenceScreen(preferenceScreen)
|
||||
|
||||
fun addPreference(preference: Preference) =
|
||||
SettingsResourcePatch.addPreference(preference)
|
||||
fun addPreference(preference: Preference) = SettingsResourcePatch.addPreference(preference)
|
||||
|
||||
fun renameIntentsTargetPackage(newPackage: String) {
|
||||
SettingsResourcePatch.overrideIntentsTargetPackage = newPackage
|
||||
|
||||
Reference in New Issue
Block a user