forked from crimera/piko
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(all): Added
Export all activities
patch from ReVanced
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
src/main/kotlin/crimera/patches/all/activity/exportall/ExportAllActivitiesPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |