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) 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!") Log.w("GeodeLauncher", "could not load Geode object!")
} else {
throw e
} }
} }
@@ -209,26 +226,26 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
} }
@SuppressLint("UnsafeDynamicallyLoadedCode") @SuppressLint("UnsafeDynamicallyLoadedCode")
private fun loadGeodeLibrary(): Boolean { private fun loadGeodeLibrary() {
// Load Geode if exists // Load Geode if exists
// bundling the object with the application allows for nicer backtraces // bundling the object with the application allows for nicer backtraces
try { try {
// put libgeode.so in jniLibs/armeabi-v7a to get this // put libgeode.so in jniLibs/armeabi-v7a to get this
System.loadLibrary("geode") System.loadLibrary("geode")
return true return
} catch (e: UnsatisfiedLinkError) { } catch (e: UnsatisfiedLinkError) {
// but users may prefer it stored with data // but users may prefer it stored with data
val geodeFilename = LaunchUtils.geodeFilename val geodeFilename = LaunchUtils.geodeFilename
val geodePath = File(filesDir.path, "launcher/$geodeFilename") val geodePath = File(filesDir.path, "launcher/$geodeFilename")
if (geodePath.exists()) { if (geodePath.exists()) {
System.load(geodePath.path) System.load(geodePath.path)
return true return
} }
// you know zmx i have 0 clue what this does so im // you know zmx i have 0 clue what this does so im
// just gonna like copy the binary from external // just gonna like copy the binary from external
// also i get 20 million permission denied errors // 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") val copiedPath = File(filesDir.path, "copied")
if (copiedPath.exists()) { if (copiedPath.exists()) {
@@ -245,17 +262,14 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
) )
if (copiedGeodePath.exists()) { if (copiedGeodePath.exists()) {
try { println("Loading Geode from ${externalGeodePath.name}")
println("Loading Geode from ${externalGeodePath.name}") System.load(copiedGeodePath.path)
System.load(copiedGeodePath.path) return
} catch (e: UnsatisfiedLinkError) {
e.printStackTrace()
}
} }
} }
}
return false throw e
}
} }
private fun createView(): FrameLayout { private fun createView(): FrameLayout {
@@ -368,6 +368,10 @@ fun SettingsScreen(
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(){}<>[]?:;'\"~`-_+=\\| ".contains(c) "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(){}<>[]?:;'\"~`-_+=\\| ".contains(c)
}} }}
) )
SettingsCard(
title = stringResource(R.string.preference_ignore_load_failure_name),
preferenceKey = PreferenceUtils.Key.IGNORE_LOAD_FAILURE,
)
OptionsButton( OptionsButton(
title = context.getString(R.string.preferences_copy_external_button), title = context.getString(R.string.preferences_copy_external_button),
description = LaunchUtils.getBaseDirectory(context).path, description = LaunchUtils.getBaseDirectory(context).path,
@@ -134,7 +134,8 @@ class PreferenceUtils(private val sharedPreferences: SharedPreferences) {
CURRENT_RELEASE_MODIFIED, CURRENT_RELEASE_MODIFIED,
LAST_DISMISSED_UPDATE, LAST_DISMISSED_UPDATE,
DISMISSED_GJ_UPDATE, DISMISSED_GJ_UPDATE,
LAUNCH_ARGUMENTS LAUNCH_ARGUMENTS,
IGNORE_LOAD_FAILURE
} }
private fun defaultValueForBooleanKey(key: Key): Boolean { private fun defaultValueForBooleanKey(key: Key): Boolean {
@@ -159,6 +160,7 @@ class PreferenceUtils(private val sharedPreferences: SharedPreferences) {
Key.LAST_DISMISSED_UPDATE -> "PreferenceLastDismissedUpdate" Key.LAST_DISMISSED_UPDATE -> "PreferenceLastDismissedUpdate"
Key.DISMISSED_GJ_UPDATE -> "PreferenceDismissedGJUpdate" Key.DISMISSED_GJ_UPDATE -> "PreferenceDismissedGJUpdate"
Key.LAUNCH_ARGUMENTS -> "PreferenceLaunchArguments" Key.LAUNCH_ARGUMENTS -> "PreferenceLaunchArguments"
Key.IGNORE_LOAD_FAILURE -> "PreferenceIgnoreLoadFailure"
} }
} }
+3 -2
View File
@@ -46,11 +46,11 @@
<!-- GeometryDashActivity strings --> <!-- GeometryDashActivity strings -->
<string name="load_failed_link_error">Failed to link libraries</string> <string name="load_failed_link_error">Failed to link libraries</string>
<string name="load_failed_link_error_description">Game libraries could not be found. This may occur if the architecture of the launcher and Geometry Dash do not match, or from a system bug.\nCheck application logs for more details.</string> <string name="load_failed_link_error_description">Game libraries could not be found. This may occur if the architecture or version of the launcher and Geometry Dash do not match, or from a system bug.\nCheck application logs for more details.</string>
<string name="load_failed_abi_error_need_64bit_description">The architecture of the launcher and Geometry Dash do not match. Please reinstall Geometry Dash from the Play Store or use the 64-bit version of the launcher to resolve this issue.\nCheck application logs for more details.</string> <string name="load_failed_abi_error_need_64bit_description">The architecture of the launcher and Geometry Dash do not match. Please reinstall Geometry Dash from the Play Store or use the 64-bit version of the launcher to resolve this issue.\nCheck application logs for more details.</string>
<string name="load_failed_abi_error_need_32bit_description">The architecture of the launcher and Geometry Dash do not match. Please reinstall Geometry Dash from the Play Store or use the 32-bit version of the launcher to resolve this issue.\nCheck application logs for more details.</string> <string name="load_failed_abi_error_need_32bit_description">The architecture of the launcher and Geometry Dash do not match. Please reinstall Geometry Dash from the Play Store or use the 32-bit version of the launcher to resolve this issue.\nCheck application logs for more details.</string>
<string name="load_failed_generic_error">Load failed</string> <string name="load_failed_generic_error">Load failed</string>
<string name="load_failed_generic_error_description">Uncaught error during game load: `%1$s`.\nCheck application logs for more details. Please report this issue!</string> <string name="load_failed_generic_error_description">Uncaught error during game load: `%1$s`.\nCheck application logs for more details.</string>
<string name="message_box_cancel">Cancel</string> <string name="message_box_cancel">Cancel</string>
<string name="message_box_accept">OK</string> <string name="message_box_accept">OK</string>
@@ -93,6 +93,7 @@
<string name="preference_category_developer">Developer</string> <string name="preference_category_developer">Developer</string>
<string name="preference_launch_arguments_name">Launch arguments</string> <string name="preference_launch_arguments_name">Launch arguments</string>
<string name="preference_launch_arguments_set_title">Set launch arguments</string> <string name="preference_launch_arguments_set_title">Set launch arguments</string>
<string name="preference_ignore_load_failure_name">Ignore loader errors</string>
<!-- ApplicationLogsActivity strings --> <!-- ApplicationLogsActivity strings -->
<string name="title_activity_application_logs">Application Logs</string> <string name="title_activity_application_logs">Application Logs</string>