From ae501e256ea462268dbae8109ad07ef457c4fd8e Mon Sep 17 00:00:00 2001 From: Maufeat Date: Sat, 17 Jan 2026 01:48:15 +0100 Subject: [bcat/news/web/am] Implement news applet, proper TLV return, external web browser URL and qlaunch app sorting (#3308) This pulls eden releases changelog & text from our github releases. We don't store the msgpack file but rather generate them in-memory for the News Applet. Uses cache folder. Files generated are: - cache/news/github_releases.json - cache/news/eden_logo.jpg - cache/news/news_read Additional changes: - Proper TLV returning for online web applet, to open external URL - Add applet type `LHub` to properly close, as it also uses TLV return - qlaunch app sorting, adds another cached .json to track last launched app timestamps and sort them accordingly Co-authored-by: crueter Co-authored-by: DraVee Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3308 Reviewed-by: MaranBr Reviewed-by: DraVee Reviewed-by: Lizzie Co-authored-by: Maufeat Co-committed-by: Maufeat --- src/common/android/applets/web_browser.cpp | 50 ++++++++++++++++++++++++++++++ src/common/android/applets/web_browser.h | 30 ++++++++++++++++++ src/common/android/id_cache.cpp | 3 ++ 3 files changed, 83 insertions(+) create mode 100644 src/common/android/applets/web_browser.cpp create mode 100644 src/common/android/applets/web_browser.h (limited to 'src/common/android') diff --git a/src/common/android/applets/web_browser.cpp b/src/common/android/applets/web_browser.cpp new file mode 100644 index 0000000000..cf844ff5fc --- /dev/null +++ b/src/common/android/applets/web_browser.cpp @@ -0,0 +1,50 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "common/android/android_common.h" +#include "common/android/id_cache.h" +#include "common/android/applets/web_browser.h" +#include "common/logging/log.h" + +static jclass s_native_library_class = nullptr; +static jmethodID s_open_external_url = nullptr; + +namespace Common::Android::WebBrowser { + +void InitJNI(JNIEnv* env) { + const jclass local = env->FindClass("org/yuzu/yuzu_emu/NativeLibrary"); + s_native_library_class = static_cast(env->NewGlobalRef(local)); + env->DeleteLocalRef(local); + s_open_external_url = env->GetStaticMethodID(s_native_library_class, "openExternalUrl", "(Ljava/lang/String;)V"); +} + +void CleanupJNI(JNIEnv* env) { + if (s_native_library_class != nullptr) { + env->DeleteGlobalRef(s_native_library_class); + s_native_library_class = nullptr; + } + s_open_external_url = nullptr; +} + +void AndroidWebBrowser::OpenLocalWebPage(const std::string& local_url, ExtractROMFSCallback extract_romfs_callback, OpenWebPageCallback callback) const { + LOG_WARNING(Frontend, "(STUBBED)"); + callback(Service::AM::Frontend::WebExitReason::WindowClosed, ""); +} + +void AndroidWebBrowser::OpenExternalWebPage(const std::string& external_url, OpenWebPageCallback callback) const { + // do a dedicated thread, calling from the this thread crashed CPU fiber. + Common::Android::RunJNIOnFiber([&](JNIEnv* env) { + if (env != nullptr && s_native_library_class != nullptr && s_open_external_url != nullptr) { + const jstring j_url = Common::Android::ToJString(env, external_url); + env->CallStaticVoidMethod(s_native_library_class, s_open_external_url, j_url); + env->DeleteLocalRef(j_url); + } else { + LOG_ERROR(Frontend, "JNI not initialized, cannot open {}", external_url); + } + return; + }); + + callback(Service::AM::Frontend::WebExitReason::WindowClosed, external_url); +} + +} // namespace Common::Android::WebBrowser diff --git a/src/common/android/applets/web_browser.h b/src/common/android/applets/web_browser.h new file mode 100644 index 0000000000..a70903e3be --- /dev/null +++ b/src/common/android/applets/web_browser.h @@ -0,0 +1,30 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#pragma once + +#include +#include + +#include "core/frontend/applets/web_browser.h" + +namespace Common::Android::WebBrowser { + +class AndroidWebBrowser final : public Core::Frontend::WebBrowserApplet { +public: + ~AndroidWebBrowser() override = default; + + void Close() const override {} + + void OpenLocalWebPage(const std::string& local_url, + ExtractROMFSCallback extract_romfs_callback, + OpenWebPageCallback callback) const override; + + void OpenExternalWebPage(const std::string& external_url, + OpenWebPageCallback callback) const override; +}; + +void InitJNI(JNIEnv* env); +void CleanupJNI(JNIEnv* env); + +} // namespace Common::Android::WebBrowser diff --git a/src/common/android/id_cache.cpp b/src/common/android/id_cache.cpp index 1198833996..eb43f4e213 100644 --- a/src/common/android/id_cache.cpp +++ b/src/common/android/id_cache.cpp @@ -4,6 +4,7 @@ #include #include "applets/software_keyboard.h" +#include "applets/web_browser.h" #include "common/android/id_cache.h" #include "common/assert.h" #include "common/fs/fs_android.h" @@ -602,6 +603,7 @@ namespace Common::Android { // Initialize applets Common::Android::SoftwareKeyboard::InitJNI(env); + Common::Android::WebBrowser::InitJNI(env); return JNI_VERSION; } @@ -631,6 +633,7 @@ namespace Common::Android { // UnInitialize applets SoftwareKeyboard::CleanupJNI(env); + WebBrowser::CleanupJNI(env); AndroidMultiplayer::NetworkShutdown(); } -- cgit v1.2.3