From 1a327c8ab66ef2e588d6843d1ab1dc46ff6a1bbe Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Tue, 28 Jul 2020 03:44:49 -0700 Subject: [PATCH] Update proguard rules for the service module --- busybox/proguard-rules.pro | 21 --------------------- core/proguard-rules.pro | 21 ++++++++++++++++----- example/build.gradle.kts | 5 +++-- example/proguard-rules.pro | 3 +++ gradle.properties | 3 ++- io/proguard-rules.pro | 21 --------------------- service/proguard-rules.pro | 21 --------------------- 7 files changed, 24 insertions(+), 71 deletions(-) delete mode 100644 busybox/proguard-rules.pro delete mode 100644 io/proguard-rules.pro delete mode 100644 service/proguard-rules.pro diff --git a/busybox/proguard-rules.pro b/busybox/proguard-rules.pro deleted file mode 100644 index f1b4245..0000000 --- a/busybox/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 diff --git a/core/proguard-rules.pro b/core/proguard-rules.pro index 31e2667..aad74af 100644 --- a/core/proguard-rules.pro +++ b/core/proguard-rules.pro @@ -20,11 +20,22 @@ # hide the original source file name. #-renamesourcefileattribute SourceFile -# Strip out verbose logging +# Strip out debugging stuffs -assumenosideeffects class com.topjohnwu.superuser.internal.Utils { - public static void log(...); - public static void ex(...); + public static void log(...); + public static void ex(...); +} +-assumenosideeffects class com.topjohnwu.superuser.Shell.Config { + public static void verboseLogging(...); +} +-assumevalues class com.topjohnwu.superuser.internal.Utils { + public static boolean vLog() return false; +} +-assumevalues class android.os.Debug { + public static boolean isDebuggerConnected() return false; } -# Make sure R8/Proguard never remove Shell.Initializer classes --keep,allowobfuscation class * extends com.topjohnwu.superuser.Shell$Initializer +# Make sure R8/Proguard don't break things +-keep,allowobfuscation class * extends com.topjohnwu.superuser.Shell$Initializer { *; } +-keep,allowobfuscation class com.topjohnwu.superuser.ipc.IPCServer { *; } +-keep,allowobfuscation class * extends com.topjohnwu.superuser.ipc.RootService { *; } diff --git a/example/build.gradle.kts b/example/build.gradle.kts index ad3e1ec..149b2ea 100644 --- a/example/build.gradle.kts +++ b/example/build.gradle.kts @@ -16,9 +16,10 @@ android { buildTypes { getByName("release") { - isMinifyEnabled = false + isMinifyEnabled = true + isShrinkResources = true proguardFiles( - getDefaultProguardFile("proguard-android.txt"), + getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" ) } diff --git a/example/proguard-rules.pro b/example/proguard-rules.pro index f1b4245..848bc28 100644 --- a/example/proguard-rules.pro +++ b/example/proguard-rules.pro @@ -19,3 +19,6 @@ # If you keep the line number information, uncomment this to # hide the original source file name. #-renamesourcefileattribute SourceFile + +-repackageclasses +-allowaccessmodification diff --git a/gradle.properties b/gradle.properties index 9e6fce1..4ef0094 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,9 +9,10 @@ # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -android.enableJetifier=true android.useAndroidX=true +android.enableJetifier=false org.gradle.jvmargs=-Xmx1536m +android.enableR8.fullMode=true # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit diff --git a/io/proguard-rules.pro b/io/proguard-rules.pro deleted file mode 100644 index f1b4245..0000000 --- a/io/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 diff --git a/service/proguard-rules.pro b/service/proguard-rules.pro deleted file mode 100644 index f1b4245..0000000 --- a/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