506bb2c2df1b3e2629ebfb2771ffec17b416c0f1
[staging/basesystem.git] / video_in_hal / systemservice / system_manager / server / src / systemmanager_application.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 ///////////////////////////////////////////////////////////////////////////////
18 /// \ingroup  tag_SystemManager
19 /// \brief    This file contains the standard set functions called by the NS
20 //            dispatcher on application initialization, cleanup and wakeup.
21 ///
22 ///////////////////////////////////////////////////////////////////////////////
23
24 #include <native_service/frameworkunified_application.h>
25 #include <native_service/frameworkunified_framework_if.h>
26 #include <native_service/frameworkunified_service_protocol.h>
27 #include <system_service/ss_templates.h>
28
29 #include "ss_sm_systemmanagerlog.h"
30 #include "ss_system_manager.h"
31
32 #include <sys/types.h>
33 #include <sys/time.h>
34 #include <sys/resource.h>
35 #include <errno.h>
36
37 //////////////////////////////////////////
38 //  Function : FrameworkunifiedOnInitialization
39 //////////////////////////////////////////
40 EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE hApp) {
41   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
42   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
43
44   eStatus = CSystemManager::GetInstance().Initialize(hApp);
45   struct rlimit setrl = {RLIM_INFINITY, RLIM_INFINITY};
46   struct rlimit getrl = {};
47   int ret = prlimit(getpid(), RLIMIT_MSGQUEUE, &setrl, &getrl);
48   if (ret != 0) {
49     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "prlimit ret%d", ret);
50     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Previous limits: soft=%lld; hard=%lld", (long long) getrl.rlim_cur,
51            (long long) getrl.rlim_max);
52   }
53   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
54   return eStatus;
55 }
56
57 //////////////////////////////////////////
58 //  Function : FrameworkunifiedOnWakeup
59 //////////////////////////////////////////
60 EFrameworkunifiedStatus FrameworkunifiedOnWakeup(HANDLE hApp) {
61   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
62   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
63   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
64   return eStatus;
65 }
66
67 //////////////////////////////////////////
68 //  Function : FrameworkunifiedOnShutdown
69 //////////////////////////////////////////
70 EFrameworkunifiedStatus FrameworkunifiedOnShutdown(HANDLE hApp) {
71   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
72   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
73   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
74   return eStatus;
75 }
76
77 ////////////////////////////////////////////////////////////////////////////////////////////
78 /// FrameworkunifiedOnDestroy
79 /// \todo Add behavior to this function
80 ////////////////////////////////////////////////////////////////////////////////////////////
81 EFrameworkunifiedStatus FrameworkunifiedOnDestroy(HANDLE hApp) {  // LCOV_EXCL_START 14:Resident process, not called by NSFW
82   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
83   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
84   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
85   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
86   return eStatus;
87 }
88 // LCOV_EXCL_STOP
89
90 ////////////////////////////////////////////////////////////////////////////////////////////
91 /// FrameworkunifiedOnEShutdown
92 /// \todo Add behavior to this function
93 ////////////////////////////////////////////////////////////////////////////////////////////
94 EFrameworkunifiedStatus FrameworkunifiedOnEShutdown(HANDLE hApp) {
95   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
96   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
97   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
98   return eStatus;
99 }
100
101 EFrameworkunifiedStatus FrameworkunifiedOnDebugDump(HANDLE hApp) {  // LCOV_EXCL_START 7:Debug code
102   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
103   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
104   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
105
106   CSystemManager* l_instance = &CSystemManager::GetInstance();
107   if (l_instance !=NULL) {
108     l_instance->SystemManagerDebugDump(hApp);
109   } else {
110     l_eStatus = eFrameworkunifiedStatusInvldHandle;
111     LOG_STATUS(l_eStatus, "Unable to acquire SM instance. Debug Dump handler not called.");  // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h  // NOLINT(whitespace/line_length)
112   }
113
114   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
115   return l_eStatus;
116 }
117 // LCOV_EXCL_STOP
118
119 /**
120  * EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE hApp)
121  * @brief Used to .
122  *
123  * @param hApp Handle to the SS_Power Framework Obj.
124  *
125  * @return method status of completion or failure.
126 */
127 EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE hApp) {
128   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
129   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "This method has not been implemented, return: eFrameworkunifiedStatusOK!");
130   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
131   return eFrameworkunifiedStatusOK;
132 }
133
134 /**
135  * EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE hApp)
136  * @brief Used to .
137  *
138  * @param hApp Handle to the SS_Power Framework Obj.
139  *
140  * @return method status of completion or failure.
141 */
142 EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE hApp) {
143   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
144   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "This method has not been implemented, return: eFrameworkunifiedStatusOK!");
145   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
146   return eFrameworkunifiedStatusOK;
147 }
148
149 /**
150  * EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE h_app)
151  *
152  * @param h_app Handle to the SS_Power Framework Obj.
153  *
154  * @return method status of completion or failure.
155  */
156
157 EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE hApp) {
158   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
159   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "This method has not been implemented, return: eFrameworkunifiedStatusOK!");
160   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
161   return eFrameworkunifiedStatusOK;
162 }
163
164 /**
165  * EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE h_app)
166  *
167  * @param h_app Handle to the SS_Power Framework Obj.
168  *
169  * @return method status of completion or failure.
170  */
171
172 EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE hApp) {
173   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
174   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "This method has not been implemented, return: eFrameworkunifiedStatusOK!");
175   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
176   return eFrameworkunifiedStatusOK;
177 }
178
179 /**
180  * EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE h_app)
181  *
182  * @param h_app Handle to the SS_Power Framework Obj.
183  *
184  * @return method status of completion or failure.
185  */
186
187 EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE hApp) {
188   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
189   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "This method has not been implemented, return: eFrameworkunifiedStatusOK!");
190   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
191   return eFrameworkunifiedStatusOK;
192 }
193
194 /**
195  * EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE h_app)
196  *
197  * @param h_app Handle to the SS_Power Framework Obj.
198  *
199  * @return method status of completion or failure.
200  */
201
202 EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE hApp) {
203   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
204   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "This method has not been implemented, return: eFrameworkunifiedStatusOK!");
205   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
206   return eFrameworkunifiedStatusOK;
207 }
208
209 /**
210  * EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE hApp)
211  * @brief Used to .
212  *
213  * @param hApp Handle to the SS_Power Framework Obj.
214  *
215  * @return method status of completion or failure.
216 */
217 EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE hApp) {
218   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
219   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "This method has not been implemented, return: eFrameworkunifiedStatusOK!");
220   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
221   return eFrameworkunifiedStatusOK;
222 }
223
224 ////////////////////////////////////////////////////////////////////////////////////////////
225 ///
226 ///
227 ////////////////////////////////////////////////////////////////////////////////////////////
228 EFrameworkunifiedStatus SystemmanagerCloseApplication(HANDLE hApp) {
229   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
230   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
231
232   l_eStatus = CSystemManager::GetInstance().CloseApplication(hApp);
233   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
234   return l_eStatus;
235 }
236 // EOF
237