Skip to content

Commit

Permalink
feat(youtube/debugging): include by default & add option to debug on …
Browse files Browse the repository at this point in the history
…Android
  • Loading branch information
oSumAtrIX committed Nov 15, 2022
1 parent 965f79b commit 3865add
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
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

@Compatibility([Package("com.google.android.youtube")])
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
internal annotation class EnableDebuggingCompatibility
internal annotation class DebuggingCompatibility
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -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.",
)
)
}
}

0 comments on commit 3865add

Please sign in to comment.