mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-28 06:41:15 +00:00
Android: Finish EmulationActivity from C++
This makes EmulationActivity automatically close if booting fails, and lets us get rid of s_emulation_end_event.
This commit is contained in:
parent
a9ef7e0e43
commit
0280f3557c
@ -563,6 +563,20 @@ public final class NativeLibrary
|
|||||||
sEmulationActivity.clear();
|
sEmulationActivity.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void finishEmulationActivity()
|
||||||
|
{
|
||||||
|
final EmulationActivity emulationActivity = sEmulationActivity.get();
|
||||||
|
if (emulationActivity == null)
|
||||||
|
{
|
||||||
|
Log.warning("[NativeLibrary] EmulationActivity is null.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log.verbose("[NativeLibrary] Finishing EmulationActivity.");
|
||||||
|
emulationActivity.runOnUiThread(emulationActivity::finish);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void updateTouchPointer()
|
public static void updateTouchPointer()
|
||||||
{
|
{
|
||||||
final EmulationActivity emulationActivity = sEmulationActivity.get();
|
final EmulationActivity emulationActivity = sEmulationActivity.get();
|
||||||
|
@ -342,7 +342,6 @@ public final class EmulationActivity extends AppCompatActivity
|
|||||||
if (keyCode == KeyEvent.KEYCODE_BACK)
|
if (keyCode == KeyEvent.KEYCODE_BACK)
|
||||||
{
|
{
|
||||||
mEmulationFragment.stopEmulation();
|
mEmulationFragment.stopEmulation();
|
||||||
finish();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return super.onKeyLongPress(keyCode, event);
|
return super.onKeyLongPress(keyCode, event);
|
||||||
@ -617,7 +616,6 @@ public final class EmulationActivity extends AppCompatActivity
|
|||||||
|
|
||||||
case MENU_ACTION_EXIT:
|
case MENU_ACTION_EXIT:
|
||||||
mEmulationFragment.stopEmulation();
|
mEmulationFragment.stopEmulation();
|
||||||
finish();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ static jmethodID s_display_alert_msg;
|
|||||||
static jmethodID s_do_rumble;
|
static jmethodID s_do_rumble;
|
||||||
static jmethodID s_update_touch_pointer;
|
static jmethodID s_update_touch_pointer;
|
||||||
static jmethodID s_on_title_changed;
|
static jmethodID s_on_title_changed;
|
||||||
|
static jmethodID s_finish_emulation_activity;
|
||||||
|
|
||||||
static jclass s_game_file_class;
|
static jclass s_game_file_class;
|
||||||
static jfieldID s_game_file_pointer;
|
static jfieldID s_game_file_pointer;
|
||||||
@ -94,6 +95,11 @@ jmethodID GetOnTitleChanged()
|
|||||||
return s_on_title_changed;
|
return s_on_title_changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jmethodID GetFinishEmulationActivity()
|
||||||
|
{
|
||||||
|
return s_finish_emulation_activity;
|
||||||
|
}
|
||||||
|
|
||||||
jclass GetAnalyticsClass()
|
jclass GetAnalyticsClass()
|
||||||
{
|
{
|
||||||
return s_analytics_class;
|
return s_analytics_class;
|
||||||
@ -221,6 +227,8 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved)
|
|||||||
s_update_touch_pointer =
|
s_update_touch_pointer =
|
||||||
env->GetStaticMethodID(s_native_library_class, "updateTouchPointer", "()V");
|
env->GetStaticMethodID(s_native_library_class, "updateTouchPointer", "()V");
|
||||||
s_on_title_changed = env->GetStaticMethodID(s_native_library_class, "onTitleChanged", "()V");
|
s_on_title_changed = env->GetStaticMethodID(s_native_library_class, "onTitleChanged", "()V");
|
||||||
|
s_finish_emulation_activity =
|
||||||
|
env->GetStaticMethodID(s_native_library_class, "finishEmulationActivity", "()V");
|
||||||
env->DeleteLocalRef(native_library_class);
|
env->DeleteLocalRef(native_library_class);
|
||||||
|
|
||||||
const jclass game_file_class = env->FindClass("org/dolphinemu/dolphinemu/model/GameFile");
|
const jclass game_file_class = env->FindClass("org/dolphinemu/dolphinemu/model/GameFile");
|
||||||
|
@ -15,6 +15,7 @@ jmethodID GetDisplayAlertMsg();
|
|||||||
jmethodID GetDoRumble();
|
jmethodID GetDoRumble();
|
||||||
jmethodID GetUpdateTouchPointer();
|
jmethodID GetUpdateTouchPointer();
|
||||||
jmethodID GetOnTitleChanged();
|
jmethodID GetOnTitleChanged();
|
||||||
|
jmethodID GetFinishEmulationActivity();
|
||||||
|
|
||||||
jclass GetAnalyticsClass();
|
jclass GetAnalyticsClass();
|
||||||
jmethodID GetSendAnalyticsReport();
|
jmethodID GetSendAnalyticsReport();
|
||||||
|
@ -77,7 +77,6 @@ ANativeWindow* s_surf;
|
|||||||
// sequentially for access.
|
// sequentially for access.
|
||||||
std::mutex s_host_identity_lock;
|
std::mutex s_host_identity_lock;
|
||||||
Common::Event s_update_main_frame_event;
|
Common::Event s_update_main_frame_event;
|
||||||
Common::Event s_emulation_end_event;
|
|
||||||
bool s_have_wm_user_stop = false;
|
bool s_have_wm_user_stop = false;
|
||||||
bool s_game_metadata_is_valid = false;
|
bool s_game_metadata_is_valid = false;
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
@ -210,17 +209,11 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_PauseEmulati
|
|||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_StopEmulation(JNIEnv*, jclass)
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_StopEmulation(JNIEnv*, jclass)
|
||||||
{
|
{
|
||||||
{
|
std::lock_guard<std::mutex> guard(s_host_identity_lock);
|
||||||
std::lock_guard<std::mutex> guard(s_host_identity_lock);
|
Core::Stop();
|
||||||
s_emulation_end_event.Reset();
|
|
||||||
Core::Stop();
|
|
||||||
|
|
||||||
// Kick the waiting event
|
// Kick the waiting event
|
||||||
s_update_main_frame_event.Set();
|
s_update_main_frame_event.Set();
|
||||||
}
|
|
||||||
|
|
||||||
// Wait for shutdown, to avoid accessing the config at the same time as the shutdown code
|
|
||||||
s_emulation_end_event.Wait();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_IsBooting(JNIEnv*, jclass)
|
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_IsBooting(JNIEnv*, jclass)
|
||||||
@ -533,7 +526,8 @@ static void Run(JNIEnv* env, const std::vector<std::string>& paths,
|
|||||||
s_surf = nullptr;
|
s_surf = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
s_emulation_end_event.Set();
|
env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(),
|
||||||
|
IDCache::GetFinishEmulationActivity());
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run___3Ljava_lang_String_2(
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run___3Ljava_lang_String_2(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user