2 * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 #include <bundle_internal.h>
25 #include "aul_comp_status.h"
29 #include "aul_error.h"
32 API int aul_comp_status_update(const char *instance_id, int status)
38 if (!instance_id || status > STATUS_TERMINATE) {
39 _E("Invalid parameter");
45 _E("Failed to create bundle");
49 bundle_add(b, AUL_K_INSTANCE_ID, instance_id);
50 snprintf(buf, sizeof(buf), "%d", status);
51 bundle_add(b, AUL_K_STATUS, buf);
53 r = aul_sock_send_bundle(AUL_UTIL_PID, getuid(),
54 COMP_STATUS_UPDATE, b, AUL_SOCK_NOREPLY);
56 _E("Failed to send the update request. error(%d)", r);
65 static int __send_request(int cmd, int opt, const char *instance_id)
72 _E("Failed to create bundle");
76 ret = bundle_add(b, AUL_K_INSTANCE_ID, instance_id);
77 if (ret != BUNDLE_ERROR_NONE) {
79 if (ret == BUNDLE_ERROR_OUT_OF_MEMORY)
81 else if (ret == BUNDLE_ERROR_INVALID_PARAMETER)
87 ret = aul_sock_send_bundle(AUL_UTIL_PID, getuid(), cmd, b, opt);
90 _E("Failed to send command(%d). error(%d)", cmd, ret);
91 return aul_error_convert(ret);
97 API int aul_comp_notify_start(const char *instance_id)
102 _E("Invalid parameter");
106 ret = __send_request(COMP_NOTIFY_START, AUL_SOCK_NOREPLY,
114 API int aul_comp_notify_exit(const char *instance_id)
119 _E("Invalid parameter");
123 ret = __send_request(COMP_NOTIFY_EXIT, AUL_SOCK_NOREPLY,
131 API int aul_comp_resume(const char *instance_id)
136 _E("Invalid parameter");
140 ret = __send_request(COMP_CONTEXT_RESUME, AUL_SOCK_NONE,
148 API int aul_comp_terminate(const char *instance_id)
153 _E("Invalid parameter");
157 ret = __send_request(COMP_CONTEXT_TERMINATE, AUL_SOCK_NONE,
165 API int aul_comp_is_running(const char *instance_id, bool *running)
169 if (!instance_id || !running) {
170 _E("Invalid parameter");
174 ret = __send_request(COMP_CONTEXT_IS_RUNNING, AUL_SOCK_NONE,
179 *running = (bool)ret;