feat(youtube/debugging): include by default & add option to debug on Android
This commit is contained in:
parent
965f79bd7f
commit
3865add799
|
@ -1,4 +1,4 @@
|
|||
package app.revanced.patches.youtube.misc.enabledebugging.annotations
|
||||
package app.revanced.patches.youtube.misc.debugging.annotations
|
||||
|
||||
import app.revanced.patcher.annotation.Compatibility
|
||||
import app.revanced.patcher.annotation.Package
|
||||
|
@ -6,4 +6,4 @@ import app.revanced.patcher.annotation.Package
|
|||
@Compatibility([Package("com.google.android.youtube")])
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
internal annotation class EnableDebuggingCompatibility
|
||||
internal annotation class DebuggingCompatibility
|
|
@ -1,28 +1,26 @@
|
|||
package app.revanced.patches.youtube.misc.enabledebugging.patch
|
||||
package app.revanced.patches.youtube.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.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.*
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.youtube.misc.enabledebugging.annotations.EnableDebuggingCompatibility
|
||||
import app.revanced.patches.youtube.misc.debugging.annotations.DebuggingCompatibility
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference
|
||||
import org.w3c.dom.Element
|
||||
|
||||
@Patch(false)
|
||||
@Patch
|
||||
@Name("debugging")
|
||||
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])
|
||||
@Description("Adds debugging options.")
|
||||
@EnableDebuggingCompatibility
|
||||
@DebuggingCompatibility
|
||||
@Version("0.0.1")
|
||||
class EnableDebuggingPatch : ResourcePatch {
|
||||
class DebuggingPatch : ResourcePatch {
|
||||
override fun execute(context: ResourceContext): PatchResult {
|
||||
SettingsPatch.PreferenceScreen.MISC.addPreferences(
|
||||
SwitchPreference(
|
||||
|
@ -34,18 +32,29 @@ class EnableDebuggingPatch : ResourcePatch {
|
|||
)
|
||||
)
|
||||
|
||||
// create an xml editor instance
|
||||
context.xmlEditor["AndroidManifest.xml"].use { dom ->
|
||||
// get the application node
|
||||
val applicationNode = dom
|
||||
.file
|
||||
.getElementsByTagName("application")
|
||||
.item(0) as Element
|
||||
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")
|
||||
// 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.",
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue