#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
#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;
#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() {
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";
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;
}
return;
}
}
+#endif // defined(ENABLE_WRT_JS)
#endif // BUILDFLAG(IS_TIZEN_TV)
-#endif
void* open_library() {
if (g_impl_lib_handle)