2 * Copyright (c) 2019 - 2022 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.
17 #include "include/aul_comp_status.h"
19 #include <bundle_cpp.h>
21 #include "include/aul.h"
22 #include "include/aul_sock.h"
23 #include "include/aul_error.h"
27 #include "app_request.h"
29 using namespace aul::internal;
31 extern "C" API int aul_comp_status_update(const char* instance_id, int status) {
32 if (instance_id == nullptr ||
33 status < STATUS_LAUNCHING ||
34 status > STATUS_TERMINATE) {
35 _E("Invalid parameter");
39 tizen_base::Bundle b {
40 { AUL_K_INSTANCE_ID, instance_id },
41 { AUL_K_STATUS, std::to_string(status) },
44 return AppRequest(COMP_STATUS_UPDATE, getuid())
46 .SendSimply(AUL_SOCK_NOREPLY);
49 extern "C" API int aul_comp_notify_start(const char* instance_id) {
50 if (instance_id == nullptr) {
51 _E("Invalid parameter");
55 return AppRequest(COMP_NOTIFY_START, getuid())
56 .SetInstId(instance_id)
57 .SendSimply(AUL_SOCK_NOREPLY);
60 extern "C" API int aul_comp_notify_exit(const char* instance_id) {
61 if (instance_id == nullptr) {
62 _E("Invalid parameter");
66 return AppRequest(COMP_NOTIFY_EXIT, getuid())
67 .SetInstId(instance_id)
68 .SendSimply(AUL_SOCK_NOREPLY);
71 extern "C" API int aul_comp_resume(const char* instance_id) {
72 if (instance_id == nullptr) {
73 _E("Invalid parameter");
77 return AppRequest(COMP_CONTEXT_RESUME, getuid())
78 .SetInstId(instance_id)
82 extern "C" API int aul_comp_terminate(const char* instance_id) {
83 if (instance_id == nullptr) {
84 _E("Invalid parameter");
88 return AppRequest(COMP_CONTEXT_TERMINATE, getuid())
89 .SetInstId(instance_id)
93 extern "C" API int aul_comp_is_running(const char* instance_id, bool* running) {
94 if (instance_id == nullptr || running == nullptr) {
95 _E("Invalid parameter");
99 int ret = AppRequest(COMP_CONTEXT_IS_RUNNING, getuid())
100 .SetInstId(instance_id)
105 *running = (ret == 0) ? false : true;