Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions apache/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.gradle.kotlin.dsl.register

val androidSourceCompatibility: JavaVersion by rootProject.extra
val androidTargetCompatibility: JavaVersion by rootProject.extra

Expand All @@ -18,14 +20,14 @@ java {
val lang3Src = "commons-lang/src/main/java/org/apache/commons/lang3"
val localDir = "local/generated"

task<Copy>("ClassUtilsX") {
tasks.register<Copy>("ClassUtilsX") {
from("$lang3Src/ClassUtils.java")
into(localDir)
filter { line: String -> line.replace("ClassUtils", "ClassUtilsX") }
rename("(.+).java", "$1X.java")
}

task<Copy>("SerializationUtilsX") {
tasks.register<Copy>("SerializationUtilsX") {
from("$lang3Src/SerializationUtils.java")
into(localDir)
filter { line: String -> line.replace("SerializationUtils", "SerializationUtilsX") }
Expand Down
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ dependencies {
implementation(libs.androidx.preference)
implementation(libs.androidx.recyclerview)
implementation(libs.androidx.swiperefreshlayout)
implementation(libs.androidx.startup)
implementation(libs.glide)
implementation(libs.material)
implementation(libs.gson)
Expand Down
2 changes: 1 addition & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ android {
namespace = "org.lsposed.lspd.core"

buildFeatures {
androidResources = false
android.androidResources.enable = false
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buildConfig = true
}

Expand Down
2 changes: 1 addition & 1 deletion dex2oat/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ android {
namespace = "org.lsposed.dex2oat"

buildFeatures {
androidResources = false
android.androidResources.enable = false
buildConfig = false
prefab = true
prefabPublishing = true
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ androidx-navigation-ui = { group = "androidx.navigation", name = "navigation-ui"
androidx-preference = { module = "androidx.preference:preference", version = "1.2.1" }
androidx-recyclerview = { module = "androidx.recyclerview:recyclerview", version = "1.4.0" }
androidx-swiperefreshlayout = { module = "androidx.swiperefreshlayout:swiperefreshlayout", version = "1.2.0-beta01" }
#noinspection GradleDependency
androidx-startup = { module = "androidx.startup:startup-runtime", version = "1.1.1" }
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this?


glide = { group = "com.github.bumptech.glide", name = "glide", version.ref = "glide" }
glide-compiler = { group = "com.github.bumptech.glide", name = "compiler", version.ref = "glide" }
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 41 additions & 22 deletions magisk-loader/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@
import org.apache.commons.codec.binary.Hex
import org.apache.tools.ant.filters.FixCrLfFilter
import org.apache.tools.ant.filters.ReplaceTokens
import org.gradle.api.Action
import org.gradle.api.provider.ProviderFactory
import org.gradle.api.tasks.Exec
import org.gradle.kotlin.dsl.register
import org.gradle.process.ExecResult
import org.gradle.process.ExecSpec
import org.gradle.process.ExecOperations
import java.io.ByteArrayOutputStream
import java.security.MessageDigest
import javax.inject.Inject

plugins {
alias(libs.plugins.agp.app)
Expand Down Expand Up @@ -94,11 +102,19 @@ android {
}
namespace = "org.lsposed.lspd"
}

abstract class Injected @Inject constructor(val magiskDir: String) {
@get:Inject
abstract val factory: ObjectFactory
}

interface ExecOpsProvider {
@get:Inject
val execOperations: ExecOperations
@get:Inject
val providers: ProviderFactory
}

dependencies {
implementation(projects.core)
implementation(projects.hiddenapi.bridge)
Expand All @@ -108,7 +124,7 @@ dependencies {
compileOnly(projects.hiddenapi.stubs)
}

val zipAll = task("zipAll") {
val zipAll = tasks.register("zipAll") {
group = "LSPosed"
}

Expand All @@ -125,7 +141,7 @@ fun afterEval() = android.applicationVariants.forEach { variant ->
val moduleId = "${flavorLowered}_$moduleBaseId"
val zipFileName = "$moduleName-v$verName-$verCode-${flavorLowered}-$buildTypeLowered.zip"

val prepareMagiskFilesTask = task<Sync>("prepareMagiskFiles$variantCapped") {
val prepareMagiskFilesTask = tasks.register<Sync>("prepareMagiskFiles$variantCapped") {
group = "LSPosed"
dependsOn(
"assemble$variantCapped",
Expand Down Expand Up @@ -204,58 +220,60 @@ fun afterEval() = android.applicationVariants.forEach { variant ->
}
}

val zipTask = task<Zip>("zip${variantCapped}") {
val zipTask = tasks.register<Zip>("zip${variantCapped}") {
group = "LSPosed"
dependsOn(prepareMagiskFilesTask)
archiveFileName = zipFileName
destinationDirectory = file("$projectDir/release")
from(magiskDir)
}

zipAll.dependsOn(zipTask)
zipAll.configure {
dependsOn(zipTask)
}

val adb: String = androidComponents.sdkComponents.adb.get().asFile.absolutePath
val pushTask = task<Exec>("push${variantCapped}") {
val pushTask = tasks.register<Exec>("push${variantCapped}") {
group = "LSPosed"
dependsOn(zipTask)
workingDir("${projectDir}/release")
commandLine(adb, "push", zipFileName, "/data/local/tmp/")
}
val flashMagiskTask = task<Exec>("flashMagisk${variantCapped}") {
val flashMagiskTask = tasks.register<Exec>("flashMagisk${variantCapped}") {
group = "LSPosed"
dependsOn(pushTask)
commandLine(
adb, "shell", "su", "-c",
"magisk --install-module /data/local/tmp/${zipFileName}"
)
}
task<Exec>("flashMagiskAndReboot${variantCapped}") {
tasks.register<Exec>("flashMagiskAndReboot${variantCapped}") {
group = "LSPosed"
dependsOn(flashMagiskTask)
commandLine(adb, "shell", "su", "-c", "/system/bin/svc", "power", "reboot")
}
val flashKsuTask = task<Exec>("flashKsu${variantCapped}") {
val flashKsuTask = tasks.register<Exec>("flashKsu${variantCapped}") {
group = "LSPosed"
dependsOn(pushTask)
commandLine(
adb, "shell", "su", "-c",
"ksud module install /data/local/tmp/${zipFileName}"
)
}
task<Exec>("flashKsuAndReboot${variantCapped}") {
tasks.register<Exec>("flashKsuAndReboot${variantCapped}") {
group = "LSPosed"
dependsOn(flashKsuTask)
commandLine(adb, "shell", "su", "-c", "/system/bin/svc", "power", "reboot")
}
val flashAPatchTask = task<Exec>("flashAPatch${variantCapped}") {
val flashAPatchTask = tasks.register<Exec>("flashAPatch${variantCapped}") {
group = "LSPosed"
dependsOn(pushTask)
commandLine(
adb, "shell", "su", "-c",
"apd module install /data/local/tmp/${zipFileName}"
)
}
task<Exec>("flashAPatchAndReboot${variantCapped}") {
tasks.register<Exec>("flashAPatchAndReboot${variantCapped}") {
group = "LSPosed"
dependsOn(flashAPatchTask)
commandLine(adb, "shell", "su", "-c", "/system/bin/svc", "power", "reboot")
Expand All @@ -267,23 +285,24 @@ afterEvaluate {
}

val adb: String = androidComponents.sdkComponents.adb.get().asFile.absolutePath
val killLspd = task<Exec>("killLspd") {
val killLspd = tasks.register<Exec>("killLspd") {
group = "LSPosed"
commandLine(adb, "shell", "su", "-c", "killall", "lspd")
isIgnoreExitValue = true
}
val pushDaemon = task<Exec>("pushDaemon") {
val pushDaemon = tasks.register<Exec>("pushDaemon") {
group = "LSPosed"
dependsOn(":daemon:assembleDebug")
workingDir(project(":daemon").layout.buildDirectory.dir("outputs/apk/debug"))
commandLine(adb, "push", "daemon-debug.apk", "/data/local/tmp/daemon.apk")
}
val pushDaemonNative = task<Exec>("pushDaemonNative") {
val pushDaemonNative = tasks.register<Exec>("pushDaemonNative") {
group = "LSPosed"
dependsOn(":daemon:assembleDebug")
doFirst {
val execOpsProvider = objects.newInstance<ExecOpsProvider>()
val abi: String = ByteArrayOutputStream().use { outputStream ->
exec {
execOpsProvider.execOperations.exec {
commandLine(adb, "shell", "getprop", "ro.product.cpu.abi")
standardOutput = outputStream
}
Expand All @@ -293,41 +312,41 @@ val pushDaemonNative = task<Exec>("pushDaemonNative") {
}
commandLine(adb, "push", "libdaemon.so", "/data/local/tmp/libdaemon.so")
}
val reRunDaemon = task<Exec>("reRunDaemon") {
val reRunDaemon = tasks.register<Exec>("reRunDaemon") {
group = "LSPosed"
dependsOn(pushDaemon, pushDaemonNative, killLspd)
// tricky to pass a minus number to avoid the injection warning
commandLine(
adb, "shell", "ASH_STANDALONE=1", "su", "-mm", "-pc",
"/data/adb/magisk/busybox sh /data/adb/modules/*_lsposed/service.sh --system-server-max-retry=-1&"
)
isIgnoreExitValue = true
}
val tmpApk = "/data/local/tmp/manager.apk"
val pushApk = task<Exec>("pushApk") {
val pushApk = tasks.register<Exec>("pushApk") {
group = "LSPosed"
dependsOn(":app:assembleDebug")
doFirst {
exec {
val execOpsProvider = objects.newInstance<ExecOpsProvider>()
execOpsProvider.execOperations.exec {
commandLine(adb, "shell", "su", "-c", "rm", "-f", tmpApk)
}
}
workingDir(project(":app").layout.buildDirectory.dir("outputs/apk/debug"))
commandLine(adb, "push", "app-debug.apk", tmpApk)
}
val openApp = task<Exec>("openApp") {
val openApp = tasks.register<Exec>("openApp") {
group = "LSPosed"
commandLine(
adb, "shell",
"am", "start", "-c", "org.lsposed.manager.LAUNCH_MANAGER",
"com.android.shell/.BugreportWarningActivity"
)
}
task("reRunApp") {
tasks.register("reRunApp") {
group = "LSPosed"
dependsOn(pushApk)
finalizedBy(reRunDaemon)
}

evaluationDependsOn(":app")
evaluationDependsOn(":daemon")
evaluationDependsOn(":daemon")