Skip to content

Commit

Permalink
Added error handling and an alertdialog when the two instances bug is…
Browse files Browse the repository at this point in the history
… hit
  • Loading branch information
amwatson committed Jan 21, 2024
1 parent bebe697 commit 12a9c59
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,17 @@ protected void onCreate(Bundle savedInstanceState) {
requestNotificationPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS);
}
}
// Check for the TWO_INSTANCES string extra
if (getIntent().getBooleanExtra(VrActivity.EXTRA_ERROR_TWO_INSTANCES, false)) {
Log.error("Error: two instances of CitraVr::VrActivity were running at the same time!");
// Show an alert dialog explaining the situation
new MaterialAlertDialogBuilder(this)
.setTitle(R.string.vr_error_two_instances_title)
.setMessage(R.string.vr_error_two_instances_message)
.setIcon(R.mipmap.ic_launcher)
.setPositiveButton(android.R.string.ok, null)
.show();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import org.citra.citra_emu.utils.Log;
public class VrActivity extends EmulationActivity {

public static final String EXTRA_ERROR_TWO_INSTANCES = "org.citra.citra_emu.vr.ERROR_TWO_INSTANCES";

private long mHandle = 0;
public static boolean hasRun = false;
public static VrActivity currentActivity = null;
Expand Down Expand Up @@ -56,13 +58,23 @@ public static void launch(Context context, final String gamePath, final String g
@Override
protected void onCreate(Bundle savedInstanceState) {
Log.info("VR [Java] onCreate()");
if (hasRun) {
super.onCreate(savedInstanceState);
if (hasRun) {
Log.info("VR [Java] VRActivity already existed");
finish();
// When we detect two instances running, due to bad cleanup
// handling, we have to terminate both of them. Restart the main
// activity with an error message telling the user what happened.
Intent relaunchMainIntent = new Intent(this, org.citra.citra_emu.ui.main.MainActivity.class);
relaunchMainIntent.putExtra(EXTRA_ERROR_TWO_INSTANCES, true);
startActivity(relaunchMainIntent);
if (currentActivity != null) {
currentActivity.finish();
}
return;
}
hasRun = true;
currentActivity = this;
super.onCreate(savedInstanceState);
mHandle = nativeOnCreate();
}

Expand Down
2 changes: 2 additions & 0 deletions src/android/app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,6 @@
<string name="vr_gamepad_warning">Probleme haben? Drücken Sie @string/button_start + @string/button_select im Gamepad, um die Eingangsmodi zu umschalten</string>
<string name="preferences_vr">Vr</string>
<string name="vr_background">VR -Umgebung</string>
<string name="vr_error_two_instances_title">Fehler: Erkennete zwei CitraVR -Instanzen</string>
<string name="vr_error_two_instances_message">Erkannte einen tödlichen Startfehler mit CitraVR. Dies ist ein bekanntes Problem. \n\nDas Problem ist jetzt gelöst. Bitte versuchen Sie, das Spiel erneut zu starten. </string>
</resources>
2 changes: 2 additions & 0 deletions src/android/app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,6 @@
<string name="vr_gamepad_warning">¿Teniendo problemas? Presione @string/button_start + @string/button_select en el gamepad para alternar los modos de entrada</string>
<string name="preferences_vr">VR</string>
<string name="vr_background">Entorno de realidad virtual</string>
<string name="vr_error_two_instances_title">Error: detectó dos instancias CitraVR</string>
<string name="vr_error_two_instances_message">Detectó un error de lanzamiento fatal con CitraVR. Este es un problema conocido. \n\nEl problema ahora se resuelve. Intente volver a lanzar el juego. </string>
</resources>
2 changes: 2 additions & 0 deletions src/android/app/src/main/res/values-fi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,6 @@
<!-- VR-specific -->
<string name="preferences_vr">VR</string>
<string name="vr_background">VR -ympäristö</string>
<string name="vr_error_two_instances_title">VIRHE: havaitsi kaksi CitraVR -tapausta</string>
<string name="vr_error_two_instances_message">Havaitsi kohtalokkaan käynnistysvirheen CitraVR: n kanssa. Tämä on tunnettu asia. \n\nongelma on nyt ratkaistu. Yritä käynnistää peli uudelleen. </string>
</resources>
2 changes: 2 additions & 0 deletions src/android/app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,6 @@
<string name="vr_gamepad_warning">Avoir des problèmes? Appuyez sur @string/button_start + @string/button_select sur le GamePad pour basculer les modes d\'entrée</string>
<string name="preferences_vr">VR</string>
<string name="vr_background">Environnement VR</string>
<string name="vr_error_two_instances_title">Erreur: détecté deux instances CitraVR</string>
<string name="vr_error_two_instances_message">Détecté un bogue de lancement fatal avec CitraVR. C\'est un problème connu. \n\nLe problème est désormais résolu. Veuillez essayer de lancer à nouveau le jeu. </string>
</resources>
2 changes: 2 additions & 0 deletions src/android/app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,6 @@
<string name="vr_gamepad_warning">Avere problemi? Premere @string/button_start + @string/button_select sul gamepad per attivare le modalità di input</string>
<string name="preferences_vr">VR</string>
<string name="vr_background">Ambiente VR</string>
<string name="vr_error_two_instances_title">Errore: rilevato due istanze CitraVR</string>
<string name="vr_error_two_instances_message">Ho rilevato un bug di lancio fatale con CitraVR. Questo è un problema noto. \n\nIl problema è ora risolto. Prova a lanciare di nuovo il gioco. </string>
</resources>
2 changes: 2 additions & 0 deletions src/android/app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,6 @@
<!-- VR-specific -->
<string name="preferences_vr">VR</string>
<string name="vr_background">VR環境</string>
<string name="vr_error_two_instances_title">エラー:2つのCitraVRインスタンスを検出しました</string>
<string name="vr_error_two_instances_message">CitraVRを使用した致命的な打ち上げバグを検出しました。これは既知の問題です。\n\n問題が解決されました。もう一度ゲームを起動してみてください。</string>
</resources>
2 changes: 2 additions & 0 deletions src/android/app/src/main/res/values-ko/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,6 @@
<string name="vr_gamepad_warning">문제가있다? 입력 모드를 전환하려면 게임 패드에서 @string/button_start + @string/button_select를 누릅니다.</string>
<string name="preferences_vr">VR</string>
<string name="vr_background">VR 환경</string>
<string name="vr_error_two_instances_title">오류 : 두 개의 CitraVR 인스턴스를 감지했습니다</string>
<string name="vr_error_two_instances_message">CitraVR로 치명적인 발사 버그를 감지했습니다. 이것은 알려진 문제입니다. \n\n이제 문제가 해결되었습니다. 게임을 다시 시작하십시오. </string>
</resources>
2 changes: 2 additions & 0 deletions src/android/app/src/main/res/values-nb/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,6 @@
<string name="vr_gamepad_warning">Har problemer? Trykk @string/button_start + @string/button_select på gamepad for å veksle inngangsmodus</string>
<string name="preferences_vr">VR</string>
<string name="vr_background">VR -miljø</string>
<string name="vr_error_two_instances_title">Feil: oppdaget to CitraVR -forekomster</string>
<string name="vr_error_two_instances_message">Oppdaget en dødelig lanseringsfeil med CitraVR. Dette er et kjent spørsmål. \n\nProblemet er nå løst. Vennligst prøv å starte spillet igjen. </string>
</resources>
2 changes: 2 additions & 0 deletions src/android/app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,6 @@
<string name="vr_gamepad_warning">Tendo problemas? Pressione @string/button_start + @string/button_select no gamepad para alternar os modos de entrada</string>
<string name="preferences_vr">Vr</string>
<string name="vr_background">Ambiente VR</string>
<string name="vr_error_two_instances_title">Erro: detectado duas instâncias de CitraVR</string>
<string name="vr_error_two_instances_message">Detectou um bug de lançamento fatal com CitraVR. Este é um problema conhecido. \n\nO problema agora está resolvido. Por favor, tente lançar o jogo novamente. </string>
</resources>
2 changes: 2 additions & 0 deletions src/android/app/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,6 @@
<string name="vr_gamepad_warning">遇到麻烦?按@string/button_start + @string/button_select在GamePad上的@string/button_select切换输入模式</string>
<string name="preferences_vr">VR</string>
<string name="vr_background">VR环境</string>
<string name="vr_error_two_instances_title">错误:检测到两个CitraVR实例</string>
<string name="vr_error_two_instances_message">通过CitraVR检测到致命的发射错误。这是一个已知的问题。\n\n现在解决了问题。请尝试再次启动游戏。</string>
</resources>
2 changes: 2 additions & 0 deletions src/android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,6 @@
<string name="vr_background">VR Environment</string>
<string name="vr_keyboard_left">&lt;</string>
<string name="vr_keyboard_right">&gt;</string>
<string name="vr_error_two_instances_title">Error: Detected Two CitraVR Instances</string>
<string name="vr_error_two_instances_message">Detected a fatal launch bug with CitraVR. This is a known issue. \n\nThe problem is now resolved. Please try launching the game again. </string>
</resources>

0 comments on commit 12a9c59

Please sign in to comment.