Update proguard

This commit is contained in:
Nullptr 2022-04-06 11:14:21 +08:00
parent c88e63e1ee
commit 774afca739
7 changed files with 26 additions and 37 deletions

View File

@ -86,6 +86,7 @@ public abstract class SigningOptions {
public abstract RunnablesExecutor getExecutor();
/** SDK dependencies of the APK */
@SuppressWarnings("mutable")
@Nullable
public abstract byte[] getSdkDependencyData();

View File

@ -10,8 +10,8 @@ android {
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
isMinifyEnabled = true
proguardFiles("proguard-rules.pro")
}
}
}
@ -22,7 +22,10 @@ androidComponents.onVariants { variant ->
task<Copy>("copyDex$variantCapped") {
dependsOn("assemble$variantCapped")
from("$buildDir/intermediates/dex/$variantLowered/mergeDex$variantCapped/classes.dex")
val dexOutPath = if (variant.buildType == "release")
"$buildDir/intermediates/dex/$variantLowered/minify${variantCapped}WithR8" else
"$buildDir/intermediates/dex/$variantLowered/mergeDex$variantCapped"
from(dexOutPath)
rename("classes.dex", "loader.dex")
into("${rootProject.projectDir}/out/assets/dex")
}
@ -38,6 +41,4 @@ androidComponents.onVariants { variant ->
dependencies {
compileOnly(projects.hiddenapi.stubs)
implementation("de.upb.cs.swt:axml:2.1.2")
}

View File

@ -1,21 +1,4 @@
# 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
-keep class org.lsposed.lspatch.appstub.LSPAppComponentFactoryStub {
public static byte[] dex;
<init>();
}

View File

@ -1,5 +1,6 @@
-keep class com.beust.jcommander.** { *; }
-keep class org.lsposed.lspatch.Patcher$Options { *; }
-keep class org.lsposed.lspatch.share.PatchConfig { *; }
-keepclassmembers class org.lsposed.patch.LSPatch {
private <fields>;
}

View File

@ -5,6 +5,7 @@ import static org.lsposed.lspatch.share.Constants.MANAGER_PACKAGE_NAME;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.IBinder;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
@ -13,6 +14,8 @@ import android.util.Log;
import org.lsposed.lspd.models.Module;
import org.lsposed.lspd.service.ILSPApplicationService;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class RemoteApplicationService implements ILSPApplicationService {
@ -26,34 +29,34 @@ public class RemoteApplicationService implements ILSPApplicationService {
Bundle back = context.getContentResolver().call(PROVIDER, "getBinder", null, null);
service = ILSPApplicationService.Stub.asInterface(back.getBinder("binder"));
if (service == null) throw new RemoteException("Binder is null");
} catch (RemoteException e) {
} catch (Throwable e) {
Log.e("LSPatch", "Error when initializing RemoteApplicationServiceClient", e);
}
}
@Override
public IBinder requestModuleBinder(String name) {
return service.asBinder();
return service == null ? null : service.asBinder();
}
@Override
public List<Module> getModulesList() throws RemoteException {
return service.getModulesList();
return service == null ? new ArrayList<>() : service.getModulesList();
}
@Override
public String getPrefsPath(String packageName) throws RemoteException {
return service.getPrefsPath(packageName);
public String getPrefsPath(String packageName) {
return new File(Environment.getDataDirectory(), "data/" + packageName + "/shared_prefs/").getAbsolutePath();
}
@Override
public Bundle requestRemotePreference(String packageName, int userId, IBinder callback) throws RemoteException {
return service.requestRemotePreference(packageName, userId, callback);
return service == null ? null : service.requestRemotePreference(packageName, userId, callback);
}
@Override
public IBinder asBinder() {
return service.asBinder();
return service == null ? null : service.asBinder();
}
@Override

View File

@ -285,7 +285,7 @@ public class LSPatch {
throw new PatchError("Error when saving config");
}
Set<String> apkArchs = new HashSet<>();
Set<String> apkArches = new HashSet<>();
logger.d("Search target apk library arch...");
@ -293,11 +293,11 @@ public class LSPatch {
var name = storedEntry.getCentralDirectoryHeader().getName();
if (name.startsWith("lib/") && name.length() >= 5) {
var arch = name.substring(4, name.indexOf('/', 5));
apkArchs.add(arch);
apkArches.add(arch);
}
}
if (apkArchs.isEmpty()) apkArchs.addAll(ARCHES);
apkArchs.removeIf((arch) -> {
if (apkArches.isEmpty()) apkArches.addAll(ARCHES);
apkArches.removeIf((arch) -> {
if (!ARCHES.contains(arch) && !arch.equals("armeabi")) {
logger.e("Warning: unsupported arch " + arch + ". Skipping...");
return true;