Lines Matching refs:serviceName
72 static int StopProcess(const char *serviceName)
74 BEGET_ERROR_CHECK(serviceName != NULL, return -1, "Service name is null.");
75 return SystemSetParameter("ohos.ctl.stop", serviceName);
78 static int GetCurrentServiceStatus(const char *serviceName, ServiceStatus *status)
82 "%s.%s", STARTUP_SERVICE_CTL, serviceName) == -1) {
91 static int RestartProcess(const char *serviceName, const char *extArgv[], int extArgc)
93 BEGET_ERROR_CHECK(serviceName != NULL, return -1, "Service name is null.");
95 if (GetCurrentServiceStatus(serviceName, &status) != 0) {
99 BEGET_LOGE("Process service %s status: %d ", serviceName, status);
101 if (StopProcess(serviceName) != 0) {
102 BEGET_LOGE("Stop service %s failed", serviceName);
105 if (ServiceWaitForStatus(serviceName, SERVICE_STOPPED, DEFAULT_PARAM_WAIT_TIMEOUT) != 0) {
106 BEGET_LOGE("Failed wait service %s stopped", serviceName);
109 if (StartProcess(serviceName, extArgv, extArgc) != 0) {
110 BEGET_LOGE("Start service %s failed", serviceName);
114 if (StartProcess(serviceName, extArgv, extArgc) != 0) {
115 BEGET_LOGE("Start service %s failed", serviceName);
122 int ServiceControlWithExtra(const char *serviceName, int action, const char *extArgv[], int extArgc)
124 BEGET_ERROR_CHECK(serviceName != NULL, return -1, "Service name is null.");
128 ret = StartProcess(serviceName, extArgv, extArgc);
131 ret = StopProcess(serviceName);
134 ret = RestartProcess(serviceName, extArgv, extArgc);
137 BEGET_LOGE("Set service %s action %d error", serviceName, action);
144 int ServiceControl(const char *serviceName, int action)
146 BEGET_ERROR_CHECK(serviceName != NULL, return -1, "Service name is null.");
147 int ret = ServiceControlWithExtra(serviceName, action, NULL, 0);
151 static int GetProcessInfo(const char *serviceName, char *nameBuffer, char *valueBuffer, ServiceStatus status)
154 STARTUP_SERVICE_CTL, serviceName) == -1) {
165 int ServiceWaitForStatus(const char *serviceName, ServiceStatus status, int waitTimeout)
167 BEGET_ERROR_CHECK(serviceName != NULL, return -1, "Service name is null.");
171 int ret = GetProcessInfo(serviceName, paramName, value, status);
176 int ServiceSetReady(const char *serviceName)
178 BEGET_ERROR_CHECK(serviceName != NULL, return -1, "Service name is null.");
181 int ret = GetProcessInfo(serviceName, paramName, value, SERVICE_READY);
186 int StartServiceByTimer(const char *serviceName, uint64_t timeout)
188 BEGET_ERROR_CHECK(serviceName != NULL, return -1, "Service name is null.");
191 return ServiceControl(serviceName, START);
195 if (snprintf_s(value, PARAM_NAME_LEN_MAX, PARAM_NAME_LEN_MAX - 1, "%s|%lld", serviceName, timeout) == -1) {
202 int StopServiceTimer(const char *serviceName)
204 BEGET_ERROR_CHECK(serviceName != NULL, return -1, "Service name is null.");
205 return SystemSetParameter("ohos.servicectrl.timer_stop", serviceName);