[M120 Migration][WRTjs][VD] Use ps-agent mount for appzone enabled model 06/308406/5
authorDongHyun Song <dh81.song@samsung.com>
Mon, 25 Mar 2024 00:41:40 +0000 (09:41 +0900)
committerDongHyun Song <dh81.song@samsung.com>
Mon, 25 Mar 2024 06:54:23 +0000 (06:54 +0000)
direct mount's mount_namespace is changed when appzone container
is enabled.
Then, chromium initilization can be failed since mount point's
internal path cannot be accessible.

So, for the enterprise models, it will disable direct mount

Reference:
https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/308292/

Change-Id: I100c872832197578108232020bfe21627e6fe992
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
packaging/chromium-efl.spec
tizen_src/build/config/BUILD.gn
tizen_src/build/config/tizen_features.gni
tizen_src/build/gn_chromiumefl.sh
tizen_src/downloadable/BUILD.gn
tizen_src/downloadable/ewk_interface_main.cc

index 030e38f..aace036 100644 (file)
@@ -528,6 +528,12 @@ touch ./tizen_src/downloadable/ewk_api_wrapper_generator.py
 %if "%{?tizen_profile_name}" == "tv" && "%{_vd_cfg_product_type}" != "AUDIO" &&  "%{_vd_cfg_product_type}" != "AV" && %{__build_chrome} != 1
   "tizen_vd_accessory=true" \
 %endif
+%if "%{_vd_cfg_product_type}" == "LFD"
+  "tizen_vd_lfd=true" \
+%endif
+%if "%{_vd_cfg_product_type}" == "IWB"
+  "tizen_vd_iwb=true" \
+%endif
 %if 0%{?component_build}
  "component=\"shared_library\"" \
 %endif
index 0773b06..fa23ca0 100644 (file)
@@ -122,4 +122,8 @@ config("tizen_feature_flags") {
   if (drm_mapi_aarch_64) {
     defines += [ "DRM_MAPI_AARCH_64" ]
   }
+
+  if (tizen_vd_lfd || tizen_vd_iwb) {
+    defines += ["TIZEN_VD_ENTERPRISE_FEATURE" ]
+  }
 }
