WiiUtils: Add doOnlineUpdate() function

This commit is contained in:
OatmealDome 2022-01-09 15:51:07 -05:00
parent 19e1809cdf
commit 2fc7671eaf
2 changed files with 22 additions and 0 deletions

View File

@ -25,4 +25,6 @@ public final class WiiUtils
public static native int importWiiSave(String file, BooleanSupplier canOverwrite);
public static native void importNANDBin(String file);
public static native int doOnlineUpdate(String region, WiiUpdateCallback callback);
}

View File

@ -8,6 +8,7 @@
#include "jni/AndroidCommon/AndroidCommon.h"
#include "jni/AndroidCommon/IDCache.h"
#include "Common/ScopeGuard.h"
#include "Core/HW/WiiSave.h"
#include "Core/WiiUtils.h"
#include "DiscIO/NANDImporter.h"
@ -108,4 +109,23 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_utils_WiiUtils_importNANDB
return "";
});
}
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_utils_WiiUtils_doOnlineUpdate(
JNIEnv* env, jclass, jstring jRegion, jobject jCallback)
{
const std::string region = GetJString(env, jRegion);
jobject jCallbackGlobal = env->NewGlobalRef(jCallback);
Common::ScopeGuard scope_guard([jCallbackGlobal, env] { env->DeleteGlobalRef(jCallbackGlobal); });
const auto callback = [&jCallbackGlobal](int processed, int total, u64 title_id) {
JNIEnv* env = IDCache::GetEnvForThread();
return static_cast<bool>(env->CallBooleanMethod(
jCallbackGlobal, IDCache::GetWiiUpdateCallbackFunction(), processed, total, title_id));
};
WiiUtils::UpdateResult result = WiiUtils::DoOnlineUpdate(callback, region);
return ConvertUpdateResult(result);
}
}