+const char* kPSAgentReady = "/run/ps_agent.pid";
+const unsigned int kPSAgentTimeout = 30000;
+
+#if TIZEN_VERSION_AT_LEAST(7, 0, 0)
+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;
+}
+
+void MountChromiumImage() {
+ if (access(CHROMIUM_PRELOAD_LIB_PATH, F_OK) == 0 ||
+ access(PATH_PRELOAD_CHROMIUM_EFL_IMG, F_OK) != 0) {
+ LOG(INFO) << "Already mounted or no chromium-efl.img";
+ return;
+ }
+
+ 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 << "\"";
+
+ rv = PS_Mount_Fast(args, strlen(args) + 1, 1, &result);
+ LOG(INFO) << "result = " << rv << ", " << result;
+ if (rv != 0 || result != 0) {
+ LOG(ERROR) << "mount failed. (" << rv << ", " << result << ")";
+ return;
+ }
+}
+
+void SetPriority(int absolute) {
+ setpriority(PRIO_PROCESS, 0, absolute);
+ LOG(INFO) << "Set process priority : " << absolute;
+}
+#endif // TIZEN_VERSION_AT_LEAST(7, 0, 0)
+#endif // OS_TIZEN_TV_PRODUCT