From 5b49351b7e0eb2c2eceab83187d0615b95483fce Mon Sep 17 00:00:00 2001 From: LoveSy Date: Tue, 2 Mar 2021 02:55:15 +0800 Subject: [PATCH] [gradle] kotlinfy (#240) --- app/build.gradle | 153 ---------- app/build.gradle.kts | 161 ++++++++++ build.gradle | 39 --- build.gradle.kts | 61 ++++ core/build.gradle | 266 ----------------- core/build.gradle.kts | 277 ++++++++++++++++++ .../lspd/nativebridge/ModuleLogger.java | 2 + .../lsposed/lspd/util/InstallerVerifier.java | 2 +- gradle.properties | 9 +- .../{build.gradle => build.gradle.kts} | 6 +- .../{build.gradle => build.gradle.kts} | 4 +- .../{build.gradle => build.gradle.kts} | 30 +- sandhook-annotation/build.gradle | 8 - sandhook-annotation/build.gradle.kts | 8 + sandhook-hooklib/build.gradle | 27 -- sandhook-hooklib/build.gradle.kts | 41 +++ settings.gradle | 6 - settings.gradle.kts | 6 + 18 files changed, 584 insertions(+), 522 deletions(-) delete mode 100644 app/build.gradle create mode 100644 app/build.gradle.kts delete mode 100644 build.gradle create mode 100644 build.gradle.kts delete mode 100644 core/build.gradle create mode 100644 core/build.gradle.kts rename hiddenapi-bridge/{build.gradle => build.gradle.kts} (90%) rename hiddenapi-stubs/{build.gradle => build.gradle.kts} (95%) rename manager-service/{build.gradle => build.gradle.kts} (50%) delete mode 100644 sandhook-annotation/build.gradle create mode 100644 sandhook-annotation/build.gradle.kts delete mode 100644 sandhook-hooklib/build.gradle create mode 100644 sandhook-hooklib/build.gradle.kts delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index 710566e2..00000000 --- a/app/build.gradle +++ /dev/null @@ -1,153 +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 - */ -import java.nio.file.Paths - -apply plugin: 'com.android.application' - -android { - compileSdkVersion androidCompileSdkVersion.toInteger() - - ndkVersion androidCompileNdkVersion - buildToolsVersion androidBuildToolsVersion - - buildFeatures { - viewBinding = true - } - - defaultConfig { - applicationId "io.github.lsposed.manager" - minSdkVersion androidMinSdkVersion.toInteger() - targetSdkVersion androidTargetSdkVersion.toInteger() - versionCode rootProject.ext.versionCode - versionName rootProject.ext.versionName - resConfigs 'en', 'zh-rCN', 'zh-rTW', 'zh-rHK', 'ru', 'uk', 'nl', 'ko', 'fr' - resValue "string", "versionName", "${rootProject.ext.versionName}" - } - - compileOptions { - targetCompatibility JavaVersion.VERSION_1_8 - sourceCompatibility JavaVersion.VERSION_1_8 - } - - lintOptions { - disable 'MissingTranslation' - disable 'ExtraTranslation' - abortOnError true - checkReleaseBuilds true - } - - packagingOptions { - exclude 'META-INF/**' - exclude 'kotlin/**' - exclude 'org/**' - exclude '**.properties' - exclude '**.bin' - } - - dependenciesInfo.includeInApk false - - buildTypes { - release { - minifyEnabled true - shrinkResources true - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - debug { - minifyEnabled false - shrinkResources false - } - } - applicationVariants.all { variant -> - variant.outputs.all { output -> - outputFileName = "LSPosedManager-${defaultConfig.versionName}-${defaultConfig.versionCode}-${buildType.name}.apk" - } - } -} - -def optimizeReleaseResources = task('optimizeReleaseResources').doLast { - def aapt2 = Paths.get(project.android.sdkDirectory.path, 'build-tools', project.android.buildToolsVersion, 'aapt2') - def zip = Paths.get(project.buildDir.path, 'intermediates', - 'processed_res', 'release', 'out', "resources-release.ap_") - def optimized = new File("${zip}.opt") - def cmd = exec { - commandLine aapt2, 'optimize', '--collapse-resource-names', - '--shorten-resource-paths', - '-o', optimized, zip - ignoreExitValue false - } - if (cmd.exitValue == 0) { - delete(zip) - optimized.renameTo("$zip") - } -} - -tasks.whenTaskAdded { task -> - if (task.name == 'processReleaseResources') { - task.finalizedBy optimizeReleaseResources - } -} - -dependencies { - final def glide_version = '4.12.0' - final def markwon_version = '4.6.2' - final def okhttp_version = '4.9.1' - annotationProcessor "com.github.bumptech.glide:compiler:$glide_version" - implementation 'androidx.activity:activity:1.2.0' - implementation 'androidx.browser:browser:1.3.0' - implementation 'androidx.constraintlayout:constraintlayout:2.0.4' - implementation 'androidx.fragment:fragment:1.3.0' - implementation 'androidx.recyclerview:recyclerview:1.1.0' - implementation 'com.caverock:androidsvg-aar:1.4' - implementation "com.github.bumptech.glide:glide:$glide_version" - implementation "com.github.bumptech.glide:okhttp3-integration:$glide_version" - implementation 'com.github.jinatonic.confetti:confetti:1.1.2' - implementation 'com.google.android.material:material:1.3.0' - implementation 'com.google.code.gson:gson:2.8.6' - implementation 'com.takisoft.preferencex:preferencex:1.1.0' - implementation 'com.takisoft.preferencex:preferencex-colorpicker:1.1.0' - implementation "com.squareup.okhttp3:okhttp:$okhttp_version" - implementation "com.squareup.okhttp3:okhttp-dnsoverhttps:$okhttp_version" - implementation "io.noties.markwon:core:$markwon_version" - implementation "io.noties.markwon:ext-strikethrough:$markwon_version" - implementation "io.noties.markwon:ext-tables:$markwon_version" - implementation "io.noties.markwon:ext-tasklist:$markwon_version" - implementation "io.noties.markwon:html:$markwon_version" - implementation "io.noties.markwon:image-glide:$markwon_version" - implementation "io.noties.markwon:linkify:$markwon_version" - implementation 'rikka.appcompat:appcompat:1.2.0-rc01' - implementation 'rikka.core:core:1.3.0' - implementation 'rikka.insets:insets:1.0.1' - implementation 'rikka.material:material:1.6.0' - implementation 'rikka.recyclerview:recyclerview-utils:1.2.0' - implementation 'rikka.widget:borderview:1.0.0' - implementation "rikka.widget:switchbar:1.0.2" - implementation 'rikka.layoutinflater:layoutinflater:1.0.1' - implementation 'tech.rectifier.preferencex-android:preferencex-simplemenu:88f93154b2' - implementation 'me.zhanghai.android.appiconloader:appiconloader-glide:1.2.0' - implementation 'me.zhanghai.android.fastscroll:library:1.1.5' - implementation files('libs/WeatherView-2.0.3.aar') - implementation project(':manager-service') -} - -configurations { - cleanedAnnotations - compile.exclude group: 'org.jetbrains' , module:'annotations' - compile.exclude group: 'androidx.appcompat', module: 'appcompat' -} diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 00000000..fca12df0 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,161 @@ +/* + * 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 + */ +import com.android.build.gradle.internal.api.BaseVariantOutputImpl +import java.nio.file.Paths; + +plugins { + id("com.android.application") + kotlin("android") +} + +android { + val androidTargetSdkVersion: Int by extra + val androidMinSdkVersion: Int by extra + val androidBuildToolsVersion: String by extra + val androidCompileSdkVersion: Int by extra + val androidCompileNdkVersion: String by extra + val androidSourceCompatibility: JavaVersion by extra + val androidTargetCompatibility: JavaVersion by extra + + compileSdkVersion(androidCompileSdkVersion) + ndkVersion = androidCompileNdkVersion + buildToolsVersion(androidBuildToolsVersion) + + buildFeatures { + viewBinding = true + } + + defaultConfig { + applicationId("io.github.lsposed.manager") + minSdkVersion(androidMinSdkVersion) + targetSdkVersion(androidTargetSdkVersion) + versionCode(extra["versionCode"] as Int) + versionName(extra["versionName"] as String) + resConfigs("en", "zh-rCN", "zh-rTW", "zh-rHK", "ru", "uk", "nl", "ko", "fr") + resValue("string", "versionName", extra["versionName"] as String) + } + + compileOptions { + targetCompatibility(androidTargetCompatibility) + sourceCompatibility(androidSourceCompatibility) + } + + lintOptions { + disable("MissingTranslation") + disable("ExtraTranslation") + isAbortOnError = true + isCheckReleaseBuilds = true + } + + packagingOptions { + exclude("META-INF/**") + exclude("kotlin/**") + exclude("org/**") + exclude("**.properties") + exclude("**.bin") + } + + dependenciesInfo.includeInApk = false + + buildTypes { + named("release") { + isMinifyEnabled = true + isShrinkResources = true + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + } + named("debug") { + isMinifyEnabled = false + isShrinkResources = false + } + } + applicationVariants.forEach { variant -> + variant.outputs.map { it as BaseVariantOutputImpl }.forEach { output -> + output.outputFileName = "LSPosedManager-${defaultConfig.versionName}-${defaultConfig.versionCode}-${variant.buildType.name}.apk" + } + } +} + +val optimizeReleaseResources = task("optimizeReleaseResources").doLast { + val aapt2 = Paths.get(project.android.sdkDirectory.path, "build-tools", project.android.buildToolsVersion, "aapt2") + val zip = Paths.get(project.buildDir.path, "intermediates", "processed_res", "release", "out", "resources-release.ap_") + val optimized = File("${zip}.opt") + val cmd = exec { + commandLine(aapt2, "optimize", "--collapse-resource-names", "--shorten-resource-paths", "-o", optimized, zip) + isIgnoreExitValue = false + } + if (cmd.exitValue == 0) { + delete(zip) + optimized.renameTo(zip.toFile()) + } +} + +tasks.whenTaskAdded { + if (name == "processReleaseResources") { + finalizedBy(optimizeReleaseResources) + } +} + +dependencies { + val glideVersion = "4.12.0" + val markwonVersion = "4.6.2" + val okhttpVersion = "4.9.1" + annotationProcessor("com.github.bumptech.glide:compiler:$glideVersion") + implementation("androidx.activity:activity:1.2.0") + implementation("androidx.browser:browser:1.3.0") + implementation("androidx.constraintlayout:constraintlayout:2.0.4") + implementation("androidx.fragment:fragment:1.3.0") + implementation("androidx.recyclerview:recyclerview:1.1.0") + implementation("com.caverock:androidsvg-aar:1.4") + implementation("com.github.bumptech.glide:glide:$glideVersion") + implementation("com.github.bumptech.glide:okhttp3-integration:$glideVersion") + implementation("com.github.jinatonic.confetti:confetti:1.1.2") + implementation("com.google.android.material:material:1.3.0") + implementation("com.google.code.gson:gson:2.8.6") + implementation("com.takisoft.preferencex:preferencex:1.1.0") + implementation("com.takisoft.preferencex:preferencex-colorpicker:1.1.0") + implementation("com.squareup.okhttp3:okhttp:$okhttpVersion") + implementation("com.squareup.okhttp3:okhttp-dnsoverhttps:$okhttpVersion") + implementation("io.noties.markwon:core:$markwonVersion") + implementation("io.noties.markwon:ext-strikethrough:$markwonVersion") + implementation("io.noties.markwon:ext-tables:$markwonVersion") + implementation("io.noties.markwon:ext-tasklist:$markwonVersion") + implementation("io.noties.markwon:html:$markwonVersion") + implementation("io.noties.markwon:image-glide:$markwonVersion") + implementation("io.noties.markwon:linkify:$markwonVersion") + implementation("rikka.appcompat:appcompat:1.2.0-rc01") + implementation("rikka.core:core:1.3.0") + implementation("rikka.insets:insets:1.0.1") + implementation("rikka.material:material:1.6.0") + implementation("rikka.recyclerview:recyclerview-utils:1.2.0") + implementation("rikka.widget:borderview:1.0.0") + implementation("rikka.widget:switchbar:1.0.2") + implementation("rikka.layoutinflater:layoutinflater:1.0.1") + implementation("tech.rectifier.preferencex-android:preferencex-simplemenu:88f93154b2") + implementation("me.zhanghai.android.appiconloader:appiconloader-glide:1.2.0") + implementation("me.zhanghai.android.fastscroll:library:1.1.5") + implementation(files("libs/WeatherView-2.0.3.aar")) + implementation(project(":manager-service")) +} + +configurations { + compile.get().exclude(group = "org.jetbrains", module = "annotations") + compile.get().exclude(group = "androidx.appcompat", module = "appcompat") +// cleanedAnnotations() +} + diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 33b27bb6..00000000 --- a/build.gradle +++ /dev/null @@ -1,39 +0,0 @@ -import org.eclipse.jgit.internal.storage.file.FileRepository -import org.eclipse.jgit.api.Git - -buildscript { - repositories { - google() - jcenter() - maven { - url 'https://storage.googleapis.com/r8-releases/raw' - } - } - dependencies { - classpath 'com.android.tools:r8:3.0.25-dev' - classpath 'com.android.tools.build:gradle:4.1.2' - classpath 'org.eclipse.jgit:org.eclipse.jgit:5.10.0.202012080955-r' - } -} - -def repo = new FileRepository(rootProject.file(".git")) -def refId = repo.refDatabase.exactRef("refs/remotes/origin/master").objectId -def commitCount = new Git(repo).log().add(refId).call().size() - -allprojects { - ext { - versionCode = commitCount + 4200 - versionName = versionName - zipPathMagiskReleasePath = project(":core").projectDir.path + "/build/tmp/release/magisk/" - } - repositories { - google() - jcenter() - maven { url 'https://jitpack.io' } - maven { url 'https://dl.bintray.com/rikkaw/Libraries' } - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..f5032797 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,61 @@ +/* + * 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 + */ +import org.eclipse.jgit.internal.storage.file.FileRepository +import org.eclipse.jgit.api.Git + +buildscript { + repositories { + google() + jcenter() + } + dependencies { + classpath("com.android.tools.build:gradle:4.1.2") + classpath("org.eclipse.jgit:org.eclipse.jgit:5.10.0.202012080955-r") + classpath(kotlin("gradle-plugin", version = "1.4.31")) + } +} + +val repo = FileRepository(rootProject.file(".git")) +val refId = repo.refDatabase.exactRef("refs/remotes/origin/master").objectId!! +val commitCount = Git(repo).log().add(refId).call().count() + +allprojects { + extra["versionCode"] = commitCount + 4200 + extra["versionName"] = "v1.2.0" + extra["androidTargetSdkVersion"] = 30 + extra["androidMinSdkVersion"] = 27 + extra["androidBuildToolsVersion"] = "30.0.3" + extra["androidCompileSdkVersion"] = 30 + extra["androidCompileNdkVersion"] = "22.0.7026061" + extra["androidSourceCompatibility"] = JavaVersion.VERSION_1_8 + extra["androidTargetCompatibility"] = JavaVersion.VERSION_1_8 + extra["apiCode"] = 93 + extra["zipPathMagiskReleasePath"] = project(":core").projectDir.path + "/build/tmp/release/magisk/" + + repositories { + google() + jcenter() + maven(url = "https://jitpack.io") + maven(url = "https://dl.bintray.com/rikkaw/Libraries") + } +} + +tasks.register("Delete", Delete::class) { + delete(rootProject.buildDir) +} diff --git a/core/build.gradle b/core/build.gradle deleted file mode 100644 index bcf2eff1..00000000 --- a/core/build.gradle +++ /dev/null @@ -1,266 +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 - */ - -import org.apache.tools.ant.filters.FixCrLfFilter -import org.gradle.internal.os.OperatingSystem - -import java.security.MessageDigest - -apply plugin: 'com.android.application' - -static def calcSha256(file) { - def md = MessageDigest.getInstance("SHA-256") - file.eachByte 4096, { bytes, size -> - md.update(bytes, 0, size) - } - return md.digest().encodeHex() -} - -ext { - module_name = "LSPosed" - jar_dest_dir = "${projectDir}/template_override/system/framework/" - is_windows = OperatingSystem.current().isWindows() - module_id = "riru_lsposed" - authors = "LSPosed Developers" - - riruModuleId = "lsposed" - - moduleMinRiruApiVersion = 10 - moduleMinRiruVersionName = "v23.0" - moduleMaxRiruApiVersion = 10 -} - -repositories { - mavenLocal() - jcenter() - maven { url 'https://dl.bintray.com/rikkaw/Libraries' } -} - -dependencies { - implementation 'rikka.ndk:riru:10' - implementation 'com.android.tools.build:apksig:4.1.2' - implementation project(path: ':sandhook-hooklib') - compileOnly project(':hiddenapi-stubs') - compileOnly 'androidx.annotation:annotation:1.1.0' - implementation project(':interface') - implementation project(':hiddenapi-bridge') - implementation project(':manager-service') -} - -android { - compileSdkVersion androidCompileSdkVersion.toInteger() - defaultConfig { - applicationId "io.github.lsposed.lspd" - minSdkVersion androidMinSdkVersion.toInteger() - targetSdkVersion androidTargetSdkVersion.toInteger() - multiDexEnabled false - - buildFeatures { - prefab true - } - - externalNativeBuild { - cmake { - abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64' - cppFlags "-std=c++17 -ffixed-x18 -Qunused-arguments -frtti -fomit-frame-pointer -fpie -fPIC" - cFlags "-std=gnu99 -ffixed-x18 -Qunused-arguments -frtti -fomit-frame-pointer -fpie -fPIC" - arguments "-DRIRU_MODULE_API_VERSION=$moduleMaxRiruApiVersion", - "-DRIRU_MODULE_VERSION=$rootProject.ext.versionCode", - "-DRIRU_MODULE_VERSION_NAME:STRING=\"$rootProject.ext.versionName\"" - } - } - - buildConfigField("int", "API_CODE", "$apiCode") - buildConfigField("String", "VERSION_NAME", "\"${rootProject.ext.versionName}\"") - buildConfigField("Integer", "VERSION_CODE", String.valueOf(rootProject.ext.versionCode)) - } - - lintOptions { - abortOnError false - checkReleaseBuilds false - } - - buildTypes { - debug { - externalNativeBuild { - cmake { - cppFlags "-O0" - cFlags "-O0" - } - } - } - release { - minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - - externalNativeBuild { - cmake { - cppFlags "-fvisibility=hidden -fvisibility-inlines-hidden -Os -Wno-unused-value -fomit-frame-pointer -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,--strip-all -fno-unwind-tables" - cFlags "-fvisibility=hidden -fvisibility-inlines-hidden -Os -Wno-unused-value -fomit-frame-pointer -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,--strip-all -fno-unwind-tables" - } - } - } - } - externalNativeBuild { - cmake { - path "src/main/cpp/CMakeLists.txt" - } - } - ndkVersion androidCompileNdkVersion - buildToolsVersion androidBuildToolsVersion - compileOptions { - targetCompatibility JavaVersion.VERSION_1_8 - sourceCompatibility JavaVersion.VERSION_1_8 - } -} - -afterEvaluate { - - android.applicationVariants.all { variant -> - def variantCapped = variant.name.capitalize() - def variantLowered = variant.name.toLowerCase() - def zipFileName = "${module_name}-${rootProject.ext.versionName}-${rootProject.ext.versionCode}-${variantLowered}.zip" - - delete file(zipPathMagiskReleasePath) - - def prepareMagiskFilesTask = task("prepareMagiskFiles${variantCapped}") { - dependsOn "assemble${variantCapped}" - doFirst { - copy { - from "${projectDir}/tpl/module.prop.tpl" - into "${projectDir}/template_override" - rename "module.prop.tpl", "module.prop" - expand(moduleId: "$module_id", - versionName: "$rootProject.ext.versionName", - versionCode: "$rootProject.ext.versionCode", authorList: "$authors", - apiCode: "$apiCode", minApi: "$moduleMinRiruApiVersion") - filter(FixCrLfFilter.class, eol: FixCrLfFilter.CrLf.newInstance("lf")) - } - copy { - from ("${rootProject.projectDir}/README.md") - into file(zipPathMagiskReleasePath) - } - } - def libPathRelease = "${buildDir}/intermediates/cmake/${variantLowered}/obj" - def exclude_list = ["util_functions.sh"] - doLast { - def dexOutPath = variant.name.contains("release") ? - "${buildDir}/intermediates/dex/${variantLowered}/minify${variantCapped}WithR8" : - "${buildDir}/intermediates/dex/${variantLowered}/mergeDex${variantCapped}" - copy { - from (dexOutPath){ - rename("classes.dex", "lspd.dex") - } - into file(zipPathMagiskReleasePath + "system/framework/") - } - copy { - from "${projectDir}/template_override" - into zipPathMagiskReleasePath - exclude exclude_list - } - copy { - from "${projectDir}/template_override" - into zipPathMagiskReleasePath - include 'util_functions.sh' - filter { line -> - line.replaceAll('%%%RIRU_MODULE_ID%%%', riruModuleId) - .replaceAll('%%%RIRU_MIN_API_VERSION%%%', moduleMinRiruApiVersion.toString()) - .replaceAll('%%%RIRU_MIN_VERSION_NAME%%%', moduleMinRiruVersionName) - } - filter(FixCrLfFilter.class, - eol: FixCrLfFilter.CrLf.newInstance("lf")) - } - copy { - include "riru_lspd" - rename('riru_lspd', 'libriru_lspd.so') - from "$libPathRelease/armeabi-v7a" - into "$zipPathMagiskReleasePath/system/lib" - } - copy { - include "riru_lspd" - rename('riru_lspd', 'libriru_lspd.so') - from "$libPathRelease/arm64-v8a" - into "$zipPathMagiskReleasePath/system/lib64" - } - copy { - include "riru_lspd" - rename('riru_lspd', 'libriru_lspd.so') - from "$libPathRelease/x86" - into "$zipPathMagiskReleasePath/system_x86/lib" - } - copy { - include "riru_lspd" - rename('riru_lspd', 'libriru_lspd.so') - from "$libPathRelease/x86_64" - into "$zipPathMagiskReleasePath/system_x86/lib64" - } - // generate sha1sum - fileTree(zipPathMagiskReleasePath).matching { - exclude "README.md", "META-INF" - }.visit { f -> - if (f.directory) return - file(f.file.path + ".sha256").text = calcSha256(f.file) - } - } - } - - def zipTask = task("zip${variantCapped}", type: Zip) { - dependsOn prepareMagiskFilesTask - archiveName zipFileName - destinationDir file("$projectDir/release") - from "$zipPathMagiskReleasePath" - } - - task("push${variantCapped}", type: Exec) { - dependsOn zipTask - workingDir "${projectDir}/release" - def commands = [android.adbExecutable, "push", - zipFileName, - "/data/local/tmp/"] - if (is_windows) { - commandLine 'cmd', '/c', commands.join(" ") - } else { - commandLine commands - } - } - task("flash${variantCapped}", type: Exec) { - dependsOn tasks.getByPath("push${variantCapped}") - workingDir "${projectDir}/release" - def commands = [android.adbExecutable, "shell", "su", "-c", - "magisk --install-module /data/local/tmp/${zipFileName}"] - if (is_windows) { - commandLine 'cmd', '/c', commands.join(" ") - } else { - commandLine commands - } - } - task("flashAndReboot${variantCapped}", type: Exec) { - dependsOn tasks.getByPath("flash${variantCapped}") - workingDir "${projectDir}/release" - def commands = [android.adbExecutable, "shell", "reboot"] - if (is_windows) { - commandLine 'cmd', '/c', commands.join(" ") - } else { - commandLine commands - } - } - } - -} diff --git a/core/build.gradle.kts b/core/build.gradle.kts new file mode 100644 index 00000000..62804973 --- /dev/null +++ b/core/build.gradle.kts @@ -0,0 +1,277 @@ +/* + * 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 + */ + +import org.apache.tools.ant.filters.FixCrLfFilter +import org.gradle.internal.os.OperatingSystem +import org.jetbrains.kotlin.daemon.common.toHexString + +import java.security.MessageDigest + +plugins { + id("com.android.application") + kotlin("android") +} + +fun calcSha256(file: File): String { + val md = MessageDigest.getInstance("SHA-256") + file.forEachBlock(4096) { bytes, size -> + md.update(bytes, 0, size) + } + return md.digest().toHexString() +} + +val moduleName = "LSPosed" +val jarDestDir = "${projectDir}/template_override/system/framework/" +val isWindows = OperatingSystem.current().isWindows +val moduleId = "riru_lsposed" +val authors = "LSPosed Developers" + +val riruModuleId = "lsposed" +val moduleMinRiruApiVersion = 10 +val moduleMinRiruVersionName = "v23.0" +val moduleMaxRiruApiVersion = 10 + +val apiCode: Int by extra + +val androidTargetSdkVersion: Int by extra +val androidMinSdkVersion: Int by extra +val androidBuildToolsVersion: String by extra +val androidCompileSdkVersion: Int by extra +val androidCompileNdkVersion: String by extra +val androidSourceCompatibility: JavaVersion by extra +val androidTargetCompatibility: JavaVersion by extra + +val zipPathMagiskReleasePath: String by extra + +val versionCode: Int by extra +val versionName: String by extra + +dependencies { + implementation("rikka.ndk:riru:10") + implementation("com.android.tools.build:apksig:4.1.2") + implementation(project(":sandhook-hooklib")) + compileOnly(project(":hiddenapi-stubs")) + compileOnly("androidx.annotation:annotation:1.1.0") + implementation(project(":interface")) + implementation(project(":hiddenapi-bridge")) + implementation(project(":manager-service")) +} + +android { + compileSdkVersion(androidCompileSdkVersion) + defaultConfig { + applicationId("io.github.lsposed.lspd") + minSdkVersion(androidMinSdkVersion) + targetSdkVersion(androidTargetSdkVersion) + multiDexEnabled = false + + buildFeatures { + prefab = true + } + + externalNativeBuild { + cmake { + abiFilters("arm64-v8a", "armeabi-v7a", "x86", "x86_64") + cppFlags("-std=c++17 -ffixed-x18 -Qunused-arguments -frtti -fomit-frame-pointer -fpie -fPIC") + cFlags("-std=gnu99 -ffixed-x18 -Qunused-arguments -frtti -fomit-frame-pointer -fpie -fPIC") + arguments("-DRIRU_MODULE_API_VERSION=$moduleMaxRiruApiVersion", + "-DRIRU_MODULE_VERSION=${extra["versionCode"]}", + "-DRIRU_MODULE_VERSION_NAME:STRING=\"${extra["versionName"]}\"") + } + } + + buildConfigField("int", "API_CODE", "$apiCode") + buildConfigField("String", "VERSION_NAME", "\"$versionName\"") + buildConfigField("Integer", "VERSION_CODE", versionCode.toString()) + } + + lintOptions { + isAbortOnError = false + isCheckReleaseBuilds = false + } + + buildTypes { + named("debug") { + externalNativeBuild { + cmake { + cppFlags("-O0") + cFlags("-O0") + } + } + } + named("release") { + isMinifyEnabled = true + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + + externalNativeBuild { + cmake { + cppFlags("-fvisibility=hidden -fvisibility-inlines-hidden -Os -Wno-unused-value -fomit-frame-pointer -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,--strip-all -fno-unwind-tables") + cFlags("-fvisibility=hidden -fvisibility-inlines-hidden -Os -Wno-unused-value -fomit-frame-pointer -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,--strip-all -fno-unwind-tables") + } + } + } + } + externalNativeBuild { + cmake { + path("src/main/cpp/CMakeLists.txt") + } + } + ndkVersion = androidCompileNdkVersion + buildToolsVersion(androidBuildToolsVersion) + + compileOptions { + targetCompatibility(androidTargetCompatibility) + sourceCompatibility(androidSourceCompatibility) + } +} + +afterEvaluate { + + android.applicationVariants.forEach { variant -> + val variantCapped = variant.name.capitalize() + val variantLowered = variant.name.toLowerCase() + val zipFileName = "$moduleName-$versionName-$versionCode-$variantLowered.zip" + + delete(file(zipPathMagiskReleasePath)) + + val prepareMagiskFilesTask = task("prepareMagiskFiles$variantCapped") { + dependsOn("assemble$variantCapped") + doFirst { + copy { + from("$projectDir/tpl/module.prop.tpl") + into("$projectDir/template_override") + rename("module.prop.tpl", "module.prop") + expand("moduleId" to moduleId, + "versionName" to versionName, + "versionCode" to versionCode, + "authorList" to authors, + "apiCode" to apiCode, + "minApi" to "$moduleMinRiruApiVersion") + filter(mapOf("eol" to FixCrLfFilter.CrLf.newInstance("lf")), FixCrLfFilter::class.java) + } + copy { + from("${rootProject.projectDir}/README.md") + into(file(zipPathMagiskReleasePath)) + } + } + val libPathRelease = "${buildDir}/intermediates/cmake/$variantLowered/obj" + val excludeList = arrayOf("util_functions.sh") + doLast { + val dexOutPath = if (variant.name.contains("release")) + "buildDir/intermediates/dex/variantLowered/minify${variantCapped}WithR8" else + "buildDir/intermediates/dex/variantLowered/mergeDex$variantCapped" + copy { + from(dexOutPath) { + rename("classes.dex", "lspd.dex") + } + into(file(zipPathMagiskReleasePath + "system/framework/")) + } + copy { + from("${projectDir}/template_override") + into(zipPathMagiskReleasePath) + exclude(*excludeList) + } + copy { + from("${projectDir}/template_override") + into(zipPathMagiskReleasePath) + include("util_functions.sh") + filter { line -> + line.replace("%%%RIRU_MODULE_ID%%%", riruModuleId) + .replace("%%%RIRU_MIN_API_VERSION%%%", moduleMinRiruApiVersion.toString()) + .replace("%%%RIRU_MIN_VERSION_NAME%%%", moduleMinRiruVersionName) + } + filter(mapOf("eol" to FixCrLfFilter.CrLf.newInstance("lf")), FixCrLfFilter::class.java) + } + copy { + include("riru_lspd") + rename("riru_lspd", "libriru_lspd.so") + from("$libPathRelease/armeabi-v7a") + into("$zipPathMagiskReleasePath/system/lib") + } + copy { + include("riru_lspd") + rename("riru_lspd", "libriru_lspd.so") + from("$libPathRelease/arm64-v8a") + into("$zipPathMagiskReleasePath/system/lib64") + } + copy { + include("riru_lspd") + rename("riru_lspd", "libriru_lspd.so") + from("$libPathRelease/x86") + into("$zipPathMagiskReleasePath/system_x86/lib") + } + copy { + include("riru_lspd") + rename("riru_lspd", "libriru_lspd.so") + from("$libPathRelease/x86_64") + into("$zipPathMagiskReleasePath/system_x86/lib64") + } + // generate sha1sum + fileTree(zipPathMagiskReleasePath).matching { + exclude("README.md", "META-INF") + }.visit { + if (isDirectory) return@visit + file(file.path + ".sha256").writeText(calcSha256(file)) + } + } + } + + val zipTask = task("zip${variantCapped}", Zip::class) { + dependsOn(prepareMagiskFilesTask) + archiveFileName.set(zipFileName) + destinationDirectory.set(file("$projectDir/release")) + from(zipPathMagiskReleasePath) + } + + task("push${variantCapped}", Exec::class) { + dependsOn(zipTask) + workingDir("${projectDir}/release") + val commands = arrayOf(android.adbExecutable, "push", + zipFileName, + "/data/local/tmp/") + if (isWindows) { + commandLine("cmd", "/c", commands.joinToString(" ")) + } else { + commandLine(commands) + } + } + task("flash${variantCapped}", Exec::class) { + dependsOn(tasks.getByPath("push${variantCapped}")) + workingDir("${projectDir}/release") + val commands = arrayOf(android.adbExecutable, "shell", "su", "-c", + "magisk --install-module /data/local/tmp/${zipFileName}") + if (isWindows) { + commandLine("cmd", "/c", commands.joinToString(" ")) + } else { + commandLine(commands) + } + } + task("flashAndReboot${variantCapped}", Exec::class) { + dependsOn(tasks.getByPath("flash${variantCapped}")) + workingDir("${projectDir}/release") + val commands = arrayOf(android.adbExecutable, "shell", "reboot") + if (isWindows) { + commandLine("cmd", "/c", commands.joinToString(" ")) + } else { + commandLine(commands) + } + } + } + +} diff --git a/core/src/main/java/io/github/lsposed/lspd/nativebridge/ModuleLogger.java b/core/src/main/java/io/github/lsposed/lspd/nativebridge/ModuleLogger.java index 9691f668..424166a2 100644 --- a/core/src/main/java/io/github/lsposed/lspd/nativebridge/ModuleLogger.java +++ b/core/src/main/java/io/github/lsposed/lspd/nativebridge/ModuleLogger.java @@ -27,6 +27,7 @@ import android.os.Process; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; +import java.util.TimeZone; import io.github.lsposed.lspd.util.Utils; @@ -37,6 +38,7 @@ public class ModuleLogger { public static void initLogger(ParcelFileDescriptor fileDescriptor) { if (fd == -1 && fileDescriptor != null) { fd = fileDescriptor.detachFd(); + logDateFormat.setTimeZone(TimeZone.getDefault()); } } diff --git a/core/src/main/java/io/github/lsposed/lspd/util/InstallerVerifier.java b/core/src/main/java/io/github/lsposed/lspd/util/InstallerVerifier.java index a9335df7..d436533f 100644 --- a/core/src/main/java/io/github/lsposed/lspd/util/InstallerVerifier.java +++ b/core/src/main/java/io/github/lsposed/lspd/util/InstallerVerifier.java @@ -35,7 +35,7 @@ import de.robv.android.xposed.XposedHelpers; public class InstallerVerifier { - private static final byte[] CERTIFICATE = {48, -126, 2, -51, 48, -126, 1, -75, -96, 3, 2, 1, 2, 2, 4, 118, 111, 58, 92, 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1, 11, 5, 0, 48, 22, 49, 20, 48, 18, 6, 3, 85, 4, 10, 19, 11, 72, 105, 116, 111, 107, 111, 116, 111, 46, 99, 110, 48, 32, 23, 13, 49, 57, 48, 56, 50, 48, 48, 50, 51, 52, 48, 57, 90, 24, 15, 50, 49, 49, 57, 48, 55, 50, 55, 48, 50, 51, 52, 48, 57, 90, 48, 22, 49, 20, 48, 18, 6, 3, 85, 4, 10, 19, 11, 72, 105, 116, 111, 107, 111, 116, 111, 46, 99, 110, 48, -126, 1, 34, 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1, 1, 5, 0, 3, -126, 1, 15, 0, 48, -126, 1, 10, 2, -126, 1, 1, 0, -101, 68, 51, -99, -100, 26, 14, 54, -127, -112, 1, -64, -52, 21, -22, -56, 123, -104, 16, 28, -74, -27, 75, 12, -39, 45, -123, -103, 50, 109, 118, 92, -88, 92, -111, -101, 61, -119, 83, -50, 67, -97, 124, -80, -7, -82, 41, -65, 41, 34, -114, 23, 10, -121, -52, 17, -12, -1, 55, 125, -90, 122, -122, 42, 114, 69, -1, -1, -76, 49, -52, 46, -126, 126, 4, 43, -52, 42, -21, -39, -98, -3, -115, -91, 40, -57, 38, -30, 7, 46, 88, -6, -103, -53, 83, -110, -75, -65, 90, 18, -52, -75, -72, -12, 115, -52, -117, -28, -38, 90, 60, -45, -22, -115, -2, -86, -34, 67, -60, -104, -74, -53, 46, 88, -3, -61, 80, 58, 85, -8, -66, -110, 118, 25, -81, -90, -82, 96, -68, 74, 31, -42, 104, -49, -121, -103, -113, 43, -43, -101, 22, -28, 124, -112, -115, -85, 67, 64, 75, -37, 32, -124, -91, -76, -58, 9, 98, -30, 3, 97, 73, 18, -9, -67, 117, -54, 35, -104, 126, -29, -117, -58, -37, -19, -47, -117, 32, 19, 99, -87, -115, -104, -34, -122, 69, 23, -101, -46, -62, -44, -47, -10, -26, -1, 105, -116, 111, -51, -99, 67, -125, 47, 127, -15, -59, 99, -82, -111, -111, -94, -123, -52, -81, 121, 50, 24, 25, 73, -53, 43, -10, 110, 27, -42, -24, 84, -36, 50, -81, -44, 111, 52, 83, -87, 7, 12, -105, 34, 36, -70, -75, -75, 45, 88, 67, -63, 2, 3, 1, 0, 1, -93, 33, 48, 31, 48, 29, 6, 3, 85, 29, 14, 4, 22, 4, 20, -3, 65, -105, 57, 8, 44, -70, 80, 52, 55, 94, -73, -57, -78, -120, 111, 59, 93, -20, 30, 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1, 11, 5, 0, 3, -126, 1, 1, 0, -109, -64, -22, -50, 87, 4, -51, -112, -117, -50, -17, -79, -80, 110, -25, 50, -83, -99, 81, 28, 53, -105, 97, -93, -74, -14, 16, 44, 106, -118, -85, 33, 11, -101, -93, -69, 36, 119, -7, -37, -45, -72, 81, -78, -60, -53, -110, 61, 65, 35, 48, -60, 65, -103, 68, -48, -16, -19, 50, -78, 102, 54, 79, -38, -83, -57, 74, -7, 49, -97, -42, -17, -13, 0, 96, -55, -38, 89, -69, -33, 100, 46, 84, -114, -71, 5, 117, -92, -38, 57, 7, -55, 2, -96, -109, -114, -80, 20, 72, -66, -115, 35, 57, 65, -58, 2, -128, -48, 85, 79, -47, 45, -76, 88, 47, 102, -80, 67, 5, 120, 98, -20, 27, 11, 114, 95, 80, -76, -54, 123, -114, -23, 36, 120, 36, -62, -88, -76, 29, 78, -14, 97, -1, -100, 82, -11, -16, 72, 43, -46, 30, 9, 9, 112, -121, -90, -45, -30, 14, 36, -3, 27, -27, 63, 72, -9, -103, -75, -84, -57, -36, 61, 33, -36, 108, -100, 98, -94, -20, -38, 103, 22, -111, -68, 49, 45, 13, 20, 27, 118, -63, 5, 5, -114, -3, 69, -120, -52, -113, -88, 113, 118, 54, -117, -76, 54, -96, 122, 97, -75, 110, 116, -42, -81, -57, -16, 36, 96, 50, -53, -6, 80, -22, -67, 75, -94, -41, 18, -93, -59, 30, 94, 89, 56, 21, -4, -46, 107, 40, 53, -70, -59, 66, 96, -103, -92, -82, -55, 97, -77, -120, -52, -42, -50, 1, -87}; + private static final byte[] CERTIFICATE = {48, -126, 2, -61, 48, -126, 1, -85, -96, 3, 2, 1, 2, 2, 4, 36, 13, 10, 11, 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1, 11, 5, 0, 48, 18, 49, 16, 48, 14, 6, 3, 85, 4, 10, 19, 7, 76, 83, 80, 111, 115, 101, 100, 48, 30, 23, 13, 50, 49, 48, 51, 48, 49, 49, 55, 49, 49, 48, 55, 90, 23, 13, 52, 54, 48, 50, 50, 51, 49, 55, 49, 49, 48, 55, 90, 48, 18, 49, 16, 48, 14, 6, 3, 85, 4, 10, 19, 7, 76, 83, 80, 111, 115, 101, 100, 48, -126, 1, 34, 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1, 1, 5, 0, 3, -126, 1, 15, 0, 48, -126, 1, 10, 2, -126, 1, 1, 0, -122, -20, -29, -82, 21, 0, 37, -64, -36, 21, 88, -73, 39, -107, 72, -34, -126, 30, 106, 8, 99, 62, -108, 126, 124, 6, -7, 12, -90, -8, -55, -24, -88, -108, 7, -109, 54, 12, -111, 85, -72, 119, -37, -112, -106, -106, 6, -120, 43, -120, 8, -8, 57, 102, -104, -28, -39, -120, 58, -124, -56, 67, 118, 55, 31, 124, -21, 101, 110, 59, 109, 119, 78, -103, 90, 101, -85, -67, 52, -42, -63, 74, 34, -11, 50, -55, 4, 7, -101, -45, -64, 87, -9, 0, -60, -125, -16, 68, -115, -87, 108, -110, 10, 3, -95, 15, -103, 56, -47, -25, 4, 24, -74, 102, 86, 2, 30, -86, -22, 25, 124, -4, -2, 43, -45, 63, 66, -93, 115, 14, 9, -82, 68, 19, -6, -120, 62, 71, 61, -119, 33, 115, -80, 23, -99, 13, 91, 99, -104, -105, -16, 47, -40, 69, 48, -87, 100, 8, -111, 93, 54, 83, 106, -49, -78, -42, 104, 44, 70, -36, 101, -27, -10, -92, -44, 90, -84, -52, -79, 120, -102, 27, -95, -71, 91, -98, -116, 35, 105, 53, 120, -61, -99, 89, 72, -18, -120, 31, 48, 104, -10, -22, -10, 121, 107, -38, -122, -7, -111, -88, -98, 36, 55, 82, -10, -80, -23, -10, 67, -62, 87, 96, 80, 4, 79, 116, 12, -20, -92, 14, -118, -11, -28, 12, -100, 79, 79, 4, -43, 33, -5, 28, -45, 39, -91, 50, -119, 62, -103, -101, 11, 23, 13, 79, -60, -99, 2, 3, 1, 0, 1, -93, 33, 48, 31, 48, 29, 6, 3, 85, 29, 14, 4, 22, 4, 20, -12, 0, 95, -84, 54, 105, -5, 73, 14, -74, -128, 118, 112, 113, 67, -21, -92, -37, 13, -73, 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1, 11, 5, 0, 3, -126, 1, 1, 0, 24, 12, 70, -87, -94, -63, 25, -29, -57, 108, 117, 95, -12, -50, 23, 40, -95, -105, 38, -112, -75, 68, 109, -2, 127, 28, 45, -115, 37, 44, -15, 68, 77, -33, 20, 30, 23, 63, 60, -42, 7, -14, -76, 9, -79, 57, 47, 67, -30, 8, 89, 95, -108, -1, -40, -115, 21, -61, -35, -111, -95, -2, -22, -35, -107, 92, -122, -72, 47, 78, 24, 35, -127, 107, -101, 64, -65, -54, 38, 46, 76, -90, 50, 60, 63, -106, -73, 3, -6, -85, 103, -29, -17, 1, -104, 15, -4, 125, -60, 25, 105, -94, -38, -58, 103, 117, -89, 95, -85, 14, 7, 120, -75, 106, -38, -67, -44, 42, 42, -93, 12, -47, 102, -55, -105, 116, -117, 69, -127, -68, 105, -27, 15, -86, -75, -58, -90, 119, -4, 1, 107, -66, -86, 48, -53, -39, 29, -54, -84, 92, 115, -45, -31, -50, 100, -75, -106, 13, 101, -101, 37, -25, -82, 63, -100, 22, 52, 57, 54, 96, 95, -19, -16, 46, -58, -55, 48, 22, 68, -28, 109, 78, 112, 123, 32, -4, -51, 41, -79, -97, 41, 7, -11, 85, -112, 0, -40, -50, 106, -104, 32, 69, 46, 68, -120, -17, -112, -72, -90, -103, 120, -95, 28, 85, 12, 35, 48, -66, 47, 84, -38, 31, -18, 6, -73, -62, 126, 60, -15, -67, 49, 22, 103, 96, -33, -27, -114, 81, -68, 123, 62, 115, 46, -106, 121, -61, -89, -28, -40, 115, 32, -13, 20, -10, 89, 87}; public static boolean verifyInstallerSignature(ApplicationInfo appInfo) { if ((appInfo.flags & ApplicationInfo.FLAG_TEST_ONLY) != 0) { diff --git a/gradle.properties b/gradle.properties index 479793ad..d979639b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,14 +10,7 @@ # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -#Sat Jan 30 19:20:27 CST 2021 -androidTargetSdkVersion=30 -androidCompileNdkVersion=22.0.7026061 -androidBuildToolsVersion=30.0.3 -apiCode=93 -androidCompileSdkVersion=30 -androidMinSdkVersion=27 +#Sat Jan 30 19:20:27 CST 202130.0.322.0.7026061 android.useAndroidX=true android.enableJetifier=true android.prefabVersion=1.1.2 -versionName=v1.1.0 diff --git a/hiddenapi-bridge/build.gradle b/hiddenapi-bridge/build.gradle.kts similarity index 90% rename from hiddenapi-bridge/build.gradle rename to hiddenapi-bridge/build.gradle.kts index 6ee6435d..fdd01b3c 100644 --- a/hiddenapi-bridge/build.gradle +++ b/hiddenapi-bridge/build.gradle.kts @@ -17,8 +17,10 @@ * Copyright (C) 2021 LSPosed Contributors */ -apply plugin: 'java-library' +plugins { + `java-library` +} dependencies { - compileOnly project(':hiddenapi-stubs') + compileOnly(project(":hiddenapi-stubs")) } \ No newline at end of file diff --git a/hiddenapi-stubs/build.gradle b/hiddenapi-stubs/build.gradle.kts similarity index 95% rename from hiddenapi-stubs/build.gradle rename to hiddenapi-stubs/build.gradle.kts index befba399..87c63453 100644 --- a/hiddenapi-stubs/build.gradle +++ b/hiddenapi-stubs/build.gradle.kts @@ -17,4 +17,6 @@ * Copyright (C) 2021 LSPosed Contributors */ -apply plugin: 'java-library' +plugins { + `java-library` +} diff --git a/manager-service/build.gradle b/manager-service/build.gradle.kts similarity index 50% rename from manager-service/build.gradle rename to manager-service/build.gradle.kts index 2a53d495..7c28e021 100644 --- a/manager-service/build.gradle +++ b/manager-service/build.gradle.kts @@ -18,27 +18,35 @@ */ plugins { - id 'com.android.library' + id("com.android.library") + kotlin("android") } android { - compileSdkVersion 30 - buildToolsVersion "30.0.3" + val androidTargetSdkVersion: Int by extra + val androidBuildToolsVersion: String by extra + val androidMinSdkVersion: Int by extra + val androidSourceCompatibility: JavaVersion by extra + val androidTargetCompatibility: JavaVersion by extra + + compileSdkVersion(androidTargetSdkVersion) + buildToolsVersion(androidBuildToolsVersion) defaultConfig { - minSdkVersion 26 - targetSdkVersion 30 - consumerProguardFiles 'proguard-rules.pro' + minSdkVersion(androidMinSdkVersion) + targetSdkVersion(androidTargetSdkVersion) + consumerProguardFiles("proguard-rules.pro") } buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + named("release") { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") } } + compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility(androidSourceCompatibility) + targetCompatibility(androidTargetCompatibility) } } diff --git a/sandhook-annotation/build.gradle b/sandhook-annotation/build.gradle deleted file mode 100644 index 0e4c5e4a..00000000 --- a/sandhook-annotation/build.gradle +++ /dev/null @@ -1,8 +0,0 @@ -apply plugin: 'java-library' - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) -} - -sourceCompatibility = "1.7" -targetCompatibility = "1.7" \ No newline at end of file diff --git a/sandhook-annotation/build.gradle.kts b/sandhook-annotation/build.gradle.kts new file mode 100644 index 00000000..9c10bb03 --- /dev/null +++ b/sandhook-annotation/build.gradle.kts @@ -0,0 +1,8 @@ +plugins { + `java-library` +} + +java { + sourceCompatibility = extra["androidSourceCompatibility"] as JavaVersion + targetCompatibility = extra["androidTargetCompatibility"] as JavaVersion +} diff --git a/sandhook-hooklib/build.gradle b/sandhook-hooklib/build.gradle deleted file mode 100644 index cbeba763..00000000 --- a/sandhook-hooklib/build.gradle +++ /dev/null @@ -1,27 +0,0 @@ -apply plugin: 'com.android.library' - -android { - compileSdkVersion androidCompileSdkVersion.toInteger() - - defaultConfig { - minSdkVersion androidMinSdkVersion.toInteger() - targetSdkVersion androidTargetSdkVersion.toInteger() - versionCode 1 - versionName "1.0" - - consumerProguardFiles 'proguard-rules.pro' - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - -} - -dependencies { - implementation fileTree(include: ['*.jar'], dir: 'libs') - api project(':sandhook-annotation') -} \ No newline at end of file diff --git a/sandhook-hooklib/build.gradle.kts b/sandhook-hooklib/build.gradle.kts new file mode 100644 index 00000000..863c8632 --- /dev/null +++ b/sandhook-hooklib/build.gradle.kts @@ -0,0 +1,41 @@ +plugins { + id("com.android.library") + kotlin("android") +} + +android { + val androidTargetSdkVersion: Int by extra + val androidCompileSdkVersion: Int by extra + val androidMinSdkVersion: Int by extra + val androidBuildToolsVersion: String by extra + val androidSourceCompatibility: JavaVersion by extra + val androidTargetCompatibility: JavaVersion by extra + + compileSdkVersion(androidCompileSdkVersion) + + defaultConfig { + minSdkVersion(androidMinSdkVersion) + targetSdkVersion(androidTargetSdkVersion) + buildToolsVersion(androidBuildToolsVersion) + versionCode(1) + versionName("1.0") + + consumerProguardFiles("proguard-rules.pro") + } + + buildTypes { + named("release") { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + compileOptions { + sourceCompatibility(androidSourceCompatibility) + targetCompatibility(androidTargetCompatibility) + } +} + +dependencies { + api(project(":sandhook-annotation")) +} diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 88c4e282..00000000 --- a/settings.gradle +++ /dev/null @@ -1,6 +0,0 @@ -rootProject.name = "LSPosed" -include ':core', ':hiddenapi-stubs', ':sandhook-hooklib', ':sandhook-annotation', ':app', ':service', ':interface', ':hiddenapi-bridge', ':manager-service' - -def service_root = "service" -project(':interface').projectDir = file("$service_root${File.separator}interface") -project(':service').projectDir = file("$service_root${File.separator}service") diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..fd5712f3 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,6 @@ +rootProject.name = "LSPosed" +include(":core", ":hiddenapi-stubs", ":sandhook-hooklib", ":sandhook-annotation", ":app", ":service", ":interface", ":hiddenapi-bridge", ":manager-service") + +val serviceRoot = "service" +project(":interface").projectDir = file("$serviceRoot${File.separator}interface") +project(":service").projectDir = file("$serviceRoot${File.separator}service")