The launchpad-loader is implemented using C++ language.
Change-Id: I9882c1c80fabd0ae81cb26fe4ac1dd72a0c19911
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src LAUNCHPAD_LOADER_SRCS)
-AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../lib/common/src
- LIB_COMMON_SRCS)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} LAUNCHPAD_LOADER_SRCS)
-ADD_EXECUTABLE(${TARGET_LAUNCHPAD_LOADER}
- ${LAUNCHPAD_LOADER_SRCS}
- ${LIB_COMMON_SRCS})
+ADD_EXECUTABLE(${TARGET_LAUNCHPAD_LOADER} ${LAUNCHPAD_LOADER_SRCS})
SET_TARGET_PROPERTIES(${TARGET_LAUNCHPAD_LOADER} PROPERTIES
SKIP_BUILD_RPATH TRUE)
TARGET_INCLUDE_DIRECTORIES(${TARGET_LAUNCHPAD_LOADER} PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/../
${CMAKE_CURRENT_SOURCE_DIR}/../lib/launchpad/inc)
-TARGET_INCLUDE_DIRECTORIES(${TARGET_LAUNCHPAD_LOADER} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/../lib/common/inc)
IF(_TIZEN_FEATURE_PRELINK)
MESSAGE(STATUS "prelink enable")
LIBCAP_DEPS
)
-TARGET_LINK_LIBRARIES(${TARGET_LAUNCHPAD_LOADER} PRIVATE ${TARGET_LAUNCHPAD})
+TARGET_LINK_LIBRARIES(${TARGET_LAUNCHPAD_LOADER} PRIVATE
+ ${TARGET_LAUNCHPAD} ${TARGET_LAUNCHPAD_GLIB})
# To support 2.x applications which use their own shared libraries.
# Since we cannot set LD_LIBRARY_PATH directly by security issue, we make the
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "launchpad-loader/launch_args.hh"
+
+namespace launchpad {
+namespace loader {
+
+LaunchArgs::LaunchArgs(int argc, char** argv, std::string app_path,
+ std::string app_id, std::string pkg_id, std::string pkg_type)
+ : argc_(argc),
+ argv_(argv),
+ app_path_(std::move(app_path)),
+ app_id_(std::move(app_id)),
+ pkg_id_(std::move(pkg_id)),
+ pkg_type_(std::move(pkg_type)) {
+}
+
+int LaunchArgs::GetArgc() const {
+ return argc_;
+}
+
+char** LaunchArgs::GetArgv() const {
+ return argv_;
+}
+
+const std::string& LaunchArgs::GetAppPath() const {
+ return app_path_;
+}
+
+const std::string& LaunchArgs::GetAppId() const {
+ return app_id_;
+}
+
+const std::string& LaunchArgs::GetPkgId() const {
+ return pkg_id_;
+}
+
+const std::string& LaunchArgs::GetPkgType() const {
+ return pkg_type_;
+}
+
+} // namespace loader
+} // namespace launchpad
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef LAUNCHPAD_LOADER_LAUNCH_ARGS_HH_
+#define LAUNCHPAD_LOADER_LAUNCH_ARGS_HH_
+
+#include <string>
+
+namespace launchpad {
+namespace loader {
+
+class LaunchArgs {
+ public:
+ LaunchArgs(int argc, char** argv, std::string app_path, std::string app_id,
+ std::string pkg_id, std::string pkg_type);
+
+ int GetArgc() const;
+ char** GetArgv() const;
+ const std::string& GetAppPath() const;
+ const std::string& GetAppId() const;
+ const std::string& GetPkgId() const;
+ const std::string& GetPkgType() const;
+
+ private:
+ int argc_;
+ char** argv_;
+ std::string app_path_;
+ std::string app_id_;
+ std::string pkg_id_;
+ std::string pkg_type_;
+};
+
+} // namespace loader
+} // namespace launchpad
+
+#endif // LAUNCHPAD_LOADER_LAUNCH_ARGS_HH_
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "launchpad-loader/launchpad_loader.hh"
+
+#include <dlfcn.h>
+
+#include <aul_keys.hh>
+#include <procfs.hh>
+#include <user_tracer.hh>
+#include <util.hh>
+
+#include "launchpad-loader/log_private.hh"
+
+namespace launchpad {
+namespace loader {
+namespace {
+
+constexpr const char kLoaderType[] = "loader_type";
+constexpr const char kLoaderTypeCommmon[] = "common-loader";
+constexpr const char kLoaderTypeHw[] = "hw-loader";
+constexpr const char kLoaderTypeSw[] = "sw-loader";
+
+void PreloadLibraries(const tizen_base::Bundle& extra) {
+ auto libs = extra.GetStringArray("preload");
+ if (libs.empty())
+ return;
+
+ uint64_t mem_pss;
+ launchpad::Procfs::GetPssMemory(getpid(), &mem_pss);
+ _W("PSS: %llu kB", mem_pss);
+ for (auto& lib : libs) {
+ if (lib.empty())
+ continue;
+
+ void* handle = dlopen(lib.c_str(), RTLD_NOW | RTLD_NODELETE);
+ if (handle == nullptr) {
+ _E("dlopen() is failed. path: %s, error: %s", lib.c_str(), dlerror());
+ continue;
+ }
+
+ launchpad::Procfs::GetPssMemory(getpid(), &mem_pss);
+ _W("Preload %s# - handle: %p, PSS: %llu kB", lib.c_str(), handle, mem_pss);
+ }
+}
+
+} // namespace
+
+LaunchpadLoader::LaunchpadLoader(int argc, char** argv)
+ : argc_(argc), argv_(argv) {
+}
+
+int LaunchpadLoader::Run() {
+ loader_lifecycle_callback_s callback;
+ callback.create = LoaderCreateCb;
+ callback.prelaunch = LoaderPreLaunchCb;
+ callback.launch = LoaderLaunchCb;
+ callback.terminate = LoaderTerminateCb;
+
+ loader_adapter_s adapter;
+ adapter.loop_begin = AdapterLoopBeginCb;
+ adapter.loop_quit = AdapterLoopQuitCb;
+ adapter.add_fd = AdapterAddFdCb;
+ adapter.remove_fd = AdapterRemoveFdCb;
+
+ return launchpad_loader_main(argc_, argv_, &callback, &adapter, this);
+}
+
+void LaunchpadLoader::InitializeTheme() {
+ _D("Initialize Theme");
+
+ char* theme = elm_theme_list_item_path_get(
+ reinterpret_cast<char*>(eina_list_data_get(elm_theme_list_get(nullptr))),
+ nullptr);
+ if (!edje_file_group_exists(theme, "*"))
+ _E("theme path: %s", theme);
+
+ free(theme);
+}
+
+void LaunchpadLoader::FinalizeWindow() {
+ _D("Finalize window");
+
+ if (conform_ != nullptr) {
+ evas_object_del(conform_);
+ conform_ = nullptr;
+ elm_conformant_precreated_object_set(nullptr);
+ }
+
+ if (bg_ != nullptr) {
+ evas_object_del(bg_);
+ bg_ = nullptr;
+ elm_bg_precreated_object_set(nullptr);
+ }
+
+ if (win_ != nullptr) {
+ evas_object_del(win_);
+ win_ = nullptr;
+ elm_win_precreated_object_set(nullptr);
+ }
+}
+
+void LaunchpadLoader::InitializeWindow() {
+ _D("Initialize Window");
+
+ win_ = elm_win_add(nullptr, "package_name", ELM_WIN_BASIC);
+ if (win_ == nullptr) {
+ _E("elm_win_add() is failed");
+ return;
+ }
+ elm_win_precreated_object_set(win_);
+
+ bg_ = elm_bg_add(win_);
+ if (bg_ == nullptr) {
+ _E("elm_bg_add() is failed");
+ } else {
+ evas_object_size_hint_weight_set(bg_, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(win_, bg_);
+ elm_bg_precreated_object_set(bg_);
+ }
+
+ conform_ = elm_conformant_add(win_);
+ if (conform_ == nullptr) {
+ _E("elm_conformant_add() is failed");
+ } else {
+ evas_object_size_hint_weight_set(conform_, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ elm_conformant_precreated_object_set(conform_);
+ }
+}
+
+void LaunchpadLoader::InitializeElementary() {
+ int ret = elm_init(argc_, argv_);
+ _D("elm_init() returned: %d", ret);
+ setenv("AUL_LOADER_INIT", "1", 1);
+
+ if (loader_type_ == kLoaderTypeSw) {
+ elm_config_accel_preference_set("none");
+ setenv("AUL_HWACC", "none", 1);
+ InitializeWindow();
+ } else if (loader_type_ == kLoaderTypeHw) {
+ elm_config_accel_preference_set("hw");
+ setenv("AUL_HWACC", "hw", 1);
+ InitializeWindow();
+ } else {
+ InitializeTheme();
+ }
+}
+
+void LaunchpadLoader::OnCreate(const tizen_base::Bundle& extra, int type) {
+ _D("Create");
+ loader_type_ = extra.GetString(kLoaderType);
+ if (loader_type_.empty()) {
+ _E("loader type is empty");
+ return;
+ }
+
+ _D("Loader type: %s", loader_type_.c_str());
+ PreloadLibraries(extra);
+ InitializeElementary();
+
+ hw_acc_config_.reset(new launchpad::HWAccelerationConfig());
+}
+
+int LaunchpadLoader::OnLaunch(const LaunchArgs& args) {
+ _D("Launch");
+ elm_app_name_set(args.GetAppId().c_str());
+
+ bundle* kb = launchpad_loader_get_bundle();
+ if (kb == nullptr)
+ return 0;
+
+ tizen_base::Bundle b(kb, false, false);
+#ifdef TIZEN_FEATURE_PRIORITY_CHANGE
+ auto high_priority = b.GetString(kAulHighPrioirty);
+ if (high_priority == "true")
+ launchpad_loader_set_priority(-12);
+
+ b.Delete(kAulHighPiority);
+#endif // TIZEN_FEATURE_PRIORITY_CHANGE
+
+ auto hwacc = b.GetString(launchpad::kAulHwAcc);
+ if (hwacc.empty())
+ return 0;
+
+ std::string loader_type;
+ if ((hwacc == "USE") ||
+ (hwacc == "SYS" && hw_acc_config_->Get() == SETTING_HW_ACCELERATION_ON))
+ loader_type = kLoaderTypeHw;
+ else
+ loader_type = kLoaderTypeSw;
+
+ if (loader_type != loader_type_)
+ FinalizeWindow();
+
+ return 0;
+}
+
+void LaunchpadLoader::ChangeCurrentWorkingDirectory(const std::string& dir) {
+ if (dir.empty())
+ return;
+
+ char old_cwd[PATH_MAX];
+ if (getcwd(old_cwd, sizeof(old_cwd)) == nullptr) {
+ _E("getcwd() is failed. errno(%d)", errno);
+ return;
+ }
+
+ old_cwd_ = old_cwd;
+ if (chdir(dir.c_str()) != 0)
+ _E("chdir() is failed. errno(%d)", errno);
+}
+
+void LaunchpadLoader::RestoreCurrentWorkingDirectory() {
+ if (old_cwd_.empty())
+ return;
+
+ if (chdir(old_cwd_.c_str()) != 0)
+ _E("chdir() is failed. errno(%d)", errno);
+}
+
+int LaunchpadLoader::DoDlopen(int argc, char** argv,
+ const std::string& lib_dir, bool* do_exec) {
+ ChangeCurrentWorkingDirectory(lib_dir);
+ launchpad::UserTracer::Print(std::to_string(getpid()) + "|lib loading start");
+ void* handle = dlopen(argv[0], RTLD_LAZY | RTLD_GLOBAL| RTLD_NODELETE);
+ if (handle == nullptr) {
+ _E("dlopen() is failed. path(%s), error(%s)", argv[0], dlerror());
+ *do_exec = true;
+ return -1;
+ }
+
+ dlerror();
+ RestoreCurrentWorkingDirectory();
+
+ auto* dl_main = reinterpret_cast<int (*)(int, char**)>(dlsym(handle, "main"));
+ if (dl_main == nullptr) {
+ _E("dlsym() is failed. Please export 'main' function. error(%s)",
+ dlerror());
+ dlclose(handle);
+ *do_exec = true;
+ return -1;
+ }
+
+ launchpad::UserTracer::Print(std::to_string(getpid()) + "|lib loading end");
+ return dl_main(argc, argv);
+}
+
+int LaunchpadLoader::DoExec(int argc, char** argv, const std::string& lib_dir) {
+ if (access(argv[0], F_OK | R_OK) != 0)
+ SECURE_LOGE("access() is failed. path(%s), errno(%d)", argv[0], errno);
+
+ SECURE_LOGD("Execute application. path(%s)", argv[0]);
+ Util::CloseAllFds();
+ if (!lib_dir.empty())
+ setenv("LD_LIBRARY_PATH", lib_dir.c_str(), 1);
+
+ unsetenv("AUL_LOADER_INIT");
+ unsetenv("AUL_HWACC");
+ if (execv(argv[0], argv) < 0) {
+ char err_buf[1024];
+ fprintf(stderr, "Failed to execute a file. path: %s, errno: %d(%s)\n",
+ argv[0], errno, strerror_r(errno, err_buf, sizeof(err_buf)));
+ exit(EXIT_FAILURE);
+ }
+
+ return 0;
+}
+
+int LaunchpadLoader::OnTerminate(int argc, char** argv) {
+ _D("Terminate");
+ std::string lib_dir = Util::GetLibDirectory(argv[0]);
+ bool do_exec = false;
+ int ret = DoDlopen(argc, argv, lib_dir, &do_exec);
+ if (do_exec)
+ ret = DoExec(argc, argv, lib_dir);
+
+ return ret;
+}
+
+void LaunchpadLoader::OnAdapterLoopBegin() {
+ ecore_main_loop_begin();
+}
+
+void LaunchpadLoader::OnAdapterLoopQuit() {
+ ecore_main_loop_quit();
+}
+
+void LaunchpadLoader::OnAdapterAddFd(int fd, loader_receiver_cb receiver) {
+ fd_handler_ = ecore_main_fd_handler_add(fd,
+ static_cast<Ecore_Fd_Handler_Flags>(ECORE_FD_READ | ECORE_FD_ERROR),
+ ProcessFdHandler, this, nullptr, nullptr);
+ if (fd_handler_ == nullptr) {
+ _E("fd handler is nullptr");
+ close(fd);
+ exit(-1);
+ }
+
+ receiver_ = receiver;
+}
+
+void LaunchpadLoader::OnAdapterRemoveFd(int fd) {
+ if (fd_handler_) {
+ ecore_main_fd_handler_del(fd_handler_);
+ fd_handler_ = nullptr;
+ receiver_ = nullptr;
+ }
+}
+
+void LaunchpadLoader::OnProcessFdHandler(int fd) {
+ if (receiver_)
+ receiver_(fd);
+}
+
+Eina_Bool LaunchpadLoader::ProcessFdHandler(void* user_data,
+ Ecore_Fd_Handler* handler) {
+ int fd = ecore_main_fd_handler_fd_get(handler);
+ if (fd == -1) {
+ _E("Failed to get fd from fd handler");
+ exit(-1);
+ }
+
+ if (ecore_main_fd_handler_active_get(handler, ECORE_FD_READ)) {
+ auto* loader = static_cast<LaunchpadLoader*>(user_data);
+ loader->OnProcessFdHandler(fd);
+ } else if (ecore_main_fd_handler_active_get(handler, ECORE_FD_ERROR)) {
+ _E("ECORE_FD_ERROR");
+ close(fd);
+ exit(-1);
+ }
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+void LaunchpadLoader::LoaderCreateCb(bundle* extra, int type, void* user_data) {
+ if (extra == nullptr) {
+ _E("extra is nullptr");
+ return;
+ }
+
+ auto* loader = static_cast<LaunchpadLoader*>(user_data);
+ loader->OnCreate(tizen_base::Bundle(extra, false, false), type);
+}
+
+int LaunchpadLoader::LoaderPreLaunchCb(int argc, char** argv,
+ const char* app_path, const char* appid, const char* pkgid,
+ const char* pkg_type, void* user_data) {
+ return 0;
+}
+
+int LaunchpadLoader::LoaderLaunchCb(int argc, char** argv, const char* app_path,
+ const char* appid, const char* pkgid, const char* pkg_type,
+ void* user_data) {
+ LaunchArgs args(argc, argv, app_path, appid, pkgid, pkg_type);
+ auto* loader = static_cast<LaunchpadLoader*>(user_data);
+ return loader->OnLaunch(args);
+}
+
+int LaunchpadLoader::LoaderTerminateCb(int argc, char** argv, void* user_data) {
+ auto* loader = static_cast<LaunchpadLoader*>(user_data);
+ return loader->OnTerminate(argc, argv);
+}
+
+void LaunchpadLoader::AdapterLoopBeginCb(void* user_data) {
+ auto* loader = static_cast<LaunchpadLoader*>(user_data);
+ loader->OnAdapterLoopBegin();
+}
+
+void LaunchpadLoader::AdapterLoopQuitCb(void* user_data) {
+ auto* loader = static_cast<LaunchpadLoader*>(user_data);
+ loader->OnAdapterLoopQuit();
+}
+
+void LaunchpadLoader::AdapterAddFdCb(void* user_data, int fd,
+ loader_receiver_cb receiver) {
+ auto* loader = static_cast<LaunchpadLoader*>(user_data);
+ loader->OnAdapterAddFd(fd, receiver);
+}
+
+void LaunchpadLoader::AdapterRemoveFdCb(void* user_data, int fd) {
+ auto* loader = static_cast<LaunchpadLoader*>(user_data);
+ loader->OnAdapterRemoveFd(fd);
+}
+
+} // namespace loader
+} // namespace launchpad
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef LAUNCHPAD_LOADER_LAUNCHPAD_LOADER_HH_
+#define LAUNCHPAD_LOADER_LAUNCHPAD_LOADER_HH_
+
+#include <Ecore.h>
+#include <Elementary.h>
+#include <bundle_cpp.h>
+#include <launchpad.h>
+
+#include <memory>
+#include <string>
+
+#include <hw_acceleration_config.hh>
+
+#include "launchpad-loader/launch_args.hh"
+
+namespace launchpad {
+namespace loader {
+
+class LaunchpadLoader {
+ public:
+ LaunchpadLoader(int argc, char** argv);
+
+ int Run();
+
+ private:
+ void OnCreate(const tizen_base::Bundle& extra, int type);
+ int OnLaunch(const LaunchArgs& args);
+ int OnTerminate(int argc, char** argv);
+
+ void OnAdapterLoopBegin();
+ void OnAdapterLoopQuit();
+ void OnAdapterAddFd(int fd, loader_receiver_cb receiver);
+ void OnAdapterRemoveFd(int fd);
+ void OnProcessFdHandler(int fd);
+
+ void InitializeElementary();
+ void InitializeWindow();
+ void FinalizeWindow();
+ void InitializeTheme();
+ void ChangeCurrentWorkingDirectory(const std::string& lib_dir);
+ void RestoreCurrentWorkingDirectory();
+ int DoDlopen(int argc, char** argv, const std::string& lib_dir,
+ bool* do_exec);
+ int DoExec(int argc, char** argv, const std::string& lib_dir);
+
+ static Eina_Bool ProcessFdHandler(void* user_data, Ecore_Fd_Handler* handler);
+ static void LoaderCreateCb(bundle* extra, int type, void* user_data);
+ static int LoaderPreLaunchCb(int argc, char** argv, const char* app_path,
+ const char* appid, const char* pkgid, const char* pkg_type,
+ void* user_data);
+ static int LoaderLaunchCb(int argc, char** argv, const char* app_path,
+ const char* appid, const char* pkgid, const char* pkg_type,
+ void* user_data);
+ static int LoaderTerminateCb(int argc, char** argv, void* user_data);
+ static void AdapterLoopBeginCb(void* user_data);
+ static void AdapterLoopQuitCb(void* user_data);
+ static void AdapterAddFdCb(void* user_data, int fd,
+ loader_receiver_cb receiver);
+ static void AdapterRemoveFdCb(void* user_data, int fd);
+
+ private:
+ int argc_;
+ char** argv_;
+ std::string loader_type_;
+ loader_receiver_cb receiver_ = nullptr;
+ Ecore_Fd_Handler* fd_handler_ = nullptr;
+ Evas_Object* win_ = nullptr;
+ Evas_Object* bg_ = nullptr;
+ Evas_Object* conform_ = nullptr;
+ std::unique_ptr<launchpad::HWAccelerationConfig> hw_acc_config_;
+ std::string old_cwd_;
+};
+
+} // namespace loader
+} // namespace launchpad
+
+#endif // LAUNCHPAD_LOADER_LAUNCHPAD_LOADER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef LAUNCHPAD_LOADER_LOG_PRIVATE_HH_
+#define LAUNCHPAD_LOADER_LOG_PRIVATE_HH_
+
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "LAUNCHPAD_LOADER"
+
+#undef _E
+#define _E LOGE
+
+#undef _W
+#define _W LOGW
+
+#undef _I
+#define _I LOGI
+
+#undef _D
+#define _D LOGD
+
+#endif // LAUNCHPAD_LOADER_LOG_PRIVATE_HH_
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "launchpad-loader/launchpad_loader.hh"
+
+int main(int argc, char** argv) {
+ launchpad::loader::LaunchpadLoader loader(argc, argv);
+ return loader.Run();
+}
+++ /dev/null
-/*
- * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define _GNU_SOURCE
-#include <stdio.h>
-#include <stdbool.h>
-#include <dlfcn.h>
-#include <sys/prctl.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <malloc.h>
-#include <linux/limits.h>
-#include <Elementary.h>
-#include <bundle_internal.h>
-#include <vconf.h>
-#include <sys/prctl.h>
-
-#include "launchpad_common.h"
-#include "launchpad_types.h"
-#include "launchpad_proc.h"
-#include "launchpad.h"
-#include "key.h"
-
-#ifndef PR_TASK_PERF_USER_TRACE
-#define PR_TASK_PERF_USER_TRACE 666
-#endif
-
-#define PATH_LIB_VC_ELM LIBDIR"/libvc-elm.so.0"
-
-extern bundle *launchpad_loader_get_bundle(void);
-
-static Ecore_Fd_Handler *__fd_handler;
-static loader_receiver_cb __receiver;
-
-static int __argc;
-static char **__argv;
-static int __sys_hwacc;
-static Evas_Object *__win;
-static Evas_Object *__bg;
-static Evas_Object *__conform;
-static int __type;
-
-enum loader_type {
- TYPE_COMMON,
- TYPE_SW,
- TYPE_HW,
- MAX_LOADER_TYPE
-};
-
-enum acc_type {
- SW_ACC,
- HW_ACC,
- MAX_ACC_TYPE
-};
-
-typedef void (*loader_convertible)(void);
-
-static void __vconf_cb(keynode_t *key, void *data)
-{
- const char *name;
-
- name = vconf_keynode_get_name(key);
- if (name && strcmp(name, VCONFKEY_SETAPPL_APP_HW_ACCELERATION) == 0) {
- __sys_hwacc = vconf_keynode_get_int(key);
- _D("sys hwacc: %d", __sys_hwacc);
- }
-}
-
-static void __init_theme(void)
-{
- char *theme = elm_theme_list_item_path_get(eina_list_data_get(
- elm_theme_list_get(NULL)), NULL);
- Eina_Bool is_exist = edje_file_group_exists(theme, "*");
-
- if (!is_exist)
- _D("theme path: %s", theme);
-
- if (theme)
- free(theme);
-}
-
-static void __init_window(void)
-{
- __win = elm_win_add(NULL, "package_name", ELM_WIN_BASIC);
- if (__win == NULL) {
- _E("[candidate] elm_win_add() failed");
- return;
- }
-
- elm_win_precreated_object_set(__win);
-
- __bg = elm_bg_add(__win);
- if (__bg) {
- evas_object_size_hint_weight_set(__bg, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
- elm_win_resize_object_add(__win, __bg);
- elm_bg_precreated_object_set(__bg);
- } else {
- _E("[candidate] elm_bg_add() failed");
- }
-
- __conform = elm_conformant_add(__win);
- if (__conform) {
- evas_object_size_hint_weight_set(__conform, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
- elm_conformant_precreated_object_set(__conform);
- } else {
- _E("elm_conformant_add() failed");
- }
-}
-
-static void __fini_window(void)
-{
- _D("Drop window");
-
- if (__conform) {
- evas_object_del(__conform);
- elm_conformant_precreated_object_set(NULL);
- __conform = NULL;
- }
-
- if (__bg) {
- evas_object_del(__bg);
- elm_bg_precreated_object_set(NULL);
- __bg = NULL;
- }
-
- if (__win) {
- evas_object_del(__win);
- elm_win_precreated_object_set(NULL);
- __win = NULL;
- }
-}
-
-static void __preload_lib(bundle *b)
-{
- void *handle = NULL;
- int i;
- int len = 0;
- const char **so_array;
- unsigned int mem_pss = 0;
-
- if (!b)
- return;
-
- so_array = bundle_get_str_array(b, "preload", &len);
-
- if (!so_array)
- return;
-
- _proc_get_mem_pss(getpid(), &mem_pss);
- _W("PSS: %u kB", mem_pss);
- for (i = 0; i < len; i++) {
- if (!so_array[i]) {
- _E("so_array[%d] is nullptr", i);
- continue;
- }
- if (so_array[i][0] == '\0') {
- _E("so_array[%d] is empty string", i);
- continue;
- }
-
- handle = dlopen(so_array[i], RTLD_NOW | RTLD_NODELETE);
- if (!handle) {
- _E("failed to load: %s, err: %s",
- so_array[i], dlerror());
- } else {
- _proc_get_mem_pss(getpid(), &mem_pss);
- _W("preload %s# - handle : %p, PSS: %u kB",
- so_array[i], handle, mem_pss);
- }
- }
-}
-
-static void __loader_create_cb(bundle *extra, int type, void *user_data)
-{
- int elm_init_cnt = 0;
- int ret;
- char *ltype = NULL;
-
- if (extra == NULL) {
- _E("No extra data");
- return;
- }
-
- bundle_get_str(extra, KEY_LOADER_TYPE, <ype);
-
- if (ltype == NULL) {
- _E("No loader type");
- return;
- }
-
- if (!strcmp(LOADER_TYPE_COMMON, ltype))
- __type = TYPE_COMMON;
- else if (!strcmp(LOADER_TYPE_SW, ltype))
- __type = TYPE_SW;
- else if (!strcmp(LOADER_TYPE_HW, ltype))
- __type = TYPE_HW;
-
- _D("Loader type:%d", __type);
-
- __preload_lib(extra);
-
- elm_init_cnt = elm_init(__argc, __argv);
- _D("[candidate] elm init, returned: %d", elm_init_cnt);
- setenv("AUL_LOADER_INIT", "1", 1);
-
- switch (__type) {
- case TYPE_SW:
- elm_config_accel_preference_set("none");
- setenv("AUL_HWACC", "none", 1);
- __init_window();
- break;
-
- case TYPE_HW:
- elm_config_accel_preference_set("hw");
- setenv("AUL_HWACC", "hw", 1);
- __init_window();
- break;
-
- default:
- __init_theme();
- break;
- }
-
- ret = vconf_get_int(VCONFKEY_SETAPPL_APP_HW_ACCELERATION, &__sys_hwacc);
- if (ret != VCONF_OK) {
- _E("Failed to get vconf int: %s",
- VCONFKEY_SETAPPL_APP_HW_ACCELERATION);
- }
-
- ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_APP_HW_ACCELERATION,
- __vconf_cb, NULL);
- if (ret != 0) {
- _E("Failed to register callback for %s",
- VCONFKEY_SETAPPL_APP_HW_ACCELERATION);
- }
-}
-
-static loader_convertible __converter_table[MAX_LOADER_TYPE][MAX_ACC_TYPE] = {
- [TYPE_COMMON][SW_ACC] = NULL,
- [TYPE_COMMON][HW_ACC] = NULL,
- [TYPE_SW][SW_ACC] = NULL,
- [TYPE_SW][HW_ACC] = __fini_window,
- [TYPE_HW][SW_ACC] = __fini_window,
- [TYPE_HW][HW_ACC] = NULL,
-};
-
-static int __loader_launch_cb(int argc, char **argv, const char *app_path,
- const char *appid, const char *pkgid, const char *pkg_type,
- void *user_data)
-{
- const char *hwacc;
- bundle *kb = launchpad_loader_get_bundle();
- int acc = SW_ACC;
- loader_convertible convert;
-#ifdef TIZEN_FEATURE_PRIORITY_CHANGE
- const char *high_priority;
-#endif
-
- elm_app_name_set(appid);
-
- vconf_ignore_key_changed(VCONFKEY_SETAPPL_APP_HW_ACCELERATION,
- __vconf_cb);
- if (kb == NULL)
- return 0;
-
-#ifdef TIZEN_FEATURE_PRIORITY_CHANGE
- high_priority = bundle_get_val(kb, AUL_K_HIGHPRIORITY);
- if (high_priority) {
- if (!strcmp(high_priority, "true"))
- launchpad_loader_set_priority(-12);
- bundle_del(kb, AUL_K_HIGHPRIORITY);
- }
-#endif
-
- hwacc = bundle_get_val(kb, AUL_K_HWACC);
-
- if (!hwacc)
- return 0;
-
- if (strcmp(hwacc, "USE") == 0 ||
- (strcmp(hwacc, "SYS") == 0 &&
- __sys_hwacc == SETTING_HW_ACCELERATION_ON)) {
- acc = HW_ACC;
- }
-
- convert = __converter_table[__type][acc];
- if (convert)
- convert();
-
- return 0;
-}
-
-static int __loader_terminate_cb(int argc, char **argv, void *user_data)
-{
- void *handle;
- int (*dl_main)(int, char **);
- char err_str[MAX_LOCAL_BUFSZ];
- char old_cwd[PATH_MAX];
- bool restore = false;
- char *libdir = NULL;
- char hwc_message[MAX_LOCAL_BUFSZ];
-
- SECURE_LOGD("[candidate] Launch real application (%s)",
- argv[LOADER_ARG_PATH]);
-
- if (getcwd(old_cwd, sizeof(old_cwd)) == NULL) {
- _E("getcwd() is failed");
- goto do_dlopen;
- }
-
- libdir = _get_libdir(argv[LOADER_ARG_PATH]);
- if (libdir == NULL)
- goto do_dlopen;
-
- /* To support 2.x applications which use their own shared libraries.
- * We set '-rpath' to make the dynamic linker looks in the CWD forcely,
- * so here we change working directory to find shared libraries well.
- */
- if (chdir(libdir))
- _E("failed to chdir: %d", errno);
- else
- restore = true;
-
-do_dlopen:
- snprintf(hwc_message, sizeof(hwc_message), "%d|lib loading start", getpid());
- prctl(PR_TASK_PERF_USER_TRACE, hwc_message, strlen(hwc_message));
- _W("dlopen(%s) ++", argv[LOADER_ARG_PATH]);
- handle = dlopen(argv[LOADER_ARG_PATH],
- RTLD_LAZY | RTLD_GLOBAL | RTLD_NODELETE);
- _W("dlopen(%s) --", argv[LOADER_ARG_PATH]);
- if (handle == NULL) {
- _E("dlopen(%s) is failed. error(%s)",
- argv[LOADER_ARG_PATH], dlerror());
- goto do_exec;
- }
-
- snprintf(hwc_message, sizeof(hwc_message), "%d|lib loading end", getpid());
- prctl(PR_TASK_PERF_USER_TRACE, hwc_message, strlen(hwc_message));
- dlerror();
-
- if (restore && chdir(old_cwd))
- _E("failed to chdir: %d", errno);
-
- dl_main = dlsym(handle, "main");
- if (dl_main == NULL) {
- _E("dlsym not founded(%s). Please export 'main' function",
- dlerror());
- dlclose(handle);
- goto do_exec;
- }
-
- free(libdir);
- return dl_main(argc, argv);
-
-do_exec:
- if (access(argv[LOADER_ARG_PATH], F_OK | R_OK)) {
- SECURE_LOGE("access() failed for file: \"%s\", error: %d (%s)",
- argv[LOADER_ARG_PATH], errno,
- strerror_r(errno, err_str, sizeof(err_str)));
- } else {
- SECURE_LOGD("[candidate] Exec application (%s)",
- __argv[LOADER_ARG_PATH]);
- _close_all_fds();
- if (libdir)
- setenv("LD_LIBRARY_PATH", libdir, 1);
- free(libdir);
- unsetenv("AUL_LOADER_INIT");
- unsetenv("AUL_HWACC");
- if (execv(argv[LOADER_ARG_PATH], argv) < 0) {
- fprintf(stderr, "Failed to execute a file. path: %s, errno: %d(%s)\n",
- argv[LOADER_ARG_PATH], errno,
- strerror_r(errno, err_str, sizeof(err_str)));
- exit(EXIT_FAILURE);
- }
- }
-
- return 0;
-}
-
-static Eina_Bool __process_fd_handler(void *data, Ecore_Fd_Handler *handler)
-{
- int fd;
-
- fd = ecore_main_fd_handler_fd_get(handler);
- if (fd == -1) {
- _D("[candidate] ECORE_FD_GET");
- exit(-1);
- }
-
- if (ecore_main_fd_handler_active_get(handler, ECORE_FD_READ)) {
- if (__receiver)
- __receiver(fd);
- } else if (ecore_main_fd_handler_active_get(handler, ECORE_FD_ERROR)) {
- _D("[candidate] ECORE_FD_ERROR");
- close(fd);
- exit(-1);
- }
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-static void __adapter_loop_begin(void *user_data)
-{
- ecore_main_loop_begin();
-}
-
-static void __adapter_loop_quit(void *user_data)
-{
- ecore_main_loop_quit();
-}
-
-static void __adapter_add_fd(void *user_data, int fd,
- loader_receiver_cb receiver)
-{
- __fd_handler = ecore_main_fd_handler_add(fd,
- ECORE_FD_READ | ECORE_FD_ERROR, __process_fd_handler,
- NULL, NULL, NULL);
- if (__fd_handler == NULL) {
- _D("fd_handler is NULL");
- close(fd);
- exit(-1);
- }
-
- __receiver = receiver;
-}
-
-static void __adapter_remove_fd(void *user_data, int fd)
-{
- if (__fd_handler) {
- ecore_main_fd_handler_del(__fd_handler);
- __fd_handler = NULL;
- __receiver = NULL;
- }
-}
-
-int main(int argc, char **argv)
-{
- loader_lifecycle_callback_s callbacks = {
- .create = __loader_create_cb,
- .launch = __loader_launch_cb,
- .terminate = __loader_terminate_cb
- };
-
- loader_adapter_s adapter = {
- .loop_begin = __adapter_loop_begin,
- .loop_quit = __adapter_loop_quit,
- .add_fd = __adapter_add_fd,
- .remove_fd = __adapter_remove_fd
- };
-
- __argc = argc;
- __argv = argv;
-
- return launchpad_loader_main(argc, argv, &callbacks, &adapter, NULL);
-}
#include <plugin.hh>
#include <stdio.hh>
#include <types.hh>
+#include <user_tracer.hh>
#include <util.hh>
#include "launchpad-process-pool/config.hh"
#include "launchpad-process-pool/debug.hh"
#include "launchpad-process-pool/log_private.hh"
#include "launchpad-process-pool/signal_manager.hh"
-#include "launchpad-process-pool/user_tracer.hh"
namespace launchpad {
namespace fs = std::filesystem;
SECURE_LOGD("input argument %d : %s##", i, app_argv[i]);
}
- auto lib_dir = Util::GetLibDirectory(app_info_);
+ auto lib_dir = Util::GetLibDirectory(app_info_->GetAppPath());
if (!lib_dir.empty())
setenv("LD_LIBRARY_PATH", lib_dir.c_str(), 1);
+++ /dev/null
-/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "launchpad-process-pool/hw_acceleration_config.hh"
-
-#include "launchpad-process-pool/log_private.hh"
-
-namespace launchpad {
-
-HWAccelerationConfig::HWAccelerationConfig()
- : vconf_(Vconf(VCONFKEY_SETAPPL_APP_HW_ACCELERATION)) {
- vconf_.Listen(this);
-
- try {
- hwacc_ = vconf_.Get<int>();
- } catch (const Exception& e) {
- _E("Exception occurs. error: %s", e.what());
- hwacc_ = -1;
- }
-}
-
-int HWAccelerationConfig::Get() const {
- return hwacc_;
-}
-
-void HWAccelerationConfig::OnKeyChanged(const Vconf::KeyNode& node) {
- hwacc_ = node.Get<int>();
- _W("Hwacc: %d", hwacc_);
-}
-
-} // namespace launchpad
+++ /dev/null
-/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef LAUNCHPAD_PROCESS_POOL_HW_ACCELERATION_CONFIG_HH_
-#define LAUNCHPAD_PROCESS_POOL_HW_ACCELERATION_CONFIG_HH_
-
-#include <vconf.hh>
-
-namespace launchpad {
-
-class HWAccelerationConfig : public Vconf::IEvent {
- public:
- HWAccelerationConfig();
-
- int Get() const;
-
- private:
- void OnKeyChanged(const Vconf::KeyNode& node) override;
-
- private:
- Vconf vconf_;
- int hwacc_;
-};
-
-} // namespace launchpad
-
-#endif // LAUNCHPAD_PROCESS_POOL_HW_ACCELERATION_CONFIG_HH_
#include <executor.hh>
#include <procfs.hh>
#include <types.hh>
+#include <user_tracer.hh>
#include <util.hh>
#include "launchpad-process-pool/config.hh"
#include "launchpad-process-pool/memory_monitor.hh"
#include "launchpad-process-pool/signal_manager.hh"
#include "launchpad-process-pool/tracer.hh"
-#include "launchpad-process-pool/user_tracer.hh"
#include "launchpad-process-pool/util.hh"
#include "launchpad-process-pool/worker.hh"
#include <exception.hh>
#include <peer_credentials.hh>
#include <procfs.hh>
+#include <user_tracer.hh>
#include <util.hh>
#include <types.hh>
#include "launchpad-process-pool/log.hh"
#include "launchpad-process-pool/log_private.hh"
#include "launchpad-process-pool/memory_monitor.hh"
-#include "launchpad-process-pool/user_tracer.hh"
#include "launchpad-process-pool/util.hh"
namespace fs = std::filesystem;
#include <utility>
#include <aul_keys.hh>
+#include <user_tracer.hh>
#include <types.hh>
#include "launchpad-process-pool/hydra_loader_context.hh"
#include "launchpad-process-pool/loader_context.hh"
#include "launchpad-process-pool/log_private.hh"
-#include "launchpad-process-pool/user_tracer.hh"
namespace launchpad {
namespace {
#include <string_view>
#include <vector>
+#include <hw_acceleration_config.hh>
+
#include "launchpad-process-pool/app_defined_loader_info_manager.hh"
#include "launchpad-process-pool/app_labels_monitor.hh"
-#include "launchpad-process-pool/hw_acceleration_config.hh"
#include "launchpad-process-pool/hydra_loader_context.hh"
#include "launchpad-process-pool/loader_context.hh"
#include "launchpad-process-pool/loader_info.hh"
+++ /dev/null
-/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "launchpad-process-pool/user_tracer.hh"
-
-#include <sys/prctl.h>
-
-#include <utility>
-
-namespace launchpad {
-namespace {
-
-const int PR_TASK_PERF_USER_TRACE = 666;
-
-} // namespace
-
-UserTracer::UserTracer(std::string message) : message_(std::move(message)) {
- Print(message_ + ": BEGIN");
-}
-
-UserTracer::~UserTracer() {
- Print(message_ + ": END");
-}
-
-void UserTracer::Print(const std::string& message) {
- prctl(PR_TASK_PERF_USER_TRACE, message.c_str(), message.length());
-}
-
-} // namespace launchpad
+++ /dev/null
-/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef LAUNCHPAD_PROCESS_POOL_USER_TRACER_HH_
-#define LAUNCHPAD_PROCESS_POOL_USER_TRACER_HH_
-
-#include <string>
-
-namespace launchpad {
-
-class UserTracer {
- public:
- explicit UserTracer(std::string message);
- ~UserTracer();
-
- static void Print(const std::string& message);
-
- private:
- std::string message_;
-};
-
-} // namespace launchpad
-
-#endif // LAUNCHPAD_PROCESS_POOL_USER_TRACER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "launchpad-common/user_tracer.hh"
+
+#include <sys/prctl.h>
+
+#include <utility>
+
+namespace launchpad {
+namespace {
+
+const int PR_TASK_PERF_USER_TRACE = 666;
+
+} // namespace
+
+UserTracer::UserTracer(std::string message) : message_(std::move(message)) {
+ Print(message_ + ": BEGIN");
+}
+
+UserTracer::~UserTracer() {
+ Print(message_ + ": END");
+}
+
+void UserTracer::Print(const std::string& message) {
+ prctl(PR_TASK_PERF_USER_TRACE, message.c_str(), message.length());
+}
+
+} // namespace launchpad
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef LAUNCHPAD_COMMON_USER_TRACER_HH_
+#define LAUNCHPAD_COMMON_USER_TRACER_HH_
+
+#include <string>
+
+namespace launchpad {
+
+class UserTracer {
+ public:
+ explicit UserTracer(std::string message);
+ ~UserTracer();
+
+ static void Print(const std::string& message);
+
+ private:
+ std::string message_;
+};
+
+} // namespace launchpad
+
+#endif // LAUNCHPAD_COMMON_USER_TRACER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "launchpad-glib/hw_acceleration_config.hh"
+
+#include "launchpad-glib/log_private.hh"
+
+namespace launchpad {
+
+HWAccelerationConfig::HWAccelerationConfig()
+ : vconf_(Vconf(VCONFKEY_SETAPPL_APP_HW_ACCELERATION)) {
+ vconf_.Listen(this);
+
+ try {
+ hwacc_ = vconf_.Get<int>();
+ } catch (const Exception& e) {
+ _E("Exception occurs. error: %s", e.what());
+ hwacc_ = -1;
+ }
+}
+
+int HWAccelerationConfig::Get() const {
+ return hwacc_;
+}
+
+void HWAccelerationConfig::OnKeyChanged(const Vconf::KeyNode& node) {
+ hwacc_ = node.Get<int>();
+ _W("Hwacc: %d", hwacc_);
+}
+
+} // namespace launchpad
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef LAUNCHPAD_GLIB_HW_ACCELERATION_CONFIG_HH_
+#define LAUNCHPAD_GLIB_HW_ACCELERATION_CONFIG_HH_
+
+#include <vconf.hh>
+
+namespace launchpad {
+
+class HWAccelerationConfig : public Vconf::IEvent {
+ public:
+ HWAccelerationConfig();
+
+ int Get() const;
+
+ private:
+ void OnKeyChanged(const Vconf::KeyNode& node) override;
+
+ private:
+ Vconf vconf_;
+ int hwacc_;
+};
+
+} // namespace launchpad
+
+#endif // LAUNCHPAD_GLIB_HW_ACCELERATION_CONFIG_HH_
return 0;
}
-std::string Util::GetLibDirectory(const AppInfo* app_info) {
- std::filesystem::path path(app_info->GetAppPath());
+std::string Util::GetLibDirectory(const std::string& app_path) {
+ std::filesystem::path path(app_path);
auto lib_dir = path.parent_path().string() + "/../lib/";
if (std::filesystem::exists(lib_dir))
return lib_dir;
static int EnableExternalPackage(const AppInfo* app_info);
static int MountResourceDirectories(const AppInfo* app_info);
static int WaitTepMount(const AppInfo* app_info);
- static std::string GetLibDirectory(const AppInfo* app_info);
+ static std::string GetLibDirectory(const std::string& app_path);
static void CloseAllFds();
static int PrepareAppSocket();
static int PrepareAppIdFile(const AppInfo* app_info);