%define __build_chrome 0
%endif
+%if "%{?tizen_profile_name}" == "tv" && %{tizen_version} >= 70
+# Tizen TV 7.0
+%define __enable_capi_thread_booster 1
+%else
+%define __enable_capi_thread_booster 0
+%endif
+
%{?_use_system_icu: %define __use_system_icu %{_use_system_icu}}
# Product tv can't utilize system icu due to nacl dependency.
%if "%{?profile}" != "tv" && %{tizen_version} == 60 && %{?_use_system_icu: 0}%{!?_use_system_icu: 1}
BuildRequires: pkgconfig(WebProduct)
%endif
+%if "%{__enable_capi_thread_booster}" == "1"
+BuildRequires: pkgconfig(capi-boost-tv)
+%endif
+
# TODO(youngsoo): The binutils-gold crashes mini_browser on the Tizen v3.0 ARM 64 bit images.
# Once fixed, use binutils-gold for all targets on Tizen v3.0.
%ifnarch aarch64 %{arm} # [M48_2564] Temporary excluding arm architecture for fixing memory issue
%if 0%{?__enable_wrt_js}
%if "%{?profile}" == "tv"
- %caps(cap_mac_admin,cap_mac_override,cap_setgid,cap_setpcap,cap_setuid,cap_sys_chroot,cap_sys_ptrace,cap_sys_admin=eip) %{_bindir}/wrt
+ %caps(cap_mac_admin,cap_mac_override,cap_setgid,cap_setpcap,cap_setuid,cap_sys_chroot,cap_sys_ptrace,cap_sys_admin,cap_sys_nice=eip) %{_bindir}/wrt
/etc/notstrip/wrt.notstrip
%if 0%{?__generate_tpk}
%{__wrt_resourcedir}/app/*
}
}
+tizen_pkg_config("capi-boost-tv") {
+ packages = []
+ if (tizen_product_tv && tizen_version >= 70) {
+ packages += [ "capi-boost-tv" ]
+ }
+}
+
tizen_pkg_config("libcapi-media-audio-io") {
packages = []
if (is_tizen) {
"//tizen_src/build:ui-gadget-1",
"//tizen_src/build:vd-win-util",
]
+ if (tizen_version >= 70) {
+ configs += [ "//tizen_src/build:capi-boost-tv" ]
+ }
} else {
configs += [
"//tizen_src/build:capi-appfw-watch-application",
void ChildTerminated(int sig_no) {
LOG(INFO) << "sig_no : " << sig_no;
+ wrt_ipc->SendMessage("CloseDBusConnection", "");
wrt_ipc.reset();
child_created = false;
struct sigaction action;
action.sa_handler = wrt::ChildTerminated;
+ action.sa_flags = 0;
sigfillset(&(action.sa_mask));
- sigaction(SIGCHLD, &action, NULL);
+ if (sigaction(SIGCHLD, &action, NULL) != 0)
+ LOG(ERROR) << "sigaction is fail";
service_app_lifecycle_callback_s ops;
memset(&ops, 0, sizeof(ops));
#include <mutex>
#include <thread>
+#include <aul_proc_group.h>
#include <dlfcn.h>
+#include <sys/resource.h>
#include <tzplatform_config.h>
#include "base/logging.h"
#include "base/threading/thread_id_name_manager.h"
+#include "content/common/zygote/zygote_communication_linux.h"
+#include "content/public/common/zygote/zygote_handle.h"
#include "wrt/src/base/platform_info.h"
+#include "wrt/src/browser/net/tv/encrypted_file_url_loader.h"
#include "wrt/src/browser/tv/input_device_manager.h"
#include "wrt/src/browser/tv/mounter.h"
#include "wrt/src/browser/tv/native_web_runtime_delegate_tv.h"
#include "wrt/src/browser/tv/wrt_browser_client_tv.h"
+#include "wrt/src/browser/tv/wrt_native_window_tv.h"
#include "wrt/src/browser/wrt_native_window.h"
#include "wrt/src/common/constants.h"
#include "wrt/src/common/locale_manager.h"
+#include "wrt/src/common/tv/application_data_tv.h"
#include "wrt/src/renderer/tv/wrt_renderer_client_tv.h"
#include "wrt/xwalk_extensions/browser/xwalk_extension_manager.h"
#include "tizen_src/chromium_impl/ui/gl/gl_shared_context_efl.h"
};
const char* kEflWebProcess = "/usr/bin/efl_webprocess";
-const char* kLoaderMode = "-lite";
const char* kZoneLibPath = LIB_PATH "/libzone.so.5";
-std::mutex worker_mutex;
+std::mutex prelaunch_mutex;
+std::mutex reallaunch_mutex;
std::string prelaunch_pkg_id;
bool CheckWindowManagerReady() {
}
}
+void SetPriorityAsIdle() {
+ LOG(INFO) << "Set process priority as 0 of process group";
+ setpriority(PRIO_PGRP, 0, 0);
+}
+
+void InitializeBeforeRealLaunch() {
+ XWalkExtensionManager::GetInstance()->PreloadExtensions();
+ std::ignore = PrivilegedService::GetInstance();
+ std::ignore = LocaleManager::GetInstance();
+
+ auto& native_runtime_tv = NativeWebRuntimeDelegateTV::GetInstance();
+ native_runtime_tv.PepperUpdatePluginService();
+ native_runtime_tv.PreloadVconfKeys();
+ native_runtime_tv.PreloadFMS();
+ native_runtime_tv.SubscribePowerState();
+ native_runtime_tv.SetLocaleDir();
+ native_runtime_tv.ClearDeadMount();
+}
+
} // namespace
-WRTMainDelegateTV::WRTMainDelegateTV() : lazy_initialize_(false) {
+WRTMainDelegateTV::WRTMainDelegateTV() {
SetExecutablePath(kEflWebProcess);
SetNoZygote(false);
}
}
bool WRTMainDelegateTV::CheckPlatformReady(int argc, char** argv) {
- for (int i = 1; i < argc; ++i) {
- if (strcmp(argv[i], kLoaderMode) == 0) {
- lazy_initialize_ = true;
- break;
- }
- }
return CheckWindowManagerReady();
}
-bool WRTMainDelegateTV::SupportLazyInitialize() {
- return lazy_initialize_;
+// static
+void WRTMainDelegateTV::GroupZygoteProcess(bool is_oom) {
+#if defined(ENABLE_PROCESS_GROUP)
+ // Group zygote process with browser process so that OOM score
+ // can be synchronized.
+ auto oom_score_adj_path = base::FilePath("/proc/self/oom_score_adj");
+ std::string oom_score;
+ base::ReadFileToString(oom_score_adj_path, &oom_score);
+ if (is_oom || oom_score == "0") {
+ auto zygote_pid = content::GetGenericZygote()->GetZygotePid();
+ LOG(INFO) << "zygote pid : " << zygote_pid << ", oom score : " << oom_score;
+ // Note. this is workaround!!
+ // If amd has failed dbus communication once with resourced, then, next call
+ // is blocked. But retry can re-connect the dbus.
+ // If already blocked, aul_proc_group_remove() can close the blocked dbus,
+ // if not blocked, this logic is not effective for process grouping.
+ std::ignore = aul_proc_group_remove(zygote_pid);
+ std::ignore = aul_proc_group_add(zygote_pid);
+ }
+#endif
}
-void WRTMainDelegateTV::LoaderCreated() {
-#if !defined(WRT_JS_BRINGUP)
- base::ThreadIdNameManager::GetInstance()->EnableSelfSmackLabeling();
-#endif
- WRTNativeWindow::EnsurePlatformWindow();
- auto* ee = WRTNativeWindow::GetPlatformCanvas();
- InputDeviceManager::GetInstance()->PreInitialize(ee);
- GLSharedContextEfl::Initialize(WRTNativeWindow::GetTopWindow());
- XWalkExtensionManager::GetInstance()->PreloadExtensions();
- auto& native_runtime_tv = NativeWebRuntimeDelegateTV::GetInstance();
- native_runtime_tv.PepperUpdatePluginService();
- native_runtime_tv.SubscribePowerState();
- native_runtime_tv.SetLocaleDir();
- native_runtime_tv.ClearDeadMount();
- std::ignore = PrivilegedService::GetInstance();
- std::ignore = LocaleManager::GetInstance();
- worker_mutex.lock();
- std::thread loader_boost_worker([]() -> void {
- worker_mutex.lock();
+void WRTMainDelegateTV::CreateWorkers() {
+ prelaunch_mutex.lock();
+ reallaunch_mutex.lock();
+ std::thread prelaunch_worker([]() -> void {
+ // wake-up by preluanch
+ prelaunch_mutex.lock();
+ LOG(INFO) << "prelaunch_worker";
SetSmackLabel(prelaunch_pkg_id);
- // PreSetupOnWorker by candidate launch
NativeWebRuntimeDelegateTV::PreSetupOnWorker();
- worker_mutex.unlock();
+ prelaunch_mutex.unlock();
+ reallaunch_mutex.lock();
+ reallaunch_mutex.unlock();
+ });
+ prelaunch_worker.detach();
+
+ std::thread reallaunch_worker([]() -> void {
+ InitializeBeforeRealLaunch();
+
+ // wake-up by real launch
+ reallaunch_mutex.lock();
+ LOG(INFO) << "reallaunch_worker";
+ auto& app_data_tv = ApplicationDataTV::GetInstance();
+ if (!app_data_tv.IsHostedApp() && app_data_tv.HasWidgetLicense()) {
+ std::ignore = GetEncryptedFileHandler();
+ }
+ NativeWebRuntimeDelegateTV::GetInstance().BuildPrivilegeCache();
+ XWalkExtensionManager::GetInstance()->PrefetchExtensions();
+ GroupZygoteProcess(false);
+ reallaunch_mutex.unlock();
});
- loader_boost_worker.detach();
+ reallaunch_worker.detach();
+
+}
+
+void WRTMainDelegateTV::LoaderCreated() {
+ CreateWorkers();
+
+ auto* ee = WRTNativeWindow::GetPlatformCanvas();
+#if !defined(ENABLE_WRT_JS)
+ GLSharedContextEfl::Initialize(ee);
+#endif
+ InputDeviceManager::GetInstance()->PreInitialize(ee);
+ WRTNativeWindowTV::SetGlobalResourceId(WRTNativeWindow::GetTopWindow());
+ SetPriorityAsIdle();
+}
+
+void WRTMainDelegateTV::LoaderTerminated() {
+ reallaunch_mutex.unlock();
}
void WRTMainDelegateTV::PrelaunchOnLoader(const std::string& pkg_id) {
prelaunch_pkg_id = pkg_id;
- worker_mutex.unlock();
+ prelaunch_mutex.unlock();
}
content::ContentBrowserClient* WRTMainDelegateTV::CreateContentBrowserClient() {
explicit WRTMainDelegateTV();
~WRTMainDelegateTV() {}
+ static void GroupZygoteProcess(bool is_oom);
+
private:
absl::optional<int> BasicStartupComplete() override;
bool CheckPlatformReady(int argc, char** argv) override;
void LoaderCreated() override;
+ void LoaderTerminated() override;
void PrelaunchOnLoader(const std::string& pkg_id) override;
bool PreSetup() override;
absl::optional<int> PostEarlyInitialization(InvokedIn invoked_in) override;
- bool SupportLazyInitialize() override;
+
+ void CreateWorkers();
content::ContentBrowserClient* CreateContentBrowserClient() override;
content::ContentRendererClient* CreateContentRendererClient() override;
-
- bool lazy_initialize_;
};
} // namespace wrt
loader_lifecycle_callback_s callback;
callback.create = [](bundle* extra, int type, void* user_data) {
LOG(INFO) << "loader created";
- ecore_idler_add(
- [](void* data) {
- LOG(INFO) << "ContentMain will be initialized in idler.";
- auto* content_main = static_cast<WRTContentMain*>(data);
- if (!content_main->main_delegate_->SupportLazyInitialize()) {
- content_main->Initialize();
- content_main->main_delegate_->LoaderCreated();
- }
- return ECORE_CALLBACK_CANCEL;
- }, static_cast<Loader*>(user_data)->content_main_);
+ auto* content_main = static_cast<Loader*>(user_data)->content_main_;
+ content_main->Initialize();
+ content_main->main_delegate_->LoaderCreated();
};
#if TIZEN_VERSION_AT_LEAST(6, 5, 0)
callback.prelaunch = [](int argc, char** argv, const char* app_path,
callback.terminate = [](int argc, char** argv, void* user_data) {
LOG(INFO) << "loader terminated";
auto* content_main = static_cast<Loader*>(user_data)->content_main_;
- if (content_main->main_delegate_->SupportLazyInitialize())
- content_main->Initialize();
-
+ content_main->main_delegate_->LoaderTerminated();
for (int i = 0; i < argc; ++i)
LOG(INFO) << "argv[" << i << "] : " << argv[i];
base::CommandLine::ForCurrentProcess()->SetProgram(
// product specific functions
virtual bool CheckPlatformReady(int argc, char** argv) { return true; }
- virtual bool SupportLazyInitialize() { return false; }
virtual void LoaderCreated() {}
+ virtual void LoaderTerminated() {}
virtual void PrelaunchOnLoader(const std::string& pkg_id) {}
virtual bool PreSetup();
auto product_type = GetProductType();
return "LFD" == product_type || "IWB" == product_type;
}
+
+bool IsSmartMonitor() {
+ bool bsmart_monitor = false;
+ if (system_info_get_custom_bool(
+ "com.samsung/featureconf/product.smart_monitor_feature_support",
+ &bsmart_monitor) != SYSTEM_INFO_ERROR_NONE) {
+ LOG(WARNING) << "fail to get smart_monitor_feature_support";
+ return false;
+ }
+ return bsmart_monitor;
+}
+
+bool IsVisualControllerSupported() {
+ bool is_supported = false;
+ if (SYSTEM_INFO_ERROR_NONE !=
+ system_info_get_custom_bool(
+ "com.samsung/featureconf/multiview.visual_controller_support",
+ &is_supported)) {
+ LOG(ERROR) << "Fail to get system info: visual_controller_support";
+ }
+ LOG(INFO) << "multiview.visual_controller supported : " << is_supported;
+ return is_supported;
+}
#endif
} // namespace wrt
bool IsSignageProduct();
bool IsUHDAModel();
bool Is8KPanel();
+bool IsSmartMonitor();
bool HasLimitQuotaPermission();
+bool IsVisualControllerSupported();
#endif
} // namespace wrt
Json::Value root;
Json::Value camera_device_list;
root["device_count"].append(std::to_string(device_list.count));
- for (int i = 0; i < device_list.count; i++) {
+ for (unsigned int i = 0; i < device_list.count; i++) {
Json::Value camera_device_info;
camera_device_info["type"] = std::to_string(device_list.device[i].type);
camera_device_info["name"] = std::string(device_list.device[i].name);
WRTProxyingURL WRTProxyingURLLoaderFactory::ParseURL(const GURL& url) {
auto& resource_manager = WRTProxyingURLLoaderFactory::GetResourceManager();
if (!resource_manager.AllowedResource(url.possibly_invalid_spec())) {
- LOG(ERROR) << "request was blocked by WARP";
+ LOG(ERROR) << "request[" << url.possibly_invalid_spec()
+ << "] was blocked by WARP";
return GURL("about:blank");
}
#if defined(OS_TIZEN_TV_PRODUCT)
return false;
}
+ LOG(INFO) << "appdrm_load_license() start";
if (appdrm_load_license(path.AsUTF8Unsafe().c_str(),
&license_handle_) != 0) {
std::string vconfValue =
#endif
return false;
}
+ LOG(INFO) << "appdrm_load_license() end";
return true;
}
void InputDeviceManager::PreInitialize(Ecore_Evas* ee) {
Ecore_Wl2_Window* wl_win = ecore_evas_wayland2_window_get(ee);
- wl_surface* surface = ecore_wl2_window_surface_get(wl_win);
- KeyRouter_RegisterNONEKey(surface);
+ focus_surface_ = ecore_wl2_window_surface_get(wl_win);
+ KeyRouter_RegisterNONEKey(focus_surface_);
+ did_register_none_ = true;
}
void InputDeviceManager::Initialize(Evas_Object* focus_view) {
- if (focus_surface_)
- return;
SetFocusSurface(focus_view);
RegisterMandatoryKeys();
}
}
void InputDeviceManager::SetFocusSurface(Evas_Object* focus_view) {
+ if (focus_surface_)
+ return;
+
Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(focus_view));
Ecore_Wl2_Window* wl_window = ecore_evas_wayland2_window_get(ee);
focus_surface_ = (struct wl_surface*)ecore_wl2_window_surface_get(wl_window);
}
void InputDeviceManager::RegisterMandatoryKeys() {
- KeyRouter_RegisterNONEKey(focus_surface_);
+ if (!did_register_none_)
+ KeyRouter_RegisterNONEKey(focus_surface_);
RegisterKey(default_keys);
}
FocusSurface* focus_surface_ = nullptr;
Ecore_Timer* lazy_handler_ = nullptr;
bool use_functionkey_ = false;
+ bool did_register_none_ = false;
std::map<std::string, std::tuple<const char*, unsigned>> func_keymap_;
};
#include <message_port.h>
#include <pkgmgr-info.h>
#include <privileged-service/PS_API.h>
+#include <security-manager/security-manager.h>
#include <tzplatform_config.h>
#include "base/command_line.h"
#include "tizen_src/chromium_impl/tizen/vconf_handle.h"
#endif
#include "tizen_src/ewk/efl_integration/common/application_type.h"
+#if !defined(WRT_JS_BRINGUP)
+#include "tizen_src/ewk/efl_integration/ewk_privilege_checker.h"
+#endif
#include "v8/include/v8.h"
+#include "wrt/src/app/tv/wrt_main_delegate_tv.h"
#include "wrt/src/base/platform_info.h"
#include "wrt/src/browser/native_web_runtime.h"
-#include "wrt/src/browser/net/tv/encrypted_file_url_loader.h"
#include "wrt/src/browser/tv/ambient_mode.h"
#include "wrt/src/browser/tv/decorator_window.h"
#include "wrt/src/browser/tv/mounter.h"
namespace {
-#define NEED_CHECK_DEADMOUNT 16
+#define NEED_CHECK_DEADMOUNT \
+ 6 // vconf wrt loader init value is -1, 6 plus 1 is 7
const char* kAllowMixedContent =
"http://samsung.com/tv/metadata/allow.mixedcontent";
std::unique_ptr<Mounter> tmg_mounter;
base::Lock worker_thread_lock;
-bool runtime_finalized = false;
bool MountTmgFile(const base::FilePath& tmg_file, bool try_mknod) {
base::AutoLock lock(worker_thread_lock);
bool ShouldRunClearDeadMount() {
#if !defined(WRT_JS_BRINGUP)
auto wrtloader_count = VconfHandle(kWrtLoaderCount).Int();
+ LOG(INFO) << "vconf loader_count is " << wrtloader_count;
if (wrtloader_count < NEED_CHECK_DEADMOUNT) {
VconfHandle(kWrtLoaderCount).Set((++wrtloader_count), true);
return false;
}
}
+NativeWebRuntimeDelegateTV::NativeWebRuntimeDelegateTV() {
+#if !defined(WRT_JS_BRINGUP)
+ content::EwkPrivilegeChecker::GetInstance()->SetPrivilegeChecker(
+ base::BindRepeating(&NativeWebRuntimeDelegateTV::CheckPrivilege,
+ base::Unretained(this)));
+#endif
+}
+
void NativeWebRuntimeDelegateTV::Initialize(void* data) {
ApplicationData::GetInstance().Initialize();
app_id_ = ApplicationData::GetInstance().app_id();
extension_manager->ParseUpgradableExtensions();
extension_manager->RegisterUpgradableExtensions();
initialized_ = true;
-
- std::thread worker_on_app([]() -> void {
- LOG(INFO) << "worker_on_app start";
- base::AutoLock lock(worker_thread_lock);
- if (runtime_finalized) return;
- if (ApplicationDataTV::GetInstance().HasWidgetLicense()) {
- std::ignore = GetEncryptedFileHandler();
- }
- XWalkExtensionManager::GetInstance()->PrefetchExtensions();
- });
- worker_on_app.detach();
}
void NativeWebRuntimeDelegateTV::DidInitialized() {
VideoSplashScreen::InitializeVSS();
SetD2dServiceMessageListener();
+ SubscribePowerState();
content::SetApplicationType(content::ApplicationType::TIZENWRT);
// Drop process privillages while web app is launching
void NativeWebRuntimeDelegateTV::Finalize() {
base::AutoLock lock(worker_thread_lock);
- runtime_finalized = true;
if (device_power_unsubscribe_state_changed_event(ChangeAmbientModeCallback)
!= POWER_ERROR_NONE)
LOG(WARNING) << "failed to unregister state changed event callback";
ClearTmpFolder();
}
+std::string NativeWebRuntimeDelegateTV::CheckPrivilege(
+ const std::string& privilege) {
+ if (!initialized_) {
+ LOG(INFO) << "Not initialized : " << privilege;
+ return "not_found";
+ }
+
+ std::string privilege_exist;
+ if (privilege_cahce_init_) {
+ if (privileges_cache_.find(privilege) != privileges_cache_.end())
+ privilege_exist = "found";
+ else
+ privilege_exist = "not_found";
+ } else {
+ auto& permissions =
+ ApplicationData::GetInstance().permissions_info().GetAPIPermissions();
+ if (permissions.find(privilege) != permissions.end())
+ privilege_exist = "found";
+ }
+
+ LOG(INFO) << "CheckPrivilege : " << privilege << " - " << privilege_exist;
+ return privilege_exist;
+}
+
+void NativeWebRuntimeDelegateTV::BuildPrivilegeCache() {
+ if (!privileges_cache_.empty())
+ return;
+
+ auto app_id = ApplicationData::GetInstance().app_id();
+ char** privileges = nullptr;
+ size_t size = 0;
+ LOG(INFO) << "security_manager_get_app_manifest_policy start";
+ security_manager_get_app_manifest_policy(
+ app_id.c_str(), getuid(), &privileges, &size);
+ LOG(INFO) << "security_manager_get_app_manifest_policy end";
+
+ if (!size)
+ return;
+
+ base::AutoLock lock(worker_thread_lock);
+ for (unsigned int i = 0; i < size; i++) {
+ if (!privileges[i]) continue;
+ LOG(INFO) << "privileges[i] : " << privileges[i];
+ privileges_cache_.insert(std::string(privileges[i]));
+ }
+
+ if (privileges_cache_.size() > 0)
+ privilege_cahce_init_ = true;
+
+ content::GetUIThreadTaskRunner({})->PostTask(
+ FROM_HERE,
+ base::BindOnce(&XWalkExtensionManager::SetCachedPrivileges,
+ base::Unretained(XWalkExtensionManager::GetInstance())));
+}
+
+std::set<std::string> NativeWebRuntimeDelegateTV::GetPrivilegeCache() {
+ base::AutoLock lock(worker_thread_lock);
+ return privileges_cache_;
+}
+
std::string NativeWebRuntimeDelegateTV::GetDiskCachePath() {
return disk_cache_path_;
}
}
void NativeWebRuntimeDelegateTV::SubscribePowerState() {
+ if (power_callback_registered_)
+ return;
+
+ base::AutoLock lock(worker_thread_lock);
if (device_power_subscribe_state_changed_event(
- ChangeAmbientModeCallback, this) != POWER_ERROR_NONE)
+ ChangeAmbientModeCallback, this) != POWER_ERROR_NONE) {
LOG(INFO) << "Can't subscribe power-state-changed event callback";
+ return;
+ }
+ power_callback_registered_ = true;
}
void NativeWebRuntimeDelegateTV::BeforeAppControlEvent(
void NativeWebRuntimeDelegateTV::HandleLowMemory() {
#if !defined(WRT_JS_BRINGUP)
- static bool low_memory_hard_warning = false;
- int low_memory_status = VconfHandle(VCONFKEY_SYSMAN_LOW_MEMORY).Int();
- if (low_memory_status == VCONFKEY_SYSMAN_LOW_MEMORY_HARD_WARNING)
- low_memory_hard_warning = true;
- if (low_memory_hard_warning && !electron::WindowList::IsEmpty()) {
+ if (electron::Browser::Get()->is_quitting()) {
+ LOG(ERROR) << "app is quiting, just return";
+ return;
+ }
+
+ WRTMainDelegateTV::GroupZygoteProcess(true);
+ if (!electron::WindowList::IsEmpty()) {
WRTNativeWindow* main_window = WRTNativeWindow::GetMainNativeWindow();
if (main_window && !main_window->IsEnabled()) {
- LOG(ERROR) << "Try to terminate itself by low memory";
+ LOG(ERROR) << "Try to terminate itself(bg app) by low memory";
NativeWebRuntime::GetInstance().RequestQuit();
- return;
}
}
- low_memory_hard_warning = true;
#endif
}
// static
void NativeWebRuntimeDelegateTV::PreSetupOnWorker() {
LOG(INFO) << "PreSetupOnWorker";
- GetInstance().TryMount();
+ if (!ApplicationData::GetInstance().IsHostedApp())
+ GetInstance().TryMount();
GetInstance().PepperUpdatePluginService();
}
void NativeWebRuntimeDelegateTV::SetLocaleDir() {
if (locale_dir_binded_)
return;
+
+ base::AutoLock lock(worker_thread_lock);
base::FilePath locale_dir;
base::PathService::Get(PathsEfl::DIR_LOCALE, &locale_dir);
auto dir = locale_dir.value().c_str();
locale_dir_binded_ = true;
}
+void NativeWebRuntimeDelegateTV::PreloadVconfKeys() {
+#if !defined(WRT_JS_BRINGUP)
+ LOG(INFO) << "PreloadVconfKeys start";
+ const char* kVconfAccessibilityTts = "db/setting/accessibility/tts";
+ const char* kVconfHomeAppId = "db/appfw/overlay_home_appid";
+ const char* kVconfHwDuid = "db/comss/hwduid";
+ const char* kVconfInspectedAppId = "db/rwi/inspected_appid";
+ const char* kVconfLanguage = "db/menu_widget/language";
+ const char* kVconfRegionFormat = "db/menu_widget/regionformat";
+ const char* kVconfRegionFormatTime = "db/menu_widget/regionformat_time1224";
+ const char* kVconfVoiceTouchAutoMode = "db/voice/vc/voice_touch/automode";
+ const char* kVconfRotationState = "db/sysman/rotation_state";
+
+ const char* kVconfDisplayRotatorStatus = "memory/display_rotator/status";
+ const char* kVconfLowMemory = "memory/sysman/low_memory";
+ const char* kVconfProxy = "memory/dnet/proxy";
+
+ VconfHandle(kVconfAccessibilityTts).Bool();
+ VconfHandle(kVconfHomeAppId).Str();
+ VconfHandle(kVconfHwDuid).Str();
+ VconfHandle(kVconfInspectedAppId).Str();
+ VconfHandle(kVconfLanguage).Str();
+ VconfHandle(kVconfRegionFormat).Str();
+ VconfHandle(kVconfRegionFormatTime).Int();
+ VconfHandle(kVconfVoiceTouchAutoMode).Bool();
+ VconfHandle(kVconfRotationState).Int();
+
+ VconfHandle(kVconfDisplayRotatorStatus).Int();
+ VconfHandle(kVconfLowMemory).Int();
+ VconfHandle(kVconfProxy).Str();
+ LOG(INFO) << "PreloadVconfKeys end";
+#endif
+}
+
+void NativeWebRuntimeDelegateTV::PreloadFMS() {
+ LOG(INFO) << "PreloadFMS start";
+ int width = 0;
+ int height = 0;
+ GetProductDiskCacheSize();
+ GetProductType();
+ GetPanelResolution(&width, &height);
+ GetWebIsolationSupport();
+ IsSmartMonitor();
+ LOG(INFO) << "PreloadFMS end";
+}
+
} // namespace wrt
void AfterAppControlEvent(const app_control_h app_control);
void PepperUpdatePluginService();
void PostEarlyInitialization();
+ void PreloadVconfKeys();
+ void PreloadFMS();
void SubscribePowerState();
void TryMount();
proxy_info_ = proxy_info;
}
+ void BuildPrivilegeCache();
+ std::set<std::string> GetPrivilegeCache();
+
private:
- NativeWebRuntimeDelegateTV() {}
+ NativeWebRuntimeDelegateTV();
~NativeWebRuntimeDelegateTV() {}
void DidInitialized() override;
void SetD2dServiceMessageListener();
void SetDiskCache(bool enable);
base::FilePath GetTmgFilePath();
+ std::string CheckPrivilege(const std::string& privilege);
std::string app_id_;
std::string disk_cache_path_;
bool need_try_mount_ = true;
bool initialized_ = false;
bool locale_dir_binded_ = false;
+ bool privilege_cahce_init_ = false;
+ bool power_callback_registered_ = false;
base::FilePath tmg_file_path_;
+ std::set<std::string> privileges_cache_;
};
} // namespace wrt
url.erase(found);
}
- widget_url = url;
#if !defined(WRT_JS_BRINGUP)
std::string vkey = kPrefixVconfKeyWidgetStatus + widget_app_id + "_URL";
- std::string url_value = VconfHandle(vkey).Str();
- LOG(INFO) << "vconf key before :" << url_value;
+ LOG(INFO) << "vconf key before :" << widget_url;
LOG(INFO) << "vconf key after :" << vkey << ", value :" << url;
VconfHandle(vkey).Set(url, true);
#endif
+ widget_url = url;
}
} // namespace wrt
const double kScaleFactorDefault = 1.0;
const double kScaleFactorLandscapeScale = 0.5625;
+unsigned int global_resource_id = 0;
+unsigned int wayland_window_id = 0;
+
void HandleResourceId(
void* data, struct tizen_resource* tizen_resource, uint32_t id) {
- unsigned int* wl_surface_id = static_cast<unsigned int*>(data);
- *wl_surface_id = id;
+ global_resource_id = id;
LOG(INFO) << "got global resource id(" << id << ") from server ";
+ auto resource_id = std::to_string(id);
+ setenv("global_resource_id", resource_id.c_str(), true);
}
void GetScreenResolution(int& width, int& height) {
return false;
#else
auto is_signage = IsSignageProduct();
+ if (!is_signage)
+ return false;
auto rotate_status = VconfHandle(kMenuOrientation).Int();
auto& meta_data_info = ApplicationData::GetInstance().meta_data_info();
auto is_landscape_scale =
ecore_evas_layer_set(ee, foreground_layer);
}
+unsigned int WRTNativeWindowTV::GetGlobalResourceId() {
+ return global_resource_id;
+}
+
int WRTNativeWindowTV::GetWindowLayer() {
auto* ee = GetPlatformCanvas();
if (ee)
WRTNativeWindowTV::WRTNativeWindowTV(const gin_helper::Dictionary& options,
electron::NativeWindow* parent)
: WRTNativeWindow::WRTNativeWindow(options, parent),
- global_resource_id_(0),
- wayland_window_id_(0),
alphaset_(false),
partial_(false),
channel_changeable_(false),
return;
top_window_ = GetTopWindow();
+ SetGlobalResourceId(top_window_);
#if defined(TIZEN_PEPPER_EXTENSIONS)
InitializePepperExtensionSystem();
TvWindowManager::GetInstance()->Initialize(top_window_);
SetDisplayRotatorCallback();
CreateMouseCursor(ewk_view);
- SetGlobalResourceId();
SetAppMetaDataInfo();
SetRuntimeVariables();
SetProxyInfo();
CursorModule_Finalize();
}
-void WRTNativeWindowTV::SetGlobalResourceId() {
- global_resource_id_ = 0;
+// static
+void WRTNativeWindowTV::SetGlobalResourceId(Evas_Object* top_window) {
+ if (global_resource_id)
+ return;
- Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(top_window_));
+ Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(top_window));
Ecore_Wl2_Window* wl_window = ecore_evas_wayland2_window_get(ee);
- wayland_window_id_ =
+ wayland_window_id =
static_cast<unsigned int>(ecore_wl2_window_id_get(wl_window));
- LOG(INFO) << "window_ = " << top_window_ << ", wl_window = " << wl_window
- << ", windowid = " << wayland_window_id_;
+ LOG(INFO) << "window_ = " << top_window << ", wl_window = " << wl_window
+ << ", windowid = " << wayland_window_id;
struct wl_surface* wl_surface =
(struct wl_surface*)ecore_wl2_window_surface_get(wl_window);
Ecore_Wl2_Display* wl2_display = ecore_wl2_connected_display_get(nullptr);
if (tz_resource) {
wl_proxy_set_queue((struct wl_proxy*)tz_resource, wl_queue);
- tizen_resource_add_listener(
- tz_resource, &tz_resource_listener, &global_resource_id_);
+ tizen_resource_add_listener(tz_resource, &tz_resource_listener, nullptr);
wl_display_roundtrip_queue(wl_display, wl_queue);
} else
LOG(ERROR) << "error to find tz_resource";
void WRTNativeWindowTV::SetRuntimeVariables() {
auto& runtime = NativeWebRuntime::GetInstance();
- std::string global_resource_id = std::to_string(global_resource_id_);
LOG(INFO) << "global_resource_id : " << global_resource_id;
- runtime.SetRuntimeVariable("global_resource_id", global_resource_id);
+ runtime.SetRuntimeVariable("global_resource_id",
+ std::to_string(global_resource_id));
std::ostringstream ostr_window_id;
ostr_window_id << top_window_;
}
bool WRTNativeWindowTV::IsSameWindowId(const unsigned int window_id) {
- return (wayland_window_id_ == window_id);
+ return (wayland_window_id == window_id);
}
void WRTNativeWindowTV::TakeScreenshot(
static void MoveWindowBackground();
static void MoveWindowForeground();
static int GetWindowLayer();
+ static unsigned int GetGlobalResourceId();
static void SetMenuZoomFill(const std::string& enable);
+ static void SetGlobalResourceId(Evas_Object* top_window);
static bool SetRotation();
explicit WRTNativeWindowTV(const gin_helper::Dictionary& options,
WRTNativeWindowTV(const WRTNativeWindowTV&) = delete;
WRTNativeWindowTV& operator=(const WRTNativeWindowTV&) = delete;
- unsigned int GetGlobalResourceId() const { return global_resource_id_; }
-
void DidFinishNavigation(const std::string& url);
void ExecuteJavaScript(const std::string& script);
void GetImeAndKeyPadConfig(bool& show_ime_panel,
void SetConformantObject(ConformantStyle style);
void SetDimScreen();
void SetDisplayRotatorCallback();
- void SetGlobalResourceId();
void SetInvisibleDelivery();
void SetKeyboardFuncKey();
void SetKeyEventChecker();
base::OneShotTimer suspend_timer_;
unsigned int suspend_delay_ = 500; // ms
- unsigned int global_resource_id_;
- unsigned int wayland_window_id_;
bool alphaset_;
bool partial_;
bool channel_changeable_;
app_control_add_extra_data(handle, kCommandKey, extra_key);
app_control_add_extra_data(handle, kCommandValue, extra_value);
}
-#if defined(OS_TIZEN_TV_PRODUCT)
- // to disable dynamic boosting
- app_control_add_extra_data(handle, "Preloading", "true");
-#endif
ret = app_control_send_launch_request(handle, nullptr, nullptr);
if (ret != APP_CONTROL_ERROR_NONE) {
LOG(ERROR) << "Failed to send launch request : " << ret;
#include "wrt/src/service/wrt_service.h"
#include "wrt/xwalk_extensions/browser/xwalk_extension_manager.h"
+#if defined(OS_TIZEN_TV_PRODUCT) && TIZEN_VERSION_AT_LEAST(7, 0, 0)
+#include <boost-api.h>
+#endif
+
namespace wrt {
namespace {
return std::string(reinterpret_cast<char*>(encoded_data), bundle_length);
}
+#if defined(OS_TIZEN_TV_PRODUCT) && TIZEN_VERSION_AT_LEAST(7, 0, 0)
+void RequestAsBackgroundProcess() {
+ static bool did_boost_down = false;
+ if (!did_boost_down) {
+ boost_app_info_t app_info;
+ app_info.parent.framework_type = BOOST_APP_FW;
+ app_info.window_type = WINDOW_TYPE_UNDEFINED;
+ app_info.status = BOOST_APP_EVENT_CREATE_REQUEST_PRELOAD;
+ boost_request_by_pid(getpid(), (const boost_info_t *)&app_info);
+ did_boost_down = true;
+ }
+}
+#endif
} // namespace
WRTServiceManager::WRTServiceManager() : quit_requested_(false) {
ecore_init();
CreateUvHandlers();
DelayShutdown();
- EarlyInitialization();
+ uv_init_threadpool();
}
WRTServiceManager::~WRTServiceManager() {}
return manager;
}
-void WRTServiceManager::EarlyInitialization() {
- uv_init_threadpool();
- XWalkExtensionManager::GetInstance()->EarlyInitialization();
-}
-
void WRTServiceManager::Shutdown() {
LOG(INFO) << "WRTServiceManager is in shutdown!";
XWalkExtensionManager::GetInstance()->Shutdown();
return;
}
+#if defined(OS_TIZEN_TV_PRODUCT) && TIZEN_VERSION_AT_LEAST(7, 0, 0)
+ RequestAsBackgroundProcess();
+#endif
+
std::vector<std::string> services;
uv_mutex_lock(&service_manager->mutex_);
services.swap(service_manager->prepared_to_start_services_);
void InitAulHandler(int argc, char** argv);
void CloseUvHandlers();
void CreateUvHandlers();
- void EarlyInitialization();
bool HandleMessageQueue();
uv_async_t handle_adder_;
#include "wrt/src/common/app_db.h"
#include "wrt/src/common/constants.h"
+#ifndef XWALK_EXTENSION_PATH
+ #error XWALK_EXTENSION_PATH is not set.
+#endif
+
namespace wrt {
+XWalkExtensionManagerTV::XWalkExtensionManagerTV() {
+ preload_extensions_["widget"] =
+ XWALK_EXTENSION_PATH + std::string("/libwidget_plugin.so");
+
+ lazyload_extensions_["tizen.systeminfo"] =
+ XWALK_EXTENSION_PATH + std::string("/libtizen_systeminfo.so");
+ lazyload_extensions_["webapis.productinfo"] =
+ XWALK_EXTENSION_PATH + std::string("/libwebapis_productinfo.so");
+ lazyload_extensions_["webapis.avplay"] =
+ XWALK_EXTENSION_PATH + std::string("/libwebapis_avplay.so");
+
+ EarlyInitialization();
+}
+
+bool XWalkExtensionManagerTV::OpenTizenCommonExntension() {
+ if (tizen_common_dlhandle_)
+ return true;
+
+ const char* tizen_common = XWALK_EXTENSION_PATH"/libtizen_common.so";
+ tizen_common_dlhandle_ = dlopen(tizen_common, RTLD_LAZY);
+ if (!tizen_common_dlhandle_) {
+ LOG(WARNING) << "fail to dlopen : " << dlerror();
+ return false;
+ }
+ return true;
+}
+
+void XWalkExtensionManagerTV::EarlyInitialization() {
+ if (!OpenTizenCommonExntension())
+ return;
+
+ typedef void (*CreateTaskQueue)(void);
+ auto create_task_queue =
+ (CreateTaskQueue)dlsym(tizen_common_dlhandle_, "CreateTaskQueue");
+ if (!create_task_queue) {
+ LOG(INFO) << "fail to dlsym : " << dlerror();
+ return;
+ }
+ create_task_queue();
+}
+
+void XWalkExtensionManagerTV::SetCachedPrivileges() {
+ if (!OpenTizenCommonExntension())
+ return;
+
+ auto privileges =
+ NativeWebRuntimeDelegateTV::GetInstance().GetPrivilegeCache();
+ if (privileges.empty())
+ return;
+
+ LOG(INFO) << "SetCachedPrivilege";
+ typedef void (*SetCachedPrivilege)(const char*);
+ auto set_privilege =
+ (SetCachedPrivilege)dlsym(tizen_common_dlhandle_, "SetCachedPrivilege");
+ if (!set_privilege) {
+ LOG(INFO) << "fail to dlsym : " << dlerror();
+ return;
+ }
+
+ for (const auto& privilege : privileges)
+ set_privilege(privilege.c_str());
+}
+
void XWalkExtensionManagerTV::LoadExtensions(
wrt::ApplicationData::AppType app_type) {
XWalkExtensionManager::LoadExtensions(app_type);
}
return "failed";
} else if (type == "tizen://getGlobalResourceId") {
- if (auto native_window_tv = wrt::WRTNativeWindowTV::GetMainNativeWindow()) {
- return std::to_string(native_window_tv->GetGlobalResourceId());
- }
- return "0";
+ return std::to_string(WRTNativeWindowTV::GetGlobalResourceId());
} else {
return XWalkExtensionManager::HandleRuntimeMessageInternal(type, value);
}
return std::string();
}
+void XWalkExtensionManagerTV::PreloadExtensions() {
+ XWalkExtensionManager::PreloadExtensions();
+
+ for (auto& extension : lazyload_extensions_) {
+ LOG(INFO) << "preload name: " << extension.first
+ << ",lib:" << extension.second;
+ void* dlhandle = dlopen(extension.second.c_str(), RTLD_LAZY);
+ if (!dlhandle)
+ LOG(WARNING) << "Fail to load libs : " << dlerror();
+ else
+ preload_handle_[extension.second] = dlhandle;
+ }
+}
+
} // namespace wrt
class XWalkExtensionManagerTV : public XWalkExtensionManager {
public:
- XWalkExtensionManagerTV() {}
+ XWalkExtensionManagerTV();
~XWalkExtensionManagerTV() {}
private:
void CreateInstance(const std::string& name,
CreateInstanceCallback callback) override;
void PrefetchExtensions() override;
+ void PreloadExtensions() override;
void ParseUpgradableExtensions() override;
void RegisterUpgradableExtensions() override;
+ void SetCachedPrivileges() override;
void UnloadExtensions() override;
std::string GetUpgradableLibPath(const std::string& name) override;
std::string HandleRuntimeMessageInternal(
const std::string& type, const std::string& value) override;
+ void EarlyInitialization();
bool IsPreloadedExtension(std::string extension_name);
bool NeedHandleUpgradeWebapiJson();
+ bool OpenTizenCommonExntension();
void SaveLoadedExtensions();
using ExtensionInfo = std::map<std::string, std::string>;
std::map<std::string, std::vector<std::string>>
upgradable_extensions_entries_; // "name" : enties[]
base::Time upgrade_webapi_modified_time_;
+ void* tizen_common_dlhandle_ = nullptr;
+ std::map<std::string, std::string> lazyload_extensions_;
};
} // namespace wrt
XWALK_EXTENSION_PATH + std::string("/libtizen_application.so");
preload_extensions_["xwalk"] =
XWALK_EXTENSION_PATH + std::string("/libtizen_utils.so");
-#if defined(OS_TIZEN_TV_PRODUCT)
- preload_extensions_["widget"] =
- XWALK_EXTENSION_PATH + std::string("/libwidget_plugin.so");
-#endif
}
XWalkExtensionManager::~XWalkExtensionManager() {}
extensions_.clear();
}
-void XWalkExtensionManager::EarlyInitialization() {
- const char* tizen_common = XWALK_EXTENSION_PATH"/libtizen_common.so";
- void* dlhandle = dlopen(tizen_common, RTLD_LAZY);
- if (!dlhandle) {
- LOG(WARNING) << "fail to dlopen : " << dlerror();
- return;
- }
- typedef void (*CreateTaskQueue)(void);
- auto create_task_queue = (CreateTaskQueue)dlsym(dlhandle, "CreateTaskQueue");
- if (!create_task_queue) {
- LOG(WARNING) << "fail to dlsym : " << dlerror();
- return;
- }
- create_task_queue();
-}
-
bool XWalkExtensionManager::ValidateSymbols(XWalkExtension* extension) {
auto& name = extension->GetName();
if (extension_symbols_.find(name) != extension_symbols_.end()) {
const ExtensionMap& GetExtensions() const { return extensions_; }
XWalkExtension::Instance* GetExtensionInstance(XW_Instance xw_instance);
- void EarlyInitialization();
void GetRuntimeVariable(const char* key, char* value, size_t value_len);
void LoadUserExtensions(const std::string app_path);
- void PreloadExtensions();
void RegisterInstance(XWalkExtension::Instance* instance);
void UnregisterInstance(XWalkExtension::Instance* instance);
int32_t GetNextInstanceID();
- // product specific functions
+ virtual void PreloadExtensions();
virtual void LoadExtensions(wrt::ApplicationData::AppType app_type);
virtual void UnloadExtensions();
+ // product specific functions
virtual void PrefetchExtensions() {}
virtual void ParseUpgradableExtensions() {}
virtual void RegisterUpgradableExtensions() {}
+ virtual void SetCachedPrivileges() {}
virtual std::string GetUpgradableLibPath(const std::string& name) {
return std::string();
}