refactor: Extract shared patch names/descriptions (#6056)

This commit is contained in:
LisoUseInAIKyrios
2025-10-07 01:15:03 +04:00
committed by GitHub
parent 603025a122
commit a30a849e6e
10 changed files with 50 additions and 18 deletions

View File

@@ -2,11 +2,13 @@ package app.revanced.patches.finanzonline.detection.root
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.shared.PATCH_DESCRIPTION_REMOVE_ROOT_DETECTION
import app.revanced.patches.shared.PATCH_NAME_REMOVE_ROOT_DETECTION
@Suppress("unused")
val rootDetectionPatch = bytecodePatch(
name = "Remove root detection",
description = "Removes the check for root permissions.",
name = PATCH_NAME_REMOVE_ROOT_DETECTION,
description = PATCH_DESCRIPTION_REMOVE_ROOT_DETECTION,
) {
compatibleWith("at.gv.bmf.bmf2go")

View File

@@ -1,12 +1,14 @@
package app.revanced.patches.idaustria.detection.root
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.shared.PATCH_DESCRIPTION_REMOVE_ROOT_DETECTION
import app.revanced.patches.shared.PATCH_NAME_REMOVE_ROOT_DETECTION
import app.revanced.util.returnEarly
@Suppress("unused")
val rootDetectionPatch = bytecodePatch(
name = "Remove root detection",
description = "Removes the check for root permissions and unlocked bootloader.",
name = PATCH_NAME_REMOVE_ROOT_DETECTION,
description = PATCH_DESCRIPTION_REMOVE_ROOT_DETECTION
) {
compatibleWith("at.gv.oe.app")

View File

@@ -4,6 +4,8 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.instagram.misc.extension.sharedExtensionPatch
import app.revanced.patches.shared.PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS
import app.revanced.patches.shared.PATCH_NAME_SANITIZE_SHARING_LINKS
import app.revanced.util.indexOfFirstInstructionOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
@@ -13,8 +15,8 @@ private const val EXTENSION_CLASS_DESCRIPTOR =
@Suppress("unused")
val sanitizeSharingLinksPatch = bytecodePatch(
name = "Sanitize sharing links",
description = "Removes the tracking query parameters from shared links.",
name = PATCH_NAME_SANITIZE_SHARING_LINKS,
description = PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS,
) {
compatibleWith("com.instagram.android")

View File

@@ -1,12 +1,14 @@
package app.revanced.patches.orfon.detection.root
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.shared.PATCH_DESCRIPTION_REMOVE_ROOT_DETECTION
import app.revanced.patches.shared.PATCH_NAME_REMOVE_ROOT_DETECTION
import app.revanced.util.returnEarly
@Suppress("unused")
val removeRootDetectionPatch = bytecodePatch(
name = "Remove root detection",
description = "Removes the check for root permissions.",
name = PATCH_NAME_REMOVE_ROOT_DETECTION,
description = PATCH_DESCRIPTION_REMOVE_ROOT_DETECTION
) {
compatibleWith("com.nousguide.android.orftvthek")

View File

@@ -2,11 +2,13 @@ package app.revanced.patches.reddit.misc.tracking.url
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.shared.PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS
import app.revanced.patches.shared.PATCH_NAME_SANITIZE_SHARING_LINKS
@Suppress("unused")
val sanitizeUrlQueryPatch = bytecodePatch(
name = "Sanitize sharing links",
description = "Removes the tracking query parameters from shared links.",
name = PATCH_NAME_SANITIZE_SHARING_LINKS,
description = PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS,
) {
compatibleWith("com.reddit.frontpage")

View File

@@ -2,11 +2,13 @@ package app.revanced.patches.serviceportalbund.detection.root
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.shared.PATCH_DESCRIPTION_REMOVE_ROOT_DETECTION
import app.revanced.patches.shared.PATCH_NAME_REMOVE_ROOT_DETECTION
@Suppress("unused")
val rootDetectionPatch = bytecodePatch(
name = "Remove root detection",
description = "Removes the check for root permissions and unlocked bootloader.",
name = PATCH_NAME_REMOVE_ROOT_DETECTION,
description = PATCH_DESCRIPTION_REMOVE_ROOT_DETECTION
) {
compatibleWith("at.gv.bka.serviceportal")

View File

@@ -0,0 +1,11 @@
package app.revanced.patches.shared
//
// Names and descriptions used by different patches implementing the same feature.
//
internal const val PATCH_NAME_REMOVE_ROOT_DETECTION = "Remove root detection"
internal const val PATCH_DESCRIPTION_REMOVE_ROOT_DETECTION = "Removes the check for root permissions and unlocked bootloader."
internal const val PATCH_NAME_SANITIZE_SHARING_LINKS = "Sanitize sharing links"
internal const val PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS = "Removes the tracking query parameters from shared links."

View File

@@ -10,6 +10,8 @@ import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.all.misc.resources.addResources
import app.revanced.patches.all.misc.resources.addResourcesPatch
import app.revanced.patches.shared.PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS
import app.revanced.patches.shared.PATCH_NAME_SANITIZE_SHARING_LINKS
import app.revanced.patches.shared.misc.settings.preference.BasePreferenceScreen
import app.revanced.patches.shared.misc.settings.preference.PreferenceCategory
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPreference.Sorting
@@ -20,14 +22,17 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
private const val EXTENSION_CLASS_DESCRIPTOR =
"Lapp/revanced/extension/shared/patches/SanitizeSharingLinksPatch;"
/**
* Patch shared by YouTube and YT Music.
*/
internal fun sanitizeSharingLinksPatch(
block: BytecodePatchBuilder.() -> Unit = {},
executeBlock: BytecodePatchContext.() -> Unit = {},
preferenceScreen: BasePreferenceScreen.Screen,
replaceMusicLinksWithYouTube: Boolean = false
) = bytecodePatch(
name = "Sanitize sharing links",
description = "Adds an option to remove the tracking query parameter from shared links.",
name = PATCH_NAME_SANITIZE_SHARING_LINKS,
description = PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS,
) {
block()

View File

@@ -3,6 +3,8 @@ package app.revanced.patches.spotify.misc.privacy
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.shared.PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS
import app.revanced.patches.shared.PATCH_NAME_SANITIZE_SHARING_LINKS
import app.revanced.patches.spotify.misc.extension.sharedExtensionPatch
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
@@ -15,8 +17,8 @@ private const val EXTENSION_CLASS_DESCRIPTOR =
@Suppress("unused")
val sanitizeSharingLinksPatch = bytecodePatch(
name = "Sanitize sharing links",
description = "Removes the tracking query parameters from shared links.",
name = PATCH_NAME_SANITIZE_SHARING_LINKS,
description = PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS,
) {
compatibleWith("com.spotify.music")

View File

@@ -2,11 +2,13 @@ package app.revanced.patches.twitter.misc.links
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.shared.PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS
import app.revanced.patches.shared.PATCH_NAME_SANITIZE_SHARING_LINKS
@Suppress("unused")
val sanitizeSharingLinksPatch = bytecodePatch(
name = "Sanitize sharing links",
description = "Removes the tracking query parameters from links before they are shared.",
name = PATCH_NAME_SANITIZE_SHARING_LINKS,
description = PATCH_DESCRIPTION_SANITIZE_SHARING_LINKS,
) {
compatibleWith(
"com.twitter.android"(