feat: option to replace libc++

This commit is contained in:
rushii 2023-01-30 15:25:11 -08:00
parent bdf6b4ddcc
commit 70ca2496d5
No known key found for this signature in database
GPG key ID: DCBE5952BB3B6420
4 changed files with 25 additions and 14 deletions

View file

@ -11,9 +11,8 @@ class PreferencesManager(preferences: SharedPreferences) : BasePreferenceManager
var replaceIcon by booleanPreference("replace_icon", true)
var devMode by booleanPreference("dev_mode", false)
var debuggable by booleanPreference("debuggable", false)
var useDexFromStorage by booleanPreference("use_dex_from_storage", false)
var dexLocation by stringPreference("dex_location", "$aliucordDir/Injector.dex")
var appName by stringPreference("app_name", "Aliucord")
var packageName by stringPreference("package_name", "com.aliucord")
var version by stringPreference("version", "146108")
var hermesReplaceLibCpp by booleanPreference("hermes_replace_libcpp", false)
}

View file

@ -114,10 +114,17 @@ fun SettingsScreen(
label = stringResource(R.string.setting_debuggable),
secondaryLabel = stringResource(R.string.setting_debuggable_desc),
pref = preferences.debuggable,
icon = { Icon(Icons.Default.BugReport, null) }
) {
preferences.debuggable = it
}
icon = { Icon(Icons.Default.BugReport, null) },
onPrefChange = { preferences.debuggable = it },
)
SettingsSwitch(
label = stringResource(R.string.setting_hermes_replace_libcpp),
secondaryLabel = stringResource(R.string.setting_hermes_replace_libcpp_desc),
icon = { Icon(Icons.Default.FileCopy, null) },
pref = preferences.hermesReplaceLibCpp,
onPrefChange = { preferences.hermesReplaceLibCpp = it },
)
}
}

View file

@ -263,13 +263,15 @@ class InstallViewModel(
}
// Download the hermes-cppruntime-release.aar file to replace in the apk
val cppRuntime = cacheDir.resolve("hermes-cppruntime-release-${latestHermesRelease.tagName}.aar").also { file ->
if (file.exists()) return@also
cached = false
val cppRuntime = if (!preferences.hermesReplaceLibCpp) null else {
cacheDir.resolve("hermes-cppruntime-release-${latestHermesRelease.tagName}.aar").also { file ->
if (file.exists()) return@also
cached = false
latestHermesRelease.assets
.find { it.name == "hermes-cppruntime-release.aar" }!!.browserDownloadUrl
.also { downloadManager.download(it, file) }
latestHermesRelease.assets
.find { it.name == "hermes-cppruntime-release.aar" }!!.browserDownloadUrl
.also { downloadManager.download(it, file) }
}
}
hermes to cppRuntime
@ -386,6 +388,8 @@ class InstallViewModel(
ZipWriter(libsApkFile, true).use { libsApk ->
// Process the hermes and cpp runtime library
for (libFile in arrayOf(hermesLibrary, cppRuntimeLibrary)) {
libFile ?: continue
// Map .aar to the embedded .so inside
val binaryName = with(libFile.name) {
when {
@ -494,7 +498,6 @@ class InstallViewModel(
}
}
// Download the injector dex
val injectorFile = step(InstallStep.DL_INJECTOR) {
cacheDir.resolve("injector-${dataJson.aliucordHash}.dex").also { file ->

View file

@ -50,8 +50,10 @@
<string name="setting_theme_desc">Manager appearance</string>
<string name="setting_app_name">App Name</string>
<string name="setting_package_name">Package Name</string>
<string name="setting_target_version">Download Version</string>
<string name="setting_target_version">Download Version (RN only)</string>
<string name="setting_dynamic_color">Dynamic color</string>
<string name="setting_hermes_replace_libcpp">Replace libc++ (RN only)</string>
<string name="setting_hermes_replace_libcpp_desc">Downloads and uses libc++ from patched hermes</string>
<string name="settings_invalid_package_name">Invalid package name, reset to com.aliucord</string>
<string name="theme_system">System</string>