summaryrefslogtreecommitdiff
path: root/Source/Android/jni/ActivityTracker.cpp
blob: 20fc7df79ad2a749f49db9302173df89c8d2a172 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright 2024 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#include <jni.h>

#include "Common/Logging/Log.h"
#include "Core/AchievementManager.h"
#include "UICommon/UICommon.h"
#include "jni/Host.h"

extern "C" {

JNIEXPORT void JNICALL
Java_org_dolphinemu_dolphinemu_utils_ActivityTracker_setBackgroundExecutionAllowedNative(
    JNIEnv*, jclass, jboolean allowed)
{
  // This is called with allowed == false when the app goes into the background.
  // We use this to stop continuously running background threads so we don't waste battery.

  INFO_LOG_FMT(CORE, "SetBackgroundExecutionAllowed {}", allowed);
  AchievementManager::GetInstance().SetBackgroundExecutionAllowed(allowed);
}

JNIEXPORT void JNICALL
Java_org_dolphinemu_dolphinemu_utils_ActivityTracker_flushUnsavedData(JNIEnv*, jclass)
{
  HostThreadLock guard;
  UICommon::FlushUnsavedData();
}
}