2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
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 ///////////////////////////////////////////////////////////////////////////////
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.
22 ///////////////////////////////////////////////////////////////////////////////
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>
29 #include "ss_sm_systemmanagerlog.h"
30 #include "ss_system_manager.h"
32 #include <sys/types.h>
34 #include <sys/resource.h>
37 //////////////////////////////////////////
38 // Function : FrameworkunifiedOnInitialization
39 //////////////////////////////////////////
40 EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE hApp) {
41 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
42 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
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);
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);
53 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
57 //////////////////////////////////////////
58 // Function : FrameworkunifiedOnWakeup
59 //////////////////////////////////////////
60 EFrameworkunifiedStatus FrameworkunifiedOnWakeup(HANDLE hApp) {
61 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
62 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
63 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
67 //////////////////////////////////////////
68 // Function : FrameworkunifiedOnShutdown
69 //////////////////////////////////////////
70 EFrameworkunifiedStatus FrameworkunifiedOnShutdown(HANDLE hApp) {
71 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
72 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
73 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
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__, "-");
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__, "-");
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__, "+");
106 CSystemManager* l_instance = &CSystemManager::GetInstance();
107 if (l_instance !=NULL) {
108 l_instance->SystemManagerDebugDump(hApp);
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)
114 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
120 * EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE hApp)
123 * @param hApp Handle to the SS_Power Framework Obj.
125 * @return method status of completion or failure.
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;
135 * EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE hApp)
138 * @param hApp Handle to the SS_Power Framework Obj.
140 * @return method status of completion or failure.
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;
150 * EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE h_app)
152 * @param h_app Handle to the SS_Power Framework Obj.
154 * @return method status of completion or failure.
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;
165 * EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE h_app)
167 * @param h_app Handle to the SS_Power Framework Obj.
169 * @return method status of completion or failure.
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;
180 * EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE h_app)
182 * @param h_app Handle to the SS_Power Framework Obj.
184 * @return method status of completion or failure.
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;
195 * EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE h_app)
197 * @param h_app Handle to the SS_Power Framework Obj.
199 * @return method status of completion or failure.
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;
210 * EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE hApp)
213 * @param hApp Handle to the SS_Power Framework Obj.
215 * @return method status of completion or failure.
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;
224 ////////////////////////////////////////////////////////////////////////////////////////////
227 ////////////////////////////////////////////////////////////////////////////////////////////
228 EFrameworkunifiedStatus SystemmanagerCloseApplication(HANDLE hApp) {
229 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
230 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
232 l_eStatus = CSystemManager::GetInstance().CloseApplication(hApp);
233 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");