Compare commits

...

6 Commits

Author SHA1 Message Date
Simonx22
c01100b82e
Merge a7d1c1cf1e into 0fdf1cc386 2025-11-15 10:23:40 -05:00
JosJuice
0fdf1cc386
Merge pull request #14112 from Simonx22/android/remove-unused-bimap-class
Android: Remove unused BiMap class
2025-11-15 16:22:17 +01:00
JosJuice
999e13b3b3
Merge pull request #14109 from OatmealDome/analytics-deadlock
DolphinAnalytics: Only call ReloadConfig in config changed callback when analytics enabled value changes
2025-11-15 14:44:54 +01:00
Simonx22
a7d1c1cf1e Android: Swap own JNI BooleanSupplier to java.util.function 2025-11-12 18:25:48 -05:00
Simonx22
d1526157df Android: Remove unused BiMap class 2025-11-12 17:26:05 -05:00
OatmealDome
df5f351add
DolphinAnalytics: Only call ReloadConfig in config changed callback when analytics enabled value changes
Co-authored-by: Simonx22 <simon@oatmealdome.me>
2025-11-12 00:09:41 -05:00
10 changed files with 25 additions and 52 deletions

View File

@ -35,6 +35,7 @@ import org.dolphinemu.dolphinemu.model.GpuDriverMetadata
import org.dolphinemu.dolphinemu.ui.main.MainPresenter
import org.dolphinemu.dolphinemu.utils.*
import java.util.*
import java.util.function.BooleanSupplier
import kotlin.collections.ArrayList
import kotlin.math.ceil
import kotlin.math.floor
@ -2593,7 +2594,7 @@ class SettingsFragmentPresenter(
fragmentView.fragmentActivity,
R.string.wii_converting,
0,
{ context.resources.getString(if (f.get()) R.string.wii_convert_success else R.string.wii_convert_failure) }
{ context.resources.getString(if (f.getAsBoolean()) R.string.wii_convert_success else R.string.wii_convert_failure) }
)
}

View File

@ -21,7 +21,7 @@ import org.dolphinemu.dolphinemu.fragments.AboutDialogFragment
import org.dolphinemu.dolphinemu.model.GameFileCache
import org.dolphinemu.dolphinemu.services.GameFileCacheManager
import org.dolphinemu.dolphinemu.utils.AfterDirectoryInitializationRunner
import org.dolphinemu.dolphinemu.utils.BooleanSupplier
import java.util.function.BooleanSupplier
import org.dolphinemu.dolphinemu.utils.CompletableFuture
import org.dolphinemu.dolphinemu.utils.ContentHandler
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization

View File

@ -1,29 +0,0 @@
// SPDX-License-Identifier: GPL-2.0-or-later
package org.dolphinemu.dolphinemu.utils;
import java.util.HashMap;
import java.util.Map;
public class BiMap<K, V>
{
private Map<K, V> forward = new HashMap<>();
private Map<V, K> backward = new HashMap<>();
public synchronized void add(K key, V value)
{
forward.put(key, value);
backward.put(value, key);
}
public synchronized V getForward(K key)
{
return forward.get(key);
}
public synchronized K getBackward(V key)
{
return backward.get(key);
}
}

View File

@ -1,11 +0,0 @@
// SPDX-License-Identifier: GPL-2.0-or-later
package org.dolphinemu.dolphinemu.utils;
import androidx.annotation.Keep;
public interface BooleanSupplier
{
@Keep
boolean get();
}

View File

