| 58 | } |
| 59 | |
| 60 | bool RenderManager::StartDesktopRender(const std::string& _work_dir, const std::string& _app_path, const std::vector<std::string>& _args) { |
| 61 | std::stringstream ss; |
| 62 | for (auto& arg : _args) { |
| 63 | ss << arg << " "; |
| 64 | } |
| 65 | ss << std::endl; |
| 66 | LOGI("Start desktop render \nwork_dir: {} \napp_path: {} \nargs:{}", _work_dir, _app_path, ss.str()); |
| 67 | |
| 68 | auto sp = context_->GetSp(); |
| 69 | auto exist_work_dir = sp->Get(kKeyWorkDir); |
| 70 | auto exist_app_path = sp->Get(kKeyAppPath); |
| 71 | auto exist_app_args = sp->Get(kKeyAppArgs); |
| 72 | auto processes = ProcessHelper::GetProcessList(false); |
| 73 | CheckAliveRenders(processes); |
| 74 | if (desktop_render_process_ != nullptr && is_desktop_render_alive_) { |
| 75 | if (exist_work_dir != _work_dir || exist_app_path != _app_path || exist_app_args != ss.str()) { |
| 76 | StopDesktopRender(); |
| 77 | } |
| 78 | else { |
| 79 | LOGI("Render is already alive, pid: {}", desktop_render_process_->pid_); |
| 80 | return true; |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | this->desktop_work_dir_ = _work_dir; |
| 85 | this->desktop_app_path_ = _app_path; |
| 86 | this->desktop_app_args_ = ss.str(); |
| 87 | |
| 88 | bool start_result = StartDesktopRenderInternal(this->desktop_work_dir_, this->desktop_app_path_, this->desktop_app_args_); |
| 89 | processes = ProcessHelper::GetProcessList(false); |
| 90 | CheckAliveRenders(processes); |
| 91 | return start_result; |
| 92 | } |
| 93 | |
| 94 | bool RenderManager::StopDesktopRender() { |
| 95 | LOGW(" *** StopDesktopRender ***"); |
no test coverage detected