[M108 Migration][WRTjs][VD] Remove privileged-service build dependency 19/289719/2
authorDongHyun Song <dh81.song@samsung.com>
Wed, 8 Mar 2023 08:58:17 +0000 (17:58 +0900)
committerDongHyun Song <dh81.song@samsung.com>
Tue, 14 Mar 2023 02:43:28 +0000 (11:43 +0900)
When libchromium-ewk is used NUI application, appzone denies the
build dependency of libprivileged-service-client.so.

Thus, this patch removes the dependency and change the way to handle
them by dlopen/dlsym.

Reference:
https://review.tizen.org/gerrit/289474/

Change-Id: I0b3bd118be5aeaf253651c51534f1f08630076ca
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
tizen_src/downloadable/BUILD.gn
tizen_src/downloadable/ewk_interface_main.cc

index a402650..a23dd8f 100644 (file)
@@ -39,7 +39,6 @@ shared_library("ewk-interface") {
     defines += [
       "LIB_UPGRADE_ROOT_DIR=\"$lib_upgrade_root_dir\"",
     ]
-    configs += [ "//tizen_src/build:privileged-service" ]
     libs += [ "lwipc", "ttrace" ]
   }
 }
index 6dfca49..9643b64 100644 (file)
 
 #define CHROMIUM_UPGRADE_LIB_PATH \
   LIB_UPGRADE_ROOT_DIR "/lib/" CHROMIUM_IMPL_LIB_FILE
+
 #include <lwipc.h>
 #include <ttrace.h>
 
-#include <privileged-service/PS_API.h>
 #include <sys/resource.h>
 #endif
 
@@ -53,6 +53,8 @@ const char* kPSAgentReady = "/run/ps_agent.pid";
 const unsigned int kPSAgentTimeout = 30000;
 
 #if TIZEN_VERSION_AT_LEAST(7, 0, 0)
+const char* kPrivilegeServiceLibPath = "libprivileged-service-client.so";
+
 bool WaitPSAgentReady() {
   static bool ps_agent_ready = false;
   if (ps_agent_ready)
@@ -92,7 +94,21 @@ void MountChromiumImage() {
 
   LOG(INFO) << "mount args: \"" << args << "\"";
 
-  rv = PS_Mount_Fast(args, strlen(args) + 1, 1, &result);
+  auto ps_handle_ = dlopen(kPrivilegeServiceLibPath, RTLD_LAZY);
+  if (!ps_handle_) {
+    LOG(ERROR) << "dlopen() fail : " << dlerror();
+    return;
+  }
+  typedef int (*ps_mount)(const char*, size_t, int, int*);
+  ps_mount PS_Mount = nullptr;
+  PS_Mount = (ps_mount)dlsym(ps_handle_, "PS_Mount_Fast");
+  if (!PS_Mount)
+    PS_Mount = (ps_mount)dlsym(ps_handle_, "PS_Mount");
+  if (!PS_Mount) {
+    LOG(ERROR) << "dlsym() fail : " << dlerror();
+    return;
+  }
+  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 << ")";