From 80b56b657598c44e88de781f05c7ef3c687b0597 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sun, 17 Jan 2021 22:15:13 +0100 Subject: [PATCH] Android: Move InstallWAD to a new WiiUtils class I'm trying to move away from dumping every native method in NativeLibrary. --- .../dolphinemu/dolphinemu/NativeLibrary.java | 2 -- .../dolphinemu/ui/main/MainPresenter.java | 5 ++--- .../dolphinemu/dolphinemu/utils/WiiUtils.java | 6 +++++ Source/Android/jni/CMakeLists.txt | 1 + Source/Android/jni/MainAndroid.cpp | 9 -------- Source/Android/jni/WiiUtils.cpp | 22 +++++++++++++++++++ 6 files changed, 31 insertions(+), 14 deletions(-) create mode 100644 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/WiiUtils.java create mode 100644 Source/Android/jni/WiiUtils.cpp diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java index 425551ff77..9a779e7f6b 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java @@ -444,8 +444,6 @@ public final class NativeLibrary public static native void ReloadLoggerConfig(); - public static native boolean InstallWAD(String file); - public static native boolean ConvertDiscImage(String inPath, String outPath, int platform, int format, int blockSize, int compression, int compressionLevel, boolean scrub, CompressCallback callback); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainPresenter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainPresenter.java index 1ded576794..9344a61e48 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainPresenter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainPresenter.java @@ -13,7 +13,6 @@ import androidx.appcompat.app.AlertDialog; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import org.dolphinemu.dolphinemu.BuildConfig; -import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting; import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag; @@ -22,9 +21,9 @@ import org.dolphinemu.dolphinemu.services.GameFileCacheService; import org.dolphinemu.dolphinemu.utils.AfterDirectoryInitializationRunner; import org.dolphinemu.dolphinemu.utils.ContentHandler; import org.dolphinemu.dolphinemu.utils.FileBrowserHelper; +import org.dolphinemu.dolphinemu.utils.WiiUtils; import java.util.Arrays; -import java.util.Set; public final class MainPresenter { @@ -162,7 +161,7 @@ public final class MainPresenter Thread installWADThread = new Thread(() -> { - if (NativeLibrary.InstallWAD(file)) + if (WiiUtils.installWAD(file)) { mainPresenterActivity.runOnUiThread( () -> Toast.makeText(mContext, R.string.wad_install_success, Toast.LENGTH_SHORT) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/WiiUtils.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/WiiUtils.java new file mode 100644 index 0000000000..6fc0b6d9ea --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/WiiUtils.java @@ -0,0 +1,6 @@ +package org.dolphinemu.dolphinemu.utils; + +public final class WiiUtils +{ + public static native boolean installWAD(String file); +} diff --git a/Source/Android/jni/CMakeLists.txt b/Source/Android/jni/CMakeLists.txt index 7f31a144aa..405d621958 100644 --- a/Source/Android/jni/CMakeLists.txt +++ b/Source/Android/jni/CMakeLists.txt @@ -5,6 +5,7 @@ add_library(main SHARED IniFile.cpp MainAndroid.cpp NativeConfig.cpp + WiiUtils.cpp ) target_link_libraries(main diff --git a/Source/Android/jni/MainAndroid.cpp b/Source/Android/jni/MainAndroid.cpp index 71c4fac565..ad91ce17c5 100644 --- a/Source/Android/jni/MainAndroid.cpp +++ b/Source/Android/jni/MainAndroid.cpp @@ -45,7 +45,6 @@ #include "Core/PowerPC/PowerPC.h" #include "Core/PowerPC/Profiler.h" #include "Core/State.h" -#include "Core/WiiUtils.h" #include "DiscIO/Blob.h" #include "DiscIO/Enums.h" @@ -596,14 +595,6 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ReloadLogger Common::Log::LogManager::Init(); } -JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_InstallWAD(JNIEnv* env, - jclass, - jstring jFile) -{ - const std::string path = GetJString(env, jFile); - return static_cast(WiiUtils::InstallWAD(path)); -} - JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ConvertDiscImage( JNIEnv* env, jclass, jstring jInPath, jstring jOutPath, jint jPlatform, jint jFormat, jint jBlockSize, jint jCompression, jint jCompressionLevel, jboolean jScrub, jobject jCallback) diff --git a/Source/Android/jni/WiiUtils.cpp b/Source/Android/jni/WiiUtils.cpp new file mode 100644 index 0000000000..c98dfe847c --- /dev/null +++ b/Source/Android/jni/WiiUtils.cpp @@ -0,0 +1,22 @@ +// Copyright 2021 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include + +#include + +#include "jni/AndroidCommon/AndroidCommon.h" + +#include "Core/WiiUtils.h" + +extern "C" { + +JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_utils_WiiUtils_installWAD(JNIEnv* env, + jclass, + jstring jFile) +{ + const std::string path = GetJString(env, jFile); + return static_cast(WiiUtils::InstallWAD(path)); +} +}