Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.

Commit

Permalink
fix: downgrade lspatch & add proguard rules (#69)
Browse files Browse the repository at this point in the history
* fix: downgrade lspatch & add proguard rules

* git annihilated lspatch
  • Loading branch information
rushiiMachine authored Jan 21, 2024
1 parent ebd6e45 commit 4909003
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ dependencies {

implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.1")
implementation("io.github.diamondminer88:zip-android:2.1.1@aar")
implementation(files("libs/lspatch-v0.6.aar"))
implementation(files("libs/lspatch.aar"))

testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
Expand Down
7 changes: 5 additions & 2 deletions app/libs/convert-lspatch.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Download LSPatch jar and convert it to an aar
# Jars cannot be used as a dependency without breaking R8 optimization

LSPATCH_URL="https://github.com/LSPosed/LSPatch/releases/download/v0.6/jar-v0.6-398-release.jar"
LSPATCH_FILE_NAME="lspatch-v0.6"
# TODO: update to latest LSPatch
#LSPATCH_URL="https://github.com/LSPosed/LSPatch/releases/download/v0.6/jar-v0.6-398-release.jar"

LSPATCH_URL="https://github.com/vendetta-mod/VendettaManager/raw/5764b16a14c42d8449722f3656b2cb42019b82a8/app/libs/lspatch.jar"
LSPATCH_FILE_NAME="lspatch"

function cleanup {
rm -rf $LSPATCH_FILE_NAME.jar META-INF AndroidManifest.xml classes.jar R.txt
Expand Down
Binary file renamed app/libs/lspatch-v0.6.aar → app/libs/lspatch.aar
Binary file not shown.
10 changes: 10 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@
# Fix missing apksig annotations and fields
-keep class com.android.apksig.internal.** { *; }

# Fix LSPatch breaking
# ref: https://github.com/LSPosed/LSPatch/blob/bbe8d93fb9230f7b04babaf1c4a11642110f55a6/manager/proguard-rules.pro#L12-L18
-keep class com.beust.jcommander.** { *; }
-keep class org.lsposed.lspatch.Patcher$Options { *; }
-keep class org.lsposed.lspatch.share.LSPConfig { *; }
-keep class org.lsposed.lspatch.share.PatchConfig { *; }
-keepclassmembers class org.lsposed.patch.LSPatch {
private <fields>;
}

# Uncomment this to preserve the line number information for
# debugging stack traces.
-keepattributes SourceFile,LineNumberTable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,11 @@ class InstallerViewModel(
}

step(InstallStep.ADD_VD) {
val files = mutableListOf<File>()
signedDir.list { _, name ->
files.add(signedDir.resolve(name))
}
logger.i("Adding Vendetta module with LSPatch")
val files = signedDir.listFiles()
?.takeIf { it.isNotEmpty() }
?: throw Error("Missing APKs from signing step")

Patcher.patch(
logger,
outputDir = lspatchedDir,
Expand All @@ -414,10 +415,11 @@ class InstallerViewModel(
}

step(InstallStep.INSTALL_APK) {
logger.i("Gathering final apks")
val files = signedDir.listFiles()!!

logger.i("Installing apks")
val files = lspatchedDir.listFiles()
?.takeIf { it.isNotEmpty() }
?: throw Error("Missing APKs from LSPatch step; failure likely")

val installer: Installer = when (preferences.installMethod) {
InstallMethod.DEFAULT -> SessionInstaller(context)
InstallMethod.SHIZUKU -> ShizukuInstaller(context)
Expand Down

0 comments on commit 4909003

Please sign in to comment.