mirror of
https://github.com/revanced/revanced-patches
synced 2024-12-01 07:22:58 +01:00
feat(youtube/debugging): include by default & add option to debug on Android
This commit is contained in:
parent
a767678598
commit
9d6d5b2922
@ -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.Compatibility
|
||||||
import app.revanced.patcher.annotation.Package
|
import app.revanced.patcher.annotation.Package
|
||||||
@ -6,4 +6,4 @@ import app.revanced.patcher.annotation.Package
|
|||||||
@Compatibility([Package("com.google.android.youtube")])
|
@Compatibility([Package("com.google.android.youtube")])
|
||||||
@Target(AnnotationTarget.CLASS)
|
@Target(AnnotationTarget.CLASS)
|
||||||
@Retention(AnnotationRetention.RUNTIME)
|
@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.Description
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
import app.revanced.patcher.data.ResourceContext
|
import app.revanced.patcher.data.ResourceContext
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.*
|
||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
|
||||||
import app.revanced.patcher.patch.ResourcePatch
|
|
||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
import app.revanced.patcher.patch.annotations.Patch
|
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.integrations.patch.IntegrationsPatch
|
||||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
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.StringResource
|
||||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference
|
import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference
|
||||||
import org.w3c.dom.Element
|
import org.w3c.dom.Element
|
||||||
|
|
||||||
@Patch(false)
|
@Patch
|
||||||
@Name("debugging")
|
@Name("debugging")
|
||||||
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])
|
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])
|
||||||
@Description("Adds debugging options.")
|
@Description("Adds debugging options.")
|
||||||
@EnableDebuggingCompatibility
|
@DebuggingCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class EnableDebuggingPatch : ResourcePatch {
|
class DebuggingPatch : ResourcePatch {
|
||||||
override fun execute(context: ResourceContext): PatchResult {
|
override fun execute(context: ResourceContext): PatchResult {
|
||||||
SettingsPatch.PreferenceScreen.MISC.addPreferences(
|
SettingsPatch.PreferenceScreen.MISC.addPreferences(
|
||||||
SwitchPreference(
|
SwitchPreference(
|
||||||
@ -34,18 +32,29 @@ class EnableDebuggingPatch : ResourcePatch {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
// create an xml editor instance
|
if (debuggable == true) {
|
||||||
context.xmlEditor["AndroidManifest.xml"].use { dom ->
|
context.xmlEditor["AndroidManifest.xml"].use { dom ->
|
||||||
// get the application node
|
val applicationNode = dom
|
||||||
val applicationNode = dom
|
.file
|
||||||
.file
|
.getElementsByTagName("application")
|
||||||
.getElementsByTagName("application")
|
.item(0) as Element
|
||||||
.item(0) as Element
|
|
||||||
|
|
||||||
// set application as debuggable
|
// set application as debuggable
|
||||||
applicationNode.setAttribute("android:debuggable", "true")
|
applicationNode.setAttribute("android:debuggable", "true")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return PatchResultSuccess()
|
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 New Issue
Block a user