diff --git a/src/main/kotlin/app/revanced/patches/all/misc/debugging/patch/DebuggingPatc.kt b/src/main/kotlin/app/revanced/patches/all/misc/debugging/patch/DebuggingPatc.kt new file mode 100644 index 000000000..a5b9942a2 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/all/misc/debugging/patch/DebuggingPatc.kt @@ -0,0 +1,43 @@ +package app.revanced.patches.all.misc.debugging.patch + +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.ResourceContext +import app.revanced.patcher.patch.* +import app.revanced.patcher.patch.annotations.DependsOn +import app.revanced.patcher.patch.annotations.Patch +import org.w3c.dom.Element + +@Patch +@Name("enable-android-debugging") +@Description("Enables Android debugging capabilities.") +@Version("0.0.1") +class EnableAndroidDebuggingPatch : ResourcePatch { + override fun execute(context: ResourceContext): PatchResult { + if (debuggable == true) { + context.xmlEditor["AndroidManifest.xml"].use { dom -> + val applicationNode = dom + .file + .getElementsByTagName("application") + .item(0) as Element + + // set application as debuggable + applicationNode.setAttribute("android:debuggable", "true") + } + } + + return PatchResultSuccess() + } + + companion object : OptionsContainer() { + var debuggable: Boolean? by option( + PatchOption.BooleanOption( + key = "debuggable", + default = true, + title = "App debugging", + description = "Whether to make the app debuggable on Android.", + ) + ) + } +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/patch/DebuggingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/patch/DebuggingPatch.kt index f25fdd0c4..8a2a8c88e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/patch/DebuggingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/debugging/patch/DebuggingPatch.kt @@ -11,15 +11,16 @@ import app.revanced.patches.shared.settings.preference.impl.StringResource import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.debugging.annotations.DebuggingCompatibility import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch +import app.revanced.patches.all.misc.debugging.patch.EnableAndroidDebuggingPatch import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch import org.w3c.dom.Element @Patch -@Name("debugging") -@DependsOn([IntegrationsPatch::class, SettingsPatch::class]) +@Name("enable-debugging") +@DependsOn([IntegrationsPatch::class, SettingsPatch::class, EnableAndroidDebuggingPatch::class]) @Description("Adds debugging options.") @DebuggingCompatibility -@Version("0.0.1") +@Version("0.0.2") class DebuggingPatch : ResourcePatch { override fun execute(context: ResourceContext): PatchResult { SettingsPatch.PreferenceScreen.MISC.addPreferences( @@ -64,29 +65,6 @@ class DebuggingPatch : ResourcePatch { ) ) - if (debuggable == true) { - context.xmlEditor["AndroidManifest.xml"].use { dom -> - val applicationNode = dom - .file - .getElementsByTagName("application") - .item(0) as Element - - // set application as debuggable - applicationNode.setAttribute("android:debuggable", "true") - } - } - return PatchResultSuccess() } - - companion object : OptionsContainer() { - var debuggable: Boolean? by option( - PatchOption.BooleanOption( - key = "debuggable", - default = false, - title = "App debugging", - description = "Whether to make the app debuggable on Android.", - ) - ) - } }