WiiUtils: Add doOnlineUpdate() function
This commit is contained in:
parent
19e1809cdf
commit
2fc7671eaf
|
@ -25,4 +25,6 @@ public final class WiiUtils
|
||||||
public static native int importWiiSave(String file, BooleanSupplier canOverwrite);
|
public static native int importWiiSave(String file, BooleanSupplier canOverwrite);
|
||||||
|
|
||||||
public static native void importNANDBin(String file);
|
public static native void importNANDBin(String file);
|
||||||
|
|
||||||
|
public static native int doOnlineUpdate(String region, WiiUpdateCallback callback);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "jni/AndroidCommon/AndroidCommon.h"
|
#include "jni/AndroidCommon/AndroidCommon.h"
|
||||||
#include "jni/AndroidCommon/IDCache.h"
|
#include "jni/AndroidCommon/IDCache.h"
|
||||||
|
|
||||||
|
#include "Common/ScopeGuard.h"
|
||||||
#include "Core/HW/WiiSave.h"
|
#include "Core/HW/WiiSave.h"
|
||||||
#include "Core/WiiUtils.h"
|
#include "Core/WiiUtils.h"
|
||||||
#include "DiscIO/NANDImporter.h"
|
#include "DiscIO/NANDImporter.h"
|
||||||
|
@ -108,4 +109,23 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_utils_WiiUtils_importNANDB
|
||||||
return "";
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue