add restart with safe mode util

This commit is contained in:
Chloe committed 2026-10-16 17:48:35 -05:00
1 parent 3194dff7ff
commit bca761f26a
2 files changed
+10 -2

No files matched your search

@@ -104,8 +104,10 @@ class MainActivity : ComponentActivity() {
val gdInstalled = GamePackageUtils.isGameInstalled(packageManager) val gdInstalled = GamePackageUtils.isGameInstalled(packageManager)
val geodeInstalled = LaunchUtils.isGeodeInstalled(this) val geodeInstalled = LaunchUtils.isGeodeInstalled(this)
if (gdInstalled && geodeInstalled && intent.getBooleanExtra("restarted", false)) { val restartImmediately = intent.getBooleanExtra("restarted", false)
onLaunch(this) if (gdInstalled && geodeInstalled && restartImmediately) {
val withSafeMode = intent.getBooleanExtra("safe-mode", false)
onLaunch(this, withSafeMode)
} }
enableEdgeToEdge() enableEdgeToEdge()
@@ -191,10 +191,16 @@ object GeodeUtils {
@JvmStatic @JvmStatic
fun restartGame() { fun restartGame() {
restartGame(true)
}
@JvmStatic
fun restartGame(safeMode: Boolean) {
activity.get()?.run { activity.get()?.run {
packageManager.getLaunchIntentForPackage(packageName)?.also { packageManager.getLaunchIntentForPackage(packageName)?.also {
val mainIntent = Intent.makeRestartActivityTask(it.component) val mainIntent = Intent.makeRestartActivityTask(it.component)
mainIntent.putExtra("restarted", true) mainIntent.putExtra("restarted", true)
mainIntent.putExtra("safe-mode", safeMode)
startActivity(mainIntent) startActivity(mainIntent)
exitProcess(0) exitProcess(0)
} }