feat:增加自定义linker注入
This commit is contained in:
@@ -13,6 +13,8 @@ import android.widget.ProgressBar;
|
||||
import android.app.Dialog;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -134,15 +136,24 @@ public class AppListFragment extends Fragment implements AppListAdapter.OnAppTog
|
||||
TextView packageName = dialogView.findViewById(R.id.packageName);
|
||||
RecyclerView soListRecyclerView = dialogView.findViewById(R.id.soListRecyclerView);
|
||||
TextView emptyText = dialogView.findViewById(R.id.emptyText);
|
||||
SwitchMaterial switchHideInjection = dialogView.findViewById(R.id.switchHideInjection);
|
||||
RadioGroup injectionMethodGroup = dialogView.findViewById(R.id.injectionMethodGroup);
|
||||
RadioButton radioStandardInjection = dialogView.findViewById(R.id.radioStandardInjection);
|
||||
RadioButton radioRiruInjection = dialogView.findViewById(R.id.radioRiruInjection);
|
||||
RadioButton radioCustomLinkerInjection = dialogView.findViewById(R.id.radioCustomLinkerInjection);
|
||||
|
||||
appIcon.setImageDrawable(appInfo.getAppIcon());
|
||||
appName.setText(appInfo.getAppName());
|
||||
packageName.setText(appInfo.getPackageName());
|
||||
|
||||
// Load current config
|
||||
boolean hideInjection = configManager.getHideInjection();
|
||||
switchHideInjection.setChecked(hideInjection);
|
||||
String injectionMethod = configManager.getAppInjectionMethod(appInfo.getPackageName());
|
||||
if ("custom_linker".equals(injectionMethod)) {
|
||||
radioCustomLinkerInjection.setChecked(true);
|
||||
} else if ("riru".equals(injectionMethod)) {
|
||||
radioRiruInjection.setChecked(true);
|
||||
} else {
|
||||
radioStandardInjection.setChecked(true);
|
||||
}
|
||||
|
||||
// Setup SO list
|
||||
List<ConfigManager.SoFile> globalSoFiles = configManager.getAllSoFiles();
|
||||
@@ -165,8 +176,16 @@ public class AppListFragment extends Fragment implements AppListAdapter.OnAppTog
|
||||
.setTitle("配置注入")
|
||||
.setView(dialogView)
|
||||
.setPositiveButton("保存", (dialog, which) -> {
|
||||
// Save hide injection setting
|
||||
configManager.setHideInjection(switchHideInjection.isChecked());
|
||||
// Save injection method
|
||||
String selectedMethod;
|
||||
if (radioCustomLinkerInjection.isChecked()) {
|
||||
selectedMethod = "custom_linker";
|
||||
} else if (radioRiruInjection.isChecked()) {
|
||||
selectedMethod = "riru";
|
||||
} else {
|
||||
selectedMethod = "standard";
|
||||
}
|
||||
configManager.setAppInjectionMethod(appInfo.getPackageName(), selectedMethod);
|
||||
|
||||
// Save SO selection
|
||||
if (soListRecyclerView.getAdapter() != null) {
|
||||
|
||||
@@ -227,6 +227,24 @@ public class ConfigManager {
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
public String getAppInjectionMethod(String packageName) {
|
||||
AppConfig appConfig = config.perAppConfig.get(packageName);
|
||||
if (appConfig == null) {
|
||||
return "standard"; // Default to standard
|
||||
}
|
||||
return appConfig.injectionMethod != null ? appConfig.injectionMethod : "standard";
|
||||
}
|
||||
|
||||
public void setAppInjectionMethod(String packageName, String method) {
|
||||
AppConfig appConfig = config.perAppConfig.get(packageName);
|
||||
if (appConfig == null) {
|
||||
appConfig = new AppConfig();
|
||||
config.perAppConfig.put(packageName, appConfig);
|
||||
}
|
||||
appConfig.injectionMethod = method;
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
// Copy SO files directly to app's data directory
|
||||
private void deploySoFilesToApp(String packageName) {
|
||||
AppConfig appConfig = config.perAppConfig.get(packageName);
|
||||
@@ -384,6 +402,7 @@ public class ConfigManager {
|
||||
public static class AppConfig {
|
||||
public boolean enabled = false;
|
||||
public List<SoFile> soFiles = new ArrayList<>();
|
||||
public String injectionMethod = "standard"; // "standard", "riru" or "custom_linker"
|
||||
}
|
||||
|
||||
public static class SoFile {
|
||||
|
||||
Reference in New Issue
Block a user