[M108 Migration][WRTjs] Introduce VconfHandle 33/289233/3
authorDongHyun Song <dh81.song@samsung.com>
Fri, 3 Mar 2023 04:27:03 +0000 (13:27 +0900)
committerDongHyun Song <dh81.song@samsung.com>
Sun, 5 Mar 2023 23:29:10 +0000 (08:29 +0900)
Adds source code of VconfHandle and removes bring-up tag.

Change-Id: I30a8ae83ac9e423d1a3778dca6b0aac497fd6880
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
14 files changed:
content/common/zygote/zygote_communication_linux.cc
content/common/zygote/zygote_communication_linux.h
tizen_src/chromium_impl/tizen/BUILD.gn
tizen_src/chromium_impl/tizen/vconf_handle.cc [new file with mode: 0644]
tizen_src/chromium_impl/tizen/vconf_handle.h [new file with mode: 0644]
wrt/src/app/tv/wrt_main_delegate_tv.cc
wrt/src/browser/api/tv/wrt_api_tv_extension.cc
wrt/src/browser/api/wrt_api_mde_extension.cc
wrt/src/browser/native_app_control.cc
wrt/src/browser/tv/encrypted_file_handler.cc
wrt/src/browser/tv/native_web_runtime_delegate_tv.cc
wrt/src/browser/tv/tv_window_manager.cc
wrt/src/browser/tv/widget_state.cc
wrt/src/browser/tv/wrt_native_window_tv.cc

index 06a5ce0..d590520 100644 (file)
@@ -357,4 +357,9 @@ void ZygoteCommunication::DropProcessPrivileges(const std::string& app_id) {
 }
 #endif
 
+#if defined(OS_TIZEN_TV_PRODUCT)
+pid_t ZygoteCommunication::GetZygotePid() {
+  return pid_;
+}
+#endif
 }  // namespace content
