2023-09-20 05:33:02 +02:00
|
|
|
package app.revanced.patches.youtube.layout.spoofappversion
|
2023-01-10 19:27:53 +01:00
|
|
|
|
|
|
|
import app.revanced.patcher.data.BytecodeContext
|
2023-06-07 03:46:13 +02:00
|
|
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
2023-01-10 19:27:53 +01:00
|
|
|
import app.revanced.patcher.patch.BytecodePatch
|
2023-09-20 05:33:02 +02:00
|
|
|
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
|
|
|
import app.revanced.patcher.patch.annotation.Patch
|
2024-01-27 02:34:01 +01:00
|
|
|
import app.revanced.patches.all.misc.resources.AddResourcesPatch
|
|
|
|
import app.revanced.patches.shared.misc.settings.preference.ListPreference
|
|
|
|
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
2023-09-20 05:33:02 +02:00
|
|
|
import app.revanced.patches.youtube.layout.spoofappversion.fingerprints.SpoofAppVersionFingerprint
|
|
|
|
import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch
|
|
|
|
import app.revanced.patches.youtube.misc.settings.SettingsPatch
|
2024-01-27 02:34:01 +01:00
|
|
|
import app.revanced.util.exception
|
2023-08-27 21:40:49 +02:00
|
|
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
2023-01-10 19:27:53 +01:00
|
|
|
|
2023-09-20 05:33:02 +02:00
|
|
|
@Patch(
|
|
|
|
name = "Spoof app version",
|
2024-01-01 16:30:04 +01:00
|
|
|
description = "Adds an option to trick YouTube into thinking you are running an older version of the app. " +
|
2023-12-02 23:54:49 +01:00
|
|
|
"This can be used to restore old UI elements and features.",
|
2024-01-27 02:34:01 +01:00
|
|
|
dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class],
|
2023-09-20 05:33:02 +02:00
|
|
|
compatiblePackages = [
|
|
|
|
CompatiblePackage(
|
|
|
|
"com.google.android.youtube", [
|
2023-09-28 01:28:25 +02:00
|
|
|
"18.32.39",
|
2023-10-08 03:37:42 +02:00
|
|
|
"18.37.36",
|
2023-11-12 16:43:11 +01:00
|
|
|
"18.38.44",
|
2023-11-12 17:01:49 +01:00
|
|
|
"18.43.45",
|
|
|
|
"18.44.41",
|
2024-01-16 19:54:06 +01:00
|
|
|
"18.45.43",
|
|
|
|
"18.48.39",
|
|
|
|
"18.49.37",
|
2024-01-17 21:24:55 +01:00
|
|
|
"19.01.34",
|
2024-01-24 14:19:02 +01:00
|
|
|
"19.02.39",
|
2024-02-04 18:38:19 +01:00
|
|
|
"19.03.35",
|
|
|
|
"19.03.36",
|
|
|
|
"19.04.37"
|
2023-09-20 05:33:02 +02:00
|
|
|
]
|
|
|
|
)
|
|
|
|
]
|
|
|
|
)
|
|
|
|
@Suppress("unused")
|
|
|
|
object SpoofAppVersionPatch : BytecodePatch(
|
|
|
|
setOf(SpoofAppVersionFingerprint)
|
2023-01-10 19:27:53 +01:00
|
|
|
) {
|
2024-01-27 02:34:01 +01:00
|
|
|
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
|
|
|
"Lapp/revanced/integrations/youtube/patches/spoof/SpoofAppVersionPatch;"
|
2023-09-20 05:33:02 +02:00
|
|
|
|
2023-08-27 21:40:49 +02:00
|
|
|
override fun execute(context: BytecodeContext) {
|
2024-01-27 02:34:01 +01:00
|
|
|
AddResourcesPatch(this::class)
|
|
|
|
|
2024-03-02 08:27:05 +01:00
|
|
|
SettingsPatch.PreferenceScreen.GENERAL_LAYOUT.addPreferences(
|
2024-01-27 02:34:01 +01:00
|
|
|
SwitchPreference("revanced_spoof_app_version"),
|
2023-04-28 19:52:22 +02:00
|
|
|
ListPreference(
|
2024-01-27 02:34:01 +01:00
|
|
|
key = "revanced_spoof_app_version_target",
|
|
|
|
summaryKey = null,
|
2023-01-10 19:27:53 +01:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
SpoofAppVersionFingerprint.result?.apply {
|
|
|
|
val insertIndex = scanResult.patternScanResult!!.startIndex + 1
|
|
|
|
val buildOverrideNameRegister =
|
|
|
|
(mutableMethod.implementation!!.instructions[insertIndex - 1] as OneRegisterInstruction).registerA
|
|
|
|
|
|
|
|
mutableMethod.addInstructions(
|
|
|
|
insertIndex,
|
|
|
|
"""
|
2023-10-02 15:26:41 +02:00
|
|
|
invoke-static {v$buildOverrideNameRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->getYouTubeVersionOverride(Ljava/lang/String;)Ljava/lang/String;
|
2023-06-07 03:46:13 +02:00
|
|
|
move-result-object v$buildOverrideNameRegister
|
|
|
|
"""
|
2023-01-10 19:27:53 +01:00
|
|
|
)
|
2023-08-27 21:40:49 +02:00
|
|
|
} ?: throw SpoofAppVersionFingerprint.exception
|
2023-01-10 19:27:53 +01:00
|
|
|
}
|
2023-07-28 23:14:22 +02:00
|
|
|
}
|