index 027b580..f98fd04 100644 (file)
@@ -32,6 +32,8 @@ declare_args() {
 
   tizen_product_tv = false
   tizen_product_da = false
+  tizen_vd_lfd = false
+  tizen_vd_iwb = false
 
   exe_dir = "/usr/lib/chromium-efl/"
   lib_ro_root_dir = "/usr/share/chromium-efl"
index 4dd81c6..ec70017 100755 (executable)
@@ -267,6 +267,14 @@ add_tizen_flags() {
     ADDITIONAL_GN_PARAMETERS+="tizen_video_hole=false
                               "
   fi
+
+  if [ "$tizen_vd_lfd" == "true" ]; then
+    ADDITIONAL_GN_PARAMETERS+="tizen_vd_lfd=true"
+  fi
+
+  if [ "$tizen_vd_iwb" == "true" ]; then
+    ADDITIONAL_GN_PARAMETERS+="tizen_vd_iwb=true"
+  fi
 }
 
 add_wayland_flags() {
index f209c4b..b2351a1 100644 (file)
@@ -40,7 +40,12 @@ shared_library("ewk-interface") {
     defines += [
       "LIB_UPGRADE_ROOT_DIR=\"$lib_upgrade_root_dir\"",
     ]
-    libs += [ "launchpad", "lwipc", "ttrace", "vconf" ]
+    configs += [
+      "//tizen_src/build:libcapi-system-info",
+      "//tizen_src/build:launchpad",
+      "//tizen_src/build:vconf"
+    ]
+    libs += [ "capi-system-info", "lwipc", "ttrace", "vconf", "launchpad" ]
   }
 }
 
index 2857e01..628a68c 100644 (file)
 #include <sys/mount.h>
 #include <sys/resource.h>
 #include <sys/statfs.h>
-#include <vconf/vconf.h>
+#include <system_info.h>
+#include <vconf.h>
 
 #if TIZEN_VERSION_AT_LEAST(8, 0, 0) && defined(TIZEN_VD_ENTERPRISE_FEATURE)
-#include <launchpad/launchpad.h>
+#include <launchpad.h>
 #endif
 #endif  // BUILDFLAG(IS_TIZEN_TV)
 #endif
@@ -67,14 +68,15 @@ inline unsigned long long ConvertMilliseconds(timespec ts) {
 #if BUILDFLAG(IS_TIZEN_TV)
 bool g_upgrade_lib = false;  // conservative policy
 const char* kChromiumMountReady = "/tmp/.chromium_mount.ready";
-#endif  // BUILDFLAG(IS_TIZEN_TV)
 
 #if defined(ENABLE_WRT_JS)
-#if BUILDFLAG(IS_TIZEN_TV)
 #define SQUASHFS_MAGIC 0x73717368
 
+const char* kPrivilegeServiceLibPath = "libprivileged-service-client.so";
+const char* kPSAgentReady = "/run/ps_agent.pid";
 const char* kUWETag = "USE_UWE";
 const char* kWrtLoaderCompleted = "/tmp/.wrt_loader.completed";
+const unsigned int kPSAgentTimeout = 30000;
 
 #if TIZEN_VERSION_AT_LEAST(8, 0, 0) && defined(TIZEN_VD_ENTERPRISE_FEATURE)
 const int kBooTypeLastModeUrlLauncher = 2;
@@ -82,10 +84,10 @@ const char* kEPAppbootType = "db/ep-common/last_mode";
 #endif
 
 char app_define_base_path[128] = {0};
-bool direct_mounted = false;
+bool try_mounted = false;
 
 bool IsFirstWrtLoader() {
-  return direct_mounted || access(kWrtLoaderCompleted, F_OK) != 0;
+  return try_mounted || access(kWrtLoaderCompleted, F_OK) != 0;
 }
 
 void DisposeLoaderIfNecessary() {
@@ -138,6 +140,83 @@ void LowerPriorityIfNecessary() {
   SetPriority(10);
 }
 
+bool WaitPSAgentReady() {
+  static bool ps_agent_ready = false;
+  if (ps_agent_ready)
+    return true;
+
+  int max_retry = 20;
+  LOG(INFO) << "Waiting the ps_agent ready";
+  while (max_retry != 0) {
+    int ret = LwipcWaitEvent(kPSAgentReady, kPSAgentTimeout);
+    if (ret == 0) {
+      LOG(INFO) << "ps_agent is ready";
+      ps_agent_ready = true;
+      return true;
+    }
+
+    --max_retry;
+    LOG(ERROR) << "ps_agent is not ready : " << (ret > 0 ? "timeout" : "fail")
+               << ", remain retry [" << max_retry << "]";
+  }
+
+  return false;
+}
+
+bool PSAgentMount(const char* image_path) {
+  if (access(image_path, F_OK) != 0) {
+    LOG(INFO) << "no chromium-efl.img";
+    return false;
+  }
+
+  if (WaitPSAgentReady() == false)
+    LOG(ERROR) << "Chromium-efl mount may not work.";
+
+  int rv = 0;
+  int result = 0;
+  const char* args = MOUNT_ARGS_PRELOAD_CHROMIUM;
+
+  LOG(INFO) << "mount args: \"" << args << "\"";
+
+  auto ps_handle_ = dlopen(kPrivilegeServiceLibPath, RTLD_LAZY);
+  if (!ps_handle_) {
+    LOG(ERROR) << "dlopen() fail : " << dlerror();
+    return false;
+  }
+  typedef int (*ps_mount)(const char*, size_t, int, int*);
+  ps_mount PS_Mount = nullptr;
+#if TIZEN_VERSION_AT_LEAST(7, 0, 0)
+  PS_Mount = (ps_mount)dlsym(ps_handle_, "PS_Mount_Fast");
+#else
+  PS_Mount = (ps_mount)dlsym(ps_handle_, "PS_Mount");
+#endif
+  if (!PS_Mount) {
+    LOG(ERROR) << "dlsym() fail : " << dlerror();
+    return false;
+  }
+  rv = PS_Mount(args, strlen(args) + 1, 1, &result);
+  LOG(INFO) << "result = " << rv << ", " << result;
+  if (rv != 0 || result != 0) {
+    LOG(ERROR) << "mount failed. (" << rv << ", " << result << ")";
+    return false;
+  }
+  return true;
+}
+
+bool IsAppzoneSupport() {
+  bool web_isolation_support = false;
+  LOG(INFO) << "fms get start";
+  if (SYSTEM_INFO_ERROR_NONE ==
+      system_info_get_custom_bool(
+          "com.samsung/featureconf/security.container.web_isolation",
+          &web_isolation_support)) {
+  LOG(INFO) << "fms get end";
+    return web_isolation_support;
+  } else {
+    return false;
+  }
+}
+
 bool DirectMount(const char* image_path, const char* point_point) {
   const char* dev_loop_control = "/dev/loop-control";
   const char* dev_loop_prefix = "/dev/loop";
@@ -199,11 +278,18 @@ bool MountDefaultChromiumImage() {
     return true;
   }
 
-  if (!DirectMount(PATH_PRELOAD_CHROMIUM_EFL_IMG, LIB_RO_ROOT_DIR)) {
-    LOG(ERROR) << "Direct mount has failed, will wait efl-install-service";
-    return false;
+  if (IsAppzoneSupport()) {
+    if (!PSAgentMount(PATH_PRELOAD_CHROMIUM_EFL_IMG)) {
+      LOG(ERROR) << "pa-agent mount has failed, will wait efl-install-service";
+      return false;
+    }
+  } else {
+    if (!DirectMount(PATH_PRELOAD_CHROMIUM_EFL_IMG, LIB_RO_ROOT_DIR)) {
+      LOG(ERROR) << "Direct mount has failed, will wait efl-install-service";
+      return false;
+    }
   }
-  direct_mounted = true;
+  try_mounted = true;
   return true;
 }
 
@@ -239,8 +325,8 @@ void TryOpenAppDefinedLib() {
     return;
   }
 }
+#endif  // defined(ENABLE_WRT_JS)
 #endif  // BUILDFLAG(IS_TIZEN_TV)
-#endif
 
 void* open_library() {
   if (g_impl_lib_handle)