Remove unused directories and files in video_in_hal
[staging/basesystem.git] / systemservice / task_manager / client / libtskm / src / tskm_api_lib.cpp
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include <unistd.h>
18 #include <signal.h>
19
20 #include <native_service/frameworkunified_framework_if.h>
21
22 #include "tskm_debug.h"
23 #include "tskm_api.h"
24
25 TSKM_ERR_t TSKM_SvcCtl(TSKM_SVCID_t svcId, const TSKM_SVC_CTL_t* ctl) {
26   TSKM_ERR_t tskmRet;
27   int ii;
28
29   for (ii = 0; ii < 3; ii++) {
30     // Retry three times
31     tskmRet = _TSKM_SvcCtl(svcId, ctl);
32     if (tskmRet == TSKM_E_RETRY) {
33       usleep(300 * 1000);  // 300ms wait
34     } else {
35       break;
36     }
37   }
38
39   return tskmRet;
40 }
41
42 TSKM_ERR_t TSKM_ErrorReboot(const TSKM_ERROR_REBOOT_t* p_info) {
43   TSKM_ERR_t tskmRet = TSKM_E_OK;
44   RPC_Result rpcRet;
45
46   rpcRet = _TSKM_ErrorReboot(p_info);
47   if (RPC_OK != rpcRet) {
48     tskmRet = TSKM_E_PAR;
49   }
50
51   return tskmRet;
52 }
53
54 TSKM_ERR_t TSKM_DataInit(HANDLE hApp, const TSKM_DATAINIT_t *p_info) {
55   TSKM_ERR_t tskmRet = TSKM_E_NG;
56   TSKM_PRINTF(TSKM_LOG_API, "%s()", __FUNCTION__)
57
58   if (!p_info || !hApp || (p_info->type != TSKM_DATAINIT_TYPE_USER)
59       || !(p_info->onCompInit)) {
60     TSKM_ASSERT(0);
61     return TSKM_E_PAR;
62   }
63
64   // LCOV_EXCL_BR_START 10: Due to compiler dependency
65   EFrameworkunifiedStatus l_eStatus = FrameworkunifiedAttachCallbackToDispatcher(hApp,
66   SS_TASK_MANAGER,
67                                                        TSKM_DATAINIT_RESP,
68                                                        p_info->onCompInit);
69   // LCOV_EXCL_BR_STOP
70   if (eFrameworkunifiedStatusOK != l_eStatus) {
71     TSKM_ASSERT(0);
72   } else {
73     HANDLE hSvc = FrameworkunifiedOpenService(hApp, SS_TASK_MANAGER);
74     if (hSvc == NULL) {
75       TSKM_ASSERT(0);
76       tskmRet = TSKM_E_STATE;
77     } else {
78       if (eFrameworkunifiedStatusOK != FrameworkunifiedSendMsg(hSvc, TSKM_DATAINIT_REQ, 0, NULL)) {
79         TSKM_ASSERT(0);
80       } else {
81         tskmRet = TSKM_E_OK;
82       }
83     }
84
85     TSKM_ASSERT(eFrameworkunifiedStatusOK == FrameworkunifiedCloseService(hApp, hSvc));
86   }
87
88   return tskmRet;
89 }  // LCOV_EXCL_BR_LINE 10: Final line
90