index 8eef1ae..eafc893 100644 (file)
@@ -78,6 +78,10 @@ class CONTENT_EXPORT ZygoteCommunication {
   void DropProcessPrivileges(const std::string& app_id);
 #endif
 
+#if defined(OS_TIZEN_TV_PRODUCT)
+  pid_t GetZygotePid();
+#endif
+
  private:
   // Should be called every time a Zygote child is born.
   void ZygoteChildBorn(pid_t process);
index aadfb32..efcb5c1 100644 (file)
@@ -10,7 +10,10 @@ static_library("system-info") {
   public_configs = [ "//tizen_src/build:capi-system-info-public" ]
 
   sources = [
+    "vconf_handle.cc",
+    "vconf_handle.h",
     "system_info.h",
     "system_info.cc",
   ]
+  deps = [ "//base" ]
 }
diff --git a/tizen_src/chromium_impl/tizen/vconf_handle.cc b/tizen_src/chromium_impl/tizen/vconf_handle.cc
new file mode 100644 (file)
index 0000000..3de3ae7
--- /dev/null
@@ -0,0 +1,89 @@
+// Copyright 2019 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "vconf_handle.h"
+
+#include <memory>
+
+#include "base/logging.h"
+
+#if defined(OS_TIZEN_TV_PRODUCT)
+#include <vconf/vconf_rtc.h>
+#endif
+
+VconfHandle::VconfHandle(const std::string vconf_key) {
+  vconf_key_ = vconf_key;
+}
+
+std::string VconfHandle::Str() {
+  std::unique_ptr<char, decltype(std::free)*>
+    vconf_value {vconf_get_str(vconf_key_.c_str()), std::free};
+  if (!vconf_value.get()) {
+    return std::string();
+  } else {
+    return std::string(vconf_value.get());
+  }
+}
+
+int VconfHandle::Int() {
+  int vconf_value = 0;
+  if (vconf_get_int(vconf_key_.c_str(), &vconf_value) < 0)
+    return -1;
+  return vconf_value;
+}
+
+absl::optional<bool> VconfHandle::Bool() {
+  int vconf_value = -1;
+  if (vconf_get_bool(vconf_key_.c_str(), &vconf_value) == -1)
+    return absl::nullopt;
+  return (vconf_value == 1);
+}
+
+void VconfHandle::Set(const char* value, const bool is_rtc) {
+  if (is_rtc) {
+#if defined(OS_TIZEN_TV_PRODUCT)
+    vconf_set_str_rtc(vconf_key_.c_str(), value);
+#else
+    LOG(ERROR) << "RunTimeCreated vconf is not supported";
+#endif
+  } else {
+    vconf_set_str(vconf_key_.c_str(), value);
+  }
+}
+
+void VconfHandle::Set(const std::string value, const bool is_rtc) {
+  if (is_rtc) {
+#if defined(OS_TIZEN_TV_PRODUCT)
+    vconf_set_str_rtc(vconf_key_.c_str(), value.c_str());
+#else
+    LOG(ERROR) << "RunTimeCreated vconf is not supported";
+#endif
+  } else {
+    vconf_set_str(vconf_key_.c_str(), value.c_str());
+  }
+}
+
+void VconfHandle::Set(const int value, const bool is_rtc) {
+  if (is_rtc) {
+#if defined(OS_TIZEN_TV_PRODUCT)
+    vconf_set_int_rtc(vconf_key_.c_str(), value);
+#else
+    LOG(ERROR) << "RunTimeCreated vconf is not supported";
+#endif
+  } else {
+    vconf_set_int(vconf_key_.c_str(), value);
+  }
+}
+
+void VconfHandle::Set(const bool value, const bool is_rtc) {
+  if (is_rtc) {
+#if defined(OS_TIZEN_TV_PRODUCT)
+    vconf_set_bool_rtc(vconf_key_.c_str(), value);
+#else
+    LOG(ERROR) << "RunTimeCreated vconf is not supported";
+#endif
+  } else {
+    vconf_set_bool(vconf_key_.c_str(), value);
+  }
+}
diff --git a/tizen_src/chromium_impl/tizen/vconf_handle.h b/tizen_src/chromium_impl/tizen/vconf_handle.h
new file mode 100644 (file)
index 0000000..dcb670d
--- /dev/null
@@ -0,0 +1,29 @@
+// Copyright 2019 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMMON_VCONF_HANDLE_H_
+#define COMMON_VCONF_HANDLE_H_
+
+#include <string>
+#include <vconf/vconf.h>
+
+#include "third_party/abseil-cpp/absl/types/optional.h"
+
+class VconfHandle {
+ public:
+  VconfHandle(const std::string vconf_key);
+
+  std::string Str();
+  int Int();
+  absl::optional<bool> Bool();
+  void Set(const char* value, const bool is_rtc = false);
+  void Set(const std::string value, const bool is_rtc = false);
+  void Set(const int value, const bool is_rtc = false);
+  void Set(const bool value, const bool is_rtc = false);
+
+ private:
+  std::string vconf_key_;
+};
+
+#endif  // COMMON_VCONF_HANDLE_H_
index aaba6c0..afaa7f7 100644 (file)
@@ -7,7 +7,6 @@
 #include <mutex>
 #include <thread>
 
-#include <aul_proc_group.h>
 #include <dlfcn.h>
 #include <sys/resource.h>
 #include <tzplatform_config.h>
 #include "wrt/xwalk_extensions/browser/xwalk_extension_manager.h"
 #include "tizen_src/chromium_impl/ui/gl/gl_shared_context_efl.h"
 
+#if TIZEN_VERSION_AT_LEAST(7, 0, 0)
+#include <aul_proc_group.h>
+#endif
+
 #ifndef LIB_PATH
 #error LIB_PATH is not set.
 #endif
@@ -152,7 +155,7 @@ bool WRTMainDelegateTV::CheckPlatformReady(int argc, char** argv) {
 
 // static
 void WRTMainDelegateTV::GroupZygoteProcess(bool is_oom) {
-#if defined(ENABLE_PROCESS_GROUP)
+#if TIZEN_VERSION_AT_LEAST(7, 0, 0)
   // 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");
index dd37c3f..6951437 100644 (file)
@@ -16,8 +16,8 @@
 #include "content/renderer/render_process_impl.h"
 #include "electron/shell/common/gin_converters/content_converter.h"
 #include "gin/object_template_builder.h"
-#if !defined(WRT_JS_BRINGUP)
 #include "tizen_src/chromium_impl/tizen/vconf_handle.h"
+#if !defined(WRT_JS_BRINGUP)
 #include "tizen_src/ewk/efl_integration/devtools_port_manager.h"
 #endif
 #include "v8/include/v8.h"
@@ -298,9 +298,7 @@ void TVExtension::SetCurrentApplication(const std::string& app_id) const {
 
 std::string TVExtension::QueryProductValue(const std::string& query) const {
   if (query == "getDuid") {
-#if !defined(WRT_JS_BRINGUP)
     return VconfHandle("db/comss/duid").Str();
-#endif
   } else if (query == "getFirmware") {
     return GetSystemInfoString(SYSTEM_INFO_KEY_SW_VERSION);
   } else if (query == "getLocalSet") {
@@ -308,15 +306,11 @@ std::string TVExtension::QueryProductValue(const std::string& query) const {
   } else if (query == "getModel") {
     return GetSystemInfoString(SYSTEM_INFO_KEY_MODEL);
   } else if (query == "getModelCode") {
-#if !defined(WRT_JS_BRINGUP)
     return VconfHandle("db/comss/modelid").Str();
-#endif
   } else if (query == "getRealModel") {
     return GetSystemInfoString(SYSTEM_INFO_KEY_PRODUCT_CODE_BOM);
   } else if (query == "getSmartTVServerVersion") {
-#if !defined(WRT_JS_BRINGUP)
     return VconfHandle("db/comss/infolinkversion").Str();
-#endif
   } else if (query == "getSmartTVServerType") {
     int server_type = -1;
     system_info_get_value_int(SYSTEM_INFO_KEY_INFO_LINK_SERVER_TYPE,
@@ -379,9 +373,7 @@ void TVExtension::TakeScreenshot(
 }
 
 void TVExtension::NotifyInstall(const std::string& install_info) const {
-#if !defined(WRT_JS_BRINGUP)
   VconfHandle(kVconfNotifyInstallKey).Set(install_info);
-#endif
 }
 
 std::string TVExtension::GetMetadata(const std::string& key) const {
@@ -404,9 +396,7 @@ std::string TVExtension::GetPreviewData(const std::string& packageId) const {
 }
 
 std::string TVExtension::GetForegroundApp() const {
-#if !defined(WRT_JS_BRINGUP)
   return VconfHandle(kVconfCurrentAppId).Str();
-#endif
 }
 
 std::string TVExtension::GetSSOGuid() const {
index e9e770f..4b12d12 100755 (executable)
@@ -4,9 +4,7 @@
 
 #include "base/logging.h"
 #include "gin/object_template_builder.h"
-#if !defined(WRT_JS_BRINGUP)
 #include "tizen_src/chromium_impl/tizen/vconf_handle.h"
-#endif
 #include "v8/include/v8.h"
 
 #if defined(OS_TIZEN_TV_PRODUCT)
@@ -130,27 +128,15 @@ void MDEExtension::SelectRemoteInput() {
 }
 
 std::string MDEExtension::GetCurrentLoginId() const {
-#if defined(WRT_JS_BRINGUP)
-  return std::string();
-#else
   return VconfHandle(kVconfCurrentLoginId).Str();
-#endif
 }
 
 std::string MDEExtension::GetDeviceName() const {
-#if defined(WRT_JS_BRINGUP)
-  return std::string();
-#else
   return VconfHandle(kVconfDeviceName).Str();
-#endif
 }
 
 std::string MDEExtension::GetDeviceUUID() const {
-#if defined(WRT_JS_BRINGUP)
-  return std::string();
-#else
   return VconfHandle(kVconfDeviceUUID).Str();
-#endif
 }
 #endif
 
index 810d768..8b47c7c 100755 (executable)
@@ -32,9 +32,7 @@
 #include "wrt/src/base/string_utils.h"
 
 #if defined(OS_TIZEN_TV_PRODUCT)
-#if !defined(WRT_JS_BRINGUP)
 #include "tizen_src/chromium_impl/tizen/vconf_handle.h"
-#endif
 #include "wrt/src/common/application_data.h"
 #endif
 
@@ -229,9 +227,7 @@ bool NativeAppControl::SendLaunchRequest() {
   auto& app_data = ApplicationData::GetInstance();
   std::string vconfValue = "AppID:" + app_data.app_id() + ", URL is blocked.";
   LOG(ERROR) << "key: rtc/memory/WebApp/LaunchFail value: " << vconfValue;
-#if !defined(WRT_JS_BRINGUP)
   VconfHandle("rtc/memory/WebApp/LaunchFail").Set(vconfValue, true);
-#endif
   return true;
 #endif
   return (app_control_send_launch_request(app_control_, nullptr, nullptr) ==
index 5a54469..b5f5f4e 100644 (file)
@@ -20,9 +20,7 @@
 
 #include "base/files/file_util.h"
 #include "base/logging.h"
-#if !defined(WRT_JS_BRINGUP)
 #include "tizen_src/chromium_impl/tizen/vconf_handle.h"
-#endif
 #include "wrt/src/base/file_utils.h"
 #include "wrt/src/common/application_data.h"
 #include "wrt/src/common/constants.h"
@@ -92,9 +90,7 @@ bool EncryptedFileHandler::LoadLicense() {
     std::string vconfValue =
         "AppID:" + app_id_ + ", appdrm loadlicense is faild";
     LOG(ERROR) << "vconf : " << kLaunchFail << " value : " << vconfValue;
-#if !defined(WRT_JS_BRINGUP)
     VconfHandle(kLaunchFail).Set(vconfValue, true);
-#endif
     return false;
   }
   LOG(INFO) << "appdrm_load_license() end";
@@ -158,9 +154,7 @@ EncryptedFileHandler::Decrypt(const base::FilePath& path) const {
       std::string vconfValue = "AppID: " + app_id_ + ", error no: "
                                + std::to_string(ret) + ", decrypt is faild";
       LOG(ERROR) << "vconf : " << kLaunchFail << " value : " << vconfValue;
-#if !defined(WRT_JS_BRINGUP)
       VconfHandle(kLaunchFail).Set(vconfValue, true);
-#endif
     }
     return DataBuffer();
   } else if (length <= 0) {
index d0b709d..36dae7a 100644 (file)
@@ -42,8 +42,8 @@
 #include "tizen_src/chromium_impl/content/common/paths_efl.h"
 #if !defined(WRT_JS_BRINGUP)
 #include "tizen_src/chromium_impl/content/public/browser/certificates_utils.h"
-#include "tizen_src/chromium_impl/tizen/vconf_handle.h"
 #endif
+#include "tizen_src/chromium_impl/tizen/vconf_handle.h"
 #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"
@@ -182,7 +182,6 @@ int ChangeAmbientModeCallback(device_power_state_info* info, void* user_data) {
 }
 
 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) {
@@ -190,7 +189,6 @@ bool ShouldRunClearDeadMount() {
     return false;
   }
   VconfHandle(kWrtLoaderCount).Set(0, true);
-#endif
   return true;
 }
 
@@ -669,7 +667,6 @@ void NativeWebRuntimeDelegateTV::SetLocaleDir() {
 }
 
 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";
@@ -699,7 +696,6 @@ void NativeWebRuntimeDelegateTV::PreloadVconfKeys() {
   VconfHandle(kVconfLowMemory).Int();
   VconfHandle(kVconfProxy).Str();
   LOG(INFO) << "PreloadVconfKeys end";
-#endif
 }
 
 void NativeWebRuntimeDelegateTV::PreloadFMS() {
index 7858d08..5633c50 100755 (executable)
@@ -23,9 +23,7 @@
 #include <ui/efl_util.h>
 
 #include "base/logging.h"
-#if !defined(WRT_JS_BRINGUP)
 #include "tizen_src/chromium_impl/tizen/vconf_handle.h"
-#endif
 #include "wrt/src/common/application_data.h"
 
 namespace wrt {
@@ -254,9 +252,7 @@ std::string TvWindowManager::ShowTextOnScreen(HostUGTextType type) {
       LOG(ERROR) << "Invalid UG state";
       return "UnknownError";
   }
-#if !defined(WRT_JS_BRINGUP)
   VconfHandle(key).Set(1);
-#endif
   return "Success";
 }
 
@@ -280,9 +276,7 @@ std::string TvWindowManager::HideTextOnScreen(HostUGTextType type) {
       LOG(ERROR) << "Invalid UG state";
       return "UnknownError";
   }
-#if !defined(WRT_JS_BRINGUP)
   VconfHandle(key).Set(0);
-#endif
   return "Success";
 }
 
index b154e2c..3012cf7 100644 (file)
@@ -17,9 +17,7 @@
 #include "wrt/src/browser/tv/widget_state.h"
 
 #include "base/logging.h"
-#if !defined(WRT_JS_BRINGUP)
 #include "tizen_src/chromium_impl/tizen/vconf_handle.h"
-#endif
 #include "wrt/src/browser/native_web_runtime.h"
 #include "wrt/src/browser/tv/ambient_mode.h"
 
@@ -67,10 +65,8 @@ void WidgetStateProvider::OnStatusChanged(const std::string& status) {
   widget_status = status;
   std::string vconfkey = kPrefixVconfKeyWidgetStatus + widget_app_id;
   LOG(ERROR) << "[WidgetStatus] key :" << vconfkey << ", value :" << status;
-#if !defined(WRT_JS_BRINGUP)
   VconfHandle(vconfkey).Set(status, true);
   VconfHandle(kVconfKeyStatusChange).Set(widget_app_id);
-#endif
 
   NativeWebRuntime::GetInstance().NotifyStatusChanged(status);
 }
@@ -97,12 +93,10 @@ void WidgetStateProvider::OnURLChanged(std::string url) {
     url.erase(found);
   }
 
-#if !defined(WRT_JS_BRINGUP)
   std::string vkey = kPrefixVconfKeyWidgetStatus + widget_app_id + "_URL";
   LOG(INFO) << "vconf key before :" << widget_url;
   LOG(INFO) << "vconf key after :" << vkey << ", value :" << url;
   VconfHandle(vkey).Set(url, true);
-#endif
   widget_url = url;
 }
 
index 829795c..2ea84b1 100644 (file)
@@ -33,9 +33,7 @@
 #include "gpu/config/gpu_switches.h"
 #include "media/base/media_switches.h"
 #include "third_party/blink/public/common/page/page_zoom.h"
-#if !defined(WRT_JS_BRINGUP)
 #include "tizen_src/chromium_impl/tizen/vconf_handle.h"
-#endif
 #include "ui/platform_window/platform_window.h"
 #include "wrt/src/base/platform_info.h"
 #include "wrt/src/browser/native_web_runtime.h"
@@ -267,9 +265,6 @@ WRTNativeWindow::ScreenOrientation ConvertSensorOrientation(
 }
 
 bool CanSupportLandscapeScale() {
-#if defined(WRT_JS_BRINGUP)
-  return false;
-#else
   auto is_signage = IsSignageProduct();
   if (!is_signage)
     return false;
@@ -278,7 +273,6 @@ bool CanSupportLandscapeScale() {
   auto is_landscape_scale =
       "landscape_scale" == meta_data_info.GetValue(kScreenOrientation);
   return is_signage && is_landscape_scale && (rotate_status == 1);
-#endif
 }
 
 }  // namespace
@@ -674,14 +668,12 @@ void WRTNativeWindowTV::SetAppMetaDataInfo() {
     ecore_evas_aux_hint_add(
         GetPlatformCanvas(), "wm.policy.win.transform.mode", "ratiofit");
 
-#if !defined(WRT_JS_BRINGUP)
     auto multi_screen_showed = VconfHandle(kMultiScreenInfoVconfKey).Str();
     if (IsMultiScreenShowed(multi_screen_showed)) {
       int width = 1920, height = 1080;
       GetScreenResolution(width, height);
       SetScreenResolution(width * 0.3165, height);
     }
-#endif
     vconf_notify_key_changed(kMultiScreenInfoVconfKey,
         MultiviewStateChangedCb, this);
   }
@@ -789,7 +781,6 @@ void WRTNativeWindowTV::SetProxyInfo() {
   auto* browser_context = WRTBrowserContext::GetInstance();
   DCHECK(browser_context);
   std::string proxy_info;
-#if !defined(WRT_JS_BRINGUP)
   auto& meta_data_info = ApplicationData::GetInstance().meta_data_info();
   if (meta_data_info.GetValue(kUseWebappProxy) == "true") {
     LOG(INFO) << "use.webapp.proxy is true";
@@ -797,7 +788,6 @@ void WRTNativeWindowTV::SetProxyInfo() {
   } else {
     proxy_info = VconfHandle(kProxyVconfKey).Str();
   }
-#endif
   if (proxy_info.empty() || proxy_info.find("://") == std::string::npos) {
     LOG(INFO) << "proxy address : " << proxy_info;
     return;
@@ -962,7 +952,6 @@ void WRTNativeWindowTV::SetWindowEffect(bool enable) {
 
 void WRTNativeWindowTV::EnableVisibilitySetting() {
   std::string app_id = ApplicationData::GetInstance().app_id();
-#if !defined(WRT_JS_BRINGUP)
   VconfHandle(kMostRecentApp).Set(app_id);
 
   if (channel_changeable_)
@@ -973,7 +962,6 @@ void WRTNativeWindowTV::EnableVisibilitySetting() {
                  : false;
   VconfHandle("memory/VDWebApp/partial").Set(opt);
   LOG(INFO) << "memory/VDWebApp/partial set as " << opt;
-#endif
 
   if (!alphaset_) {
     activateScreenSaver(const_cast<char*>("DEFAULT"),
@@ -1003,7 +991,6 @@ void WRTNativeWindowTV::EnableVisibilitySetting() {
 }
 
 void WRTNativeWindowTV::DisableVisibilitySetting() {
-#if !defined(WRT_JS_BRINGUP)
   std::string app_id = ApplicationData::GetInstance().app_id();
   std::string most_recent_app = VconfHandle(kMostRecentApp).Str();
 
@@ -1023,7 +1010,6 @@ void WRTNativeWindowTV::DisableVisibilitySetting() {
                 "{'app_id': '%s'}", app_id.c_str());
   LOG(INFO) << "Set apps_recent_changed as " << json_str;
   VconfHandle("memory/eden/apps/apps_recent_changed").Set(json_str);
-#endif
 }
 
 void WRTNativeWindowTV::VisibilityChangedAsBackground() {