Skip to content

Commit

Permalink
feat(all): Added Export all activities patch from ReVanced
Browse files Browse the repository at this point in the history
  • Loading branch information
Swakshan committed Jun 4, 2024
1 parent be20f90 commit 7cc405f
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package crimera.patches.all.activity.exportall

import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotation.Patch

//credits - @ReVanced
@Patch(
name = "Export all activities",
description = "Makes all app activities exportable.",
use = false,
)
@Suppress("unused")
object ExportAllActivitiesPatch : ResourcePatch() {
private const val EXPORTED_FLAG = "android:exported"

override fun execute(context: ResourceContext) {
context.xmlEditor["AndroidManifest.xml"].use { editor ->
val document = editor.file

val activities = document.getElementsByTagName("activity")

for (i in 0..activities.length) {
activities.item(i)?.apply {
val exportedAttribute = attributes.getNamedItem(EXPORTED_FLAG)

if (exportedAttribute != null) {
if (exportedAttribute.nodeValue != "true") {
exportedAttribute.nodeValue = "true"
}
}
// Reason why the attribute is added in the case it does not exist:
// https://github.com/revanced/revanced-patches/pull/1751/files#r1141481604
else {
document.createAttribute(EXPORTED_FLAG)
.apply { value = "true" }
.let(attributes::setNamedItem)
}
}
}
}
}
}

0 comments on commit 7cc405f

Please sign in to comment.