From bf84a681a546bd065775e51527d4bcf61f44d498 Mon Sep 17 00:00:00 2001 From: Olekoop Date: Wed, 7 Aug 2024 20:59:46 +0200 Subject: [PATCH] Android: Use LibWebView for command line flags On Android there's really no real way to provide command line flags. We are using a dummy Main::Argument that only contains "ladybird" as a name of the program. The strings of Main::Argument cannot be empty, otherwise the program throws an error. However the argc and argv can be set to 0 and nullptr --- .../Android/src/main/cpp/LadybirdActivity.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Ladybird/Android/src/main/cpp/LadybirdActivity.cpp b/Ladybird/Android/src/main/cpp/LadybirdActivity.cpp index f3ad098bda0..82225ae929f 100644 --- a/Ladybird/Android/src/main/cpp/LadybirdActivity.cpp +++ b/Ladybird/Android/src/main/cpp/LadybirdActivity.cpp @@ -30,6 +30,13 @@ static OwnPtr s_main_event_loop; static jobject s_java_instance; static jmethodID s_schedule_event_loop_method; +struct Application : public WebView::Application { + WEB_VIEW_APPLICATION(Application); +}; + +Application::Application(Badge, Main::Arguments&) +{ +} extern "C" JNIEXPORT void JNICALL Java_org_serenityos_ladybird_LadybirdActivity_initNativeCode(JNIEnv*, jobject, jstring, jstring, jobject); @@ -76,10 +83,17 @@ Java_org_serenityos_ladybird_LadybirdActivity_initNativeCode(JNIEnv* env, jobjec Core::EventLoopManager::install(*event_loop_manager); s_main_event_loop = make(); + // The strings cannot be empty + Main::Arguments arguments = { + .argc = 0, + .argv = nullptr, + .strings = Span { new StringView("ladybird"sv), 1 } + }; + // FIXME: We are not making use of this Application object to track our processes. // So, right now, the Application's ProcessManager is constantly empty. // (However, LibWebView depends on an Application object existing, so we do have to actually create one.) - s_application = make(0, nullptr); + s_application = Application::create(arguments, "about:newtab"sv); } extern "C" JNIEXPORT void JNICALL