Skip to content

Commit

Permalink
feat(All): Add Remove internet permission patch
Browse files Browse the repository at this point in the history
  • Loading branch information
jkennethcarino committed Mar 3, 2024
1 parent 41ee15c commit 5c7e3d5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 23 deletions.
6 changes: 3 additions & 3 deletions api/privacy-revanced-patches.api
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
public final class dev/jkcarino/revanced/patches/example/ExamplePatch : app/revanced/patcher/patch/BytecodePatch {
public static final field INSTANCE Ldev/jkcarino/revanced/patches/example/ExamplePatch;
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
public final class dev/jkcarino/revanced/patches/all/misc/network/RemoveInternetPermissionPatch : app/revanced/patcher/patch/ResourcePatch {
public static final field INSTANCE Ldev/jkcarino/revanced/patches/all/misc/network/RemoveInternetPermissionPatch;
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package dev.jkcarino.revanced.patches.all.misc.network

import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotation.Patch
import org.w3c.dom.Element

@Patch(
name = "Remove internet permission",
description = "Removes unnecessary internet permission from apps that can function without internet access.",
use = false
)
@Suppress("unused")
object RemoveInternetPermissionPatch : ResourcePatch() {
override fun execute(context: ResourceContext) {
context.xmlEditor["AndroidManifest.xml"].use { editor ->
val usesPermissions = editor.file.getElementsByTagName("uses-permission")

for (i in 0 until usesPermissions.length) {
val element = usesPermissions.item(i) as? Element ?: continue
if (element.getAttribute("android:name") == "android.permission.INTERNET") {
element.parentNode.removeChild(element)
break
}
}
}
}
}

This file was deleted.

0 comments on commit 5c7e3d5

Please sign in to comment.