Android: Detect when native code should flush unsaved data
This commit is contained in:
parent
c9bdda63dc
commit
cc77248ee2
|
@ -49,10 +49,21 @@ class ActivityTracker : ActivityLifecycleCallbacks {
|
||||||
|
|
||||||
override fun onActivitySaveInstanceState(activity: Activity, bundle: Bundle) {}
|
override fun onActivitySaveInstanceState(activity: Activity, bundle: Bundle) {}
|
||||||
|
|
||||||
|
override fun onActivityPostSaveInstanceState(activity: Activity, bundle: Bundle) {
|
||||||
|
if (DirectoryInitialization.areDolphinDirectoriesReady() &&
|
||||||
|
!activity.isChangingConfigurations
|
||||||
|
) {
|
||||||
|
flushUnsavedData()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onActivityDestroyed(activity: Activity) {}
|
override fun onActivityDestroyed(activity: Activity) {}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
external fun setBackgroundExecutionAllowedNative(allowed: Boolean)
|
external fun setBackgroundExecutionAllowedNative(allowed: Boolean)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
external fun flushUnsavedData()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
#include "Common/Logging/Log.h"
|
#include "Common/Logging/Log.h"
|
||||||
#include "Core/AchievementManager.h"
|
#include "Core/AchievementManager.h"
|
||||||
|
#include "UICommon/UICommon.h"
|
||||||
|
#include "jni/Host.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
|
@ -18,4 +20,11 @@ Java_org_dolphinemu_dolphinemu_utils_ActivityTracker_setBackgroundExecutionAllow
|
||||||
INFO_LOG_FMT(CORE, "SetBackgroundExecutionAllowed {}", allowed);
|
INFO_LOG_FMT(CORE, "SetBackgroundExecutionAllowed {}", allowed);
|
||||||
AchievementManager::GetInstance().SetBackgroundExecutionAllowed(allowed);
|
AchievementManager::GetInstance().SetBackgroundExecutionAllowed(allowed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT void JNICALL
|
||||||
|
Java_org_dolphinemu_dolphinemu_utils_ActivityTracker_flushUnsavedData(JNIEnv*, jclass)
|
||||||
|
{
|
||||||
|
HostThreadLock guard;
|
||||||
|
UICommon::FlushUnsavedData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,6 +158,11 @@ void Shutdown()
|
||||||
Config::Shutdown();
|
Config::Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FlushUnsavedData()
|
||||||
|
{
|
||||||
|
INFO_LOG_FMT(CORE, "Flushing unsaved data...");
|
||||||
|
}
|
||||||
|
|
||||||
void InitControllers(const WindowSystemInfo& wsi)
|
void InitControllers(const WindowSystemInfo& wsi)
|
||||||
{
|
{
|
||||||
if (g_controller_interface.IsInit())
|
if (g_controller_interface.IsInit())
|
||||||
|
|
|
@ -14,6 +14,8 @@ namespace UICommon
|
||||||
void Init();
|
void Init();
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
|
||||||
|
void FlushUnsavedData();
|
||||||
|
|
||||||
void InitControllers(const WindowSystemInfo& wsi);
|
void InitControllers(const WindowSystemInfo& wsi);
|
||||||
void ShutdownControllers();
|
void ShutdownControllers();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue