[Base] Android error reporting via SIGABRT/RuntimeException
This commit is contained in:
parent
c5e3332640
commit
d2ef8d3300
|
@ -0,0 +1,21 @@
|
||||||
|
package jp.xenia;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for all unchecked exceptions thrown by the Xenia project components.
|
||||||
|
*/
|
||||||
|
public class XeniaRuntimeException extends RuntimeException {
|
||||||
|
public XeniaRuntimeException() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public XeniaRuntimeException(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public XeniaRuntimeException(String name, Throwable cause) {
|
||||||
|
super(name, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public XeniaRuntimeException(Exception cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,11 +3,10 @@ package jp.xenia.emulator;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
|
||||||
|
import jp.xenia.XeniaRuntimeException;
|
||||||
|
|
||||||
public abstract class WindowedAppActivity extends Activity {
|
public abstract class WindowedAppActivity extends Activity {
|
||||||
private static final String TAG = "WindowedAppActivity";
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// TODO(Triang3l): Move all demos to libxenia.so.
|
// TODO(Triang3l): Move all demos to libxenia.so.
|
||||||
System.loadLibrary("xenia-ui-window-vulkan-demo");
|
System.loadLibrary("xenia-ui-window-vulkan-demo");
|
||||||
|
@ -26,11 +25,12 @@ public abstract class WindowedAppActivity extends Activity {
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
mAppContext = initializeWindowedAppOnCreateNative(getWindowedAppIdentifier(), getAssets());
|
final String windowedAppIdentifier = getWindowedAppIdentifier();
|
||||||
|
mAppContext = initializeWindowedAppOnCreateNative(windowedAppIdentifier, getAssets());
|
||||||
if (mAppContext == 0) {
|
if (mAppContext == 0) {
|
||||||
Log.e(TAG, "Error initializing the windowed app");
|
|
||||||
finish();
|
finish();
|
||||||
return;
|
throw new XeniaRuntimeException(
|
||||||
|
"Error initializing the windowed app " + windowedAppIdentifier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -500,7 +501,13 @@ void FatalError(const std::string_view str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ShutdownLogging();
|
ShutdownLogging();
|
||||||
std::exit(1);
|
|
||||||
|
#if XE_PLATFORM_ANDROID
|
||||||
|
// Throw an error that can be reported to the developers via the store.
|
||||||
|
std::abort();
|
||||||
|
#else
|
||||||
|
std::exit(EXIT_FAILURE);
|
||||||
|
#endif // XE_PLATFORM_ANDROID
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace xe
|
} // namespace xe
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* Xenia : Xbox 360 Emulator Research Project *
|
||||||
|
******************************************************************************
|
||||||
|
* Copyright 2022 Ben Vanik. All rights reserved. *
|
||||||
|
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
#include "xenia/base/assert.h"
|
||||||
|
#include "xenia/base/system.h"
|
||||||
|
|
||||||
|
namespace xe {
|
||||||
|
|
||||||
|
void LaunchWebBrowser(const std::string_view url) {
|
||||||
|
// TODO(Triang3l): Intent.ACTION_VIEW (need a Java VM for the thread -
|
||||||
|
// possibly restrict this to the UI thread).
|
||||||
|
assert_always();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LaunchFileExplorer(const std::filesystem::path& path) { assert_always(); }
|
||||||
|
|
||||||
|
void ShowSimpleMessageBox(SimpleMessageBoxType type, std::string_view message) {
|
||||||
|
// TODO(Triang3l): Likely not needed much at all. ShowSimpleMessageBox is a
|
||||||
|
// concept pretty unfriendly to platforms like Android because it's blocking,
|
||||||
|
// and because it can be called from threads other than the UI thread. In the
|
||||||
|
// normal execution flow, dialogs should preferably be asynchronous, and used
|
||||||
|
// only in the UI thread. However, non-blocking messages may be good for error
|
||||||
|
// reporting - investigate the usage of Toasts with respect to threads, and
|
||||||
|
// aborting the process immediately after showing a Toast. For a Toast, the
|
||||||
|
// Java VM for the calling thread is needed.
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace xe
|
Loading…
Reference in New Issue