chore: Separate extensions by app (#3905)

This commit is contained in:
oSumAtrIX
2024-12-05 12:12:48 +01:00
committed by GitHub
parent 69ec47cbef
commit cc40246e60
314 changed files with 371 additions and 148 deletions

View File

@ -543,6 +543,7 @@ public final class app/revanced/patches/shared/misc/extension/ExtensionHook {
public final class app/revanced/patches/shared/misc/extension/SharedExtensionPatchKt {
public static final fun extensionHook (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Lapp/revanced/patches/shared/misc/extension/ExtensionHook;
public static synthetic fun extensionHook$default (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lapp/revanced/patches/shared/misc/extension/ExtensionHook;
public static final fun sharedExtensionPatch (Ljava/lang/String;[Lapp/revanced/patches/shared/misc/extension/ExtensionHook;)Lapp/revanced/patcher/patch/BytecodePatch;
public static final fun sharedExtensionPatch ([Lapp/revanced/patches/shared/misc/extension/ExtensionHook;)Lapp/revanced/patcher/patch/BytecodePatch;
}

View File

@ -5,7 +5,8 @@ import app.revanced.patches.all.misc.transformation.IMethodCall
import app.revanced.patches.all.misc.transformation.filterMapInstruction35c
import app.revanced.patches.all.misc.transformation.transformInstructionsPatch
internal const val EXTENSION_CLASS_DESCRIPTOR_PREFIX = "Lapp/revanced/extension/all/connectivity/wifi/spoof/SpoofWifiPatch"
internal const val EXTENSION_CLASS_DESCRIPTOR_PREFIX =
"Lapp/revanced/extension/all/connectivity/wifi/spoof/SpoofWifiPatch"
internal const val EXTENSION_CLASS_DESCRIPTOR = "$EXTENSION_CLASS_DESCRIPTOR_PREFIX;"
@ -15,7 +16,7 @@ val spoofWifiPatch = bytecodePatch(
description = "Spoofs an existing Wi-Fi connection.",
use = false,
) {
extendWith("extensions/all/connectivity/wifi/spoof/spoof-wifi.rve")
extendWith("extensions/all/misc/connectivity/wifi/spoof/spoof-wifi.rve")
dependsOn(
transformInstructionsPatch(

View File

@ -34,7 +34,7 @@ val removeScreenCaptureRestrictionPatch = bytecodePatch(
description = "Removes the restriction of capturing audio from apps that normally wouldn't allow it.",
use = false,
) {
extendWith("extensions/all/screencapture/remove-screen-capture-restriction.rve")
extendWith("extensions/all/misc/screencapture/remove-screen-capture-restriction.rve")
dependsOn(
removeCaptureRestrictionResourcePatch,

View File

@ -19,7 +19,7 @@ val removeScreenshotRestrictionPatch = bytecodePatch(
description = "Removes the restriction of taking screenshots in apps that normally wouldn't allow it.",
use = false,
) {
extendWith("extensions/all/screenshot/remove-screenshot-restriction.rve")
extendWith("extensions/all/misc/screenshot/remove-screenshot-restriction.rve")
dependsOn(
// Remove the restriction of taking screenshots.

View File

@ -3,4 +3,7 @@ package app.revanced.patches.music.misc.extension
import app.revanced.patches.music.misc.extension.hooks.applicationInitHook
import app.revanced.patches.shared.misc.extension.sharedExtensionPatch
val sharedExtensionPatch = sharedExtensionPatch(applicationInitHook)
val sharedExtensionPatch = sharedExtensionPatch(
"music",
applicationInitHook,
)

View File

@ -3,4 +3,4 @@ package app.revanced.patches.reddit.customclients.boostforreddit.misc.extension
import app.revanced.patches.reddit.customclients.boostforreddit.misc.extension.hooks.initHook
import app.revanced.patches.shared.misc.extension.sharedExtensionPatch
val sharedExtensionPatch = sharedExtensionPatch(initHook)
val sharedExtensionPatch = sharedExtensionPatch("boostforreddit", initHook)

View File

@ -3,4 +3,4 @@ package app.revanced.patches.reddit.customclients.sync.syncforreddit.extension
import app.revanced.patches.reddit.customclients.sync.syncforreddit.extension.hooks.initHook
import app.revanced.patches.shared.misc.extension.sharedExtensionPatch
val sharedExtensionPatch = sharedExtensionPatch(initHook)
val sharedExtensionPatch = sharedExtensionPatch("sync", initHook)

View File

@ -2,4 +2,4 @@ package app.revanced.patches.reddit.misc.extension
import app.revanced.patches.shared.misc.extension.sharedExtensionPatch
val sharedExtensionPatch = sharedExtensionPatch()
val sharedExtensionPatch = sharedExtensionPatch("reddit")

View File

@ -14,6 +14,26 @@ import java.util.jar.JarFile
internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/shared/Utils;"
/**
* A patch to extend with an extension shared with multiple patches.
*
* @param extensionName The name of the extension to extend with.
*/
fun sharedExtensionPatch(
extensionName: String,
vararg hooks: ExtensionHook,
) = bytecodePatch {
dependsOn(sharedExtensionPatch(*hooks))
extendWith("extensions/$extensionName.rve")
}
/**
* A patch to extend with the "shared" extension.
*
* @param hooks The hooks to get the application context for use in the extension,
* commonly for the onCreate method of exported activities.
*/
fun sharedExtensionPatch(
vararg hooks: ExtensionHook,
) = bytecodePatch {

View File

@ -2,4 +2,4 @@ package app.revanced.patches.tiktok.misc.extension
import app.revanced.patches.shared.misc.extension.sharedExtensionPatch
val sharedExtensionPatch = sharedExtensionPatch(initHook)
val sharedExtensionPatch = sharedExtensionPatch("tiktok", initHook)

View File

@ -2,4 +2,4 @@ package app.revanced.patches.tudortmund.misc.extension
import app.revanced.patches.shared.misc.extension.sharedExtensionPatch
val sharedExtensionPatch = sharedExtensionPatch()
val sharedExtensionPatch = sharedExtensionPatch("tudortmund")

View File

@ -2,4 +2,4 @@ package app.revanced.patches.tumblr.misc.extension
import app.revanced.patches.shared.misc.extension.sharedExtensionPatch
val sharedExtensionPatch = sharedExtensionPatch()
val sharedExtensionPatch = sharedExtensionPatch("tumblr")

View File

@ -2,4 +2,4 @@ package app.revanced.patches.twitch.misc.extension
import app.revanced.patches.shared.misc.extension.sharedExtensionPatch
val sharedExtensionPatch = sharedExtensionPatch(initHook)
val sharedExtensionPatch = sharedExtensionPatch("twitch", initHook)

View File

@ -2,4 +2,4 @@ package app.revanced.patches.twitter.misc.extension
import app.revanced.patches.shared.misc.extension.sharedExtensionPatch
val sharedExtensionPatch = sharedExtensionPatch()
val sharedExtensionPatch = sharedExtensionPatch("twitter")

View File

@ -3,7 +3,4 @@ package app.revanced.patches.youtube.misc.extension
import app.revanced.patches.shared.misc.extension.sharedExtensionPatch
import app.revanced.patches.youtube.misc.extension.hooks.*
// TODO: Move this to a "Hook.kt" file. Same for other extension hook patches.
val sharedExtensionPatch = sharedExtensionPatch(
applicationInitHook,
)
val sharedExtensionPatch = sharedExtensionPatch("youtube", applicationInitHook)

View File

@ -11,6 +11,7 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.shared.misc.mapping.get
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
import app.revanced.patches.shared.misc.mapping.resourceMappings
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
import app.revanced.patches.youtube.misc.playservice.is_19_25_or_greater
import app.revanced.patches.youtube.misc.playservice.is_19_35_or_greater
import app.revanced.util.*
@ -214,15 +215,17 @@ private var visibilityImmediateInsertIndex: Int = 0
val playerControlsPatch = bytecodePatch(
description = "Manages the code for the player controls of the YouTube player.",
) {
dependsOn(playerControlsResourcePatch)
dependsOn(
playerControlsResourcePatch,
sharedExtensionPatch,
)
execute {
fun MutableMethod.indexOfFirstViewInflateOrThrow() =
indexOfFirstInstructionOrThrow {
val reference = getReference<MethodReference>()
reference?.definingClass == "Landroid/view/ViewStub;" &&
reference.name == "inflate"
}
fun MutableMethod.indexOfFirstViewInflateOrThrow() = indexOfFirstInstructionOrThrow {
val reference = getReference<MethodReference>()
reference?.definingClass == "Landroid/view/ViewStub;" &&
reference.name == "inflate"
}
playerBottomControlsInflateFingerprint.method.apply {
inflateBottomControlMethod = this
@ -292,7 +295,7 @@ val playerControlsPatch = bytecodePatch(
"""
invoke-static { v$register }, $EXTENSION_CLASS_DESCRIPTOR->getPlayerTopControlsLayoutResourceName(Ljava/lang/String;)Ljava/lang/String;
move-result-object v$register
"""
""",
)
}
}