diff --git a/patches/api/patches.api b/patches/api/patches.api index 7feb20361..fd9424c7b 100644 --- a/patches/api/patches.api +++ b/patches/api/patches.api @@ -6,6 +6,10 @@ public final class app/revanced/patches/all/misc/adb/HideAdbPatchKt { public static final fun getHideAdbStatusPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } +public final class app/revanced/patches/all/misc/appicon/HideAppIconPatchKt { + public static final fun getHideAppIconPatch ()Lapp/revanced/patcher/patch/ResourcePatch; +} + public final class app/revanced/patches/all/misc/build/BaseSpoofBuildInfoPatchKt { public static final fun baseSpoofBuildInfoPatch (Lkotlin/jvm/functions/Function0;)Lapp/revanced/patcher/patch/BytecodePatch; } diff --git a/patches/src/main/kotlin/app/revanced/patches/all/misc/appicon/HideAppIconPatch.kt b/patches/src/main/kotlin/app/revanced/patches/all/misc/appicon/HideAppIconPatch.kt new file mode 100644 index 000000000..a0411d89f --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/all/misc/appicon/HideAppIconPatch.kt @@ -0,0 +1,48 @@ +package app.revanced.patches.all.misc.appicon + +import app.revanced.patcher.patch.resourcePatch +import app.revanced.util.asSequence +import app.revanced.util.childElementsSequence +import java.util.logging.Logger +import org.w3c.dom.Element + +@Suppress("unused") +val hideAppIconPatch = resourcePatch( + name = "Hide app icon", + description = "Hides the app icon from the Android launcher.", + use = false, +) { + execute { + document("AndroidManifest.xml").use { document -> + var changed = false + + val intentFilters = document.getElementsByTagName("intent-filter") + for (node in intentFilters.asSequence().filterIsInstance()) { + var hasMainAction = false + var launcherCategory: Element? = null + + for (child in node.childElementsSequence()) { + when (child.tagName) { + "action" -> if (child.getAttribute("android:name") == "android.intent.action.MAIN") { + hasMainAction = true + } + "category" -> if (child.getAttribute("android:name") == "android.intent.category.LAUNCHER") { + launcherCategory = child + } + } + } + + if (hasMainAction && launcherCategory != null) { + launcherCategory.setAttribute("android:name", "android.intent.category.DEFAULT") + changed = true + } + } + + if (!changed) { + Logger.getLogger(this::class.java.name) + .warning("No changes made: Did not find any launcher intent-filters to change.") + } + } + } +} +