|
|
|
@ -4,6 +4,7 @@ |
|
|
|
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
|
|
#define ENABLE_UPDATE_CHECKER 1
|
|
|
|
#define VMA_IMPLEMENTATION
|
|
|
|
#include "video_core/vulkan_common/vma.h"
|
|
|
|
|
|
|
|
@ -1615,23 +1616,52 @@ JNIEXPORT jboolean JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_isNightlyBuild( |
|
|
|
#endif
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifdef ENABLE_UPDATE_CHECKER
|
|
|
|
|
|
|
|
JNIEXPORT jobjectArray JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_checkForUpdate( |
|
|
|
JNIEnv* env, |
|
|
|
jobject obj) { |
|
|
|
const bool is_prerelease = ((strstr(Common::g_build_version, "pre-alpha") != nullptr) || |
|
|
|
(strstr(Common::g_build_version, "alpha") != nullptr) || |
|
|
|
(strstr(Common::g_build_version, "beta") != nullptr) || |
|
|
|
(strstr(Common::g_build_version, "rc") != nullptr)); |
|
|
|
const std::optional<UpdateChecker::Update> release = |
|
|
|
std::optional<UpdateChecker::Update> checkForUpdate() { |
|
|
|
const bool is_prerelease = ((strstr(Common::g_build_version, "pre-alpha") != NULL) || |
|
|
|
(strstr(Common::g_build_version, "alpha") != NULL) || |
|
|
|
(strstr(Common::g_build_version, "beta") != NULL) || |
|
|
|
(strstr(Common::g_build_version, "rc") != NULL)); |
|
|
|
const std::optional<UpdateChecker::Update> latest_release_tag = |
|
|
|
UpdateChecker::GetLatestRelease(is_prerelease); |
|
|
|
|
|
|
|
if (!release || release->tag == Common::g_build_version) { |
|
|
|
return nullptr; |
|
|
|
if (!latest_release_tag) |
|
|
|
goto empty; |
|
|
|
|
|
|
|
{ |
|
|
|
std::string tag, build; |
|
|
|
if (Common::g_is_nightly_build) { |
|
|
|
std::vector<std::string> result; |
|
|
|
|
|
|
|
boost::split(result, latest_release_tag->tag, boost::is_any_of(".")); |
|
|
|
if (result.size() != 2) |
|
|
|
goto empty; |
|
|
|
tag = result[1]; |
|
|
|
|
|
|
|
boost::split(result, std::string{Common::g_build_version}, boost::is_any_of("-")); |
|
|
|
if (result.empty()) |
|
|
|
goto empty; |
|
|
|
build = result[0]; |
|
|
|
} else { |
|
|
|
tag = latest_release_tag->tag; |
|
|
|
build = Common::g_build_version; |
|
|
|
} |
|
|
|
|
|
|
|
if (tag != build) |
|
|
|
return latest_release_tag.value(); |
|
|
|
} |
|
|
|
|
|
|
|
empty: |
|
|
|
return std::nullopt; |
|
|
|
} |
|
|
|
|
|
|
|
JNIEXPORT jobjectArray JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_checkForUpdate( |
|
|
|
JNIEnv* env, |
|
|
|
jobject obj) { |
|
|
|
std::optional<UpdateChecker::Update> release = checkForUpdate(); |
|
|
|
if (!release) return nullptr; |
|
|
|
|
|
|
|
const std::string tag = release->tag; |
|
|
|
const std::string name = release->name; |
|
|
|
|
|
|
|
|