@ -2,6 +2,8 @@
package org.dolphinemu.dolphinemu.utils
import java.util.function.BooleanSupplier
object WiiUtils {
const val RESULT_SUCCESS = 0
const val RESULT_ERROR = 1

View File

@ -52,7 +52,7 @@ static jmethodID s_network_helper_get_network_prefix_length;
static jmethodID s_network_helper_get_network_gateway;
static jclass s_boolean_supplier_class;
static jmethodID s_boolean_supplier_get;
static jmethodID s_boolean_supplier_get_as_boolean;
static jclass s_ar_cheat_class;
static jfieldID s_ar_cheat_pointer;
@ -310,9 +310,9 @@ jmethodID GetNetworkHelperGetNetworkGateway()
return s_network_helper_get_network_gateway;
}
jmethodID GetBooleanSupplierGet()
jmethodID GetBooleanSupplierGetAsBoolean()
{
return s_boolean_supplier_get;
return s_boolean_supplier_get_as_boolean;
}
jclass GetARCheatClass()
@ -669,10 +669,10 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved)
env->GetStaticMethodID(s_network_helper_class, "GetNetworkGateway", "()I");
env->DeleteLocalRef(network_helper_class);
const jclass boolean_supplier_class =
env->FindClass("org/dolphinemu/dolphinemu/utils/BooleanSupplier");
const jclass boolean_supplier_class = env->FindClass("java/util/function/BooleanSupplier");
s_boolean_supplier_class = reinterpret_cast<jclass>(env->NewGlobalRef(boolean_supplier_class));
s_boolean_supplier_get = env->GetMethodID(s_boolean_supplier_class, "get", "()Z");
s_boolean_supplier_get_as_boolean =
env->GetMethodID(s_boolean_supplier_class, "getAsBoolean", "()Z");
env->DeleteLocalRef(boolean_supplier_class);
const jclass ar_cheat_class =

View File

@ -51,7 +51,7 @@ jmethodID GetNetworkHelperGetNetworkIpAddress();
jmethodID GetNetworkHelperGetNetworkPrefixLength();
jmethodID GetNetworkHelperGetNetworkGateway();
jmethodID GetBooleanSupplierGet();
jmethodID GetBooleanSupplierGetAsBoolean();
jclass GetARCheatClass();
jfieldID GetARCheatPointer();

View File

@ -87,7 +87,7 @@ JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_utils_WiiUtils_importWiiSa
{
const std::string path = GetJString(env, jFile);
const auto can_overwrite = [&] {
const jmethodID get = IDCache::GetBooleanSupplierGet();
const jmethodID get = IDCache::GetBooleanSupplierGetAsBoolean();
return static_cast<bool>(env->CallBooleanMethod(jCanOverwrite, get));
};

View File

@ -57,10 +57,19 @@ void DolphinAnalytics::AndroidSetGetValFunc(std::function<std::string(std::strin
DolphinAnalytics::DolphinAnalytics()
{
m_last_analytics_enabled = Config::Get(Config::MAIN_ANALYTICS_ENABLED);
ReloadConfig();
MakeBaseBuilder();
m_config_changed_callback_id = Config::AddConfigChangedCallback([this] { ReloadConfig(); });
m_config_changed_callback_id = Config::AddConfigChangedCallback([this] {
bool current_analytics_enabled = Config::Get(Config::MAIN_ANALYTICS_ENABLED);
if (m_last_analytics_enabled != current_analytics_enabled)
{
m_last_analytics_enabled = current_analytics_enabled;
ReloadConfig();
}
});
}
DolphinAnalytics::~DolphinAnalytics()
@ -80,7 +89,7 @@ void DolphinAnalytics::ReloadConfig()
// Install the HTTP backend if analytics support is enabled.
std::unique_ptr<Common::AnalyticsReportingBackend> new_backend;
if (Config::Get(Config::MAIN_ANALYTICS_ENABLED))
if (m_last_analytics_enabled)
{
new_backend = std::make_unique<Common::HttpAnalyticsBackend>(ANALYTICS_ENDPOINT);
}

View File

@ -203,4 +203,5 @@ private:
std::mutex m_reporter_mutex;
Common::AnalyticsReporter m_reporter;
Config::ConfigChangedCallbackID m_config_changed_callback_id{};
bool m_last_analytics_enabled = false;
};