make geode load failures a hard error

This commit is contained in:
qimiko committed 2024-01-27 23:16:33 -07:00
1 parent 5521869ac9
commit 9dc501c9ab
4 files changed
+37 -16

No files matched your search

@@ -136,8 +136,25 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
setupPostLibraryLoad(gdPackageInfo)
if (!loadGeodeLibrary()) {
try {
loadGeodeLibrary()
} catch (e: UnsatisfiedLinkError) {
handleGeodeException(e)
} catch (e: Exception) {
handleGeodeException(e)
}
}
private fun handleGeodeException(e: Throwable) {
e.printStackTrace()
val ignoreFailure = PreferenceUtils.get(this)
.getBoolean(PreferenceUtils.Key.IGNORE_LOAD_FAILURE)
if (ignoreFailure) {
Log.w("GeodeLauncher", "could not load Geode object!")
} else {
throw e
}
}
@@ -209,26 +226,26 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
}
@SuppressLint("UnsafeDynamicallyLoadedCode")
private fun loadGeodeLibrary(): Boolean {
private fun loadGeodeLibrary() {
// Load Geode if exists
// bundling the object with the application allows for nicer backtraces
try {
// put libgeode.so in jniLibs/armeabi-v7a to get this
System.loadLibrary("geode")
return true
return
} catch (e: UnsatisfiedLinkError) {
// but users may prefer it stored with data
val geodeFilename = LaunchUtils.geodeFilename
val geodePath = File(filesDir.path, "launcher/$geodeFilename")
if (geodePath.exists()) {
System.load(geodePath.path)
return true
return
}
// you know zmx i have 0 clue what this does so im
// just gonna like copy the binary from external
// also i get 20 million permission denied errors
val externalGeodePath = LaunchUtils.getInstalledGeodePath(this) ?: return false
val externalGeodePath = LaunchUtils.getInstalledGeodePath(this)!!
val copiedPath = File(filesDir.path, "copied")
if (copiedPath.exists()) {
@@ -245,17 +262,14 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
)
if (copiedGeodePath.exists()) {
try {
println("Loading Geode from ${externalGeodePath.name}")
System.load(copiedGeodePath.path)
} catch (e: UnsatisfiedLinkError) {
e.printStackTrace()
}
println("Loading Geode from ${externalGeodePath.name}")
System.load(copiedGeodePath.path)
return
}
}
}
return false
throw e
}
}
private fun createView(): FrameLayout {
@@ -368,6 +368,10 @@ fun SettingsScreen(
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(){}<>[]?:;'\"~`-_+=\\| ".contains(c)
}}
)
SettingsCard(
title = stringResource(R.string.preference_ignore_load_failure_name),
preferenceKey = PreferenceUtils.Key.IGNORE_LOAD_FAILURE,
)
OptionsButton(
title = context.getString(R.string.preferences_copy_external_button),
description = LaunchUtils.getBaseDirectory(context).path,
@@ -134,7 +134,8 @@ class PreferenceUtils(private val sharedPreferences: SharedPreferences) {
CURRENT_RELEASE_MODIFIED,
LAST_DISMISSED_UPDATE,
DISMISSED_GJ_UPDATE,
LAUNCH_ARGUMENTS
LAUNCH_ARGUMENTS,
IGNORE_LOAD_FAILURE
}
private fun defaultValueForBooleanKey(key: Key): Boolean {
@@ -159,6 +160,7 @@ class PreferenceUtils(private val sharedPreferences: SharedPreferences) {
Key.LAST_DISMISSED_UPDATE -> "PreferenceLastDismissedUpdate"
Key.DISMISSED_GJ_UPDATE -> "PreferenceDismissedGJUpdate"
Key.LAUNCH_ARGUMENTS -> "PreferenceLaunchArguments"
Key.IGNORE_LOAD_FAILURE -> "PreferenceIgnoreLoadFailure"
}
}