mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2026-01-11 13:46:17 +00:00
feat: Add Strip platform libraries patch
This commit is contained in:
@@ -96,6 +96,10 @@ public final class app/revanced/patches/all/misc/network/OverrideCertificatePinn
|
||||
public static final fun getOverrideCertificatePinningPatch ()Lapp/revanced/patcher/patch/ResourcePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/all/misc/optimization/StripPlatformLibrariesPatchKt {
|
||||
public static final fun getStripPlatformLibrariesPatch ()Lapp/revanced/patcher/patch/RawResourcePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/all/misc/packagename/ChangePackageNamePatchKt {
|
||||
public static field packageNameOption Lapp/revanced/patcher/patch/Option;
|
||||
public static final fun getChangePackageNamePatch ()Lapp/revanced/patcher/patch/ResourcePatch;
|
||||
|
||||
@@ -4,7 +4,7 @@ import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patcher.patch.booleanOption
|
||||
import app.revanced.patcher.patch.resourcePatch
|
||||
import app.revanced.patcher.patch.stringsOption
|
||||
import app.revanced.util.Utils.trimIndentMultiline
|
||||
import app.revanced.util.trimIndentMultiline
|
||||
import app.revanced.util.getNode
|
||||
import org.w3c.dom.Element
|
||||
import java.io.File
|
||||
|
||||
@@ -5,7 +5,7 @@ import app.revanced.patcher.patch.rawResourcePatch
|
||||
import app.revanced.patcher.patch.stringsOption
|
||||
import app.revanced.patches.shared.misc.hex.HexPatchBuilder
|
||||
import app.revanced.patches.shared.misc.hex.hexPatch
|
||||
import app.revanced.util.Utils.trimIndentMultiline
|
||||
import app.revanced.util.trimIndentMultiline
|
||||
|
||||
@Suppress("unused")
|
||||
val hexPatch = rawResourcePatch(
|
||||
|
||||
@@ -2,7 +2,7 @@ package app.revanced.patches.all.misc.network
|
||||
|
||||
import app.revanced.patcher.patch.resourcePatch
|
||||
import app.revanced.patches.all.misc.debugging.enableAndroidDebuggingPatch
|
||||
import app.revanced.util.Utils.trimIndentMultiline
|
||||
import app.revanced.util.trimIndentMultiline
|
||||
import org.w3c.dom.Element
|
||||
import java.io.File
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package app.revanced.patches.all.misc.optimization
|
||||
|
||||
import android.os.Build.SUPPORTED_ABIS
|
||||
import app.revanced.patcher.patch.rawResourcePatch
|
||||
import app.revanced.patcher.patch.stringsOption
|
||||
import app.revanced.util.isAndroid
|
||||
|
||||
@Suppress("unused")
|
||||
val stripPlatformLibrariesPatch = rawResourcePatch(
|
||||
"Strip platform libraries",
|
||||
"Removes unused platform-native libraries from the APK to reduce package size" +
|
||||
"- if detected automatically, the device's unsupported ABIs by default."
|
||||
) {
|
||||
val allAbis = listOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64")
|
||||
val supportedAbis = if (isAndroid) SUPPORTED_ABIS.toList() else allAbis
|
||||
|
||||
val platformsToKeep by stringsOption(
|
||||
key = "platformsToKeep",
|
||||
title = "Platforms to keep",
|
||||
description = "The platforms to keep in the APK.",
|
||||
default = supportedAbis,
|
||||
values = mapOf("Keep all" to allAbis) + allAbis.associate { "Only $it" to listOf(it) },
|
||||
required = true
|
||||
)
|
||||
|
||||
execute {
|
||||
val platforms = platformsToKeep!!
|
||||
get("libs").listFiles { it.name !in platforms }?.forEach { it.deleteRecursively() }
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package app.revanced.patches.instagram.ghost.story
|
||||
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.util.Utils.trimIndentMultiline
|
||||
import app.revanced.util.trimIndentMultiline
|
||||
import app.revanced.util.returnEarly
|
||||
|
||||
@Suppress("unused")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package app.revanced.patches.instagram.misc.devmenu
|
||||
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.util.Utils.trimIndentMultiline
|
||||
import app.revanced.util.trimIndentMultiline
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
|
||||
import app.revanced.util.returnEarly
|
||||
|
||||
@@ -17,7 +17,7 @@ import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
|
||||
import app.revanced.patches.shared.misc.settings.preference.BasePreferenceScreen
|
||||
import app.revanced.patches.shared.misc.settings.preference.ListPreference
|
||||
import app.revanced.util.ResourceGroup
|
||||
import app.revanced.util.Utils.trimIndentMultiline
|
||||
import app.revanced.util.trimIndentMultiline
|
||||
import app.revanced.util.addInstructionsAtControlFlowLabel
|
||||
import app.revanced.util.copyResources
|
||||
import app.revanced.util.findElementByAttributeValueOrThrow
|
||||
|
||||
@@ -16,7 +16,7 @@ import app.revanced.patches.shared.misc.mapping.resourceMappings
|
||||
import app.revanced.patches.shared.misc.settings.preference.ListPreference
|
||||
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
||||
import app.revanced.util.ResourceGroup
|
||||
import app.revanced.util.Utils.trimIndentMultiline
|
||||
import app.revanced.util.trimIndentMultiline
|
||||
import app.revanced.util.copyResources
|
||||
import app.revanced.util.findElementByAttributeValueOrThrow
|
||||
import app.revanced.util.forEachLiteralValueInstruction
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
package app.revanced.util
|
||||
|
||||
internal object Utils {
|
||||
internal fun String.trimIndentMultiline() =
|
||||
this.split("\n")
|
||||
.joinToString("\n") { it.trimIndent() } // Remove the leading whitespace from each line.
|
||||
.trimIndent() // Remove the leading newline.
|
||||
}
|
||||
internal fun String.trimIndentMultiline() =
|
||||
this.split("\n")
|
||||
.joinToString("\n") { it.trimIndent() } // Remove the leading whitespace from each line.
|
||||
.trimIndent() // Remove the leading newline.
|
||||
|
||||
internal fun Boolean.toHexString(): String = if (this) "0x1" else "0x0"
|
||||
internal fun Boolean.toHexString(): String = if (this) "0x1" else "0x0"
|
||||
|
||||
internal val isAndroid = try {
|
||||
Class.forName("android.os.Build")
|
||||
true
|
||||
} catch (_: ClassNotFoundException) {
|
||||
false
|
||||
}
|
||||
@@ -16,6 +16,7 @@ public class Build {
|
||||
public static final String MODEL = null;
|
||||
public static final String PRODUCT = null;
|
||||
public static final String RADIO = null;
|
||||
public static final String[] SUPPORTED_ABIS = null;
|
||||
public static final String TAGS = null;
|
||||
public static final String TYPE = null;
|
||||
public static final String USER = null;
|
||||
|
||||
Reference in New Issue
Block a user