diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 09490a51f..49523c99f 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -57,6 +57,10 @@ android { keepDebugSymbols += "**/*.so" } } + + kotlin { + jvmToolchain(17) + } } setupApp() diff --git a/app/shared/build.gradle.kts b/app/shared/build.gradle.kts index 9ac491b18..d794c75fa 100644 --- a/app/shared/build.gradle.kts +++ b/app/shared/build.gradle.kts @@ -7,7 +7,3 @@ setupCommon() android { namespace = "com.topjohnwu.shared" } - -dependencies { - api("io.michaelrocks:paranoid-core:0.3.7") -} diff --git a/app/shared/src/main/java/com/topjohnwu/magisk/ProviderInstaller.java b/app/shared/src/main/java/com/topjohnwu/magisk/ProviderInstaller.java index c969a85ba..56ed00232 100644 --- a/app/shared/src/main/java/com/topjohnwu/magisk/ProviderInstaller.java +++ b/app/shared/src/main/java/com/topjohnwu/magisk/ProviderInstaller.java @@ -2,9 +2,6 @@ package com.topjohnwu.magisk; import android.content.Context; -import io.michaelrocks.paranoid.Obfuscate; - -@Obfuscate public class ProviderInstaller { public static boolean install(Context context) { diff --git a/app/shared/src/main/java/com/topjohnwu/magisk/StubApk.java b/app/shared/src/main/java/com/topjohnwu/magisk/StubApk.java index 5ae838856..af4b2387b 100644 --- a/app/shared/src/main/java/com/topjohnwu/magisk/StubApk.java +++ b/app/shared/src/main/java/com/topjohnwu/magisk/StubApk.java @@ -20,9 +20,6 @@ import java.io.IOException; import java.lang.reflect.Method; import java.util.Map; -import io.michaelrocks.paranoid.Obfuscate; - -@Obfuscate public class StubApk { private static File dynDir; private static Method addAssetPath; diff --git a/app/shared/src/main/java/com/topjohnwu/magisk/utils/APKInstall.java b/app/shared/src/main/java/com/topjohnwu/magisk/utils/APKInstall.java index 07de53eca..1bc7a6d72 100644 --- a/app/shared/src/main/java/com/topjohnwu/magisk/utils/APKInstall.java +++ b/app/shared/src/main/java/com/topjohnwu/magisk/utils/APKInstall.java @@ -25,9 +25,6 @@ import java.util.UUID; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import io.michaelrocks.paranoid.Obfuscate; - -@Obfuscate public final class APKInstall { public static void transfer(InputStream in, OutputStream out) throws IOException { diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 5fc31f66e..b65cc6b7f 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -17,16 +17,10 @@ gradlePlugin { } } -tasks.withType { - kotlinOptions { - jvmTarget = "11" - } -} - dependencies { implementation(kotlin("gradle-plugin", "1.8.0")) implementation("com.android.tools.build:gradle:7.4.1") implementation("androidx.navigation:navigation-safe-args-gradle-plugin:2.5.3") - implementation("io.michaelrocks:paranoid-gradle-plugin:0.3.7") + implementation("org.lsposed.lsparanoid:gradle-plugin:0.5.0") implementation("org.eclipse.jgit:org.eclipse.jgit:6.4.0.202211300538-r") } diff --git a/buildSrc/src/main/java/Codegen.kt b/buildSrc/src/main/java/Codegen.kt index bd022088e..78f31e01e 100644 --- a/buildSrc/src/main/java/Codegen.kt +++ b/buildSrc/src/main/java/Codegen.kt @@ -159,7 +159,7 @@ fun genStubManifest(srcDir: File, outDir: File): String { fun List.process() = asSequence() .filter(::notJavaKeyword) // Distinct by lower case to support case insensitive file systems - .distinctBy { it.toLowerCase(Locale.ROOT) } + .distinctBy { it.lowercase() } val names = mutableListOf() names.addAll(c1) @@ -174,8 +174,7 @@ fun genStubManifest(srcDir: File, outDir: File): String { cls.append(names.random(kRANDOM)) // Old Android does not support capitalized package names // Check Android 7.0.0 PackageParser#buildClassName - cls[0] = cls[0].toLowerCase() - yield(cls.toString()) + yield(cls.toString().replaceFirstChar { it.lowercase() }) } }.distinct().iterator() diff --git a/buildSrc/src/main/java/Setup.kt b/buildSrc/src/main/java/Setup.kt index 4eb49ffe6..5d117c5fb 100644 --- a/buildSrc/src/main/java/Setup.kt +++ b/buildSrc/src/main/java/Setup.kt @@ -53,12 +53,12 @@ fun Project.setupCommon() { } compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = "11" + jvmTarget = "17" } } } @@ -133,8 +133,8 @@ private fun Project.setupAppCommon() { } android.applicationVariants.all { - val projectName = project.name.toLowerCase(Locale.ROOT) - val variantCapped = name.capitalize(Locale.ROOT) + val projectName = project.name.lowercase() + val variantCapped = name.replaceFirstChar { it.uppercase() } tasks.getByPath(":$projectName:package$variantCapped").doLast { val apk = outputs.files.asFileTree.filter { it.name.endsWith(".apk") }.singleFile val comment = "version=${Config.version}\nversionCode=${Config.versionCode}" @@ -191,7 +191,7 @@ fun Project.setupApp() { } android.applicationVariants.all { - val variantCapped = name.capitalize(Locale.ROOT) + val variantCapped = name.replaceFirstChar { it.uppercase() } val stubTask = tasks.getByPath(":stub:package$variantCapped") val stubApk = stubTask.outputs.files.asFileTree.filter { @@ -249,8 +249,8 @@ fun Project.setupStub() { setupAppCommon() android.applicationVariants.all { - val variantCapped = name.capitalize(Locale.ROOT) - val variantLowered = name.toLowerCase(Locale.ROOT) + val variantCapped = name.replaceFirstChar { it.uppercase() } + val variantLowered = name.lowercase() val manifest = file("src/${variantLowered}/AndroidManifest.xml") val outSrcDir = File(buildDir, "generated/source/obfuscate/${variantLowered}") val templateDir = file("template") @@ -299,11 +299,12 @@ fun Project.setupStub() { } // Override optimizeReleaseResources task tasks.whenTaskAdded { - val apk = File(buildDir, "intermediates/processed_res/" + - "release/out/resources-release.ap_") - val optRes = File(buildDir, "intermediates/optimized_processed_res/" + - "release/resources-release-optimize.ap_") if (name == "optimizeReleaseResources") { + dependsOn("generateReleaseObfuscatedSources") + val apk = File(buildDir, "intermediates/processed_res/" + + "release/out/resources-release.ap_") + val optRes = File(buildDir, "intermediates/optimized_processed_res/" + + "release/resources-release-optimize.ap_") doLast { apk.copyTo(optRes, true) } } } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 943f0cbfa..ccebba771 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2b22d057a..fc10b601f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 65dcd68d6..79a61d421 100755 --- a/gradlew +++ b/gradlew @@ -144,7 +144,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +152,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac diff --git a/stub/build.gradle.kts b/stub/build.gradle.kts index 88ece58ae..eff37f597 100644 --- a/stub/build.gradle.kts +++ b/stub/build.gradle.kts @@ -1,11 +1,12 @@ plugins { id("com.android.application") - id("io.michaelrocks.paranoid") + id("org.lsposed.lsparanoid") } -paranoid { - obfuscationSeed = if (RAND_SEED != 0) RAND_SEED else null - includeSubprojects = true +lsparanoid { + seed = if (RAND_SEED != 0) RAND_SEED else null + includeDependencies = true + global = true } android { diff --git a/stub/src/main/java/com/topjohnwu/magisk/ClassLoaders.java b/stub/src/main/java/com/topjohnwu/magisk/ClassLoaders.java index ef34023e3..02badde13 100644 --- a/stub/src/main/java/com/topjohnwu/magisk/ClassLoaders.java +++ b/stub/src/main/java/com/topjohnwu/magisk/ClassLoaders.java @@ -14,13 +14,9 @@ import java.io.File; import java.util.HashMap; import java.util.Map; -import io.michaelrocks.paranoid.Obfuscate; - // Wrap the actual classloader as we only want to resolve classname // mapping when loading from platform (via LoadedApk.mClassLoader) -@Obfuscate class AppClassLoader extends ClassLoader { - final Map mapping = new HashMap<>(); AppClassLoader(File apk) { diff --git a/stub/src/main/java/com/topjohnwu/magisk/DelegateApplication.java b/stub/src/main/java/com/topjohnwu/magisk/DelegateApplication.java index 0ed578b32..8b0dfd258 100644 --- a/stub/src/main/java/com/topjohnwu/magisk/DelegateApplication.java +++ b/stub/src/main/java/com/topjohnwu/magisk/DelegateApplication.java @@ -4,9 +4,6 @@ import android.app.Application; import android.content.Context; import android.content.res.Configuration; -import io.michaelrocks.paranoid.Obfuscate; - -@Obfuscate public class DelegateApplication extends Application { private Application receiver; diff --git a/stub/src/main/java/com/topjohnwu/magisk/DelegateRootService.java b/stub/src/main/java/com/topjohnwu/magisk/DelegateRootService.java index 3ca5b91a5..06db8b56b 100644 --- a/stub/src/main/java/com/topjohnwu/magisk/DelegateRootService.java +++ b/stub/src/main/java/com/topjohnwu/magisk/DelegateRootService.java @@ -9,9 +9,6 @@ import android.util.Log; import java.io.File; import java.lang.reflect.Constructor; -import io.michaelrocks.paranoid.Obfuscate; - -@Obfuscate public class DelegateRootService extends ContextWrapper { public DelegateRootService() { diff --git a/stub/src/main/java/com/topjohnwu/magisk/DownloadActivity.java b/stub/src/main/java/com/topjohnwu/magisk/DownloadActivity.java index da6276baf..ee67f7186 100644 --- a/stub/src/main/java/com/topjohnwu/magisk/DownloadActivity.java +++ b/stub/src/main/java/com/topjohnwu/magisk/DownloadActivity.java @@ -43,9 +43,6 @@ import javax.crypto.SecretKey; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; -import io.michaelrocks.paranoid.Obfuscate; - -@Obfuscate public class DownloadActivity extends Activity { private static final String APP_NAME = "Magisk"; diff --git a/stub/src/main/java/com/topjohnwu/magisk/DynLoad.java b/stub/src/main/java/com/topjohnwu/magisk/DynLoad.java index 487b37f5b..41ce3d9d9 100644 --- a/stub/src/main/java/com/topjohnwu/magisk/DynLoad.java +++ b/stub/src/main/java/com/topjohnwu/magisk/DynLoad.java @@ -21,9 +21,6 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.HashMap; -import io.michaelrocks.paranoid.Obfuscate; - -@Obfuscate @SuppressWarnings("ResultOfMethodCallIgnored") public class DynLoad { diff --git a/stub/src/main/java/com/topjohnwu/magisk/net/Networking.java b/stub/src/main/java/com/topjohnwu/magisk/net/Networking.java index 470996ff8..bc93dc48a 100644 --- a/stub/src/main/java/com/topjohnwu/magisk/net/Networking.java +++ b/stub/src/main/java/com/topjohnwu/magisk/net/Networking.java @@ -10,9 +10,6 @@ import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; -import io.michaelrocks.paranoid.Obfuscate; - -@Obfuscate public class Networking { private static final int READ_TIMEOUT = 15000; diff --git a/stub/src/main/java/com/topjohnwu/magisk/net/Request.java b/stub/src/main/java/com/topjohnwu/magisk/net/Request.java index 3c05ec048..76ade5b1c 100644 --- a/stub/src/main/java/com/topjohnwu/magisk/net/Request.java +++ b/stub/src/main/java/com/topjohnwu/magisk/net/Request.java @@ -22,9 +22,6 @@ import java.net.HttpURLConnection; import java.util.Scanner; import java.util.concurrent.Executor; -import io.michaelrocks.paranoid.Obfuscate; - -@Obfuscate public class Request implements Closeable { private final HttpURLConnection conn; private Executor executor = null;