mirror of
https://github.com/kvorschk/Magisk.git
synced 2026-12-05 03:20:46 -05:00
Remove dynamic APK class and resource loading across :app, :shared, and :stub. Consolidate stub resources into :stub and remove stub obfuscation and encryption. - Merge :stub-res into :stub and delete the :stub-res module. - Delete DynLoad, DelegateComponentFactory, ClassLoaders, StubApplication, StubRootService, and dummy component classes. - Delete StubApk, DynamicClassLoader, and CompoundEnumeration from :shared. - Remove lsparanoid, stub component randomization, resource encryption, and Stub.kt from build-logic. - Remove stubVersion and STUB_VERSION tracking. - Simplify DownloadActivity to use direct resources and APKInstall. - Remove isRunningAsStub and stub-specific hooks across :core. Assisted-by: Gemini 4 Argon
64 lines
1.9 KiB
Kotlin
64 lines
1.9 KiB
Kotlin
|
|
import org.gradle.api.Plugin
|
|
import org.gradle.api.Project
|
|
import org.gradle.kotlin.dsl.provideDelegate
|
|
import java.io.File
|
|
import java.util.Properties
|
|
val ABI_SUPPORT_LIST = listOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64", "riscv64")
|
|
|
|
private val props = Properties()
|
|
|
|
object Config {
|
|
operator fun get(key: String): String? {
|
|
val v = props[key] as? String ?: return null
|
|
return v.ifBlank { null }
|
|
}
|
|
|
|
fun contains(key: String) = get(key) != null
|
|
|
|
// Properties from config.prop and flags.prop, may be null
|
|
val version: String get() = get("version") ?: "null"
|
|
val abiList: List<String> get() = get("abiList")?.split(",") ?: ABI_SUPPORT_LIST
|
|
|
|
// Properties from gradle.properties, should always exist
|
|
val versionCode: Int get() = get("magisk.versionCode")!!.toInt()
|
|
}
|
|
|
|
fun Project.rootFile(path: String): File {
|
|
val file = File(path)
|
|
return if (file.isAbsolute) file
|
|
else File(rootProject.file(".."), path)
|
|
}
|
|
|
|
class MagiskPlugin : Plugin<Project> {
|
|
override fun apply(project: Project) = project.applyPlugin()
|
|
|
|
private fun Project.applyPlugin() {
|
|
props.clear()
|
|
|
|
// Get gradle properties relevant to Magisk
|
|
props.putAll(providers.gradlePropertiesPrefixedBy("magisk.").get())
|
|
|
|
// Load config.prop
|
|
val configPath = findProperty("configPath") as String?
|
|
val configFile = rootFile(configPath ?: "config.prop")
|
|
if (configFile.exists()) {
|
|
configFile.inputStream().use {
|
|
val config = Properties()
|
|
config.load(it)
|
|
props.putAll(config)
|
|
}
|
|
}
|
|
|
|
// Load flags.prop, generated by build.py
|
|
val flagsProp = rootProject.layout.buildDirectory.file("flags.prop").get().asFile
|
|
if (flagsProp.exists()) {
|
|
flagsProp.inputStream().use {
|
|
val flags = Properties()
|
|
flags.load(it)
|
|
props.putAll(flags)
|
|
}
|
|
}
|
|
}
|
|
}
|