From 24d9c0bda9f1495d0ea8da992ab559f020eb327e Mon Sep 17 00:00:00 2001 From: JingMatrix Date: Fri, 6 Mar 2026 15:27:05 +0100 Subject: [PATCH 1/3] Clean up gradle build configurations 1. Apply Kotlin format to gradle files 2. Simplify gradle configurations 3. Remove unused project files --- app/build.gradle.kts | 51 +++++------ build.gradle.kts | 88 ++++++++++--------- core/build.gradle.kts | 38 ++------ .../lsposed/lspd/nativebridge/HookBridge.java | 37 -------- .../lsposed/lspd/nativebridge/NativeAPI.java | 25 ------ .../lspd/nativebridge/ResourcesHook.java | 38 -------- daemon/build.gradle.kts | 69 ++++++++------- daemon/src/main/jni/CMakeLists.txt | 2 + dex2oat/build.gradle.kts | 12 +-- external/CMakeLists.txt | 2 + gradle/libs.versions.toml | 2 - hiddenapi/bridge/build.gradle.kts | 27 +----- hiddenapi/stubs/build.gradle.kts | 23 +---- native/CMakeLists.txt | 3 +- services/daemon-service/build.gradle.kts | 38 +------- services/daemon-service/proguard-rules.pro | 21 ----- services/manager-service/build.gradle.kts | 40 +-------- services/manager-service/proguard-rules.pro | 1 - settings.gradle.kts | 2 +- xposed/build.gradle.kts | 2 +- 20 files changed, 131 insertions(+), 390 deletions(-) delete mode 100644 core/src/main/java/org/lsposed/lspd/nativebridge/HookBridge.java delete mode 100644 core/src/main/java/org/lsposed/lspd/nativebridge/NativeAPI.java delete mode 100644 core/src/main/java/org/lsposed/lspd/nativebridge/ResourcesHook.java delete mode 100644 services/daemon-service/proguard-rules.pro delete mode 100644 services/manager-service/proguard-rules.pro diff --git a/app/build.gradle.kts b/app/build.gradle.kts index fbdd16e9e..9ad7a2288 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -69,13 +69,7 @@ android { } } - sourceSets { - named("main") { - res { - srcDirs("src/common/res") - } - } - } + sourceSets { named("main") { res { srcDirs("src/common/res") } } } namespace = defaultManagerPackageName } @@ -88,27 +82,28 @@ autoResConfig { materialThemeBuilder { themes { - for ((name, color) in listOf( - "Red" to "F44336", - "Pink" to "E91E63", - "Purple" to "9C27B0", - "DeepPurple" to "673AB7", - "Indigo" to "3F51B5", - "Blue" to "2196F3", - "LightBlue" to "03A9F4", - "Cyan" to "00BCD4", - "Teal" to "009688", - "Green" to "4FAF50", - "LightGreen" to "8BC3A4", - "Lime" to "CDDC39", - "Yellow" to "FFEB3B", - "Amber" to "FFC107", - "Orange" to "FF9800", - "DeepOrange" to "FF5722", - "Brown" to "795548", - "BlueGrey" to "607D8F", - "Sakura" to "FF9CA8" - )) { + for ((name, color) in + listOf( + "Red" to "F44336", + "Pink" to "E91E63", + "Purple" to "9C27B0", + "DeepPurple" to "673AB7", + "Indigo" to "3F51B5", + "Blue" to "2196F3", + "LightBlue" to "03A9F4", + "Cyan" to "00BCD4", + "Teal" to "009688", + "Green" to "4FAF50", + "LightGreen" to "8BC3A4", + "Lime" to "CDDC39", + "Yellow" to "FFEB3B", + "Amber" to "FFC107", + "Orange" to "FF9800", + "DeepOrange" to "FF5722", + "Brown" to "795548", + "BlueGrey" to "607D8F", + "Sakura" to "FF9CA8", + )) { create("Material$name") { lightThemeFormat = "ThemeOverlay.Light.%s" darkThemeFormat = "ThemeOverlay.Dark.%s" diff --git a/build.gradle.kts b/build.gradle.kts index 841dc99c9..d1d1c12e4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,11 +9,8 @@ import org.gradle.api.provider.ValueSourceParameters import org.gradle.process.ExecOperations plugins { - alias(libs.plugins.lsplugin.cmaker) - alias(libs.plugins.lsplugin.jgit) alias(libs.plugins.agp.lib) apply false alias(libs.plugins.agp.app) apply false - alias(libs.plugins.nav.safeargs) apply false alias(libs.plugins.kotlin) apply false alias(libs.plugins.ktfmt) } @@ -64,43 +61,9 @@ abstract class GitLatestTagValueSource : ValueSource("format") { source = project.fileTree(rootDir) - include("*.gradle.kts", "*/build.gradle.kts") + include( + "*.gradle.kts", + "*/build.gradle.kts", + "hiddenapi/*/build.gradle.kts", + "services/*-service/build.gradle.kts", + ) dependsOn(":xposed:ktfmtFormat") dependsOn(":zygisk:ktfmtFormat") } diff --git a/core/build.gradle.kts b/core/build.gradle.kts index fee240a03..27854d37f 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -1,43 +1,17 @@ -/* - * This file is part of LSPosed. - * - * LSPosed is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * LSPosed is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with LSPosed. If not, see . - * - * Copyright (C) 2021 - 2022 LSPosed Contributors - */ +val versionCodeProvider: Provider by rootProject.extra +val versionNameProvider: Provider by rootProject.extra -val verName: String by rootProject.extra -val verCode: Int by rootProject.extra - -plugins { - alias(libs.plugins.agp.lib) -} +plugins { alias(libs.plugins.agp.lib) } android { namespace = "org.lsposed.lspd.core" - buildFeatures { - androidResources = false - buildConfig = true - } + androidResources { enable = false } defaultConfig { - consumerProguardFiles("proguard-rules.pro") - buildConfigField("String", "FRAMEWORK_NAME", """"${rootProject.name}"""") - buildConfigField("String", "VERSION_NAME", """"$verName"""") - buildConfigField("long", "VERSION_CODE", """$verCode""") + buildConfigField("String", "VERSION_NAME", """"${versionCodeProvider.get()}"""") + buildConfigField("long", "VERSION_CODE", versionCodeProvider.get()) } buildTypes { diff --git a/core/src/main/java/org/lsposed/lspd/nativebridge/HookBridge.java b/core/src/main/java/org/lsposed/lspd/nativebridge/HookBridge.java deleted file mode 100644 index 1c1e8da87..000000000 --- a/core/src/main/java/org/lsposed/lspd/nativebridge/HookBridge.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.lsposed.lspd.nativebridge; - -import java.lang.reflect.Executable; -import java.lang.reflect.Method; -import java.lang.reflect.InvocationTargetException; - -import dalvik.annotation.optimization.FastNative; - -public class HookBridge { - public static native boolean hookMethod(boolean useModernApi, Executable hookMethod, Class hooker, int priority, Object callback); - - public static native boolean unhookMethod(boolean useModernApi, Executable hookMethod, Object callback); - - public static native boolean deoptimizeMethod(Executable method); - - public static native T allocateObject(Class clazz) throws InstantiationException; - - public static native Object invokeOriginalMethod(Executable method, Object thisObject, Object... args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException; - - public static native Object invokeSpecialMethod(Executable method, char[] shorty, Class clazz, Object thisObject, Object... args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException; - - @FastNative - public static native boolean instanceOf(Object obj, Class clazz); - - @FastNative - public static native boolean setTrusted(Object cookie); - - public static native Object[][] callbackSnapshot(Class hooker_callback, Executable method); - - /** - * Retrieves the static initializer () of a class as a Method object. - * Standard Java reflection cannot access this. - * @param clazz The class to inspect. - * @return A Method object for the static initializer, or null if it doesn't exist. - */ - public static native Method getStaticInitializer(Class clazz); -} diff --git a/core/src/main/java/org/lsposed/lspd/nativebridge/NativeAPI.java b/core/src/main/java/org/lsposed/lspd/nativebridge/NativeAPI.java deleted file mode 100644 index eeca6134d..000000000 --- a/core/src/main/java/org/lsposed/lspd/nativebridge/NativeAPI.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * This file is part of LSPosed. - * - * LSPosed is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * LSPosed is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with LSPosed. If not, see . - * - * Copyright (C) 2020 EdXposed Contributors - * Copyright (C) 2021 LSPosed Contributors - */ - -package org.lsposed.lspd.nativebridge; - -public class NativeAPI { - public static native void recordNativeEntrypoint(String library_name); -} diff --git a/core/src/main/java/org/lsposed/lspd/nativebridge/ResourcesHook.java b/core/src/main/java/org/lsposed/lspd/nativebridge/ResourcesHook.java deleted file mode 100644 index 1b6b08753..000000000 --- a/core/src/main/java/org/lsposed/lspd/nativebridge/ResourcesHook.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file is part of LSPosed. - * - * LSPosed is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * LSPosed is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with LSPosed. If not, see . - * - * Copyright (C) 2020 EdXposed Contributors - * Copyright (C) 2021 LSPosed Contributors - */ - -package org.lsposed.lspd.nativebridge; - -import android.content.res.Resources; -import android.content.res.XResources; - -import dalvik.annotation.optimization.FastNative; - -public class ResourcesHook { - - public static native boolean initXResourcesNative(); - - public static native boolean makeInheritable(Class clazz); - - public static native ClassLoader buildDummyClassLoader(ClassLoader parent, String resourceSuperClass, String typedArraySuperClass); - - @FastNative - public static native void rewriteXmlReferencesNative(long parserPtr, XResources origRes, Resources repRes); -} diff --git a/daemon/build.gradle.kts b/daemon/build.gradle.kts index b54617cc7..93abf08fd 100644 --- a/daemon/build.gradle.kts +++ b/daemon/build.gradle.kts @@ -47,7 +47,7 @@ android { buildConfigField( "String", "DEFAULT_MANAGER_PACKAGE_NAME", - """"$defaultManagerPackageName"""" + """"$defaultManagerPackageName"""", ) buildConfigField("String", "MANAGER_INJECTED_PKG_NAME", """"$injectedPackageName"""") buildConfigField("int", "MANAGER_INJECTED_UID", """$injectedPackageUid""") @@ -55,11 +55,7 @@ android { buildTypes { all { - externalNativeBuild { - cmake { - arguments += "-DANDROID_ALLOW_UNDEFINED_SYMBOLS=true" - } - } + externalNativeBuild { cmake { arguments += "-DANDROID_ALLOW_UNDEFINED_SYMBOLS=true" } } } release { isMinifyEnabled = true @@ -68,11 +64,7 @@ android { } } - externalNativeBuild { - cmake { - path("src/main/jni/CMakeLists.txt") - } - } + externalNativeBuild { cmake { path("src/main/jni/CMakeLists.txt") } } namespace = "org.lsposed.daemon" } @@ -81,35 +73,44 @@ android.applicationVariants.all { val variantCapped = name.replaceFirstChar { it.uppercase() } val variantLowered = name.lowercase() - val outSrcDir = - layout.buildDirectory.dir("generated/source/signInfo/${variantLowered}").get() - val signInfoTask = tasks.register("generate${variantCapped}SignInfo") { - dependsOn(":app:validateSigning${variantCapped}") - val sign = rootProject.project(":app").extensions - .getByType(ApplicationExtension::class.java) - .buildTypes.named(variantLowered).get().signingConfig - val outSrc = file("$outSrcDir/org/lsposed/lspd/util/SignInfo.java") - outputs.file(outSrc) - doLast { - outSrc.parentFile.mkdirs() - val certificateInfo = KeystoreHelper.getCertificateInfo( - sign?.storeType, - sign?.storeFile, - sign?.storePassword, - sign?.keyPassword, - sign?.keyAlias - ) - PrintStream(outSrc).print( - """ + val outSrcDir = layout.buildDirectory.dir("generated/source/signInfo/${variantLowered}").get() + val signInfoTask = + tasks.register("generate${variantCapped}SignInfo") { + dependsOn(":app:validateSigning${variantCapped}") + val sign = + rootProject + .project(":app") + .extensions + .getByType(ApplicationExtension::class.java) + .buildTypes + .named(variantLowered) + .get() + .signingConfig + val outSrc = file("$outSrcDir/org/lsposed/lspd/util/SignInfo.java") + outputs.file(outSrc) + doLast { + outSrc.parentFile.mkdirs() + val certificateInfo = + KeystoreHelper.getCertificateInfo( + sign?.storeType, + sign?.storeFile, + sign?.storePassword, + sign?.keyPassword, + sign?.keyAlias, + ) + PrintStream(outSrc) + .print( + """ |package org.lsposed.lspd.util; |public final class SignInfo { | public static final byte[] CERTIFICATE = {${ certificateInfo.certificate.encoded.joinToString(",") }}; - |}""".trimMargin() - ) + |}""" + .trimMargin() + ) + } } - } registerJavaGeneratingTask(signInfoTask, outSrcDir.asFile) } diff --git a/daemon/src/main/jni/CMakeLists.txt b/daemon/src/main/jni/CMakeLists.txt index 049bbcd80..4723660c2 100644 --- a/daemon/src/main/jni/CMakeLists.txt +++ b/daemon/src/main/jni/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.10) project(daemon) +set(CMAKE_CXX_STANDARD 23) + add_subdirectory(${VECTOR_ROOT}/external external) set(SOURCES diff --git a/dex2oat/build.gradle.kts b/dex2oat/build.gradle.kts index fd155f31c..b8bd508fa 100644 --- a/dex2oat/build.gradle.kts +++ b/dex2oat/build.gradle.kts @@ -1,15 +1,9 @@ -plugins { - alias(libs.plugins.agp.lib) -} +plugins { alias(libs.plugins.agp.lib) } android { namespace = "org.matrix.vector.dex2oat" - androidResources.enable = false + androidResources { enable = false } - externalNativeBuild { - cmake { - path("src/main/cpp/CMakeLists.txt") - } - } + externalNativeBuild { cmake { path("src/main/cpp/CMakeLists.txt") } } } diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 75a4b4c06..184ce4f25 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.10) project(external) +set(CMAKE_CXX_STANDARD 23) + set(XZ_SOURCES xz_crc32.c xz_crc64.c diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6faa2f4fc..aeccc21e3 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -17,8 +17,6 @@ ktfmt = { id = "com.ncorti.ktfmt.gradle", version.ref = "ktfmt" } materialthemebuilder = { id = "dev.rikka.tools.materialthemebuilder", version = "1.5.1" } lsplugin-resopt = { id = "org.lsposed.lsplugin.resopt", version = "1.6" } lsplugin-apksign = { id = "org.lsposed.lsplugin.apksign", version = "1.4" } -lsplugin-cmaker = { id = "org.lsposed.lsplugin.cmaker", version = "1.2" } -lsplugin-jgit = { id = "org.lsposed.lsplugin.jgit", version = "1.1" } [libraries] rikkax-appcompat = { module = "dev.rikka.rikkax.appcompat:appcompat", version = "1.6.1" } diff --git a/hiddenapi/bridge/build.gradle.kts b/hiddenapi/bridge/build.gradle.kts index 72b254863..4248982c5 100644 --- a/hiddenapi/bridge/build.gradle.kts +++ b/hiddenapi/bridge/build.gradle.kts @@ -1,26 +1,3 @@ -/* - * This file is part of LSPosed. - * - * LSPosed is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * LSPosed is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with LSPosed. If not, see . - * - * Copyright (C) 2021 LSPosed Contributors - */ +plugins { `java-library` } -plugins { - `java-library` -} - -dependencies { - compileOnly(projects.hiddenapi.stubs) -} +dependencies { compileOnly(projects.hiddenapi.stubs) } diff --git a/hiddenapi/stubs/build.gradle.kts b/hiddenapi/stubs/build.gradle.kts index 384caffcf..92fcaf36d 100644 --- a/hiddenapi/stubs/build.gradle.kts +++ b/hiddenapi/stubs/build.gradle.kts @@ -1,25 +1,4 @@ -/* - * This file is part of LSPosed. - * - * LSPosed is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * LSPosed is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with LSPosed. If not, see . - * - * Copyright (C) 2021 LSPosed Contributors - */ - -plugins { - `java-library` -} +plugins { `java-library` } java { sourceCompatibility = JavaVersion.VERSION_1_8 diff --git a/native/CMakeLists.txt b/native/CMakeLists.txt index c8ab37084..cd0785d51 100644 --- a/native/CMakeLists.txt +++ b/native/CMakeLists.txt @@ -12,8 +12,9 @@ add_library(${PROJECT_NAME} STATIC ${NATIVE_SOURCES}) set(IGNORED_WARNINGS -Wno-c99-extensions -Wno-extra-semi - -Wno-gnu-zero-variadic-macro-arguments -Wno-gnu-flexible-array-initializer + -Wno-gnu-string-literal-operator-templat + -Wno-gnu-zero-variadic-macro-arguments -Wno-variadic-macros -Wno-zero-length-array ) diff --git a/services/daemon-service/build.gradle.kts b/services/daemon-service/build.gradle.kts index 1b0c0f96b..e583a2570 100644 --- a/services/daemon-service/build.gradle.kts +++ b/services/daemon-service/build.gradle.kts @@ -1,40 +1,9 @@ -/* - * This file is part of LSPosed. - * - * LSPosed is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * LSPosed is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with LSPosed. If not, see . - * - * Copyright (C) 2021 LSPosed Contributors - */ - -plugins { - alias(libs.plugins.agp.lib) -} +plugins { alias(libs.plugins.agp.lib) } android { - buildFeatures { - aidl = true - } + buildFeatures { aidl = true } - defaultConfig { - consumerProguardFiles("proguard-rules.pro") - } - - buildTypes { - release { - isMinifyEnabled = false - } - } + buildTypes { release { isMinifyEnabled = false } } sourceSets { named("main") { @@ -44,7 +13,6 @@ android { } aidlPackagedList += "org/lsposed/lspd/models/Module.aidl" - aidlPackagedList += "org/lsposed/lspd/models/PreloadedApk.aidl" namespace = "org.lsposed.lspd.daemonservice" } diff --git a/services/daemon-service/proguard-rules.pro b/services/daemon-service/proguard-rules.pro deleted file mode 100644 index 481bb4348..000000000 --- a/services/daemon-service/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/services/manager-service/build.gradle.kts b/services/manager-service/build.gradle.kts index 1c775b510..1edbe01cc 100644 --- a/services/manager-service/build.gradle.kts +++ b/services/manager-service/build.gradle.kts @@ -1,43 +1,11 @@ -/* - * This file is part of LSPosed. - * - * LSPosed is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * LSPosed is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with LSPosed. If not, see . - * - * Copyright (C) 2021 LSPosed Contributors - */ - -plugins { - alias(libs.plugins.agp.lib) -} +plugins { alias(libs.plugins.agp.lib) } android { - buildFeatures { - aidl = true - } + buildFeatures { aidl = true } - defaultConfig { - consumerProguardFiles("proguard-rules.pro") - } + buildTypes { release { isMinifyEnabled = false } } - buildTypes { - release { - isMinifyEnabled = false - } - } namespace = "org.lsposed.lspd.managerservice" } -dependencies { - api(libs.rikkax.parcelablelist) -} +dependencies { api(libs.rikkax.parcelablelist) } diff --git a/services/manager-service/proguard-rules.pro b/services/manager-service/proguard-rules.pro deleted file mode 100644 index 8b1378917..000000000 --- a/services/manager-service/proguard-rules.pro +++ /dev/null @@ -1 +0,0 @@ - diff --git a/settings.gradle.kts b/settings.gradle.kts index 0b57d6a2d..abc95ae74 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -16,7 +16,7 @@ dependencyResolutionManagement { } } -rootProject.name = "LSPosed" +rootProject.name = "Vector" include( ":app", diff --git a/xposed/build.gradle.kts b/xposed/build.gradle.kts index 29b5ffc69..2d153bb91 100644 --- a/xposed/build.gradle.kts +++ b/xposed/build.gradle.kts @@ -9,7 +9,7 @@ ktfmt { kotlinLangStyle() } android { namespace = "org.matrix.vector.xposed" - buildFeatures { androidResources { enable = false } } + androidResources { enable = false } sourceSets { named("main") { java.srcDirs("src/main/kotlin", "libxposed/api/src/main/java") } } } From a91ee032851d7db9e99564b0200753d3be99db4f Mon Sep 17 00:00:00 2001 From: JingMatrix Date: Fri, 6 Mar 2026 17:04:49 +0100 Subject: [PATCH 2/3] Avoid hardcoding package names --- core/build.gradle.kts | 1 + zygisk/build.gradle.kts | 36 +++++++++++++++++-- zygisk/module/action.sh | 6 ++-- zygisk/src/main/cpp/module.cpp | 17 ++++----- .../matrix/vector/ParasiticManagerHooker.kt | 13 +++++-- .../vector/ParasiticManagerSystemHooker.kt | 6 ++-- .../kotlin/org/matrix/vector/core/Main.kt | 3 +- 7 files changed, 61 insertions(+), 21 deletions(-) diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 27854d37f..5e6695814 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -9,6 +9,7 @@ android { androidResources { enable = false } defaultConfig { + consumerProguardFiles("proguard-rules.pro") buildConfigField("String", "FRAMEWORK_NAME", """"${rootProject.name}"""") buildConfigField("String", "VERSION_NAME", """"${versionCodeProvider.get()}"""") buildConfigField("long", "VERSION_CODE", versionCodeProvider.get()) diff --git a/zygisk/build.gradle.kts b/zygisk/build.gradle.kts index 7c44f43aa..2a3b31354 100644 --- a/zygisk/build.gradle.kts +++ b/zygisk/build.gradle.kts @@ -12,11 +12,32 @@ ktfmt { kotlinLangStyle() } val versionCodeProvider: Provider by rootProject.extra val versionNameProvider: Provider by rootProject.extra +val injectedPackageName: String by rootProject.extra +val injectedPackageUid: Int by rootProject.extra +val defaultManagerPackageName: String by rootProject.extra android { namespace = "org.matrix.vector" - defaultConfig { multiDexEnabled = false } + defaultConfig { + multiDexEnabled = false + buildConfigField("String", "InjectedPackageName", """"${injectedPackageName}"""") + buildConfigField("String", "ManagerPackageName", """"${defaultManagerPackageName}"""") + + val flags = + listOf( + "-DINJECTED_PACKAGE_NAME='\"${injectedPackageName}\"'", + "-DINJECTED_PACKAGE_UID=${injectedPackageUid}", + "-DMANAGER_PACKAGE_NAME='\"${defaultManagerPackageName}\"'", + ) + + externalNativeBuild { + cmake { + cFlags.addAll(flags) + cppFlags.addAll(flags) + } + } + } buildTypes { release { @@ -66,7 +87,7 @@ androidComponents { ) into(tempModuleDir) from("${rootProject.projectDir}/README.md") - from("$projectDir/module") { exclude("module.prop", "customize.sh", "daemon") } + from("$projectDir/module") { exclude("module.prop", "action.sh", "daemon") } from("$projectDir/module") { include("module.prop") expand( @@ -75,7 +96,16 @@ androidComponents { ) } from("$projectDir/module") { - include("customize.sh", "daemon") + include("action.sh") + val tokens = + mapOf( + "MANAGER_PACKAGE_NAME" to defaultManagerPackageName, + "INJECTED_PACKAGE_NAME" to injectedPackageName, + ) + filter("tokens" to tokens) + } + from("$projectDir/module") { + include("daemon") val tokens = mapOf("DEBUG" to if (variantLowered == "debug") "true" else "false") filter("tokens" to tokens) diff --git a/zygisk/module/action.sh b/zygisk/module/action.sh index 05a2b4267..c3ea8c1a3 100644 --- a/zygisk/module/action.sh +++ b/zygisk/module/action.sh @@ -1,4 +1,4 @@ -DEFAULT_MANAGER_PACKAGE_NAME="org.lsposed.manager" -INJECTED_PACKAGE_NAME="com.android.shell" +MANAGER_PACKAGE_NAME="@MANAGER_PACKAGE_NAME@" +INJECTED_PACKAGE_NAME="@INJECTED_PACKAGE_NAME@" -am start -c "${DEFAULT_MANAGER_PACKAGE_NAME}.LAUNCH_MANAGER" "${INJECTED_PACKAGE_NAME}/.BugreportWarningActivity" +am start -c "${MANAGER_PACKAGE_NAME}.LAUNCH_MANAGER" "${INJECTED_PACKAGE_NAME}/.BugreportWarningActivity" diff --git a/zygisk/src/main/cpp/module.cpp b/zygisk/src/main/cpp/module.cpp index 43f5c4a96..c25a53018 100644 --- a/zygisk/src/main/cpp/module.cpp +++ b/zygisk/src/main/cpp/module.cpp @@ -12,8 +12,6 @@ #include "ipc_bridge.h" -using namespace std::literals::string_view_literals; - namespace vector::native::module { // --- Process UID Constants --- @@ -34,8 +32,11 @@ constexpr int SHARED_RELRO_UID = 1037; // Android uses this to separate users. UID = AppID + UserID * 10000. constexpr int PER_USER_RANGE = 100000; -constexpr uid_t MANAGER_UID = 2000; // com.android.shell -constexpr uid_t GID_INET = 3003; // Android's Internet group ID. +// Defined via CMake generated marcos +constexpr uid_t kHostPackageUid = INJECTED_PACKAGE_UID; +const char *const kHostPackageName = INJECTED_PACKAGE_NAME; +const char *const kManagePackageName = MANAGER_PACKAGE_NAME; +constexpr uid_t GID_INET = 3003; // Android's Internet group ID. // A simply ConfigBridge implemnetation holding obfuscation maps in memory using obfuscation_map_t = std::map; @@ -230,9 +231,9 @@ void VectorModule::preAppSpecialize(zygisk::AppSpecializeArgs *args) { // --- Manager App Special Handling --- // We identify our manager app by a special UID and // grant it internet permissions by adding it to the INET group. - if (args->uid == MANAGER_UID) { + if (args->uid == kHostPackageUid) { lsplant::JUTFString nice_name_str(env_, args->nice_name); - if (nice_name_str.get() == "org.lsposed.manager"sv) { + if (nice_name_str.get() == std::string(kManagePackageName)) { LOGI("Manager app detected. Granting internet permissions."); is_manager_app_ = true; @@ -252,7 +253,7 @@ void VectorModule::preAppSpecialize(zygisk::AppSpecializeArgs *args) { jint inet_gid = GID_INET; env_->SetIntArrayRegion(new_gids, original_gids_count, 1, &inet_gid); - args->nice_name = env_->NewStringUTF("com.android.shell"); + args->nice_name = env_->NewStringUTF(INJECTED_PACKAGE_NAME); args->gids = new_gids; } } @@ -297,7 +298,7 @@ void VectorModule::postAppSpecialize(const zygisk::AppSpecializeArgs *args) { } if (is_manager_app_) { - args->nice_name = env_->NewStringUTF("org.lsposed.manager"); + args->nice_name = env_->NewStringUTF(kManagePackageName); } // --- Framework Injection --- diff --git a/zygisk/src/main/kotlin/org/matrix/vector/ParasiticManagerHooker.kt b/zygisk/src/main/kotlin/org/matrix/vector/ParasiticManagerHooker.kt index 8c7240115..5c06706de 100644 --- a/zygisk/src/main/kotlin/org/matrix/vector/ParasiticManagerHooker.kt +++ b/zygisk/src/main/kotlin/org/matrix/vector/ParasiticManagerHooker.kt @@ -115,7 +115,11 @@ object ParasiticManagerHooker { */ private fun sendBinderToManager(classLoader: ClassLoader, binder: IBinder) { runCatching { - val clazz = XposedHelpers.findClass("org.lsposed.manager.Constants", classLoader) + val clazz = + XposedHelpers.findClass( + BuildConfig.ManagerPackageName + ".Constants", + classLoader, + ) val ok = XposedHelpers.callStaticMethod( clazz, @@ -195,7 +199,10 @@ object ParasiticManagerHooker { val pkgInfo = getManagerPkgInfo(arg.applicationInfo) ?: return@forEachIndexed pkgInfo.activities - ?.find { it.name == "org.lsposed.manager.ui.activity.MainActivity" } + ?.find { + it.name == + BuildConfig.ManagerPackageName + ".ui.activity.MainActivity" + } ?.let { it.applicationInfo = pkgInfo.applicationInfo param.args[i] = it @@ -205,7 +212,7 @@ object ParasiticManagerHooker { arg.component = ComponentName( arg.component!!.packageName, - "org.lsposed.manager.ui.activity.MainActivity", + BuildConfig.ManagerPackageName + ".ui.activity.MainActivity", ) } } diff --git a/zygisk/src/main/kotlin/org/matrix/vector/ParasiticManagerSystemHooker.kt b/zygisk/src/main/kotlin/org/matrix/vector/ParasiticManagerSystemHooker.kt index 32a033bc1..8b3ce43d8 100644 --- a/zygisk/src/main/kotlin/org/matrix/vector/ParasiticManagerSystemHooker.kt +++ b/zygisk/src/main/kotlin/org/matrix/vector/ParasiticManagerSystemHooker.kt @@ -35,19 +35,19 @@ class ParasiticManagerSystemHooker : HandleSystemServerProcessHooker.Callback { val intent = callback.args[0] as? Intent ?: return // Check if this intent is meant for the LSPosed Manager - if (!intent.hasCategory("org.lsposed.manager.LAUNCH_MANAGER")) return + if (!intent.hasCategory(BuildConfig.ManagerPackageName + ".LAUNCH_MANAGER")) return val result = callback.result as? ActivityInfo ?: return // We only intercept if it's currently resolving to the shell/fallback - if (result.packageName != "com.android.shell") return + if (result.packageName != BuildConfig.InjectedPackageName) return // --- Redirection Logic --- // We create a copy of the ActivityInfo to avoid polluting the system's cache. val redirectedInfo = ActivityInfo(result).apply { // Force the manager to run in its own dedicated process name - processName = "org.lsposed.manager" + processName = BuildConfig.ManagerPackageName // Set a standard theme so transition animations work correctly theme = android.R.style.Theme_DeviceDefault_Settings diff --git a/zygisk/src/main/kotlin/org/matrix/vector/core/Main.kt b/zygisk/src/main/kotlin/org/matrix/vector/core/Main.kt index 267a7cf32..894298ab4 100644 --- a/zygisk/src/main/kotlin/org/matrix/vector/core/Main.kt +++ b/zygisk/src/main/kotlin/org/matrix/vector/core/Main.kt @@ -6,6 +6,7 @@ import org.lsposed.lspd.core.ApplicationServiceClient.serviceClient import org.lsposed.lspd.core.Startup import org.lsposed.lspd.service.ILSPApplicationService import org.lsposed.lspd.util.Utils +import org.matrix.vector.BuildConfig import org.matrix.vector.ParasiticManagerHooker import org.matrix.vector.ParasiticManagerSystemHooker @@ -38,7 +39,7 @@ object Main { // Check if this process is the designated Vector Manager. // If so, we perform "parasitic" injection into a host (com.android.shell) // and terminate further standard Xposed loading for this specific process. - if (niceName == "org.lsposed.manager" && ParasiticManagerHooker.start()) { + if (niceName == BuildConfig.ManagerPackageName && ParasiticManagerHooker.start()) { Utils.logI("Parasitic manager loaded into host, skipping standard bootstrap.") return } From 3c29a8b327680cad0b6c75964132ac261538aee1 Mon Sep 17 00:00:00 2001 From: JingMatrix Date: Fri, 6 Mar 2026 18:01:00 +0100 Subject: [PATCH 3/3] Upgrade gradle packages --- gradle/libs.versions.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index aeccc21e3..9ec38ab0f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] agp = "8.13.1" -kotlin = "2.2.21" -nav = "2.9.6" +kotlin = "2.3.10" +nav = "2.9.7" appcenter = "5.0.5" glide = "5.0.5" okhttp = "5.3.2" @@ -30,7 +30,7 @@ rikkax-recyclerview = { module = "dev.rikka.rikkax.recyclerview:recyclerview-ktx rikkax-widget-borderview = { module = "dev.rikka.rikkax.widget:borderview", version = "1.1.0" } rikkax-widget-mainswitchbar = { module = "dev.rikka.rikkax.widget:mainswitchbar", version = "1.0.2" } -androidx-activity = { module = "androidx.activity:activity", version = "1.12.1" } +androidx-activity = { module = "androidx.activity:activity", version = "1.12.4" } androidx-annotation = { module = "androidx.annotation:annotation", version = "1.9.1" } androidx-browser = { module = "androidx.browser:browser", version = "1.9.0" } androidx-constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version = "2.2.1" }