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 provides support for System Manager business logic.
21 ///////////////////////////////////////////////////////////////////////////////
22 #include <system_service/ss_heartbeat_service_protocol.h>
23 #include <system_service/ss_system_manager_if.h>
24 #include <system_service/ss_system_manager_if_local.h>
25 #include <native_service/frameworkunified_multithreading.h>
27 #include <system_service/ss_system_manager_notifications.h>
28 #include <system_service/ss_system_manager_notifications_local.h>
29 #include <native_service/frameworkunified_framework_if.h>
30 #include <system_service/ss_services.h>
31 #include <system_service/ss_power_service_if.h>
32 #include <processlauncher/ProcessLauncher.h>
33 #include <processlauncher/ss_sm_process_launcher_protocol.h>
34 #include <processlauncher/ss_sm_process_launcher.h>
35 #include <heartbeat/ss_hb_thread.h>
37 #include <system_service/ss_power_service_notifications.h>
38 #include <system_service/ss_power_service_protocol.h>
40 #include <native_service/ns_np_service.h>
41 #include <native_service/ns_np_service_protocol.h>
42 #include <native_service/ns_backup.h>
44 #include <stub/ss_diag.h>
46 #include <system_service/ss_error_message.h>
47 #include <system_service/ss_test_clients.h>
48 #include <system_service/ss_templates.h>
49 #include <native_service/ns_plogger_if.h>
53 #include <sys/types.h>
61 #include "ss_system_manager_callbacks.h"
62 #include "ss_system_manager.h"
63 #include "ss_sm_systemmanagerlog.h"
64 #include "ss_sm_config.h"
66 using namespace std; // NOLINT
68 extern SS_String GetStr(SS_SMModuleState f_enum);
70 template<typename C, eFrameworkunifiedStatus (C::*M)(HANDLE)> EFrameworkunifiedStatus SysMgrCallback(HANDLE hApp) {
71 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
72 C * pObj = static_cast<C *>(&CSystemManager::GetInstance());
73 if (pObj) { // LCOV_EXCL_BR_LINE 5 : new error
74 l_eStatus = (pObj->*M)(hApp);
79 template<typename C, eFrameworkunifiedStatus (C::*M)(HANDLE, UI_32)>
80 EFrameworkunifiedStatus SysMgrCbType2(HANDLE hApp, UI_32 f_UI_32) {
81 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
82 C * pObj = static_cast<C *>(&CSystemManager::GetInstance());
83 if (pObj) { // LCOV_EXCL_BR_LINE 5 : new error
84 l_eStatus = (pObj->*M)(hApp, f_UI_32);
89 template<typename C, BOOL (C::*M)(UI_32)>
90 BOOL SysMgrCbType3(UI_32 f_UI_32) {
91 BOOL l_bValue = FALSE;
92 C * pObj = static_cast<C *>(&CSystemManager::GetInstance());
93 if (pObj) { // LCOV_EXCL_BR_LINE 5 : new error
94 l_bValue = (pObj->*M)(f_UI_32);
104 VOID CSystemManager::LogGroupModulesState(UI_32 f_groupId, std::string pStr) {
105 if (IS_ZONE_SET(ZONE_INFO)) { // LCOV_EXCL_BR_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
106 // LCOV_EXCL_START 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
107 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
108 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
110 GroupLaunchMapIter l_GroupIterator = m_MapProclaunchGrps.find(f_groupId);
111 if (l_GroupIterator == m_MapProclaunchGrps.end()) {
112 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
113 " Error: Group %d not found; 'm_MapProclaunchGrps' is empty",
116 std::string sIsOKFlag;
117 TEXT(__FUNCTION__, " Group %d/%s, %ld modules: %s, %s", f_groupId,
118 l_GroupIterator->second.name.c_str(),
119 l_GroupIterator->second.modules.size(), pStr.c_str(),
120 GetStr(m_SMCurrentState).c_str());
122 ModuleLaunchListIter l_ModuleListIterator = l_GroupIterator->second.modules.begin();
124 l_ModuleListIterator != l_GroupIterator->second.modules.end();
125 l_ModuleListIterator++, i++) {
126 sIsOKFlag = GetModuleCondition(l_ModuleListIterator) ? " " : // 'blank' means OK
127 "X"; // 'X' means state mismatch
130 " %2d: %-24s Start Req'd: %-5s %s %-24s %3dms, %3dms, %d",
131 i, l_ModuleListIterator->name.c_str(),
132 l_ModuleListIterator->is_start_required ?
133 "TRUE" : "FALSE", sIsOKFlag.c_str(),
134 l_ModuleListIterator->ModuleStateStr().c_str(),
135 static_cast<SI_16>(l_ModuleListIterator->m_startReason.GetDelta()),
136 static_cast<SI_16>(l_ModuleListIterator->m_stopReason.GetDelta()),
137 l_ModuleListIterator->pid);
140 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
143 } // End of VOID CSystemManager::LogGroupModulesState( UI_32 f_groupId, std::string pStr)
145 VOID CSystemManager::LogAllGroupModulesState(std::string pStr) {
146 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
148 std::string l_sIsOKFlag;
149 GroupLaunchMapIter l_GroupIterator = m_MapProclaunchGrps.begin();
151 std::stringstream l_comStream;
153 l_comStream << pStr << "," << GetStr(m_SMCurrentState);
155 std::string l_comStr = l_comStream.str();
156 SystemmanagerLogString(ZONE_STATE, __FUNCTION__, l_comStr);
158 while (l_GroupIterator != m_MapProclaunchGrps.end()) {
159 std::stringstream l_tblStream;
160 l_tblStream << "G" << l_GroupIterator->second.id << "/" << l_GroupIterator->second.name;
162 ModuleLaunchListIter l_ModuleListIterator = l_GroupIterator->second.modules.begin();
165 l_ModuleListIterator != l_GroupIterator->second.modules.end();
166 l_ModuleListIterator++, i++) {
167 // Since NPPService exceptionally transitions to STARTED when StartReq'd = N, it is not checked
169 GetModuleCondition(l_ModuleListIterator)
170 | (FRAMEWORKUNIFIED_NS_NPSERVICE == l_ModuleListIterator->name) ?
171 " " : // 'blank' means OK
172 "X"; // 'X' means state mismatch
174 std::string l_isStartReqd = l_ModuleListIterator->is_start_required ? "T" : "F";
176 l_tblStream << endl << " " << std::setw(2) << std::right << i << ":"
177 << l_ModuleListIterator->pid << " "
178 << l_ModuleListIterator->name << " " << "StartReq:"
179 << l_isStartReqd << " " << l_sIsOKFlag
180 << l_ModuleListIterator->ModuleStateStr();
182 if (l_ModuleListIterator->is_start_required && (FRAMEWORKUNIFIED_NS_NPSERVICE != l_ModuleListIterator->name)) { // LCOV_EXCL_BR_LINE 6: Because the condition cannot be set // NOLINT(whitespace/line_length)
184 << static_cast<SI_32>(l_ModuleListIterator->m_startReason.GetDelta())
186 << static_cast<SI_32>(l_ModuleListIterator->m_stopReason.GetDelta())
193 // Outputs each GROUP so that buffers do not overflow.
194 std::string l_logMsgStr = l_tblStream.str();
195 SystemmanagerLogString(ZONE_STATE, __FUNCTION__, l_logMsgStr);
198 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
199 } // End of VOID CSystemManager::LogAllGroupModulesState(std::string pStr)
201 BOOL CSystemManager::GetModuleCondition(ModuleLaunchListIter & f_ModuleIter) {
202 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
203 BOOL l_bIsModuleStateGood = TRUE;
205 switch (m_SMCurrentState) { // LCOV_EXCL_BR_LINE 6: As no values are passed into the default case
206 case SS_SM_READY_TO_LAUNCH_APP:
207 l_bIsModuleStateGood = f_ModuleIter->IsModuleState(MODULE_STATE_INVALID);
210 case SS_SM_APPS_LAUNCH_IN_PROGRESS:
211 l_bIsModuleStateGood = f_ModuleIter->IsModuleState(MODULE_STATE_SKIPPED)
212 || f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCH_FAILED)
213 || f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHING)
214 || f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHED);
217 case SS_SM_APPS_LAUNCHED_READY_TO_START:
218 l_bIsModuleStateGood = f_ModuleIter->IsModuleState(MODULE_STATE_SKIPPED)
219 || f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCH_FAILED)
220 || f_ModuleIter->IsModuleState(MODULE_STATE_CONNECTED)
221 || f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHED);
224 case SS_SM_APPS_START_IN_PROGRESS:
225 l_bIsModuleStateGood = f_ModuleIter->IsModuleState(MODULE_STATE_SKIPPED)
226 || f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCH_FAILED)
227 || (f_ModuleIter->is_start_required
228 && (f_ModuleIter->IsModuleState(MODULE_STATE_START_SENT)
229 || f_ModuleIter->IsModuleState(
230 MODULE_STATE_STARTED)))
231 || (!f_ModuleIter->is_start_required
232 && (f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHED)
233 || f_ModuleIter->IsModuleState(
234 MODULE_STATE_CONNECTED)));
237 case SS_SM_APPS_START_COMPLETE:
238 l_bIsModuleStateGood =
239 ((f_ModuleIter->IsModuleState(MODULE_STATE_SKIPPED) == TRUE)
240 || (f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCH_FAILED) == TRUE)
241 || ((f_ModuleIter->is_start_required == TRUE)
242 && (f_ModuleIter->IsModuleState(MODULE_STATE_STARTED) == TRUE))
243 || ((f_ModuleIter->is_start_required == FALSE)
244 && ((f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHED) == TRUE)
245 || (f_ModuleIter->IsModuleState(MODULE_STATE_CONNECTED) == TRUE)))) ? (BOOL) TRUE : (BOOL) FALSE;
248 case SS_SM_APPS_PRE_START_IN_PROGRESS:
249 l_bIsModuleStateGood =
250 ((f_ModuleIter->IsModuleState(MODULE_STATE_SKIPPED) == TRUE)
251 || (f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCH_FAILED) == TRUE)
252 || ((f_ModuleIter->is_start_required == TRUE)
253 && ((f_ModuleIter->IsModuleState(MODULE_STATE_START_PRE_SENT) == TRUE)
254 || (f_ModuleIter->IsModuleState(MODULE_STATE_STARTED_PRE) == TRUE)))
255 || ((f_ModuleIter->is_start_required == FALSE)
256 && ((f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHED) == TRUE)
257 || (f_ModuleIter->IsModuleState(MODULE_STATE_CONNECTED) == TRUE)))) ? (BOOL) TRUE : (BOOL) FALSE;
260 case SS_SM_APPS_PRE_STOP_IN_PROGRESS:
261 l_bIsModuleStateGood =
262 ((f_ModuleIter->IsModuleState(MODULE_STATE_SKIPPED) == TRUE)
263 || (f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCH_FAILED) == TRUE)
264 || ((f_ModuleIter->is_start_required == TRUE)
265 && ((f_ModuleIter->IsModuleState(MODULE_STATE_STOP_PRE_SENT) == TRUE)
266 || (f_ModuleIter->IsModuleState(MODULE_STATE_STOPPED_PRE) == TRUE)))
267 || ((f_ModuleIter->is_start_required == FALSE)
268 && ((f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHED) == TRUE)
269 || (f_ModuleIter->IsModuleState(MODULE_STATE_CONNECTED) == TRUE)))) ? (BOOL) TRUE : (BOOL) FALSE;
272 case SS_SM_APPS_PRE_RUN_COMPLETE:
273 l_bIsModuleStateGood =
274 ((f_ModuleIter->IsModuleState(MODULE_STATE_SKIPPED) == TRUE)
275 || (f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCH_FAILED) == TRUE)
276 || ((f_ModuleIter->is_start_required == TRUE)
277 && ((f_ModuleIter->IsModuleState(MODULE_STATE_STARTED_PRE) == TRUE)
278 || (f_ModuleIter->IsModuleState(MODULE_STATE_STOPPED_PRE) == TRUE)))
279 || ((f_ModuleIter->is_start_required == FALSE)
280 && ((f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHED) == TRUE)
281 || (f_ModuleIter->IsModuleState(MODULE_STATE_CONNECTED) == TRUE)))) ? (BOOL) TRUE : (BOOL) FALSE;
284 case SS_SM_APPS_BACKGROUND_START_IN_PROGRESS:
285 l_bIsModuleStateGood =
286 ((f_ModuleIter->IsModuleState(MODULE_STATE_SKIPPED) == TRUE)
287 || (f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCH_FAILED) == TRUE)
288 || ((f_ModuleIter->is_start_required == TRUE)
289 && ((f_ModuleIter->IsModuleState(MODULE_STATE_START_BACKGROUND_SENT) == TRUE)
290 || (f_ModuleIter->IsModuleState(MODULE_STATE_STARTED_BACKGROUND) == TRUE)))
291 || ((f_ModuleIter->is_start_required == FALSE)
292 && ((f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHED) == TRUE)
293 || (f_ModuleIter->IsModuleState(MODULE_STATE_CONNECTED) == TRUE)))) ? (BOOL) TRUE : (BOOL) FALSE;
296 case SS_SM_APPS_BACKGROUND_STOP_IN_PROGRESS:
297 l_bIsModuleStateGood =
298 ((f_ModuleIter->IsModuleState(MODULE_STATE_SKIPPED) == TRUE)
299 || (f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCH_FAILED) == TRUE)
300 || ((f_ModuleIter->is_start_required == TRUE)
301 && ((f_ModuleIter->IsModuleState(MODULE_STATE_STOP_BACKGROUND_SENT) == TRUE)
302 || (f_ModuleIter->IsModuleState(MODULE_STATE_STOPPED_BACKGROUND) == TRUE)))
303 || ((f_ModuleIter->is_start_required == FALSE)
304 && ((f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHED) == TRUE)
305 || (f_ModuleIter->IsModuleState(MODULE_STATE_CONNECTED) == TRUE)))) ? (BOOL) TRUE : (BOOL) FALSE;
307 case SS_SM_APPS_BACKGROUND_RUN_COMPLETE:
308 l_bIsModuleStateGood =
309 ((f_ModuleIter->IsModuleState(MODULE_STATE_SKIPPED) == TRUE)
310 || (f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCH_FAILED) == TRUE)
311 || ((f_ModuleIter->is_start_required == TRUE)
312 && ((f_ModuleIter->IsModuleState(MODULE_STATE_STARTED_BACKGROUND) == TRUE)
313 || (f_ModuleIter->IsModuleState(MODULE_STATE_STOPPED_BACKGROUND) == TRUE)))
314 || ((f_ModuleIter->is_start_required == FALSE)
315 && ((f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHED) == TRUE)
316 || (f_ModuleIter->IsModuleState(MODULE_STATE_CONNECTED) == TRUE)))) ? (BOOL) TRUE : (BOOL) FALSE;
319 case SS_SM_APPS_STOPPING_AT__CWORD56__REQ:
320 case SS_SM_APPS_STOPPING_AT_INTERNAL_REQ:
321 l_bIsModuleStateGood = f_ModuleIter->IsModuleState(MODULE_STATE_SKIPPED)
322 || f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCH_FAILED)
323 || (f_ModuleIter->is_start_required
324 && (f_ModuleIter->IsModuleState(MODULE_STATE_STOP_SENT)
325 || f_ModuleIter->IsModuleState(
326 MODULE_STATE_STOPPED)))
327 || (!f_ModuleIter->is_start_required
328 && (f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHED)
329 || f_ModuleIter->IsModuleState(
330 MODULE_STATE_CONNECTED)));
333 case SS_SM_WAITING_FOR_CRITICAL_APPS_AT__CWORD56__REQ:
334 case SS_SM_WAITING_FOR_CRITICAL_APPS_AT_INTERNAL_REQ:
335 l_bIsModuleStateGood = f_ModuleIter->IsModuleState(MODULE_STATE_SKIPPED)
336 || f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCH_FAILED)
337 || (f_ModuleIter->is_start_required
338 && f_ModuleIter->IsModuleState(MODULE_STATE_STOPPED))
339 || (!f_ModuleIter->is_start_required
340 && (f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHED)
341 || f_ModuleIter->IsModuleState(
342 MODULE_STATE_CONNECTED)));
345 // default: Don't code a 'default' here - let the compiler
346 // issue a warning ( set via -Wall or -Wswitch ) when the set of
347 // enumerations changes - then the maintainer will
348 // automagically know to update this switch statement.
351 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
352 return l_bIsModuleStateGood;
353 } // End of BOOL CSystemManager::GetModuleCondition( ModuleLaunchListIter & f_ModuleIter )
355 /*****************************************************************************
356 @ingroup: CSystemManager
357 @brief: Post Termination handler
361 *****************************************************************************/
362 EFrameworkunifiedStatus CSystemManager::SendRequestToHeartBeat(HANDLE hApp,
363 EHBProtocolMessages tRequest, VOID *tReqMessageData,
364 UI_32 u32SizeofMessage) {
365 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
368 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
370 case SS_HEARTBEAT_START:
372 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "SS_HEARTBEAT_START");
375 case SS_HEARTBEAT_STOP:
377 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "SS_HEARTBEAT_STOP");
378 tReqMessageData = NULL;
381 case SS_HEARTBEAT_DELETE_MODULE_ENTRY:
383 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "SS_HEARTBEAT_DELETE_MODULE_ENTRY");
386 case SS_HEARTBEAT_APPEND_MODULE_ENTRY:
388 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "SS_HEARTBEAT_APPEND_MODULE_ENTRY");
393 l_eStatus = eFrameworkunifiedStatusInvldParam;
394 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error : Ignored Invalid message id 0x%X", tRequest);
398 if (TRUE == bValid) { // LCOV_EXCL_BR_LINE 200:tRequest cannot be default, so bValid cannot be false
399 if (INVALID_HANDLE != m_hHeartbeatThread.m_ThreadHdl) { // LCOV_EXCL_BR_LINE 200:m_ThreadHdl cannot be null
400 if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendChild(hApp, m_hHeartbeatThread.m_ThreadHdl, tRequest, u32SizeofMessage, tReqMessageData))) { // LCOV_EXCL_BR_LINE 4:NSFW error case //NOLINT (whitespace/line_length)
401 // LCOV_EXCL_START 4: nsfw error
402 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
403 LOG_ERROR("FrameworkunifiedSendChild()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
407 // LCOV_EXCL_START 200: m_ThreadHdl cannot be null
408 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
409 l_eStatus = eFrameworkunifiedStatusInvldHandle;
410 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error : Invalid Heartbeat Thread Handle, cannot send message");
414 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
418 ///////////////////////////////////////////////////////////////////////////////
419 /// \ingroup OnModuleConnectWaitTimeout
420 /// SM maintains timer (40 sec) to check if all modules opened session with him whoever requires Start.
421 /// This timer is common to all modules. After timeout it checks the status of every module in group map.
422 /// If a module requires start and does not connect, SM will initiate error event logging followed by Soft Reset
426 /// \return EFrameworkunifiedStatus
427 /// Success ==> eFrameworkunifiedStatusOK
428 /// Failure ==> Other values
429 ///////////////////////////////////////////////////////////////////////////////
430 EFrameworkunifiedStatus CSystemManager::OnModuleConnectWaitTimeout(HANDLE hApp) {
431 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
432 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
434 static SI_32 l_NumTimesChecked = 0;
436 char l_cFormat[] = " Received from (Timer expiration %d)";
437 char l_cBuf[sizeof(l_cFormat) + 1];
438 snprintf(l_cBuf, sizeof(l_cBuf), l_cFormat, l_NumTimesChecked + 1);
439 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, l_cBuf);
442 std::string l_ProcName;
444 SetCmdHist("SM_TIMER_MODULE_CONNECT_WAIT_TIMER", m_TimerCmdHist, // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
445 m_TimerHistIter, FrameworkunifiedGetMsgSrc(hApp)); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
447 BOOL l_bModuleConnMissed = false;
449 GroupLaunchMap::reverse_iterator l_grp_riter = m_MapProclaunchGrps.rbegin();
451 ModuleLaunchList::reverse_iterator l_mod_riter;
453 if (l_grp_riter == m_MapProclaunchGrps.rend()) { // LCOV_EXCL_BR_LINE 200: group cannot be empty
454 // LCOV_EXCL_START 200: group cannot be empty
455 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
456 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: Group Map is Empty"); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
457 l_eStatus = eFrameworkunifiedStatusDbRecNotFound;
460 // scan the group map in reverse order
461 for (; l_grp_riter != m_MapProclaunchGrps.rend(); l_grp_riter++) {
462 l_mod_riter = l_grp_riter->second.modules.rbegin();
463 for (; l_mod_riter != l_grp_riter->second.modules.rend();
465 SMModuleState l_ModuleState = l_mod_riter->GetModuleState();
466 // if the module is still in MODULE_STATE_LAUNCHED state at
467 // this point though it requires start something is wrong with
468 // the module. SM initiates error event logging followed by
470 if (l_mod_riter->is_start_required
471 && ((l_ModuleState == MODULE_STATE_INVALID)
472 || (l_ModuleState == MODULE_STATE_SKIPPED)
473 || (l_ModuleState == MODULE_STATE_LAUNCHING)
474 || (l_ModuleState == MODULE_STATE_LAUNCHED)
475 || (l_ModuleState == MODULE_STATE_LAUNCH_FAILED))) {
476 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
477 " Module %s/%s is not connected",
478 l_mod_riter->name.c_str(),
479 l_mod_riter->ModuleStateStr().c_str());
480 l_bModuleConnMissed = true;
481 l_ProcName.assign(l_mod_riter->name);
483 if (l_ModuleState == MODULE_STATE_LAUNCHED) {
484 CALL_AND_LOG_STATUS_IF_ERRORED( // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
485 l_mod_riter->SetPriority( // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
486 m_SystemManagerPriority - 1)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
493 PreLaunchModuleListIter l_itr;
494 for (l_itr = m_PreLaunchModuleList.begin();
495 m_PreLaunchModuleList.end() != l_itr; l_itr++) {
496 if ((-1 == l_itr->pid) && (l_itr->critical)) { // LCOV_EXCL_BR_LINE 200: all prelaunch mode is not critical // NOLINT(whitespace/line_length)
497 // LCOV_EXCL_START 200: all prelaunch mode is not critical
498 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
499 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, " Module %s is not launched", // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
500 l_itr->name.c_str()); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
501 l_bModuleConnMissed = true;
502 l_ProcName.assign(l_itr->name);
508 if (true == l_bModuleConnMissed) {
509 if (l_NumTimesChecked < m_SMConfig.MCConfig.ModuleConnectionNumTimesToCheck) {
511 " l_NumTimesChecked %d < ModuleConnectionNumTimesToCheck %d, "
512 "will re-check in %d seconds. ";
513 char l_cBuf[sizeof(l_cFormat) + 1 + 1 + 1];
514 snprintf(l_cBuf, sizeof(l_cBuf), l_cFormat, l_NumTimesChecked,
515 m_SMConfig.MCConfig.ModuleConnectionNumTimesToCheck,
516 m_SMConfig.MCConfig.ModuleConnectionTimeOutSec);
517 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, l_cBuf);
520 l_eStatus = eFrameworkunifiedStatusBadConnection;
522 " Module connection timeout for %s and "
523 "l_NumTimesChecked %d == ModuleConnectionNumTimesToCheck %d. "
524 " Stopping ModuleConnectTimeOut timer and resetting _CWORD102_.";
525 char l_cBuf[sizeof(l_cFormat) + MAX_NAME_SIZE_APP + 1 + 1];
526 snprintf(l_cBuf, sizeof(l_cBuf), l_cFormat, l_ProcName.c_str(),
528 m_SMConfig.MCConfig.ModuleConnectionNumTimesToCheck);
529 LOG_ERROR(l_cBuf); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
531 m_GroupLaunchTimer->StopTimer(m_aTimerIDs[eSM_TIMER_MODULE_CONNECT_WAIT_TIMER]); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
533 SMLoggingInfo l_loggingInfo; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
534 l_loggingInfo.resetReason = e_SS_SM_CPU_RESET_REASON_GENERIC_ERR; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
536 // initiate error event logging
537 l_eStatus = ErrorEventEnqueue(hApp, eErrorEventTypeModConnFailed,
538 l_ProcName, eErrorEventResetTypeHard, l_loggingInfo);
539 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: ModConnFailed %s",
541 fprintf(stderr, "SS_SysManager/%s/Error: ModConnFailed %s\n", // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
542 __FUNCTION__, l_ProcName.c_str()); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
543 LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
544 "ErrorEventEnqueue(eErrorEventTypeModConnFailed)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
548 " l_NumTimesChecked = %d, ModuleConnectionNumTimesToCheck = %d. "
549 "All modules connected. Stopping ModuleConnectTimeOut timer.";
550 char l_cBuf[sizeof(l_cFormat) + 1 + 1];
551 snprintf(l_cBuf, sizeof(l_cBuf), l_cFormat, l_NumTimesChecked,
552 m_SMConfig.MCConfig.ModuleConnectionNumTimesToCheck);
553 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, l_cBuf);
555 m_GroupLaunchTimer->StopTimer(m_aTimerIDs[eSM_TIMER_MODULE_CONNECT_WAIT_TIMER]); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
558 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
560 } // End of EFrameworkunifiedStatus CSystemManager::OnModuleConnectWaitTimeout( HANDLE hApp )
562 ///////////////////////////////////////////////////////////////////////////////
563 /// \ingroup OnClientStartMonitorTimerExpiry
569 /// \return EFrameworkunifiedStatus
570 /// Success ==> eFrameworkunifiedStatusOK
571 /// Failure ==> Other values
572 ///////////////////////////////////////////////////////////////////////////////
573 EFrameworkunifiedStatus CSystemManager::OnClientStartMonitorTimerExpiry(HANDLE hApp) {
574 EFrameworkunifiedStatus l_eStatus;
575 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
577 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Received from group %d"
578 //, m_ActiveGroupId);
579 , m_SystemStarter.get_id());
582 SetCmdHist("SM_TIMER_CLIENT_START_MONITOR", m_TimerCmdHist, m_TimerHistIter, FrameworkunifiedGetMsgSrc(hApp)); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
583 // sprintf( cBuf, "ProcessGroupAsStarted(%d)", m_ActiveGroupId);
584 sprintf(cBuf, "ProcessGroupAsStarted(%d)", m_SystemStarter.get_id()); // NOLINT
585 l_eStatus = ProcessGroupAsStarted(hApp, m_SystemStarter.get_id());
586 LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, cBuf); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
588 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
594 ///////////////////////////////////////////////////////////////////////////////
595 /// \ingroup send_power_request_complete_response
596 /// send power request completion response to power
600 /// \return EFrameworkunifiedStatus
601 /// Success ==> eFrameworkunifiedStatusOK
602 /// Failure ==> Other values
603 ///////////////////////////////////////////////////////////////////////////////
604 EFrameworkunifiedStatus CSystemManager::send_power_request_complete_response(HANDLE hApp, std::string pStr) {
605 EFrameworkunifiedStatus l_eStatus;
606 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
608 // send Wake-up complete response to Power
609 l_eStatus = FrameworkunifiedSendMsg(m_hPowerServiceSession,
610 SS_SM_WAKEUP_MODULES_CMPL_RSPN, sizeof(wakeInfo), (PVOID) & m_Wake);
611 LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, "FrameworkunifiedSendMsg(SS_SM_WAKEUP_MODULES_CMPL_RSPN)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
613 LogAllGroupModulesState(pStr);
615 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
617 } // End of EFrameworkunifiedStatus CSystemManager::send_power_request_complete_response( HANDLE hApp )
619 ///////////////////////////////////////////////////////////////////////////////
620 /// \ingroup OnNPPStatusCheckMonitorTimerExpiry
622 /// \brief Called when NPP fails to provide a ready status in the specified.
623 /// amount of time. This function will periodically request a new status
624 /// ACK from NPP service until one is received. See OnNPPReadyStatusCallback().
626 /// Note: NPP usually pushes a ready event to SM and the reversion to
627 /// polling the NPP ready ACK is for additional robustness. Failure
628 /// to receive an NPP ready ACK will prevent system startup.
630 /// \param [in] hApp - Handle to framework application.
632 /// \return EFrameworkunifiedStatus
633 /// Success ==> eFrameworkunifiedStatusOK
634 /// Failure ==> Other values
635 ///////////////////////////////////////////////////////////////////////////////
636 EFrameworkunifiedStatus CSystemManager::OnNPPStatusCheckMonitorTimerExpiry(HANDLE hApp) {
637 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
638 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
640 SetCmdHist("SM_TIMER_NPP_STATUS_CHECK_MONITOR", m_TimerCmdHist, // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
641 m_TimerHistIter, FrameworkunifiedGetMsgSrc(hApp)); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
643 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " m_bIsNPP_ServicesStarted is '%s'",
644 GetStr(m_bIsNPP_ServicesStarted).c_str());
646 if (FALSE == m_bIsNPP_ServicesStarted) {
647 l_eStatus = FrameworkunifiedNPGetReadyStatusOfNPP(hApp);
648 LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "FrameworkunifiedNPGetReadyStatusOfNPP()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
650 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
654 ///////////////////////////////////////////////////////////////////////////////
655 /// \ingroup OnNPPReadyStatusCallback
657 /// \brief Called when NPP returns a status ACK indicating that the service is
658 /// operational and ready to respond to subsequent requests.
660 /// \param [in] hApp - Handle to framework application.
662 /// \return EFrameworkunifiedStatus
663 /// Success ==> eFrameworkunifiedStatusOK
664 /// Failure ==> Other values
665 ///////////////////////////////////////////////////////////////////////////////
666 EFrameworkunifiedStatus CSystemManager::OnNPPReadyStatusCallback(HANDLE hApp) { // LCOV_EXCL_START 6: Because the condition cannot be set
667 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
668 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
669 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
670 INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
671 FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(hApp));
673 SetCmdHist("NPS_GET_READYSTATUS_ACK", m_SMCmdHist, m_SMHistIter, FrameworkunifiedGetMsgSrc(hApp));
675 l_eStatus = OnNPPReadyEventCallback(hApp);
676 LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "OnNPPReadyEventCallback()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
678 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
683 EFrameworkunifiedStatus CSystemManager::OnNPPReadyEventCallback(HANDLE hApp) {
684 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
685 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
686 PCSTR l_moduleName = FrameworkunifiedGetMsgSrc(hApp);
687 FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "from %s", l_moduleName);
689 SetCmdHist("NPS_NPP_READY_EVENT", m_SMCmdHist, m_SMHistIter, l_moduleName); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
690 if (TRUE == m_bIsNPP_ServicesStarted) {
691 l_eStatus = eFrameworkunifiedStatusMsgNotProcessed;
692 LOG_ERROR("TRUE == m_bIsNPP_ServicesStarted"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
694 ModuleLaunchListIter l_ModuleListIter;
695 m_bIsNPP_ServicesStarted = TRUE;
696 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " m_bIsNPP_ServicesStarted set 'TRUE'");
697 m_GroupLaunchTimer->StopTimer(m_aTimerIDs[eSM_TIMER_NPP_STATUS_CHECK_MONITOR]);
699 UI_32 l_cbCmdIdArrayNPPService[] = { NPS_NPP_READY_EVENT, NPS_GET_READYSTATUS_ACK };
701 if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedDetachCallbacksFromDispatcher(hApp, FRAMEWORKUNIFIED_NS_NPSERVICE, l_cbCmdIdArrayNPPService, static_cast<UI_32>(_countof(l_cbCmdIdArrayNPPService))))) { // LCOV_EXCL_BR_LINE 4:NSFW error case //NOLINT (whitespace/line_length)
702 // LCOV_EXCL_START 4: nsfw error code
703 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
704 LOG_ERROR("FrameworkunifiedDetachCallbacksFromDispatcher()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
706 } else if (eFrameworkunifiedStatusOK != (l_eStatus = register_all_notification_callbacks(hApp))) { // LCOV_EXCL_BR_LINE 4:NSFW error case //NOLINT (whitespace/line_length)
707 // LCOV_EXCL_START 4: nsfw error code
708 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
709 LOG_ERROR("register_all_notification_callbacks()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
711 } else if (eFrameworkunifiedStatusOK != (l_eStatus = GetModuleIterator(l_moduleName, l_ModuleListIter))) { // LCOV_EXCL_BR_LINE 200:NPP always in launch map //NOLINT (whitespace/line_length)
712 // LCOV_EXCL_START 200 : NPP service always in launch map
713 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
714 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
715 " Error: Module %s not found in Group Launch Map", // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
716 l_moduleName); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
719 l_ModuleListIter->SetModuleState(MODULE_STATE_STARTED);
721 if (m_oSystemLauncher.get_id() == 1) {
722 m_oSystemLauncher.advance_id();
725 l_eStatus = OnLaunchGroup(hApp);
726 LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "OnLaunchGroup(hApp)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
727 if (eFrameworkunifiedStatusOK == l_eStatus) { // LCOV_EXCL_BR_LINE 200: OnLaunchGroup() return ok
728 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " successful");
733 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
735 } // End of EFrameworkunifiedStatus CSystemManager::OnNPPReadyEventCallback( HANDLE hApp )
737 ///////////////////////////////////////////////////////////////////////////////
738 /// \ingroup OnBackupMgrAvailCallback
739 /// BackupManager Availability Notification Callback
744 /// \return EFrameworkunifiedStatus
745 /// Success ==> eFrameworkunifiedStatusOK
746 /// Failure ==> Other values
747 ///////////////////////////////////////////////////////////////////////////////
748 EFrameworkunifiedStatus CSystemManager::OnBackupMgrAvailCallback(HANDLE hApp) {
749 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
750 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
752 if (sizeof(ServiceAvailability) != FrameworkunifiedGetMsgLength(hApp)) { // LCOV_EXCL_BR_LINE 4: nsfw error
753 // LCOV_EXCL_START 4: nsfw error
754 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
755 SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
757 l_eStatus = eFrameworkunifiedStatusFail;
758 } else if (strcmp(FrameworkunifiedGetLastNotification(hApp), NTFY_BackupMgr_Availability) != 0) { // LCOV_EXCL_BR_LINE 200:cannot be false //NOLINT (whitespace/line_length)
759 // LCOV_EXCL_START 200: cannot be false
760 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
761 SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
762 l_eStatus = eFrameworkunifiedStatusFail;
765 m_bIsBackupAvail = FrameworkunifiedIsServiceAvailable(hApp);
766 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "BackupAvail:%s", m_bIsBackupAvail ? "T" : "F");
768 l_eStatus = OnLaunchGroup(hApp);
769 LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "OnLaunchGroup(hApp)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
772 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
774 } // End of EFrameworkunifiedStatus CSystemManager::OnBackupMgrAvailCallback(HANDLE hApp)
776 ///////////////////////////////////////////////////////////////////////////////
777 /// \ingroup OnPowerRequestCallback
778 /// PowerRequest callback handler
783 /// \return EFrameworkunifiedStatus
784 /// Success ==> eFrameworkunifiedStatusOK
785 /// Failure ==> Other values
786 ///////////////////////////////////////////////////////////////////////////////
787 EFrameworkunifiedStatus CSystemManager::OnPowerRequestCallback(HANDLE hApp) {
788 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
789 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
790 Pwr_ServiceSetInterface tServiceIf;
791 INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
793 SetCmdHist("SS_SM_POWER_REQUEST_MSG", m__CWORD56_CmdHist, m__CWORD56_HistIter, FrameworkunifiedGetMsgSrc(hApp));
795 // OnSystemManagerDebugDump(hApp);
797 // Check hApp ptr, msg size, msg reception, read msg if all ok. *
798 // Report any errors found. *
800 if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < Pwr_ServiceSetInterface > (hApp, tServiceIf))) { // LCOV_EXCL_BR_LINE 4:NSFW error case //NOLINT (whitespace/line_length)
801 // LCOV_EXCL_START 4: nsfw error
802 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
803 LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
806 // NOTE: interface_unified always set userMode as 0. so don't use m_lastUserMode.
807 m_lastUserMode = tServiceIf.data.powerRequestMsg.userMode;
809 // 2012 December 04 Temporary hack ( I hope ) to set m_Wake to nominal
810 // values. At present, the 'Power Request Message Response' is sent
811 // back to Power Services via the 'send_power_request_complete_response()'
812 // function, which uses m_Wake.
814 m_SSBool_to_PowerTypeEnumMap[m_SSUserMode_to_SSBoolEnumMap[m_lastUserMode]];
816 m_Wake.up.factor = tServiceIf.data.powerRequestMsg.startupReason;
818 if (epswfINVALID != m_Wake.up.factor) {
819 m_StartUpReason = m_Wake.up.factor;
822 m_userModeChangeReason = tServiceIf.data.powerRequestMsg.userModeChangeReason;
823 m_Wake.up.userModeChangeReason = m_userModeChangeReason;
825 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "UserMode:%s, SM State:%s",
826 GetStr(m_lastUserMode).c_str(),
827 GetStr(m_SMCurrentState).c_str());
828 FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "UserMode:%s, SM State:%s",
829 GetStr(m_lastUserMode).c_str(),
830 GetStr(m_SMCurrentState).c_str());
831 CALL_AND_LOG_STATUS(PublishPowerOnOffNotification(hApp)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
833 switch (m_SMCurrentState) { // LCOV_EXCL_BR_LINE 6: As not all cases can be passed through
834 case SS_SM_READY_TO_LAUNCH_APP:
835 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
836 " Error: Received a PowerRequest command while still in "
837 "the '%s' state !!!",
838 GetStr(m_SMCurrentState).c_str());
839 l_eStatus = eFrameworkunifiedStatusErrOther;
842 case SS_SM_APPS_LAUNCH_IN_PROGRESS:
843 // When Start is received while processes are launching, we
844 // need to send the Start request later, once the 'Open
845 // Session Request' is received from the application.
847 // Deliberate commenting-out of case-break to allow this case to
848 // use following case's logic.
852 case SS_SM_APPS_LAUNCHED_READY_TO_START:
853 case SS_SM_APPS_START_COMPLETE:
854 case SS_SM_APPS_PRE_RUN_COMPLETE:
855 case SS_SM_APPS_BACKGROUND_RUN_COMPLETE:
856 case SS_SM_APPS_START_IN_PROGRESS:
857 case SS_SM_APPS_PRE_START_IN_PROGRESS:
858 case SS_SM_APPS_PRE_STOP_IN_PROGRESS:
859 case SS_SM_APPS_BACKGROUND_START_IN_PROGRESS:
860 case SS_SM_APPS_BACKGROUND_STOP_IN_PROGRESS:
861 FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "Startup Reason is '%s'", GetStr(m_StartUpReason).c_str());
862 if ((m_userModeChangeReason == epsumcrPARKING_B)
863 || ((m_userModeChangeReason == epsumcrPRE_BA) && (m_SMCurrentState == SS_SM_APPS_PRE_RUN_COMPLETE))
864 || ((m_userModeChangeReason == epsumcrNORMAL) && (m_SMCurrentState == SS_SM_APPS_START_COMPLETE))
865 || ((m_userModeChangeReason == epsumcrBACKGROUND_BA)
866 && (m_SMCurrentState == SS_SM_APPS_BACKGROUND_RUN_COMPLETE))) {
867 // send the Power Request complete response to PowerService
868 // LCOV_EXCL_BR_START 15: Excluded due to inlined functions
869 CALL_AND_LOG_STATUS_IF_ERRORED(send_power_request_complete_response(hApp, "Power Request"));
870 // LCOV_EXCL_BR_STOP 15: Excluded due to inlined functions
873 // Publish the UserMode 'Off' notification now for those
874 // applications that need immediate notification ( HMI )
875 if (m_lastUserMode == epsumOFF) {
876 CALL_AND_LOG_STATUS(PublishUserModeNotification(hApp)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
879 CALL_AND_LOG_STATUS(BeginStartup(hApp)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
883 case SS_SM_APPS_STOPPING_AT__CWORD56__REQ:
884 case SS_SM_WAITING_FOR_CRITICAL_APPS_AT__CWORD56__REQ:
886 // Reset System Manager to handle (re)starting as if this is a
888 m_GroupLaunchTimer->StopTimer(m_aTimerIDs[eSM_TIMER_CLIENT_STOP_MONITOR]);
890 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Aborted %s, resetting to %s,"
891 " restarting Application groups at group %d",
892 GetStr(m_SMCurrentState).c_str(),
893 GetStr(SS_SM_APPS_START_IN_PROGRESS).c_str()
894 , m_SystemStarter.get_id());
896 CALL_AND_LOG_STATUS(BeginStartup(hApp)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
900 case SS_SM_APPS_STOPPING_AT_INTERNAL_REQ:
901 case SS_SM_WAITING_FOR_CRITICAL_APPS_AT_INTERNAL_REQ: // LCOV_EXCL_START 8: As no value is set
902 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
903 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
904 " Warning: System Manager state is %d/'%s', ignoring "
905 "PowerRequest command", m_SMCurrentState,
906 GetStr(m_SMCurrentState).c_str());
910 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
912 } // End of EFrameworkunifiedStatus CSystemManager::OnPowerRequestCallback( HANDLE hApp )
914 ///////////////////////////////////////////////////////////////////////////////
916 /// Begin the Startup process
921 /// \return EFrameworkunifiedStatus
922 /// Success ==> eFrameworkunifiedStatusOK
923 /// Failure ==> Other values
924 ///////////////////////////////////////////////////////////////////////////////
925 EFrameworkunifiedStatus CSystemManager::BeginStartup(HANDLE hApp) {
926 EFrameworkunifiedStatus l_eStatus;
927 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
929 if ((m_userModeChangeReason != epsumcrPARKING_B) &&
930 (m_userModeChangeReason != epsumcrPRE_BA) &&
931 (m_userModeChangeReason != epsumcrNORMAL) &&
932 (m_userModeChangeReason != epsumcrBACKGROUND_BA)) {
933 // Not a power state transition request.
934 return eFrameworkunifiedStatusOK;
937 switch (m_userModeChangeReason) { // LCOV_EXCL_BR_LINE 6: Excluded because it has been guarded to prevent out-of-range values from entering immediately before.
939 // LCOV_EXCL_BR_START 6: This function is an internal function, and it is guarded so that the value outside the range is not entered by the caller, so it is excluded.
940 if ((m_SMCurrentState == SS_SM_APPS_START_COMPLETE) || (m_SMCurrentState == SS_SM_APPS_BACKGROUND_RUN_COMPLETE)) {
941 // LCOV_EXCL_BR_STOP 6: This function is an internal function, and it is guarded so that the value outside the range is not entered by the caller, so it is excluded.
942 m_SystemStarter.to_end();
943 SMSetState(hApp, SS_SM_APPS_PRE_STOP_IN_PROGRESS);
945 m_SystemStarter.to_begin();
946 SMSetState(hApp, SS_SM_APPS_PRE_START_IN_PROGRESS);
950 m_SystemStarter.to_begin();
951 SMSetState(hApp, SS_SM_APPS_START_IN_PROGRESS);
953 case epsumcrBACKGROUND_BA:
954 if (m_SMCurrentState == SS_SM_APPS_START_COMPLETE) {
955 m_SystemStarter.to_end();
956 SMSetState(hApp, SS_SM_APPS_BACKGROUND_STOP_IN_PROGRESS);
958 m_SystemStarter.to_begin();
959 SMSetState(hApp, SS_SM_APPS_BACKGROUND_START_IN_PROGRESS);
966 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
967 " Starting 'Start Resp Monitor' Timer with '%d' sec",
968 m_SMConfig.MCConfig.ModuleStartRespTimeOutSec);
970 m_GroupLaunchTimer->StartTimer(
971 m_aTimerIDs[eSM_TIMER_START_RESP_MONITOR_WAIT_TIMER],
972 m_SMConfig.MCConfig.ModuleStartRespTimeOutSec, 0, 0, 0);
974 l_eStatus = start_all_modules_of_group(hApp, m_SystemStarter.get_id());
975 if (eFrameworkunifiedStatusOK != l_eStatus) {
976 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
977 " Error: start_all_modules_of_group(%d) errored: %d/'%s'",
978 m_SystemStarter.get_id(), l_eStatus, GetStr(l_eStatus).c_str());
980 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
982 } // End of EFrameworkunifiedStatus CSystemManager::BeginStartup( HANDLE hApp )
984 ///////////////////////////////////////////////////////////////////////////////
985 /// \ingroup OnWakeupCallback
986 /// WakeUp callback handler
991 /// \return EFrameworkunifiedStatus
992 /// Success ==> eFrameworkunifiedStatusOK
993 /// Failure ==> Other values
994 ///////////////////////////////////////////////////////////////////////////////
995 EFrameworkunifiedStatus CSystemManager::OnWakeupCallback(HANDLE hApp) { // LCOV_EXCL_START 6: Because the condition cannot be set
996 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
997 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
998 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
999 INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp);
1000 FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "Received from %s", FrameworkunifiedGetMsgSrc(hApp));
1002 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1004 } // End of EFrameworkunifiedStatus CSystemManager::OnWakeupCallback( HANDLE hApp )
1007 ///////////////////////////////////////////////////////////////////////////////
1008 /// \ingroup OnModuleStartCompleteResponse
1009 /// Start Response\Ack Handlers
1014 /// \return EFrameworkunifiedStatus
1015 /// Success ==> eFrameworkunifiedStatusOK
1016 /// Failure ==> Other values
1017 ///////////////////////////////////////////////////////////////////////////////
1018 EFrameworkunifiedStatus CSystemManager::OnModuleStartCompleteResponse(HANDLE hApp) {
1019 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1020 EFrameworkunifiedStatus l_eStatus;
1021 INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
1022 FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "%s", FrameworkunifiedGetMsgSrc(hApp));
1024 SetCmdHist("system_manager protocol completion response", m_SMCmdHist, m_SMHistIter, FrameworkunifiedGetMsgSrc(hApp)); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
1026 ModuleLaunchListIter l_ModuleListIter;
1027 std::string l_moduleName = FrameworkunifiedGetMsgSrc(hApp);
1028 l_eStatus = GetModuleIterator(l_moduleName.c_str(), l_ModuleListIter);
1029 if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 200:always be eFrameworkunifiedStatusOK
1030 // LCOV_EXCL_START 200: always be eFrameworkunifiedStatusOK
1031 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1032 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1033 " Error: Module %s not found in Group Launch Map",
1034 l_moduleName.c_str());
1037 switch (m_SMCurrentState) { // LCOV_EXCL_BR_LINE 200: cannot be SS_SM_READY_TO_LAUNCH_APP
1038 case SS_SM_READY_TO_LAUNCH_APP:
1039 // LCOV_EXCL_START 200: cannot be SS_SM_READY_TO_LAUNCH_APP
1040 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1041 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1042 " Error: Received while in the '%s' state !!!",
1043 GetStr(m_SMCurrentState).c_str());
1044 l_eStatus = eFrameworkunifiedStatusErrOther;
1048 case SS_SM_APPS_LAUNCH_IN_PROGRESS:
1049 case SS_SM_APPS_LAUNCHED_READY_TO_START:
1050 case SS_SM_APPS_START_IN_PROGRESS:
1051 case SS_SM_APPS_PRE_START_IN_PROGRESS:
1052 case SS_SM_APPS_PRE_STOP_IN_PROGRESS:
1053 case SS_SM_APPS_BACKGROUND_START_IN_PROGRESS:
1054 case SS_SM_APPS_BACKGROUND_STOP_IN_PROGRESS:
1056 const SMModuleState l_state = InProgressStateToState(); // LCOV_EXCL_BR_LINE 11: Gcov constraints (because exception-handling routes are automatically generated) // NOLINT(whitespace/line_length)
1057 if (l_state != MODULE_STATE_INVALID) {
1058 const PCSTR l_loglist[] = {"start", "pre start", "pre stop", "background start", "background stop", ""};
1060 switch (l_state) { // LCOV_EXCL_BR_LINE 6: As no other value is returned
1061 case MODULE_STATE_STARTED:
1062 l_logtxt = l_loglist[0];
1064 case MODULE_STATE_STARTED_PRE:
1065 l_logtxt = l_loglist[1];
1067 case MODULE_STATE_STOPPED_PRE:
1068 l_logtxt = l_loglist[2];
1070 case MODULE_STATE_STARTED_BACKGROUND:
1071 l_logtxt = l_loglist[3];
1073 case MODULE_STATE_STOPPED_BACKGROUND:
1074 l_logtxt = l_loglist[4];
1076 // LCOV_EXCL_START 6: As no other value is returned
1078 AGL_ASSERT_NOT_TESTED();
1079 l_logtxt = l_loglist[5];
1081 // LCOV_EXCL_STOP 6: As no other value is returned
1083 l_eStatus = ModuleCompleteResponse(hApp, l_ModuleListIter, l_state, // LCOV_EXCL_BR_LINE 11: Gcov constraints (because exception-handling routes are automatically generated) // NOLINT(whitespace/line_length)
1084 SysMgrCbType3<CSystemManager, &CSystemManager::IsGroupStarted>,
1085 SysMgrCbType2<CSystemManager, &CSystemManager::ProcessGroupAsStarted>,
1091 case SS_SM_APPS_STOPPING_AT__CWORD56__REQ:
1092 case SS_SM_APPS_STOPPING_AT_INTERNAL_REQ:
1093 case SS_SM_WAITING_FOR_CRITICAL_APPS_AT__CWORD56__REQ:
1094 case SS_SM_WAITING_FOR_CRITICAL_APPS_AT_INTERNAL_REQ:
1095 // SystemManager changed state while this module was starting;
1096 // tell this module to stop.
1097 if (!l_ModuleListIter->IsModuleState(MODULE_STATE_STOP_SENT)
1098 && !l_ModuleListIter->IsModuleState(MODULE_STATE_STOPPED)) {
1099 T_SS_SM_STOP_DataStructType l_SM_STOP_Struct;
1100 l_SM_STOP_Struct.shutdownTrigger = m_shutdownTrigger;
1101 l_SM_STOP_Struct.lastUserMode = m_lastUserMode;
1103 CALL_AND_LOG_STATUS( // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1104 l_ModuleListIter->SendMsgAndUpdateState(
1105 &l_SM_STOP_Struct));
1109 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: Received while in the '%s' state !!!", GetStr(m_SMCurrentState).c_str());
1110 l_eStatus = eFrameworkunifiedStatusErrOther;
1112 } // End switch ( m_SMCurrentState )
1114 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1116 } // End of EFrameworkunifiedStatus CSystemManager::OnModuleStartCompleteResponse( HANDLE hApp )
1118 ///////////////////////////////////////////////////////////////////////////////
1119 /// \ingroup ModuleCompleteResponse
1120 /// Start Response\Ack Handlers
1125 /// \return EFrameworkunifiedStatus
1126 /// Success ==> eFrameworkunifiedStatusOK
1127 /// Failure ==> Other values
1128 ///////////////////////////////////////////////////////////////////////////////
1129 EFrameworkunifiedStatus CSystemManager::ModuleCompleteResponse(HANDLE hApp,
1130 ModuleLaunchListIter f_ModuleListIter, SMModuleState f_moduleState,
1131 FncCbType3 f_isGroupDoneFnc, FncCbType2 f_groupDoneFnc,
1132 PCSTR f_sCompleteTypeText) {
1133 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
1134 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1135 std::string l_moduleName = FrameworkunifiedGetMsgSrc(hApp);
1136 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
1137 " Received from %s, m_SystemStarter.get_id() is %d",
1138 l_moduleName.c_str()
1139 , m_SystemStarter.get_id());
1141 f_ModuleListIter->SetModuleState(f_moduleState);
1142 if (f_ModuleListIter->group_id != m_SystemStarter.get_id()) {
1143 // In PastModel002, it is assumed that there is no service that returns a FrameworkunifiedOnStop reply after the NPP service.
1144 // However, since _CWORD71_ does not assume this, completion of waiting for termination of the CRITICAL service must be
1145 // judged even when services other than the Group1 service terminate last.
1146 // Initially, SS_SM_WAITING_FOR_CRITICAL_APPS_AT_XXXX should be handled separately by ProcessModuleStopCompleteResponse(),
1147 // but this is limited to ModuleCompleteResponse in order to avoid code deviation from PastModel002 and limit the scope of effect.
1148 // LCOV_EXCL_BR_START 200 : m_SMCurrentState can't be SS_SM_WAITING_FOR_CRITICAL_APPS_AT__CWORD56__REQ and SS_SM_WAITING_FOR_CRITICAL_APPS_AT_INTERNAL_REQ // NOLINT(whitespace/line_length)
1149 if ((MODULE_STATE_STOPPED == f_moduleState)
1150 && ((m_SMCurrentState
1151 == SS_SM_WAITING_FOR_CRITICAL_APPS_AT__CWORD56__REQ)
1152 || (m_SMCurrentState
1153 == SS_SM_WAITING_FOR_CRITICAL_APPS_AT_INTERNAL_REQ))) {
1154 // LCOV_EXCL_BR_STOP 200 : m_SMCurrentState can't be SS_SM_WAITING_FOR_CRITICAL_APPS_AT__CWORD56__REQ and SS_SM_WAITING_FOR_CRITICAL_APPS_AT_INTERNAL_REQ // NOLINT(whitespace/line_length)
1155 // LCOV_EXCL_START 200 : m_SMCurrentState can't be SS_SM_WAITING_FOR_CRITICAL_APPS_AT__CWORD56__REQ and SS_SM_WAITING_FOR_CRITICAL_APPS_AT_INTERNAL_REQ // NOLINT(whitespace/line_length)
1156 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1157 check_all_groups_have_stopped(hApp);
1160 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
1161 " %s ( group %d ) received out-of-synch; m_SystemStarter.get_id() is %d",
1162 l_moduleName.c_str(), f_ModuleListIter->group_id
1163 , m_SystemStarter.get_id());
1166 if ((*f_isGroupDoneFnc)(f_ModuleListIter->group_id)) { // LCOV_EXCL_BR_LINE 11: Gcov constraints (because exception-handling routes are automatically generated) // NOLINT(whitespace/line_length)
1167 l_eStatus = (*f_groupDoneFnc)(hApp, f_ModuleListIter->group_id); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
1168 } else if (IS_ZONE_SET(ZONE_INFO)) { // LCOV_EXCL_BR_LINE 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
1169 // LCOV_EXCL_START 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
1170 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1171 TEXT(__FUNCTION__, // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
1172 " Group %d %s incomplete, m_SystemStarter.get_id() is %d", // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
1173 f_ModuleListIter->group_id, f_sCompleteTypeText // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
1174 , m_SystemStarter.get_id()); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
1176 sprintf(cBuf, "%s incomplete", f_sCompleteTypeText); // NOLINT
1177 LogGroupModulesState(f_ModuleListIter->group_id, cBuf); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
1182 const SMModuleState l_transition_state = InProgressStateToState(); // LCOV_EXCL_BR_LINE 11: Gcov constraints (because exception-handling routes are automatically generated) // NOLINT(whitespace/line_length)
1183 if (l_transition_state == f_moduleState) { // LCOV_EXCL_BR_LINE 6: As no other value is returned
1184 if (have_all_services_start_completed(l_transition_state) == TRUE) {
1185 if ((m_SMCurrentState == SS_SM_APPS_PRE_START_IN_PROGRESS)
1186 || (m_SMCurrentState == SS_SM_APPS_PRE_STOP_IN_PROGRESS)) {
1187 SMSetState(hApp, SS_SM_APPS_PRE_RUN_COMPLETE); // LCOV_EXCL_BR_LINE 11: Gcov constraints (because exception-handling routes are automatically generated) // NOLINT(whitespace/line_length)
1188 } else if ((m_SMCurrentState == SS_SM_APPS_BACKGROUND_START_IN_PROGRESS)
1189 || (m_SMCurrentState == SS_SM_APPS_BACKGROUND_STOP_IN_PROGRESS)) {
1190 SMSetState(hApp, SS_SM_APPS_BACKGROUND_RUN_COMPLETE); // LCOV_EXCL_BR_LINE 11: Gcov constraints (because exception-handling routes are automatically generated) // NOLINT(whitespace/line_length)
1192 SMSetState(hApp, SS_SM_APPS_START_COMPLETE); // LCOV_EXCL_BR_LINE 11: Gcov constraints (because exception-handling routes are automatically generated) // NOLINT(whitespace/line_length)
1197 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1199 } // End of EFrameworkunifiedStatus CSystemManager::ModuleCompleteResponse(
1201 ///////////////////////////////////////////////////////////////////////////////
1202 /// \ingroup OnStartRespMonitorTimeout
1203 /// SM maintains timer to check if all modules sent start response to him whoever requires Start.
1204 /// This timer is common to all modules. After timeout it checks the status of every module in group map.
1205 /// If a module sent start and does not respond, SM will initiate error event logging followed by Soft Reset
1209 /// \return EFrameworkunifiedStatus
1210 /// Success ==> eFrameworkunifiedStatusOK
1211 /// Failure ==> Other values
1212 ///////////////////////////////////////////////////////////////////////////////
1213 EFrameworkunifiedStatus CSystemManager::OnStartRespMonitorTimeout(HANDLE hApp) { // LCOV_EXCL_START 6: Because the condition cannot be set
1214 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1215 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
1216 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1217 INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
1218 FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(hApp));
1220 std::string l_ProcName;
1221 BOOL l_isStartRespNotReceived = false;
1223 SetCmdHist("SM_TIMER_START_RESP_MONITOR_WAIT_TIMER", m_TimerCmdHist,
1224 m_TimerHistIter, FrameworkunifiedGetMsgSrc(hApp));
1225 GroupLaunchMap::reverse_iterator l_grp_riter = m_MapProclaunchGrps.rbegin();
1226 ModuleLaunchList::reverse_iterator l_mod_riter;
1228 if (l_grp_riter == m_MapProclaunchGrps.rend()) {
1229 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: Group Map is Empty");
1231 // scan the group map in reverse order
1232 for (; l_grp_riter != m_MapProclaunchGrps.rend(); l_grp_riter++) {
1233 l_mod_riter = l_grp_riter->second.modules.rbegin();
1234 for (; l_mod_riter != l_grp_riter->second.modules.rend(); l_mod_riter++) {
1235 // if a module sent start and not received response from module SM wait for "ModuleStartRespTimeout"
1236 // and initiated error event
1237 // logging followed by soft reset
1239 if (l_mod_riter->is_start_required) {
1240 if (l_mod_riter->IsModuleState(MODULE_STATE_START_SENT)) {
1241 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
1242 " Module [%s] did not respond(%s) to SM in allocated time [%d] sec",
1243 l_mod_riter->name.c_str(),
1244 l_mod_riter->ModuleStateStr().c_str(),
1245 m_SMConfig.MCConfig.ModuleStartRespTimeOutSec);
1246 l_isStartRespNotReceived = true;
1247 l_ProcName.assign(l_mod_riter->name);
1254 if (true == l_isStartRespNotReceived) {
1255 char l_cFormat[] = " Error. Module '%s' start response timeout.";
1256 char l_cBuf[sizeof(l_cFormat) + MAX_NAME_SIZE_APP];
1257 snprintf(l_cBuf, sizeof(l_cBuf), l_cFormat, l_ProcName.c_str());
1258 TEXT(__FUNCTION__, l_cBuf); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
1259 FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, l_cBuf);
1261 SMLoggingInfo l_loggingInfo;
1262 l_loggingInfo.resetReason = e_SS_SM_CPU_RESET_REASON_GENERIC_ERR;
1264 // initate error event logging
1265 l_eStatus = ErrorEventEnqueue(hApp, eErrorEventTypeStartRespFailed,
1266 l_ProcName, eErrorEventResetTypeHard, l_loggingInfo);
1267 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: StartRespFailed %s", l_ProcName.c_str());
1268 fprintf(stderr, "SS_SysManager/%s/Error: StartRespFailed %s\n",
1269 __FUNCTION__, l_ProcName.c_str());
1270 LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
1271 "ErrorEventEnqueue(eErrorEventTypeStartRespFailed)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
1273 FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__,
1274 " All modules returned Start Response.");
1276 l_eStatus = FrameworkunifiedSendChild(hApp, m_hHeartbeatThread.m_ThreadHdl,
1277 SS_HEARTBEAT_AVAIL_CHECK_REQ, 0, NULL);
1278 SS_ASERT(l_eStatus == eFrameworkunifiedStatusOK); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1281 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1283 } // End of EFrameworkunifiedStatus CSystemManager::OnStartRespMonitorTimeout(HANDLE hApp)
1286 ///////////////////////////////////////////////////////////////////////////////
1287 /// \ingroup OnShutdownCompleteMonitorTimeout
1288 /// SM maintains timer to check if all modules sent start response to him whoever requires Start.
1289 /// This timer is common to all modules. After timeout it checks the status of every module in group map.
1290 /// If a module sent start and does not respond, SM will initiate error event logging followed by Soft Reset
1294 /// \return EFrameworkunifiedStatus
1295 /// Success ==> eFrameworkunifiedStatusOK
1296 /// Failure ==> Other values
1297 ///////////////////////////////////////////////////////////////////////////////
1298 EFrameworkunifiedStatus CSystemManager::OnShutdownCompleteMonitorTimeout(HANDLE hApp) {
1299 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
1300 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1301 INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
1303 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: Reset Timeout");
1305 l_eStatus = SecureChipOff();
1306 if (eFrameworkunifiedStatusOK != l_eStatus) {
1307 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: SecureChipOff Failed");
1310 m_ResetFactor = PSM_FACTOR_AGL_WITH_HISTORY;
1312 l_eStatus = perform_force_reset(hApp);
1314 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1316 } // End of EFrameworkunifiedStatus CSystemManager::OnShutdownCompleteMonitorTimeout(HANDLE hApp)
1318 ///////////////////////////////////////////////////////////////////////////////
1319 /// \ingroup start_all_modules_of_group
1320 /// Send START to all modules of the given group
1325 /// \return EFrameworkunifiedStatus
1326 /// Success ==> eFrameworkunifiedStatusOK
1327 /// Failure ==> Other values
1328 ///////////////////////////////////////////////////////////////////////////////
1329 EFrameworkunifiedStatus CSystemManager::start_all_modules_of_group(HANDLE hApp, UI_32 f_ui32GroupNumber) {
1330 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
1331 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1333 GroupLaunchMapIter l_GroupIterator = m_MapProclaunchGrps.find(
1335 if (l_GroupIterator == m_MapProclaunchGrps.end()) { // LCOV_EXCL_BR_LINE 6: Because the condition cannot be set
1336 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1337 FRAMEWORKUNIFIEDLOG(ZONE_ERR,
1339 , " Error: Group %d not found; 'm_MapProclaunchGrps' is empty",
1341 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1342 l_eStatus = eFrameworkunifiedStatusInvldParam; // LCOV_EXCL_LINE 6: Because the condition cannot be set
1344 T_SS_SM_START_DataStructType f_startupData(m_StartUpReason,
1345 m_PowerType_to_SSBoolEnumMap[m_Wake.powerupType],
1346 m_DataResetMode, m_startUpConfirmationMsg.securityStatus,
1347 m_startUpConfirmationMsg.wakeupType, m_DramBackupStatus,
1348 m_ResetStatus, m_ResetCount);
1350 UI_32 l_numModulesMessaged = 0;
1351 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
1352 " Attempting to send Start Requests to Group %d/'%s'",
1353 f_ui32GroupNumber, l_GroupIterator->second.name.c_str());
1355 for (ModuleLaunchListIter l_ModuleListIterator =
1356 l_GroupIterator->second.modules.begin();
1357 l_ModuleListIterator != l_GroupIterator->second.modules.end();
1358 l_ModuleListIterator++) {
1360 // Every branch below must ZONE_INFO log how it dispenses w/
1362 // Note: ModuleLaunchParams::SetModuleState() performs that
1363 // ZONE_INFO logging internally.
1364 if (!l_ModuleListIterator->is_start_required) {
1365 if (FRAMEWORKUNIFIED_NS_NPSERVICE == l_ModuleListIterator->name) {
1366 const SMModuleState l_transition_state = InProgressStateToState(); // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
1367 l_ModuleListIterator->SetModuleState(l_transition_state); // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
1370 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
1371 " %s 'is_start_required' is False;"
1372 " leaving state as '%s'",
1373 l_ModuleListIterator->name.c_str(),
1374 l_ModuleListIterator->ModuleStateStr().c_str());
1376 l_eStatus = eFrameworkunifiedStatusOK;
1377 } else if (NULL == l_ModuleListIterator->hsession) { // LCOV_EXCL_BR_LINE 6: hsession can not be null.
1378 l_eStatus = eFrameworkunifiedStatusOK; // Log a message. But its not a failure
1379 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, " Warning: NULL == hsession;"
1380 " %s not connected yet",
1381 l_ModuleListIterator->name.c_str());
1383 switch (l_ModuleListIterator->GetModuleState()) { // LCOV_EXCL_BR_LINE 6: As not all cases can be passed through
1384 case MODULE_STATE_INVALID:
1385 case MODULE_STATE_SKIPPED:
1386 case MODULE_STATE_LAUNCH_FAILED:
1387 // LCOV_EXCL_START 6: Because the state of the corresponding variable cannot be set
1388 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1389 l_eStatus = eFrameworkunifiedStatusOK; // Log a message. But its not a failure
1390 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
1391 " %s is %s, NOT sending system_manager protocol message",
1392 l_ModuleListIterator->name.c_str(),
1393 l_ModuleListIterator->ModuleStateStr().c_str());
1397 case MODULE_STATE_START_SENT:
1398 case MODULE_STATE_START_PRE_SENT:
1399 case MODULE_STATE_STOP_PRE_SENT:
1400 case MODULE_STATE_START_BACKGROUND_SENT:
1401 case MODULE_STATE_STOP_BACKGROUND_SENT:
1402 l_eStatus = eFrameworkunifiedStatusOK;
1403 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
1404 " %s is %s, NOT sending system_manager protocol message",
1405 l_ModuleListIterator->name.c_str(),
1406 l_ModuleListIterator->ModuleStateStr().c_str());
1407 l_numModulesMessaged++;
1410 case MODULE_STATE_LAUNCHING:
1411 case MODULE_STATE_LAUNCHED:
1412 // LCOV_EXCL_START 6: Because the state of the corresponding variable cannot be set
1413 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1414 l_eStatus = eFrameworkunifiedStatusOK; // Log a message. But its not a failure
1415 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
1416 " %s is %s, NOT sending system_manager protocol message",
1417 l_ModuleListIterator->name.c_str(),
1418 l_ModuleListIterator->ModuleStateStr().c_str());
1422 case MODULE_STATE_CONNECTED:
1423 case MODULE_STATE_STARTED:
1424 case MODULE_STATE_START_FAILED:
1425 case MODULE_STATE_STOP_FAILED:
1426 case MODULE_STATE_STOP_SENT:
1427 case MODULE_STATE_STOPPED:
1428 case MODULE_STATE_STARTED_PRE:
1429 case MODULE_STATE_START_PRE_FAILED:
1430 case MODULE_STATE_STOPPED_PRE:
1431 case MODULE_STATE_STOP_PRE_FAILED:
1432 case MODULE_STATE_STARTED_BACKGROUND:
1433 case MODULE_STATE_START_BACKGROUND_FAILED:
1434 case MODULE_STATE_STOPPED_BACKGROUND:
1435 case MODULE_STATE_STOP_BACKGROUND_FAILED:
1437 const UI_32 l_iCmd = InProgressStateToSendMsg(); // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
1438 if (l_iCmd != SS_SYSTEM_MANAGER_PROTOCOL_ENDING_INDEX) { // LCOV_EXCL_BR_LINE 6: Excluded due to value never returned at present
1439 // LCOV_EXCL_BR_START 15: Excluded due to inlined functions
1440 CALL_AND_LOG_STATUS_IF_ERRORED(l_ModuleListIterator->SendMsgAndUpdateState(l_iCmd, &f_startupData));
1441 // LCOV_EXCL_BR_STOP 15: Excluded due to inlined functions
1442 l_numModulesMessaged++;
1446 // default: Don't code a 'default' here - let the compiler
1447 // detect when the set of module_state enumerations changes -
1448 // then the System Service's System Manager maintainer will
1449 // automagically know to update this switch statement.
1454 if (0 == l_numModulesMessaged) {
1455 LogGroupModulesState(f_ui32GroupNumber, " Warning: NO modules were sent system_manager protocol message"); // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
1458 snprintf(l_cBuf, sizeof(l_cBuf), "ProcessGroupAsStarted(%d)", l_GroupIterator->second.id);
1459 l_eStatus = ProcessGroupAsStarted(hApp, l_GroupIterator);
1460 LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, l_cBuf); // LCOV_EXCL_BR_LINE 6: Because the condition cannot be set
1462 m_GroupLaunchTimer->StartTimer(
1463 m_aTimerIDs[eSM_TIMER_CLIENT_START_MONITOR],
1464 SS_CLIENT_START_MONITOR_TIMER_CONFIG, 0, 0, 0);
1467 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1469 } // End of EFrameworkunifiedStatus CSystemManager::start_all_modules_of_group(HANDLE hApp, UI_32 f_ui32GroupNumber)
1471 ///////////////////////////////////////////////////////////////////////////////
1472 /// \ingroup start_all_modules_of_group
1473 /// mark the specified group as started. If there is another group to start,
1474 /// do so, else send Start Complete Response to the Start Requester.
1479 /// \return EFrameworkunifiedStatus
1480 /// Success ==> eFrameworkunifiedStatusOK
1481 /// Failure ==> Other values
1482 ///////////////////////////////////////////////////////////////////////////////
1483 EFrameworkunifiedStatus CSystemManager::ProcessGroupAsStarted(HANDLE hApp, UI_32 f_groupId) {
1484 EFrameworkunifiedStatus l_eStatus;
1485 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1487 GroupLaunchMapIter l_GroupIterator = m_MapProclaunchGrps.find(f_groupId);
1488 if (l_GroupIterator == m_MapProclaunchGrps.end()) {
1489 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1490 " Error: Group %d not found; 'm_MapProclaunchGrps' is empty", f_groupId);
1491 l_eStatus = eFrameworkunifiedStatusInvldParam;
1493 l_eStatus = ProcessGroupAsStarted(hApp, l_GroupIterator);
1496 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1498 } // End of EFrameworkunifiedStatus CSystemManager::ProcessGroupAsStarted( HANDLE hApp, UI_32 f_groupId )
1500 ///////////////////////////////////////////////////////////////////////////////
1501 /// \ingroup start_all_modules_of_group
1502 /// mark the specified group as started. If there is another group to start,
1503 /// do so, else send Start Complete Response to the Start Requester.
1508 /// \return EFrameworkunifiedStatus
1509 /// Success ==> eFrameworkunifiedStatusOK
1510 /// Failure ==> Other values
1511 ///////////////////////////////////////////////////////////////////////////////
1512 EFrameworkunifiedStatus CSystemManager::ProcessGroupAsStarted(HANDLE hApp,
1513 GroupLaunchMapIter f_GroupIterator) {
1514 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
1515 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1516 UI_32 l_groupID = m_SystemStarter.get_id();
1519 m_GroupLaunchTimer->StopTimer(m_aTimerIDs[eSM_TIMER_CLIENT_START_MONITOR]);
1521 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
1522 " Group %d/%s start completed, m_SystemStarter.get_id() is %d",
1523 f_GroupIterator->second.id, f_GroupIterator->second.name.c_str(),
1526 if (f_GroupIterator->second.id != l_groupID) {
1527 FRAMEWORKUNIFIEDLOG(ZONE_INFO,
1529 , " The just-started group ( %d/%s ) is not the current Active "
1530 " Group ( %d ); not starting next group's modules",
1531 f_GroupIterator->second.id,
1532 f_GroupIterator->second.name.c_str(), l_groupID);
1534 if ((m_SMCurrentState == SS_SM_APPS_START_IN_PROGRESS)
1535 || (m_SMCurrentState == SS_SM_APPS_PRE_START_IN_PROGRESS)
1536 || (m_SMCurrentState == SS_SM_APPS_BACKGROUND_START_IN_PROGRESS)) {
1537 // check if WakeUp Level has been achieved
1538 if (m_SystemStarter.is_end() == FALSE) {
1539 // Start modules from next group
1540 l_groupID = m_SystemStarter.advance_id(); // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
1541 char l_cBuf[100] = {0};
1542 snprintf(l_cBuf, sizeof(l_cBuf), "start_all_modules_of_group(%u)", l_groupID);
1543 l_eStatus = start_all_modules_of_group(hApp, l_groupID); // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
1544 LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, l_cBuf); // LCOV_EXCL_BR_LINE 6: Because the condition cannot be set
1546 } else if ((m_SMCurrentState == SS_SM_APPS_PRE_STOP_IN_PROGRESS)
1547 || (m_SMCurrentState == SS_SM_APPS_BACKGROUND_STOP_IN_PROGRESS)) {
1548 if (m_SystemStarter.is_begin() == FALSE) {
1549 // Stop modules from next group
1550 l_groupID = m_SystemStarter.decrement_id(); // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
1551 char l_cBuf[100] = {0};
1552 snprintf(l_cBuf, sizeof(l_cBuf), "stop_all_modules_of_group(%u)", l_groupID);
1553 l_eStatus = start_all_modules_of_group(hApp, l_groupID); // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
1554 LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, l_cBuf); // LCOV_EXCL_BR_LINE 6: Because the condition cannot be set
1557 // MISRA C++-2008 Rule 6-4-2
1561 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1563 } // End of EFrameworkunifiedStatus CSystemManager::ProcessGroupAsStarted( GroupLaunchMapIter f_GroupIterator )
1565 ///////////////////////////////////////////////////////////////////////////////
1566 /// \ingroup calculate_max_shutdown_time
1567 /// Calculate maximum shutdown time of apps critical to shutdown
1568 /// from the launch group map
1573 /// Max Value of critical shutdown apps shutdown time
1574 ///////////////////////////////////////////////////////////////////////////////
1575 UI_32 CSystemManager::calculate_max_shutdown_time() {
1576 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1577 UI_32 l_MaxShutdownTimeValue = 0;
1578 std::string moduleName;
1580 GroupLaunchMapIter l_GroupIterator = m_MapProclaunchGrps.begin();
1581 for (; l_GroupIterator != m_MapProclaunchGrps.end(); l_GroupIterator++) {
1582 ModuleLaunchListIter l_ModuleListIterator =
1583 l_GroupIterator->second.modules.begin();
1584 for (; l_ModuleListIterator != l_GroupIterator->second.modules.end();
1585 l_ModuleListIterator++) {
1586 if (l_ModuleListIterator->shutdown_critical) {
1587 if (l_MaxShutdownTimeValue < l_ModuleListIterator->shutdown_wait_time) {
1588 moduleName = l_ModuleListIterator->name;
1589 l_MaxShutdownTimeValue = l_ModuleListIterator->shutdown_wait_time;
1594 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Max time: Module %s, time %d s",
1595 moduleName.c_str(), l_MaxShutdownTimeValue);
1596 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1597 return l_MaxShutdownTimeValue;
1600 ///////////////////////////////////////////////////////////////////////////////
1601 /// \ingroup OnShutdownModulesRequest
1602 /// Send Shutdown to all modules in reverse order of group
1606 /// \return EFrameworkunifiedStatus
1607 /// Success ==> eFrameworkunifiedStatusOK
1608 /// Failure ==> Other values
1609 ///////////////////////////////////////////////////////////////////////////////
1610 EFrameworkunifiedStatus CSystemManager::OnShutdownModulesRequest(HANDLE hApp) {
1611 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1612 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
1614 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__,
1615 " Received from %s, m_SystemStarter.get_id() is %d",
1616 FrameworkunifiedGetMsgSrc(hApp)
1617 , m_SystemStarter.get_id());
1619 FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "m_SystemStarter.get_id() is %d", m_SystemStarter.get_id());
1621 SetCmdHist("SS_SM_SHUTDOWN_MODULES", m__CWORD56_CmdHist, m__CWORD56_HistIter, FrameworkunifiedGetMsgSrc(hApp)); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
1623 Pwr_ServiceSetInterface l_tServiceSetIf;
1625 // Check hApp ptr, msg size, msg reception, read msg if all ok. *
1626 if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < Pwr_ServiceSetInterface > (hApp, l_tServiceSetIf))) { // LCOV_EXCL_BR_LINE 4: nsfw error
1627 // LCOV_EXCL_START 4: nsfw error
1628 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1629 LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1632 BOOL isImmShutdown = FALSE;
1634 // If the Shutdown is not completed after the Shutdown is requested, it is forcibly reset.
1635 m_GroupLaunchTimer->StartTimer(
1636 m_aTimerIDs[eSM_TIMER_SHUTDOWN_COMPLETE_MONITOR],
1637 SM_SHUTDOWN_COMPLETE_MONITOR_TIMEOUT, 0, 0, 0);
1639 if (m_isImmResetReq) {
1640 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, " ImmReset");
1641 isImmShutdown = TRUE;
1644 switch (l_tServiceSetIf.data.shutdownRequestMsg.lastUserMode) {
1646 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1647 " Error: shutdownRequestMsg.lastUserMode == epsumINVALID");
1648 l_eStatus = eFrameworkunifiedStatusInvldParam;
1653 switch (m_SMCurrentState) {
1654 case SS_SM_READY_TO_LAUNCH_APP:
1655 case SS_SM_APPS_LAUNCH_IN_PROGRESS:
1656 case SS_SM_APPS_LAUNCHED_READY_TO_START:
1657 isImmShutdown = TRUE;
1658 case SS_SM_APPS_START_COMPLETE:
1659 case SS_SM_APPS_START_IN_PROGRESS:
1660 case SS_SM_APPS_PRE_START_IN_PROGRESS:
1661 case SS_SM_APPS_PRE_STOP_IN_PROGRESS:
1662 case SS_SM_APPS_PRE_RUN_COMPLETE:
1663 case SS_SM_APPS_BACKGROUND_START_IN_PROGRESS:
1664 case SS_SM_APPS_BACKGROUND_STOP_IN_PROGRESS:
1665 case SS_SM_APPS_BACKGROUND_RUN_COMPLETE:
1667 if (l_tServiceSetIf.data.shutdownRequestMsg.shutdownTrigger ==
1670 if (PowerHalSetResetInfo(AGL_RESET_COUNTER, m_ResetCount)) { // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
1671 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1672 "Could not back up m_ResetCount(%lu) to power_hal", m_ResetCount);
1675 if (PowerHalSetResetInfo(AGL_ERRLOG_COUNTER, 0)) { // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
1676 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1677 "Could not reset AGL_ERRLOG_COUNTER");
1680 if (!m_isPrevErrEventCompleted
1681 || ((!((m_SMCurrentState == SS_SM_APPS_START_COMPLETE)
1682 || (m_SMCurrentState == SS_SM_APPS_PRE_RUN_COMPLETE)
1683 || (m_SMCurrentState == SS_SM_APPS_BACKGROUND_RUN_COMPLETE)))
1684 && (l_tServiceSetIf.data.shutdownRequestMsg.shutdownTrigger
1686 || l_tServiceSetIf.data.shutdownRequestMsg.shutdownTrigger
1687 == epssdmsdtNORMAL_RESET))) {
1688 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "shutdown pending");
1689 if (!m_dqDeferMsg.empty()) {
1690 SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1692 SM_POWER_EVENT_INFO deferMsg(SS_SM_SHUTDOWN_MODULES, l_tServiceSetIf);
1693 m_dqDeferMsg.push(deferMsg);
1696 // The shutdownTrigger has already been validated by
1697 // Power::OnShutdownRequestMsg()
1698 m_shutdownTrigger = l_tServiceSetIf.data.shutdownRequestMsg.shutdownTrigger;
1699 m_lastUserMode = l_tServiceSetIf.data.shutdownRequestMsg.lastUserMode;
1701 // Notify services ShutDownTrigger the FrameworkunifiedOnStop, if dataResetMode is configured
1702 // When using FastSleep, be aware that it may be overwritten here
1703 switch (m_DataResetMode) {
1704 case e_SS_SM_DATA_RESET_MODE_FACTORY:
1705 m_shutdownTrigger = epssdmsdtFACTORY_DATA_RESET;
1707 case e_SS_SM_DATA_RESET_MODE_USER:
1708 m_shutdownTrigger = epssdmsdtUSER_DATA_RESET;
1714 if (isImmShutdown) {
1715 m_GroupLaunchTimer->StopTimer(m_aTimerIDs[eSM_TIMER_GROUP_LAUNCH_WAIT_TIMER]);
1717 // Do not use m_shutdownTrigger because it is updated on DataReset
1718 switch (l_tServiceSetIf.data.shutdownRequestMsg.shutdownTrigger) {
1719 case epssdmsdtGENERIC_ERROR_RESET:
1720 case epssdmsdtFATAL_ERROR_RESET:
1721 CALL_AND_LOG_STATUS((*m_pfStopCompleteHandler)(hApp)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1724 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
1725 " Warning: Received a Shutdown command while in "
1726 "the '%s' state - returning Shutdown "
1728 GetStr(m_SMCurrentState).c_str());
1730 CALL_AND_LOG_STATUS(SendShutdownResponseMessage(hApp)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1735 InitiateAllGroupsShutdown(hApp);
1740 case SS_SM_APPS_STOPPING_AT__CWORD56__REQ:
1741 case SS_SM_APPS_STOPPING_AT_INTERNAL_REQ:
1742 case SS_SM_WAITING_FOR_CRITICAL_APPS_AT__CWORD56__REQ:
1743 case SS_SM_WAITING_FOR_CRITICAL_APPS_AT_INTERNAL_REQ:
1744 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
1745 " Warning: Received a Shutdown command while already in "
1746 "the '%s' state !!!",
1747 GetStr(m_SMCurrentState).c_str());
1749 } // End switch ( m_SMCurrentState )
1751 } // End case epsumOFF | epsumON
1752 } // End switch (m_lastUserMode )
1755 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1757 } // End of EFrameworkunifiedStatus CSystemManager::OnShutdownModulesRequest( HANDLE hApp )
1759 ///////////////////////////////////////////////////////////////////////////////
1760 /// \ingroup SendSystemModeInfoResponse
1761 /// send SystemModeInfo to
1762 /// _CWORD56_ ( via Power Service-> PSMShadow ) as an IPC 'Start Notification'
1763 /// message, informing _CWORD56_ of the startup state of the _CWORD102_.
1765 /// \param [in] HANDLE hApp
1767 /// \return EFrameworkunifiedStatus
1768 /// Success ==> eFrameworkunifiedStatusOK
1769 /// Failure ==> Other values
1770 ///////////////////////////////////////////////////////////////////////////////
1771 EFrameworkunifiedStatus CSystemManager::SendSystemModeInfoResponse(HANDLE hApp, EPWR_STARTUP_STAGE_TYPE f_startupStage) {
1772 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1773 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
1774 SystemModeInfo l_SystemModeInfo;
1776 memcpy(&l_SystemModeInfo, &m_SystemModeInfo, sizeof(l_SystemModeInfo));
1778 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "stage:%d", f_startupStage);
1779 l_SystemModeInfo.startupStage = f_startupStage;
1781 l_eStatus = FrameworkunifiedSendMsg(m_hPowerServiceSession, SS_SM_SYSTEM_MODE_INFO_RSPN,
1782 sizeof(l_SystemModeInfo), (PVOID) & l_SystemModeInfo);
1784 if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
1785 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1786 " Error: SendSystemModeInfoResponse(%s) errored: 0x%X",
1787 GetStr(l_SystemModeInfo.startupStage).c_str(), l_eStatus);
1789 // LCOV_EXCL_START 4: NSFW error case.
1790 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1791 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
1792 " SendSystemModeInfoResponse(%s) successful",
1793 GetStr(l_SystemModeInfo.startupStage).c_str());
1797 LOG_STATUS(l_eStatus, "FrameworkunifiedSendMsg(SS_SM_SYSTEM_MODE_INFO_RSPN)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1798 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1800 } // End of EFrameworkunifiedStatus CSystemManager::SendSystemModeInfoResponse( HANDLE hApp )
1802 ///////////////////////////////////////////////////////////////////////////////
1803 /// \ingroup OnSystemModeInfoRequest
1804 /// Handle System Mode Info request. Send System Mode Info read from NVM
1806 /// \param [in] HANDLE hApp
1808 /// \return EFrameworkunifiedStatus
1809 /// Success ==> eFrameworkunifiedStatusOK
1810 /// Failure ==> Other values
1811 ///////////////////////////////////////////////////////////////////////////////
1812 EFrameworkunifiedStatus CSystemManager::OnSystemModeInfoRequest(HANDLE hApp) {
1813 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1814 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
1815 INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
1816 FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(hApp));
1817 m_isRcvModeInfo = TRUE;
1819 SetCmdHist("SS_SM_SYSTEM_MODE_INFO_REQ", m__CWORD56_CmdHist, m__CWORD56_HistIter, FrameworkunifiedGetMsgSrc(hApp));
1821 if (m_SystemModeInfo.startupStage == epssusfINVALID) {
1822 // Transitioning to SYSTEM_SERVICES_STARTED if startupStage == INVALID
1823 m_SystemModeInfo.startupStage = epssusSYSTEM_SERVICES_STARTED;
1826 l_eStatus = SendSystemModeInfoResponse(hApp, epssusSYSTEM_SERVICES_STARTED);
1827 LOG_STATUS(l_eStatus, "SendSystemModeInfoResponse()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1829 if (TRUE == m_isRstPending) {
1830 ESMCpuResetReason l_resetReason = m_rstPendingInfo.resetReason;
1831 std::string l_messageStr = m_rstPendingInfo.messageStr;
1833 m_isRstPending = FALSE;
1834 m_rstPendingInfo.resetReason = e_SS_SM_CPU_RESET_REASON_INVALID;
1835 memset(m_rstPendingInfo.messageStr, 0, sizeof(m_rstPendingInfo.messageStr));
1837 l_eStatus = PerformCpuReset(hApp, l_resetReason, l_messageStr);
1838 LOG_STATUS(l_eStatus, "PerformCpuReset()"); // LCOV_EXCL_BR_LINE 6: Because it is executed only once and cannot see all branches
1841 if (m_SystemModeInfo.startupStage == epssusALL_SERVICES_LAUNCHED) {
1842 // If startupStage == ALL_SERVICES_LAUNCHED
1843 // Notify here because Launch of all SVCs is completed first.
1844 l_eStatus = SendSystemModeInfoResponse(hApp, epssusALL_SERVICES_LAUNCHED);
1845 LOG_STATUS(l_eStatus, "SendSystemModeInfoResponse()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1848 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1850 } // End of EFrameworkunifiedStatus CSystemManager::OnSystemModeInfoRequest( HANDLE hApp )
1852 ///////////////////////////////////////////////////////////////////////////////
1853 /// \ingroup OnInitCompReportCallback
1854 /// Handle InitComp report.
1856 /// \param [in] HANDLE hApp
1858 /// \return EFrameworkunifiedStatus
1859 /// Success ==> eFrameworkunifiedStatusOK
1860 /// Failure ==> Other values
1861 ///////////////////////////////////////////////////////////////////////////////
1862 EFrameworkunifiedStatus CSystemManager::OnInitCompReportCallback(HANDLE hApp) {
1863 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1864 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
1865 INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
1866 FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(hApp));
1868 SetCmdHist("SS_SM_INITCOMP_REP", m__CWORD56_CmdHist, m__CWORD56_HistIter, FrameworkunifiedGetMsgSrc(hApp));
1870 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1872 } // End of EFrameworkunifiedStatus CSystemManager::OnInitCompReportCallback( HANDLE hApp )
1874 ///////////////////////////////////////////////////////////////////////////////
1875 /// \ingroup have_all_services_start_completed
1876 /// check if state of all services is MODULE_STATE_STARTED
1882 /// Success ==> TRUE
1883 /// Failure ==> FALSE
1884 ///////////////////////////////////////////////////////////////////////////////
1885 BOOL CSystemManager::have_all_services_start_completed(const SMModuleState f_moduleState) {
1886 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1887 BOOL bIsStartCompleted = TRUE;
1888 SMModuleState l_failedState = MODULE_STATE_INVALID;
1890 switch (f_moduleState) {
1891 case MODULE_STATE_STARTED:
1892 l_failedState = MODULE_STATE_START_FAILED;
1894 case MODULE_STATE_STARTED_PRE:
1895 l_failedState = MODULE_STATE_START_PRE_FAILED;
1897 case MODULE_STATE_STOPPED_PRE:
1898 l_failedState = MODULE_STATE_STOP_PRE_FAILED;
1900 case MODULE_STATE_STARTED_BACKGROUND:
1901 l_failedState = MODULE_STATE_START_BACKGROUND_FAILED;
1903 case MODULE_STATE_STOPPED_BACKGROUND:
1904 l_failedState = MODULE_STATE_STOP_BACKGROUND_FAILED;
1907 bIsStartCompleted = FALSE;
1910 if (l_failedState != MODULE_STATE_INVALID) {
1911 GroupLaunchMapIter l_GroupIterator = m_MapProclaunchGrps.begin();
1912 for (; l_GroupIterator != m_MapProclaunchGrps.end(); l_GroupIterator++) {
1913 ModuleLaunchListIter l_ModuleListIterator = l_GroupIterator->second.modules.begin();
1914 for (; l_ModuleListIterator != l_GroupIterator->second.modules.end(); l_ModuleListIterator++) {
1915 if ((l_ModuleListIterator->is_start_required == TRUE)
1916 && ((l_ModuleListIterator->IsModuleState(f_moduleState) == FALSE) // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
1917 && (l_ModuleListIterator->IsModuleState(MODULE_STATE_SKIPPED) == FALSE) // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
1918 && (l_ModuleListIterator->IsModuleState(l_failedState) == FALSE))) { // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
1919 // Allow _SKIPPED/START_FAILED for StartRespMonitor conditions
1920 bIsStartCompleted = FALSE;
1926 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1927 return bIsStartCompleted;
1930 ///////////////////////////////////////////////////////////////////////////////
1931 /// \ingroup is_critical_service_stopped
1938 /// Success ==> TRUE
1939 /// Failure ==> FALSE
1940 ///////////////////////////////////////////////////////////////////////////////
1941 BOOL CSystemManager::is_service_shutdown_ready(ModuleLaunchListIter &modIte) {
1942 if (((modIte->shutdown_critical && modIte->is_start_required)
1943 || (modIte->name == FRAMEWORKUNIFIED_NS_NPSERVICE))
1944 && modIte->IsModuleState(MODULE_STATE_STOPPED) == FALSE) {
1945 // Not shutdown_ready if NPP or shutdown_critical services are not STOPPED.
1951 ///////////////////////////////////////////////////////////////////////////////
1952 /// \ingroup have_critical_services_stopped
1953 /// check if state of all critical services is MODULE_STATE_STOPPED
1959 /// Success ==> TRUE
1960 /// Failure ==> FALSE
1961 ///////////////////////////////////////////////////////////////////////////////
1962 BOOL CSystemManager::have_critical_services_stopped() {
1963 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1964 uint numStoppingModules = 0;
1966 GroupLaunchMapIter l_GroupIterator = m_MapProclaunchGrps.begin();
1967 for (; l_GroupIterator != m_MapProclaunchGrps.end(); l_GroupIterator++) {
1968 ModuleLaunchListIter l_ModuleListIterator = l_GroupIterator->second.modules.begin();
1969 for (; l_ModuleListIterator != l_GroupIterator->second.modules.end(); l_ModuleListIterator++) {
1970 if (l_ModuleListIterator->IsModuleState(MODULE_STATE_STOP_SENT)
1971 && l_ModuleListIterator->shutdown_critical) {
1972 numStoppingModules++;
1976 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1977 return (numStoppingModules == 0);
1980 ///////////////////////////////////////////////////////////////////////////////
1981 /// \ingroup perform_force_reset
1987 /// \return EFrameworkunifiedStatus
1988 /// Success ==> eFrameworkunifiedStatusOK
1989 /// Failure ==> Other values
1990 ///////////////////////////////////////////////////////////////////////////////
1991 EFrameworkunifiedStatus CSystemManager::perform_force_reset(HANDLE hApp) {
1992 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
1993 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "+");
1995 // Since initialization must be performed by the PSMs during FactReset, do not NaviDet them as much as possible.
1996 if (e_SS_SM_DATA_RESET_MODE_FACTORY == m_DataResetMode) {
1998 "SS_SysManager/%s/NO NAVIDET!! but SendShutdownComp for FactReset\n", __FUNCTION__);
1999 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2000 "NO NAVIDET!! but SendShutdownComp for FactReset");
2001 CALL_AND_LOG_STATUS(send_shutdown_complete_response(hApp)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2003 } else if (access("/var/local/lib/basesystem/nv/BS/ss/system_manager/rwdata/ss_debug", F_OK) == 0) {
2004 fprintf(stderr, "SS_SysManager/%s/NO NAVIDET!! but SendShutdownComp\n", __FUNCTION__);
2005 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "NO NAVIDET!! but SendShutdownComp");
2006 CALL_AND_LOG_STATUS(send_shutdown_complete_response(hApp)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2013 if (0 == PsmNaviResetPower(hApp, m_ResetFactor)) { // LCOV_EXCL_BR_LINE 200: power_hal if, can not to be error.
2014 SS_ASERT_ERRNO(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2017 fprintf(stderr, "SS_SysManager/%s/Error: Not Reset !!!\n", __FUNCTION__);
2018 l_eStatus = eFrameworkunifiedStatusFail;
2021 send_shutdown_complete_response(hApp); // Try to NAVI_RESET even if ignored
2023 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "-");
2027 ///////////////////////////////////////////////////////////////////////////////
2029 ///////////////////////////////////////////////////////////////////////////////
2030 /// \ingroup send_shutdown_complete_response
2036 /// \return EFrameworkunifiedStatus
2037 /// Success ==> eFrameworkunifiedStatusOK
2038 /// Failure ==> Other values
2039 ///////////////////////////////////////////////////////////////////////////////
2040 EFrameworkunifiedStatus CSystemManager::send_shutdown_complete_response(HANDLE hApp) {
2041 EFrameworkunifiedStatus l_eStatus;
2042 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
2044 CALL_AND_LOG_STATUS(ResetModulesStateToConnected(hApp)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2046 SMSetState(hApp, SS_SM_APPS_LAUNCHED_READY_TO_START);
2047 // m_ActiveGroupId = SS_SM_INITIAL_GROUP;
2049 // all the modules have stopped, send Shutdown Response to Power Service
2050 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
2051 " All critical services have stopped, Active Group ID is now %d",
2052 m_SystemStarter.get_id());
2054 CALL_AND_LOG_STATUS(SendShutdownResponseMessage(hApp)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2057 // Normal, production flow is to call SendShutdownResponseMessage(), which
2058 // sends the Shutdown Response message to the _CWORD56_, causing the _CWORD56_ to
2059 // remove power from the _CWORD102_ before queued-up FRAMEWORKUNIFIEDLOG messages can be // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
2060 // processed by SS_LoggerService.
2062 // Optional development flow is to NOT call SendShutdownResponseMessage(),
2063 // thus giving the _CWORD102_ time to process its FRAMEWORKUNIFIEDLOG messages. Since this is an // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
2064 // abnormal, 'bad' condition of NOT sending a Shutdown Response message to
2065 // the _CWORD56_, be very obvious about this state by displaying both
2066 // compile-time and run-time warning messages.
2068 #warning NOT calling SendShutdownResponseMessage(hApp) !
2069 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
2070 " Warning: SendShutdownResponseMessage( hApp ) "
2071 "#def'f out; ShutdownResponse NOT sent to _CWORD56_");
2074 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2078 ///////////////////////////////////////////////////////////////////////////////
2080 ///////////////////////////////////////////////////////////////////////////////
2081 EFrameworkunifiedStatus CSystemManager::SendShutdownResponseMessage(HANDLE hApp) {
2082 EFrameworkunifiedStatus l_eStatus;
2083 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
2084 l_eStatus = FrameworkunifiedSendMsg(m_hPowerServiceSession, // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
2085 SS_SM_SHUTDOWN_MODULES_CMPL_RSPN, 0, (PVOID) NULL); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
2086 LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
2087 "FrameworkunifiedSendMsg(PowerService,SS_SM_SHUTDOWN_MODULES_CMPL_RSPN)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
2089 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2091 } // End of EFrameworkunifiedStatus CSystemManager::SendShutdownResponseMessage( HANDLE hApp )
2094 PsmFactorT CSystemManager::GetResetFactor(PCSTR f_module_name, BOOL f_user_reset) {
2095 PsmFactorT l_reset_factor = PSM_FACTOR_NONE;
2096 EFrameworkunifiedStatus l_eStatus;
2097 ModuleLaunchListIter l_moduleIter;
2098 l_eStatus = GetModuleIterator(f_module_name, l_moduleIter); // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
2099 if (eFrameworkunifiedStatusOK != l_eStatus) {
2100 LOG_ERROR("GetModuleIterator()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2102 l_reset_factor = GetResetFactor(l_moduleIter, f_user_reset);
2104 return l_reset_factor;
2105 } // End of PsmFactorT CSystemManager::GetResetFactor(PCSTR f_module_name)
2108 PsmFactorT CSystemManager::GetResetFactor(const ModuleLaunchListIter f_module_iter, BOOL f_user_reset) {
2109 PsmFactorT l_reset_factor;
2110 if (f_module_iter->IsAGLUnit() == TRUE) {
2111 if (f_module_iter->IsAGLResetHistoryDisable() == TRUE) {
2112 l_reset_factor = PSM_FACTOR_AGL;
2114 l_reset_factor = PSM_FACTOR_AGL_WITH_HISTORY;
2117 if (f_module_iter->IsNonAGLResetHistoryDisable() == TRUE) {
2118 l_reset_factor = PSM_FACTOR_TIER1;
2120 l_reset_factor = PSM_FACTOR_TIER1_WITH_HISTORY;
2124 if (f_user_reset == TRUE) {
2125 if ((l_reset_factor == PSM_FACTOR_AGL) || (l_reset_factor == PSM_FACTOR_TIER1)) {
2126 l_reset_factor = PSM_FACTOR_USER;
2128 l_reset_factor = PSM_FACTOR_USER_WITH_HISTORY;
2131 return l_reset_factor;
2132 } // End of PsmFactorT GetResetFactor(ModuleLaunchListIter & f_module_iter)
2133 ///////////////////////////////////////////////////////////////////////////////
2134 /// \ingroup OnClientStopMonitorTimerExpiry
2140 /// \return EFrameworkunifiedStatus
2141 /// Success ==> eFrameworkunifiedStatusOK
2142 /// Failure ==> Other values
2143 ///////////////////////////////////////////////////////////////////////////////
2144 EFrameworkunifiedStatus CSystemManager::OnClientStopMonitorTimerExpiry(HANDLE hApp) {
2145 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
2146 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
2148 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Received from group %d", m_SystemStarter.get_id());
2150 SetCmdHist("SM_TIMER_CLIENT_STOP_MONITOR", m_TimerCmdHist, m_TimerHistIter, FrameworkunifiedGetMsgSrc(hApp)); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2152 if ((m_SMCurrentState == SS_SM_WAITING_FOR_CRITICAL_APPS_AT__CWORD56__REQ)
2153 || (m_SMCurrentState == SS_SM_WAITING_FOR_CRITICAL_APPS_AT_INTERNAL_REQ)
2154 || m_SystemStarter.get_id() <= SS_SM_THIRD_GROUP) {
2155 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: StopCompTimeout:gid:%d", m_SystemStarter.get_id());
2156 fprintf(stderr, "SS_SysManager/%s/Error: StopCompTimeout:gid:%d\n", __FUNCTION__, m_SystemStarter.get_id());
2158 for (GroupLaunchMapIter l_GroupIterator = m_MapProclaunchGrps.begin();
2159 l_GroupIterator != m_MapProclaunchGrps.end();
2160 l_GroupIterator++) {
2161 for (ModuleLaunchListIter l_ModuleListIterator = l_GroupIterator->second.modules.begin();
2162 l_ModuleListIterator != l_GroupIterator->second.modules.end();
2163 l_ModuleListIterator++) {
2164 if (l_ModuleListIterator->group_id >= m_SystemStarter.get_id()
2165 && is_service_shutdown_ready(l_ModuleListIterator) == FALSE) {
2166 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: %s", l_ModuleListIterator->name.c_str());
2167 fprintf(stderr, "SS_SysManager/%s/Error: %s\n", __FUNCTION__, l_ModuleListIterator->name.c_str()); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2172 if (!m_SystemStarter.is_begin()) {
2173 // Continue termination processing to perform BackupManager termination processing.
2174 m_SystemStarter.decrement_id();
2175 check_all_groups_have_stopped(hApp);
2178 fprintf(stderr, "SS_SysManager/%s:SVC stop timeout\n", __FUNCTION__);
2179 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " SVC stop timeout");
2180 l_eStatus = CallStopCompleteHandler(hApp);
2181 LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, "CallStopCompleteHandler( hApp )"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
2184 // The current m_ActiveGroupId group just timed out. If possible,
2185 // decrement it, and then see if there are more groups to send
2186 // stop requests to.
2187 if (!m_SystemStarter.is_begin()) {
2188 m_SystemStarter.decrement_id();
2190 check_all_groups_have_stopped(hApp);
2193 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2195 } // End of EFrameworkunifiedStatus CSystemManager::OnClientStopMonitorTimerExpiry( HANDLE hApp )
2197 ///////////////////////////////////////////////////////////////////////////////
2198 /// \ingroup check_all_groups_have_stopped
2199 /// check that all the groups has stopped
2205 ///////////////////////////////////////////////////////////////////////////////
2206 VOID CSystemManager::check_all_groups_have_stopped(HANDLE hApp) {
2207 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
2208 UI_32 l_ActiveGroupId = m_SystemStarter.get_id();
2209 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
2210 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
2211 " m_SystemStarter.get_id() is %d, 'm_NPPStopSent' is '%s'"
2212 , m_SystemStarter.get_id(), GetStr(m_NPPStopSent).c_str());
2214 // send stop to next group in reverse order
2215 // FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " m_NPPStopSent is %s", GetStr(m_NPPStopSent).c_str()); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
2216 if (!m_NPPStopSent) {
2217 l_eStatus = stop_all_modules_of_group(hApp);
2218 if (eFrameworkunifiedStatusOK != l_eStatus) {
2219 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2220 " Error: stop_all_modules_of_group(%d) errored: %d/'%s'",
2221 l_ActiveGroupId, l_eStatus, GetStr(l_eStatus).c_str());
2223 } else { // (m_ActiveGroupId < SS_SM_INITIAL_GROUP)
2224 BOOL l_bIsDetectTimeout;
2226 if ((l_bIsDetectTimeout = !have_critical_services_stopped())) {
2227 // If the Critical service is not terminated even when the final GROUP is completed, DUMP the applicable service and issue NAVI_DET.
2228 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " FinalCriticalCheck");
2229 fprintf(stderr, "SS_SysManager/%s:FinalCriticalCheck\n", __FUNCTION__); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
2231 for (GroupLaunchMapIter l_GroupIterator = m_MapProclaunchGrps.begin();
2232 l_GroupIterator != m_MapProclaunchGrps.end();
2233 l_GroupIterator++) {
2234 for (ModuleLaunchListIter l_ModuleListIterator = l_GroupIterator->second.modules.begin();
2235 l_ModuleListIterator != l_GroupIterator->second.modules.end();
2236 l_ModuleListIterator++) {
2237 if (is_service_shutdown_ready(l_ModuleListIterator) == FALSE) {
2238 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: %s",
2239 l_ModuleListIterator->name.c_str());
2240 fprintf(stderr, "SS_SysManager/%s/Error: %s\n", // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2242 l_ModuleListIterator->name.c_str()); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2246 fprintf(stderr, "SS_SysManager/%s:critical service no stop\n", __FUNCTION__);
2247 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "critical service no stop");
2250 CALL_AND_LOG_STATUS(CallStopCompleteHandler(hApp, l_bIsDetectTimeout)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2252 // In PastModel002, there was a transition to WAITING_FOR_CRITICAL_APPS in the following processing, but in _CWORD71_,
2253 // the transition to WAITING_FOR_CRITICAL_APPS was eliminated by revising the termination processing.
2256 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2258 } // End of VOID CSystemManager::check_all_groups_have_stopped( HANDLE hApp )
2260 ///////////////////////////////////////////////////////////////////////////////
2261 /// \ingroup MarkModuleStateStopped
2262 /// Sets Module State to STOP COMPLETE
2267 /// \return EFrameworkunifiedStatus
2268 /// Success ==> eFrameworkunifiedStatusOK
2269 /// Failure ==> Other values
2270 ///////////////////////////////////////////////////////////////////////////////
2273 ///////////////////////////////////////////////////////////////////////////////
2274 /// \ingroup OnNppStopComplete
2275 /// Npp Stop Complete complete Response\Ack Handlers
2280 /// \return EFrameworkunifiedStatus
2281 /// Success ==> eFrameworkunifiedStatusOK
2282 /// Failure ==> Other values
2283 ///////////////////////////////////////////////////////////////////////////////
2284 EFrameworkunifiedStatus CSystemManager::OnNppStopComplete(HANDLE hApp) {
2285 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
2286 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
2287 INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
2288 FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(hApp));
2290 SetCmdHist("NPS_NPP_STOP_ACK", m_SMCmdHist, m_SMHistIter, FrameworkunifiedGetMsgSrc(hApp)); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2293 snprintf(l_cBuf, sizeof(l_cBuf), "ProcessModuleStopCompleteResponse(%s)", FRAMEWORKUNIFIED_NS_NPSERVICE);
2294 l_eStatus = ProcessModuleStopCompleteResponse(hApp, FRAMEWORKUNIFIED_NS_NPSERVICE);
2295 LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, l_cBuf); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
2297 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2298 return eFrameworkunifiedStatusOK;
2301 EFrameworkunifiedStatus CSystemManager::GetModuleIterator(PCSTR f_moduleName, ModuleLaunchListIter &f_moduleIter) {
2302 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
2303 EFrameworkunifiedStatus l_eStatus;
2305 ModuleLaunchListIter l_moduleIter;
2306 // static int l_numTimesEntered = 0 ;
2307 // l_numTimesEntered++ ;
2308 // FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__ // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
2309 // , " NTE %d: Looking for %s"
2310 // , l_numTimesEntered
2313 BOOL l_bIsFound = FALSE;
2314 for (GroupLaunchMapIter l_GroupIter = m_MapProclaunchGrps.begin();
2315 !l_bIsFound && l_GroupIter != m_MapProclaunchGrps.end();
2317 // FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__ // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
2318 // , " NTE %d: Checking group %d/%s"
2319 // , l_numTimesEntered
2320 // , l_GroupIter->second.id
2321 // , l_GroupIter->second.name.c_str());
2323 for (l_moduleIter = l_GroupIter->second.modules.begin();
2324 !l_bIsFound && (l_moduleIter != l_GroupIter->second.modules.end());
2326 // FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__ // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
2327 // , " NTE %d: Checking PCSTR '%s' against std::string '%s': %d, %s"
2328 // , l_numTimesEntered
2330 // , l_moduleIter->name.c_str()
2331 // , strcmp(l_moduleIter->name.c_str(), f_moduleName)
2332 // , (0 == strcmp(l_moduleIter->name.c_str(), f_moduleName) ? "True" : "False"));
2335 (0 == strcmp(l_moduleIter->name.c_str(), f_moduleName));
2337 f_moduleIter = l_moduleIter;
2338 // FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
2340 // " '%s' is in group %d/%s"
2341 //// , l_numTimesEntered
2342 // , f_moduleIter->name.c_str()
2343 // , l_GroupIter->second.id
2344 // , l_GroupIter->second.name.c_str());
2345 l_eStatus = eFrameworkunifiedStatusOK;
2351 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2353 " Error: '%s' is not in group map 'm_MapProclaunchGrps'"
2354 // , l_numTimesEntered
2356 if (0 != strcmp(f_moduleName, SERVICE_SYSMANAGER)) {
2357 SysMgrConfiguration m_launchConfig;
2358 m_launchConfig.PrintAllInfo(m_MapProclaunchGrps);
2360 l_eStatus = eFrameworkunifiedStatusDbRecNotFound;
2362 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2364 } // End of EFrameworkunifiedStatus CSystemManager::GetModuleIterator( PCSTR f_moduleName
2366 BOOL CSystemManager::IsGroupStarted(UI_32 f_groupID) {
2367 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
2368 BOOL l_bIsStarted = TRUE;
2370 GroupLaunchMapIter l_GroupIter = m_MapProclaunchGrps.find(f_groupID);
2371 if (l_GroupIter == m_MapProclaunchGrps.end()) {
2372 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: Group Map Empty; was looking for group %d", f_groupID);
2374 ModuleLaunchListIter l_ModuleListIter = l_GroupIter->second.modules.begin();
2375 const SMModuleState l_dest_state = InProgressStateToState(); // LCOV_EXCL_BR_LINE 11: Gcov constraints (because exception-handling routes are automatically generated) // NOLINT(whitespace/line_length)
2376 if (l_dest_state != MODULE_STATE_INVALID) {
2377 for (; l_ModuleListIter != l_GroupIter->second.modules.end(); l_ModuleListIter++) {
2378 if (((l_ModuleListIter->IsModuleState(l_dest_state) == FALSE) // LCOV_EXCL_BR_START 11:Gcov constraints (because exception-handling routes are automatically generated)
2379 && (l_ModuleListIter->IsModuleState(MODULE_STATE_START_FAILED) == FALSE)
2380 && (l_ModuleListIter->IsModuleState(MODULE_STATE_START_PRE_FAILED) == FALSE)
2381 && (l_ModuleListIter->IsModuleState(MODULE_STATE_STOP_PRE_FAILED) == FALSE)
2382 && (l_ModuleListIter->IsModuleState(MODULE_STATE_START_BACKGROUND_FAILED) == FALSE)
2383 && (l_ModuleListIter->IsModuleState(MODULE_STATE_STOP_BACKGROUND_FAILED) == FALSE)
2384 && (l_ModuleListIter->IsModuleState(MODULE_STATE_STOP_FAILED) == FALSE))
2385 // LCOV_EXCL_BR_STOP 11:Gcov constraints (because exception-handling routes are automatically generated)
2386 || ((l_ModuleListIter->is_start_required == TRUE)
2387 // LCOV_EXCL_START 6: Because the value cannot be stored to make the condition true
2388 && ((l_ModuleListIter->IsModuleState(MODULE_STATE_LAUNCHING) == TRUE)
2389 || (l_ModuleListIter->IsModuleState(MODULE_STATE_CONNECTED) == TRUE)
2390 || (l_ModuleListIter->IsModuleState(MODULE_STATE_LAUNCHED) == TRUE)))) {
2391 // LCOV_EXCL_STOP 6: Because the value cannot be stored to make the condition true
2392 l_bIsStarted = FALSE;
2393 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " No: '%s' in group %d/%s is '%s'", l_ModuleListIter->name.c_str(),
2394 l_GroupIter->second.id, l_GroupIter->second.name.c_str(),
2395 l_ModuleListIter->ModuleStateStr().c_str());
2401 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2402 return l_bIsStarted;
2403 } // End of BOOL CSystemManager::IsGroupStarted(UI_32 f_groupId)
2405 BOOL CSystemManager::IsGroupStopped(UI_32 f_groupID) {
2406 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
2407 BOOL l_bIsStopped = TRUE;
2408 ModuleLaunchListIter l_ModuleListIter;
2410 GroupLaunchMapIter l_GroupIter = m_MapProclaunchGrps.find(f_groupID);
2411 if (l_GroupIter == m_MapProclaunchGrps.end()) {
2412 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
2413 " Warning: Group Map Empty; was looking for group %d",
2416 for (l_ModuleListIter = l_GroupIter->second.modules.begin();
2418 && l_ModuleListIter != l_GroupIter->second.modules.end();
2419 l_ModuleListIter++) {
2420 if (l_ModuleListIter->IsModuleState(MODULE_STATE_STOP_SENT)) {
2421 l_bIsStopped = FALSE;
2425 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2426 return l_bIsStopped;
2427 } // End of BOOL CSystemManager::IsGroupStopped(UI_32 f_groupId)
2429 ///////////////////////////////////////////////////////////////////////////////
2430 /// \ingroup OnStopComplete
2431 /// Shutdown complete Response\Ack Handlers
2436 /// \return EFrameworkunifiedStatus
2437 /// Success ==> eFrameworkunifiedStatusOK
2438 /// Failure ==> Other values
2439 ///////////////////////////////////////////////////////////////////////////////
2440 EFrameworkunifiedStatus CSystemManager::OnModuleStopCompleteResponse(HANDLE hApp) {
2441 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
2442 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusErrOther;
2443 INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
2445 PCSTR l_moduleName = FrameworkunifiedGetMsgSrc(hApp);
2447 FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "from %s", l_moduleName);
2448 SetCmdHist("SS_SM_STOP_COMPL_RSPN", m_SMCmdHist, m_SMHistIter, l_moduleName);
2451 snprintf(l_cBuf, sizeof(l_cBuf), "ProcessModuleStopCompleteResponse(%s)", l_moduleName);
2452 l_eStatus = ProcessModuleStopCompleteResponse(hApp, l_moduleName);
2453 LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, l_cBuf); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
2455 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2457 } // End of EFrameworkunifiedStatus CSystemManager::OnModuleStopCompleteResponse( HANDLE hApp )
2459 ///////////////////////////////////////////////////////////////////////////////
2460 /// \ingroup OnGetStartExtInfo
2465 /// \return EFrameworkunifiedStatus
2466 /// Success ==> eFrameworkunifiedStatusOK
2467 /// Failure ==> Other values
2468 ///////////////////////////////////////////////////////////////////////////////
2469 EFrameworkunifiedStatus CSystemManager::OnGetStartExtInfo(HANDLE hApp) {
2470 EFrameworkunifiedStatus l_eStatus;
2471 T_SS_SM_START_ExtDataStructType l_extInfo = { 0 };
2473 SS_STATIC_ASERT(sizeof(T_SS_SM_START_ExtDataStructType) == SS_SM_START_EXT_INFO_SIZE); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2475 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+ ");
2477 SetCmdHist("SS_SM_GET_START_EXT_INFO", m_SMCmdHist, m_SMHistIter, FrameworkunifiedGetMsgSrc(hApp));
2479 l_extInfo.isProgUpdated =
2480 (m_ProgUpdateState & SS_SM_PROG_UPDATE_STATE_UPDATED) ? TRUE : FALSE;
2481 l_extInfo.isMapUpdated =
2482 (m_ProgUpdateState & SS_SM_PROG_UPDATE_STATE_MAP_UPDATED) ? TRUE : FALSE; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2483 l_extInfo.isMapDiffUpdated =
2484 (m_ProgUpdateState & SS_SM_PROG_UPDATE_STATE_MAPDIFF_UPDATED) ? TRUE : FALSE; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2486 ModuleLaunchListIter l_ModuleListIter;
2488 l_eStatus = GetModuleIterator(FrameworkunifiedGetMsgSrc(hApp), l_ModuleListIter);
2489 if (eFrameworkunifiedStatusOK != l_eStatus) {
2490 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: %s not found", FrameworkunifiedGetMsgSrc(hApp));
2492 switch (l_ModuleListIter->relaunch_status) {
2494 l_extInfo.relaunchStatus = e_SS_SM_RELAUNCH_STATUS_NONE;
2497 // LCOV_EXCL_START 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
2498 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2499 l_extInfo.relaunchStatus = e_SS_SM_RELAUNCH_STATUS_SAFE;
2502 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2503 l_extInfo.relaunchStatus = e_SS_SM_RELAUNCH_STATUS_ERR;
2506 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2507 SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2508 l_extInfo.relaunchStatus = e_SS_SM_RELAUNCH_STATUS_NONE;
2514 // Instead of sending Return Message, this function must call FrameworkunifiedSetSyncResponseData()
2515 // because this request is sent by FrameworkunifiedInvokeSync()
2516 l_eStatus = FrameworkunifiedSetSyncResponseData(hApp, &l_extInfo, sizeof(l_extInfo));
2517 LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedSetSyncResponseData()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2519 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2521 } // End of EFrameworkunifiedStatus CSystemManager::OnGetStartExtInfo( HANDLE hApp )
2523 ///////////////////////////////////////////////////////////////////////////////
2524 /// \ingroup OnGetStopExtInfo
2529 /// \return EFrameworkunifiedStatus
2530 /// Success ==> eFrameworkunifiedStatusOK
2531 /// Failure ==> Other values
2532 ///////////////////////////////////////////////////////////////////////////////
2533 EFrameworkunifiedStatus CSystemManager::OnGetStopExtInfo(HANDLE hApp) {
2534 EFrameworkunifiedStatus l_eStatus;
2535 T_SS_SM_STOP_ExtDataStructType l_extInfo = { 0 };
2537 SS_STATIC_ASERT(sizeof(T_SS_SM_STOP_ExtDataStructType) == SS_SM_STOP_EXT_INFO_SIZE); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2539 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+ ");
2541 SetCmdHist("SS_SM_GET_STOP_EXT_INFO", m_SMCmdHist, m_SMHistIter, FrameworkunifiedGetMsgSrc(hApp));
2543 l_extInfo.isProgUpdated =
2544 (m_ProgUpdateState & SS_SM_PROG_UPDATE_STATE_UPDATED) ? TRUE : FALSE;
2546 // Instead of sending Return Message, this function must call FrameworkunifiedSetSyncResponseData()
2547 // because this request is sent by FrameworkunifiedInvokeSync()
2548 l_eStatus = FrameworkunifiedSetSyncResponseData(hApp, &l_extInfo, sizeof(l_extInfo));
2549 LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedSetSyncResponseData()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2551 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2553 } // End of EFrameworkunifiedStatus CSystemManager::OnGetStopExtInfo( HANDLE hApp )
2555 ///////////////////////////////////////////////////////////////////////////////
2556 /// \ingroup OnModuleStopCompleteNotification
2561 /// \return EFrameworkunifiedStatus
2562 /// Success ==> eFrameworkunifiedStatusOK
2563 /// Failure ==> Other values
2564 ///////////////////////////////////////////////////////////////////////////////
2565 EFrameworkunifiedStatus CSystemManager::OnModuleStopCompleteNotification(HANDLE hApp) { // LCOV_EXCL_START 6: Because the condition cannot be set
2566 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2567 EFrameworkunifiedStatus l_eStatus;
2569 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+ ");
2570 INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
2571 FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(hApp));
2573 ShutdownComplete l_shutdownNotif; /// \file frameworkunified_framework_types.h
2575 // Check hApp ptr, msg size, msg reception, read msg if all ok. *
2576 // Report any errors found. *
2578 if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < ShutdownComplete > (hApp, l_shutdownNotif))) {
2579 LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2581 PCSTR l_moduleName = l_shutdownNotif.cServiceName;
2582 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
2583 " '%s' 'Shutdown Complete Status' is 0x%X", l_moduleName,
2584 l_shutdownNotif.eShutdownCompleteStatus);
2587 snprintf(l_cBuf, sizeof(l_cBuf),
2588 "ProcessModuleStopCompleteResponse(%s)", l_moduleName);
2589 l_eStatus = ProcessModuleStopCompleteResponse(hApp, l_moduleName);
2590 LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, l_cBuf); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
2593 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2595 } // End of EFrameworkunifiedStatus CSystemManager::onmodulestopcompletenotification( HANDLE hApp )
2598 EFrameworkunifiedStatus CSystemManager::ProcessModuleStopCompleteResponse(HANDLE hApp, PCSTR f_moduleName) {
2599 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
2600 EFrameworkunifiedStatus l_eStatus;
2602 ModuleLaunchListIter l_ModuleListIter;
2603 l_eStatus = GetModuleIterator(f_moduleName, l_ModuleListIter);
2604 if (eFrameworkunifiedStatusOK != l_eStatus) {
2605 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: Module %s not found in Group Launch Map", f_moduleName);
2607 switch (m_SMCurrentState) {
2608 case SS_SM_READY_TO_LAUNCH_APP:
2609 case SS_SM_APPS_LAUNCH_IN_PROGRESS:
2610 case SS_SM_APPS_LAUNCHED_READY_TO_START:
2611 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2612 " Error: Received from client while in "
2613 "the '%s' state !!!",
2614 GetStr(m_SMCurrentState).c_str());
2615 l_eStatus = eFrameworkunifiedStatusErrOther;
2618 case SS_SM_APPS_STOPPING_AT__CWORD56__REQ:
2619 case SS_SM_APPS_STOPPING_AT_INTERNAL_REQ:
2620 case SS_SM_WAITING_FOR_CRITICAL_APPS_AT__CWORD56__REQ:
2621 case SS_SM_WAITING_FOR_CRITICAL_APPS_AT_INTERNAL_REQ:
2622 if (m_SystemStarter.get_id() == SS_SM_THIRD_GROUP) {
2623 // Execute shutdown_critical services termination synchronization prior to CoreModule(backupManager termination processing
2624 l_ModuleListIter->SetModuleState(MODULE_STATE_STOPPED);
2625 if (have_critical_services_stopped()) { // Transition after all critical services have ended
2626 ProcessGroupOnModuleStopResponse(hApp, m_SystemStarter.get_id());
2629 l_eStatus = ModuleCompleteResponse(hApp, l_ModuleListIter,
2630 MODULE_STATE_STOPPED,
2631 (SysMgrCbType3<CSystemManager,
2632 &CSystemManager::IsGroupStopped>),
2633 (SysMgrCbType2<CSystemManager,
2634 &CSystemManager::ProcessGroupOnModuleStopResponse>),
2639 case SS_SM_APPS_START_COMPLETE:
2640 case SS_SM_APPS_START_IN_PROGRESS:
2641 case SS_SM_APPS_PRE_RUN_COMPLETE:
2642 case SS_SM_APPS_PRE_START_IN_PROGRESS:
2643 case SS_SM_APPS_PRE_STOP_IN_PROGRESS:
2644 case SS_SM_APPS_BACKGROUND_RUN_COMPLETE:
2645 case SS_SM_APPS_BACKGROUND_START_IN_PROGRESS:
2646 case SS_SM_APPS_BACKGROUND_STOP_IN_PROGRESS:
2647 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2648 " Error: Received from client while in "
2649 "the '%s' state !!!",
2650 GetStr(m_SMCurrentState).c_str());
2651 l_eStatus = eFrameworkunifiedStatusErrOther;
2653 } // End switch ( m_SMCurrentState )
2656 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2658 } // End of EFrameworkunifiedStatus CSystemManager::ProcessModuleStopCompleteResponse(
2660 EFrameworkunifiedStatus CSystemManager::ProcessGroupOnModuleStopResponse(HANDLE hApp, UI_32 f_groupID) {
2661 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
2662 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
2663 UI_32 l_ActiveGroupId = m_SystemStarter.get_id();
2665 m_GroupLaunchTimer->StopTimer(m_aTimerIDs[eSM_TIMER_CLIENT_STOP_MONITOR]);
2667 if (f_groupID != l_ActiveGroupId) {
2668 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
2669 " Group %d stop complete, but m_SystemStarter.get_id() is %d",
2671 // , m_ActiveGroupId); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
2674 if (!m_SystemStarter.is_begin()) {
2675 m_SystemStarter.decrement_id();
2677 check_all_groups_have_stopped(hApp);
2679 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2681 } // End of EFrameworkunifiedStatus CSystemManager::ProcessGroupOnModuleStopResponse( HANDLE hApp
2683 ///////////////////////////////////////////////////////////////////////////////
2684 /// \ingroup stop_all_modules_of_group
2685 /// Send SS_SM_STOP to all modules of the given group
2691 ///////////////////////////////////////////////////////////////////////////////
2692 EFrameworkunifiedStatus CSystemManager::stop_all_modules_of_group(HANDLE hApp) {
2693 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
2694 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
2695 ModuleLaunchList::reverse_iterator l_revIter;
2697 UI_32 l_uiMaxGroupWaitTime_sec = 0;
2698 UI_32 l_uiMaxGroupWaitTime_msec = 0;
2699 UI_32 l_uiModuleWaitTime = 0;
2701 // GroupLaunchMapIter l_GroupIterator = m_MapProclaunchGrps.find(m_ActiveGroupId);
2702 GroupLaunchMapIter l_GroupIterator = m_MapProclaunchGrps.find(m_SystemStarter.get_id());
2703 if (l_GroupIterator == m_MapProclaunchGrps.end()) {
2704 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2705 " Error: Group %d not found; 'm_MapProclaunchGrps' is empty"
2706 //, m_ActiveGroupId); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
2707 , m_SystemStarter.get_id());
2708 l_eStatus = eFrameworkunifiedStatusDbRecNotFound;
2710 int l_numModulesMessaged = 0;
2711 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "StopReq grp:%d", m_SystemStarter.get_id());
2713 T_SS_SM_STOP_DataStructType l_SM_STOP_Struct;
2714 l_SM_STOP_Struct.shutdownTrigger = m_shutdownTrigger;
2715 l_SM_STOP_Struct.lastUserMode = m_lastUserMode;
2717 for (l_revIter = l_GroupIterator->second.modules.rbegin();
2718 l_revIter != l_GroupIterator->second.modules.rend();
2720 // LCOV_EXCL_BR_START 11: Excluded due to gcov constraints (others)
2721 if ((l_revIter->IsModuleState(MODULE_STATE_START_SENT) == TRUE)
2722 || (l_revIter->IsModuleState(MODULE_STATE_STARTED) == TRUE)
2723 || (l_revIter->IsModuleState(MODULE_STATE_START_PRE_SENT) == TRUE)
2724 || (l_revIter->IsModuleState(MODULE_STATE_STARTED_PRE) == TRUE)
2725 || (l_revIter->IsModuleState(MODULE_STATE_STOP_PRE_SENT) == TRUE)
2726 || (l_revIter->IsModuleState(MODULE_STATE_STOPPED_PRE) == TRUE)
2727 || (l_revIter->IsModuleState(MODULE_STATE_START_BACKGROUND_SENT) == TRUE)
2728 || (l_revIter->IsModuleState(MODULE_STATE_STARTED_BACKGROUND) == TRUE)
2729 || (l_revIter->IsModuleState(MODULE_STATE_STOP_BACKGROUND_SENT) == TRUE)
2730 || (l_revIter->IsModuleState(MODULE_STATE_STOPPED_BACKGROUND) == TRUE)) {
2731 // LCOV_EXCL_BR_STOP 11: Excluded due to gcov constraints (others)
2732 if (FRAMEWORKUNIFIED_NS_NPSERVICE == l_revIter->name) {
2733 if (epssdmsdtFACTORY_DATA_RESET == m_shutdownTrigger) {
2734 CALL_AND_LOG_STATUS(FrameworkunifiedSendStopToNSNPP(hApp, eFrameworkunifiedDataResetShutdown, eFrameworkunifiedUserData | eFrameworkunifiedFactoryData)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2735 } else if (epssdmsdtUSER_DATA_RESET == m_shutdownTrigger) {
2736 CALL_AND_LOG_STATUS(FrameworkunifiedSendStopToNSNPP(hApp, eFrameworkunifiedDataResetShutdown, eFrameworkunifiedUserData)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2737 } else if (epssdmsdtFAST_SLEEP_MODE == m_shutdownTrigger) {
2738 CALL_AND_LOG_STATUS(FrameworkunifiedSendStopToNSNPP(hApp, eFrameworkunifiedQuickShutdown)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2740 CALL_AND_LOG_STATUS(FrameworkunifiedSendStopToNSNPP(hApp, eFrameworkunifiedNormalShutdown)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2743 if (eFrameworkunifiedStatusOK != l_eStatus) {
2744 l_revIter->SetModuleState(MODULE_STATE_STOP_FAILED);
2746 l_revIter->SetModuleState(MODULE_STATE_STOP_SENT);
2747 l_numModulesMessaged++;
2750 m_NPPStopSent = TRUE;
2751 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " m_NPPStopSent is %s", GetStr(m_NPPStopSent).c_str()); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
2752 // End else if ( FRAMEWORKUNIFIED_NS_NPSERVICE == l_ModuleListIter->name )
2754 l_eStatus = l_revIter->SendMsgAndUpdateState(&l_SM_STOP_Struct);
2755 LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, "l_revIter->SendMsgAndUpdateState(&l_SM_STOP_Struct)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
2756 if (eFrameworkunifiedStatusOK == l_eStatus) {
2757 if (epssdmsdtFAST_SLEEP_MODE == m_shutdownTrigger) {
2758 l_uiModuleWaitTime = l_revIter->fast_shutdown_wait_time;
2761 l_uiModuleWaitTime = l_revIter->shutdown_wait_time;
2763 if (l_uiModuleWaitTime > l_uiMaxGroupWaitTime_sec) {
2764 l_uiMaxGroupWaitTime_sec = l_uiModuleWaitTime;
2766 l_numModulesMessaged++;
2768 } // End if MODULE_STATE_STARTED || MODULE_STATE_START_SENT
2769 } else if (l_revIter->IsModuleState(MODULE_STATE_INVALID)
2770 && FRAMEWORKUNIFIED_NS_NPSERVICE == l_revIter->name) {
2771 m_NPPStopSent = TRUE;
2772 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "StopNotSent:%s is INVALID", FRAMEWORKUNIFIED_NS_NPSERVICE);
2774 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "StopNotSent:%s is %s",
2775 l_revIter->name.c_str(),
2776 l_revIter->ModuleStateStr().c_str());
2780 if (0 == l_numModulesMessaged) {
2781 LogGroupModulesState(m_SystemStarter.get_id() // m_ActiveGroupId // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2782 , " Warning: NO modules were sent SS_SM_STOP");
2784 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "StopComp grp:%d", l_GroupIterator->second.id);
2786 if (m_SystemStarter.get_id() > SS_SM_INITIAL_GROUP) {
2787 m_SystemStarter.decrement_id();
2788 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, " m_ActiveGroupId is now %d", m_SystemStarter.get_id());
2790 check_all_groups_have_stopped(hApp);
2793 if (epssdmsdtFAST_SLEEP_MODE == m_shutdownTrigger) {
2794 // fast shutdown wait time always comes in milli seconds
2795 UI_32 l_uiTotalWaitTime = l_uiMaxGroupWaitTime_sec;
2796 l_uiMaxGroupWaitTime_sec = l_uiTotalWaitTime / 1000;
2797 l_uiMaxGroupWaitTime_msec = l_uiTotalWaitTime % 1000;
2799 // Other types of shutdown except fast shutdown always comes in seconds.
2800 l_uiMaxGroupWaitTime_msec = 0;
2803 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "StopTimer grp:%d time:%d.%d",
2804 m_SystemStarter.get_id(), l_uiMaxGroupWaitTime_sec,
2805 l_uiMaxGroupWaitTime_msec);
2806 m_GroupLaunchTimer->StartTimerMulti(
2807 m_aTimerIDs[eSM_TIMER_CLIENT_STOP_MONITOR],
2808 l_uiMaxGroupWaitTime_sec, l_uiMaxGroupWaitTime_msec, 0, 0,
2809 m_SystemStarter.get_id());
2812 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2814 } // End of VOID CSystemManager::stop_all_modules_of_group(HANDLE hApp)
2816 EFrameworkunifiedStatus CSystemManager::ValidateUserModeMessage(HANDLE hApp, EPWR_USER_MODE_TYPE &l_eUserModeState) { // LCOV_EXCL_START 6: Because the condition cannot be set // NOLINT(whitespace/line_length)
2817 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2818 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
2819 EFrameworkunifiedStatus l_eStatus;
2820 Pwr_ServiceSetInterface tServiceSetIf;
2821 EPWR_USER_MODE_TYPE l_my_eUserModeState;
2824 // Check hApp ptr, msg size, msg reception, read msg if all ok. *
2825 if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < Pwr_ServiceSetInterface > (hApp, tServiceSetIf))) {
2826 LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2828 l_my_eUserModeState = tServiceSetIf.data.user_mode.mode;
2829 switch (l_my_eUserModeState) {
2831 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: l_eUserModeState == epsumINVALID");
2832 l_eStatus = eFrameworkunifiedStatusInvldParam;
2837 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Validated '%s'",
2838 l_my_eUserModeState == epsumON ? "epsumON" : "epsumOFF");
2839 l_eUserModeState = l_my_eUserModeState;
2840 l_eStatus = eFrameworkunifiedStatusOK;
2843 // default: Don't code a 'default' here - let the compiler
2844 // issue a warning ( set via -Wall or -Wswitch ) when the set of
2845 // enumerations changes - then the maintainer will
2846 // automagically know to update this switch statement.
2849 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2851 } // End of EFrameworkunifiedStatus CSystemManager::ValidateUserModeMessage( HANDLE hApp, EPWR_USER_MODE_TYPE &l_eUserModeState )
2854 //*****************************************************************************
2855 // Next Wakeup Type Set Protocol functions *
2857 EFrameworkunifiedStatus CSystemManager::OnSetNextWakeupTypeRequest(HANDLE hApp) {
2858 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
2859 EFrameworkunifiedStatus l_eStatus;
2860 ESMNextWakeupType l_wakeupType;
2862 INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
2863 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(hApp));
2864 SetCmdHist("SS_SM_NEXT_WAKEUP_TYPE_SET_REQ", m_SMCmdHist, m_SMHistIter, FrameworkunifiedGetMsgSrc(hApp));
2866 if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < ESMNextWakeupType > (hApp, l_wakeupType))) {
2867 LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2869 switch (l_wakeupType) {
2870 case e_SS_SM_NEXT_WAKEUP_TYPE_NONE:
2871 case e_SS_SM_NEXT_WAKEUP_TYPE_COLD:
2872 case e_SS_SM_NEXT_WAKEUP_TYPE_HOT:
2875 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "unknown type(%d)", l_wakeupType);
2876 l_eStatus = eFrameworkunifiedStatusInvldParam;
2879 l_eStatus = FrameworkunifiedSetSyncResponseData(hApp, &l_eStatus, sizeof(l_eStatus));
2880 LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedSetSyncResponseData()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2882 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2884 } // End of EFrameworkunifiedStatus CSystemManager::OnSetNextWakeupTypeRequest( HANDLE hApp )
2887 // End of Boot Mode Protocol functions *
2888 //*****************************************************************************
2891 //*****************************************************************************
2892 // Data Reset Mode Protocol functions *
2894 EFrameworkunifiedStatus CSystemManager::OnSetDataResetModeRequest(HANDLE hApp) {
2895 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
2896 EFrameworkunifiedStatus l_eStatus;
2897 ESMDataResetModeInfo l_dataResetMode;
2898 INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
2899 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(hApp));
2901 SetCmdHist("SS_SM_DATA_RESET_MODE_SET_REQ", m_SMCmdHist, m_SMHistIter, FrameworkunifiedGetMsgSrc(hApp));
2903 if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < ESMDataResetModeInfo > (hApp, l_dataResetMode))) {
2904 LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2907 m_DataResetMode = l_dataResetMode;
2908 tmp = static_cast<uint32_t>(m_DataResetMode);
2909 if (PowerHalSetResetInfo(AGL_DATARESET_STATE, tmp)) { // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
2910 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Could not set AGL_DATARESET_STATE.");
2911 // Return error to client of system_manager.
2912 l_eStatus = eFrameworkunifiedStatusFail;
2916 // Instead of sending Return Message, this function must call FrameworkunifiedSetSyncResponseData()
2917 // because this request is sent by FrameworkunifiedInvokeSync()
2919 l_eStatus = FrameworkunifiedSetSyncResponseData(hApp, &l_eStatus, sizeof(l_eStatus));
2920 LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedSetSyncResponseData()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2922 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2924 } // End of EFrameworkunifiedStatus CSystemManager::OnSetDataResetModeRequest( HANDLE hApp )
2926 EFrameworkunifiedStatus CSystemManager::OnSetProgUpdateStateRequest(HANDLE hApp) {
2927 EFrameworkunifiedStatus l_eStatus;
2928 SMProgUpdateState l_progUpdateState;
2930 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
2931 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(hApp));
2933 SetCmdHist("SS_SM_PROG_UPDATE_STATE_SET_REQ", m_SMCmdHist, m_SMHistIter, FrameworkunifiedGetMsgSrc(hApp));
2935 if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < SMProgUpdateState > (hApp, l_progUpdateState))) { // LCOV_EXCL_BR_LINE 4: nsfw error
2936 // LCOV_EXCL_START 4: nsfw error
2937 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2938 LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2941 m_ProgUpdateState |= l_progUpdateState;
2942 if (PowerHalSetResetInfo(AGL_PROGUPDATE_STATE, m_ProgUpdateState)) { // LCOV_EXCL_BR_LINE 11:Gcov constraints (because exception-handling routes are automatically generated)
2943 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Could not set AGL_PROGUPDATE_STATE.");
2944 // return Error to client of system_manager.
2945 l_eStatus = eFrameworkunifiedStatusFail;
2948 // Instead of sending Return Message, this function must call FrameworkunifiedSetSyncResponseData()
2949 // because this request is sent by FrameworkunifiedInvokeSync()
2950 l_eStatus = FrameworkunifiedSetSyncResponseData(hApp, &l_eStatus, sizeof(l_eStatus));
2951 LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedSetSyncResponseData()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2953 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2955 } // End of EFrameworkunifiedStatus CSystemManager::OnSetProgUpdateStateRequest( HANDLE hApp )
2957 EFrameworkunifiedStatus CSystemManager::CallStopCompleteHandler(HANDLE hApp, BOOL bIsDetectTimeout /* = FALSE */) {
2958 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "+");
2959 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
2962 if (bIsDetectTimeout) {
2963 fprintf(stderr, "SS_SysManager/%s/State StopComplete(timeout)\n", __FUNCTION__);
2965 fprintf(stderr, "SS_SysManager/%s/State StopComplete\n", __FUNCTION__);
2968 l_eStatus = SecureChipOff();
2969 if (eFrameworkunifiedStatusOK != l_eStatus) {
2970 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: SecureChipOff Failed");
2973 l_eStatus = (*m_pfStopCompleteHandler)(hApp);
2975 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "-");
2977 } // End of EFrameworkunifiedStatus CSystemManager::CallStopCompleteHandler( HANDLE hApp )
2980 //*****************************************************************************
2981 // Soft Reset Protocol functions *
2983 static char *get_line(const char *filepath) {
2984 char line[LINE_MAX];
2987 if ((fp = fopen(filepath, "rb")) == NULL)
2989 if (fgets(line, LINE_MAX, fp) == NULL) { // LCOV_EXCL_BR_LINE 5:fgets error
2990 // LCOV_EXCL_START 5: fgets error
2991 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2998 return strdup(line);
3001 EFrameworkunifiedStatus CSystemManager::PerformCpuReset(HANDLE hApp,
3002 ESMCpuResetReason f_eSmCpuResetReason, std::string f_messageStr) {
3003 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
3004 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
3005 if (FALSE == m_isRcvModeInfo) {
3006 // If the condition for implementing the CpuReset request is not satisfied, keep the request.
3007 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "Cpu Reset Pending");
3008 m_isRstPending = TRUE;
3009 m_rstPendingInfo.resetReason = f_eSmCpuResetReason;
3010 snprintf(m_rstPendingInfo.messageStr,
3011 sizeof(m_rstPendingInfo.messageStr), "%s", f_messageStr.c_str());
3013 switch (f_eSmCpuResetReason) {
3014 case e_SS_SM_CPU_RESET_REASON_CRITICAL_ERR:
3015 case e_SS_SM_CPU_RESET_REASON_GENERIC_ERR:
3016 case e_SS_SM_CPU_RESET_REASON_DSP_ERR:
3017 m_isImmResetReq = TRUE;
3018 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, " will reset immediately");
3019 // The break is omitted because the same process as for a normal reboot is performed.
3020 case e_SS_SM_CPU_RESET_REASON_USER_FORCE_RESET:
3021 m_pfStopCompleteHandler = (SysMgrCallback<CSystemManager, &CSystemManager::perform_force_reset>);
3022 case e_SS_SM_CPU_RESET_REASON_NORMAL: {
3023 TSystemManagerCpuResetInfo l_resetInfo;
3025 l_resetInfo.resetReason = f_eSmCpuResetReason;
3026 snprintf(l_resetInfo.messageStr, SS_SM_RESET_MSG_STR_SIZE, "%s", f_messageStr.c_str());
3027 l_eStatus = FrameworkunifiedSendMsg(m_hPowerServiceSession, SS_SM_CPU_RESET_REQ,
3028 sizeof(l_resetInfo), (PVOID) & l_resetInfo);
3029 LOG_STATUS(l_eStatus, // LCOV_EXCL_BR_LINE 6: Because the condition cannot be set
3030 "FrameworkunifiedSendMsg(m_hPowerServiceSession, SS_SM_CPU_RESET_REQ)");
3033 case e_SS_SM_CPU_RESET_REASON_DATA_RESET: {
3034 ESMDataResetType l_eSmDataResetType;
3036 switch (m_DataResetMode) {
3037 case e_SS_SM_DATA_RESET_MODE_FACTORY:
3038 l_eSmDataResetType = e_SS_SM_DATA_RESET_TYPE_FACTORY;
3040 case e_SS_SM_DATA_RESET_MODE_USER:
3041 l_eSmDataResetType = e_SS_SM_DATA_RESET_TYPE_USER;
3042 l_eStatus = FrameworkunifiedBroadcastEvent(hApp, SS_SM_EVENT_USER_DATA_RESET, NULL, 0);
3043 LOG_STATUS(l_eStatus, "FrameworkunifiedBroadcastEvent(SS_SM_EVENT_USER_DATA_RESET)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
3046 SS_ASERT_LOG(0, "unexpected data reset mode : %d", m_DataResetMode); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
3047 l_eStatus = eFrameworkunifiedStatusInvldParam;
3050 if (l_eStatus == eFrameworkunifiedStatusOK) {
3051 l_eStatus = FrameworkunifiedSendMsg(m_hPowerServiceSession,
3052 SS_SM_REMOTE_DATA_RESET_REQ, sizeof(l_eSmDataResetType),
3053 (PVOID) & l_eSmDataResetType);
3054 LOG_STATUS(l_eStatus, "FrameworkunifiedSendMsg(m_hPowerServiceSession, SS_SM_REMOTE_DATA_RESET_REQ)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
3058 case e_SS_SM_CPU_RESET_REASON_INVALID:
3060 SS_ASERT_LOG(0, " Error: Unknown CPU reset request type: 0x%X/%d", // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
3061 f_eSmCpuResetReason, f_eSmCpuResetReason);
3062 l_eStatus = eFrameworkunifiedStatusInvldParam;
3067 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
3069 } // End of EFrameworkunifiedStatus CSystemManager::PerformCpuReset( ESMCpuResetReason f_eSmCpuResetReason )
3071 //*****************************************************************************
3072 // CPU Reset Protocol functions *
3074 EFrameworkunifiedStatus CSystemManager::OnCpuResetRequest(HANDLE hApp) { // SS_SM_CPU_RESET_REQ
3075 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
3076 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
3077 std::string l_moduleName = FrameworkunifiedGetMsgSrc(hApp);
3078 INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
3079 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "from %s", l_moduleName.c_str());
3081 // If you implement FastSleep,
3082 // ShutdownTrigger of FrameworkunifiedOnStop needs to be changed to FAST_SLEEP_MODE,
3083 // and also MaxShutdownTime needs to be changed to CriticalAppsMaxShutdownTimeFastSleep
3086 TSystemManagerCpuResetInfo l_resetInfo;
3087 SetCmdHist("SS_SM_CPU_RESET_REQ", m_SMCmdHist, m_SMHistIter, // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
3088 FrameworkunifiedGetMsgSrc(hApp)); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
3089 if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < TSystemManagerCpuResetInfo > (hApp, l_resetInfo))) {
3090 LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
3093 EErrorEventType l_errorEventType;
3094 SMLoggingInfo l_loggingInfo; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
3096 l_loggingInfo.messageStr = l_resetInfo.messageStr;
3097 l_loggingInfo.suffixStr = l_resetInfo.suffixStr;
3099 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__,
3100 " CPU Reset Reason: '%d'/'%s' from %s",
3101 l_resetInfo.resetReason,
3102 GetStr(l_resetInfo.resetReason).c_str(),
3103 FrameworkunifiedGetMsgSrc(hApp));
3105 if (e_SS_SM_CPU_RESET_REASON_IMMRESET_NORMAL == l_resetInfo.resetReason) {
3106 m_isImmResetReq = TRUE;
3107 l_resetInfo.resetReason = e_SS_SM_CPU_RESET_REASON_NORMAL;
3109 switch (l_resetInfo.resetReason) {
3110 case e_SS_SM_CPU_RESET_REASON_DATA_RESET:
3111 switch (m_DataResetMode) {
3112 case e_SS_SM_DATA_RESET_MODE_FACTORY:
3113 case e_SS_SM_DATA_RESET_MODE_USER:
3115 case e_SS_SM_DATA_RESET_MODE_NONE:
3117 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "unexpected data reset mode : %d", m_DataResetMode);
3118 throw eFrameworkunifiedStatusInvldParam;
3120 case e_SS_SM_CPU_RESET_REASON_CRITICAL_ERR:
3121 case e_SS_SM_CPU_RESET_REASON_GENERIC_ERR:
3122 case e_SS_SM_CPU_RESET_REASON_DSP_ERR:
3123 case e_SS_SM_CPU_RESET_REASON_NORMAL:
3124 l_errorEventType = eErrorEventTypeModuleInvokedResetRequest;
3125 l_loggingInfo.resetReason = l_resetInfo.resetReason;
3127 case e_SS_SM_CPU_RESET_REASON_USER_FORCE_RESET:
3128 // Separate ErrorEventType only for USER_FORCE_RESET, because the logs to be saved differ.
3129 l_errorEventType = eErrorEventTypeUserInvokedUserForceReset;
3130 l_loggingInfo.resetReason = e_SS_SM_CPU_RESET_REASON_USER_FORCE_RESET;
3132 case e_SS_SM_CPU_RESET_REASON_INVALID:
3134 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
3135 " Error: Unknown CPU reset request type: 0x%X/%d",
3136 l_resetInfo.resetReason, l_resetInfo.resetReason);
3137 throw eFrameworkunifiedStatusInvldParam;
3140 l_eStatus = ErrorEventEnqueue(hApp, l_errorEventType, l_moduleName,
3141 eErrorEventResetTypeHard, l_loggingInfo);
3143 snprintf(l_cBuf, sizeof(l_cBuf), "ErrorEventEnqueue(%s)",
3144 GetStr(l_errorEventType).c_str()); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
3145 LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, l_cBuf); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
3147 } catch (EFrameworkunifiedStatus e) {
3151 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
3155 // End of CPU Reset Protocol functions *
3156 //*****************************************************************************
3158 VOID CSystemManager::InitiateAllGroupsShutdown(HANDLE hApp) {
3159 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
3160 EFrameworkunifiedStatus l_eStatus;
3162 // Prioritize safe termination sequence and do not save logs during termination
3163 m_errorEventQueueLocked = TRUE;
3165 m_MaxShutdownTime = calculate_max_shutdown_time();
3167 l_eStatus = FrameworkunifiedNPPublishNotification(hApp, NTFY_SSSystemMgrShutdownStarted, NULL, 0);
3169 SetCmdHist(NTFY_SSSystemMgrShutdownStarted, m_PubCmdHist, m_PubHistIter, ""); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
3171 LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
3172 "FrameworkunifiedNPPublishNotification(" NTFY_SSSystemMgrShutdownStarted ")");
3174 m_GroupLaunchTimer->StopTimer(m_aTimerIDs[eSM_TIMER_START_RESP_MONITOR_WAIT_TIMER]);
3175 m_GroupLaunchTimer->StopTimer(m_aTimerIDs[eSM_TIMER_CLIENT_START_MONITOR]);
3177 // Stop Heartbeat thread activity
3178 l_eStatus = SendRequestToHeartBeat(hApp, SS_HEARTBEAT_STOP, NULL, 0);
3179 LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "SendRequestToHeartBeat(SS_HEARTBEAT_STOP)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
3181 SMSetState(hApp, SS_SM_APPS_STOPPING_AT__CWORD56__REQ);
3183 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "shutdownTrigger:%s, lastUserMode:%s",
3184 GetStr(m_shutdownTrigger).c_str(), GetStr(m_lastUserMode).c_str());
3186 fprintf(stderr, // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
3187 "SS_SysManager/%s/State shutdownTrigger:%s, lastUserMode:%s\n", // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
3188 __FUNCTION__, GetStr(m_shutdownTrigger).c_str(), // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
3189 GetStr(m_lastUserMode).c_str()); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
3191 /// Send SS_SM_STOP to all modules, starting with the m_ActiveGroupId group
3192 m_NPPStopSent = FALSE;
3193 check_all_groups_have_stopped(hApp);
3195 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
3197 } // End of EFrameworkunifiedStatus CSystemManager::InitiateAllGroupsShutdown(HANDLE hApp)
3199 VOID CSystemManager::SendDeferMsg(HANDLE hApp) {
3200 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
3202 if (!m_dqDeferMsg.empty()) {
3203 EFrameworkunifiedStatus l_eStatus;
3204 SM_POWER_EVENT_INFO deferMsg;
3206 deferMsg = m_dqDeferMsg.front();
3209 HANDLE hSender = McOpenSender(SERVICE_SYSMANAGER);
3210 if (hSender == NULL) { // LCOV_EXCL_BR_LINE 4: nsfw error
3211 // LCOV_EXCL_START 4: nsfw error
3212 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
3213 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: McOpenSender(SERVICE_SYSMANAGER)");
3216 CALL_AND_LOG_STATUS_IF_ERRORED( // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
3217 McSend(hSender, SERVICE_POWER, deferMsg.first,
3218 sizeof(Pwr_ServiceSetInterface),
3219 (PVOID) & deferMsg.second));
3220 CALL_AND_LOG_STATUS_IF_ERRORED(McClose(hSender)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
3224 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
3226 } // End of VOID CSystemManager::SendDeferMsg(HANDLE hApp)
3228 ///////////////////////////////////////////////////////////////////////////////
3229 /// \ingroup PublishPowerOnOffNotification
3230 /// Power Off notification handler
3234 /// \return EFrameworkunifiedStatus
3235 /// Success ==> eFrameworkunifiedStatusOK
3236 /// Failure ==> Other values
3237 ///////////////////////////////////////////////////////////////////////////////
3238 EFrameworkunifiedStatus CSystemManager::PublishPowerOnOffNotification(HANDLE hApp) {
3239 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
3240 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
3242 l_eStatus = PerformPowerOnOffUserModePublication(hApp, NTFY_SSSystemMgrPowerOnOff);
3244 SetCmdHist(NTFY_SSSystemMgrPowerOnOff, m_PubCmdHist, m_PubHistIter, "");
3245 LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, "PerformPowerOnOffUserModePublication()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
3247 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
3251 EFrameworkunifiedStatus CSystemManager::PublishUserModeNotification(HANDLE hApp) {
3252 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
3253 EFrameworkunifiedStatus l_eStatus;
3255 l_eStatus = PerformPowerOnOffUserModePublication(hApp, NTFY_SSSystemMgrUserMode);
3257 SetCmdHist(NTFY_SSSystemMgrUserMode, m_PubCmdHist, m_PubHistIter, "");
3258 LOG_STATUS_REC_HIST_IF_ERRORED(l_eStatus, "PerformPowerOnOffUserModePublication()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
3260 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
3262 } // End of EFrameworkunifiedStatus CSystemManager::PublishUserModeNotification(
3264 EFrameworkunifiedStatus CSystemManager::PerformPowerOnOffUserModePublication(HANDLE hApp, const char * p_NotificationStr) {
3265 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
3266 EFrameworkunifiedStatus l_eStatus;
3267 char l_cBuf[500] = { 0 };
3269 if (m_SMConfig.UMConfig.IsUserModeNotificationABOOL) {
3270 BOOL l_bUuserMode(m_PowerType_to_SSBoolEnumMap[m_Wake.powerupType]);
3272 snprintf(l_cBuf, sizeof(l_cBuf), "FrameworkunifiedNPPublishNotification(%s, %s)",
3273 p_NotificationStr, GetStr(l_bUuserMode).c_str());
3274 l_eStatus = FrameworkunifiedNPPublishNotification(hApp, p_NotificationStr,
3275 &l_bUuserMode, sizeof(l_bUuserMode));
3277 T_SS_SM_UserModeOnOffNotification_Struct l_UserModeOnOffStruct(
3278 m_PowerType_to_SSBoolEnumMap[m_Wake.powerupType],
3279 m_StartUpReason, m_userModeChangeReason);
3281 snprintf(l_cBuf, sizeof(l_cBuf),
3282 "FrameworkunifiedNPPublishNotification(%s, %s, %s, %s)", p_NotificationStr,
3283 GetStr(l_UserModeOnOffStruct.isUserModeOn).c_str(),
3284 GetStr(m_StartUpReason).c_str(),
3285 GetStr(m_userModeChangeReason).c_str());
3286 l_eStatus = FrameworkunifiedNPPublishNotification(hApp, p_NotificationStr,
3287 &l_UserModeOnOffStruct, sizeof(l_UserModeOnOffStruct));
3290 SetCmdHist(p_NotificationStr, m_PubCmdHist, m_PubHistIter, "");
3291 LOG_STATUS(l_eStatus, l_cBuf); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
3293 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
3295 } // End of EFrameworkunifiedStatus CSystemManager::PerformPowerOnOffUserModePublication(
3297 EFrameworkunifiedStatus CSystemManager::ResetModulesStateToConnected(HANDLE hApp) {
3298 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
3299 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
3300 ModuleLaunchListIter l_moduleIter;
3301 for (GroupLaunchMapIter l_GroupIter = m_MapProclaunchGrps.begin();
3302 l_GroupIter != m_MapProclaunchGrps.end(); l_GroupIter++) {
3303 for (l_moduleIter = l_GroupIter->second.modules.begin();
3304 l_moduleIter != l_GroupIter->second.modules.end();
3306 if (l_moduleIter->name == FRAMEWORKUNIFIED_NS_NPSERVICE) {
3307 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " %s ( Group %d/%s ) is %s",
3308 l_moduleIter->name.c_str(), l_GroupIter->second.id,
3309 l_GroupIter->second.name.c_str(),
3310 l_moduleIter->ModuleStateStr().c_str());
3311 l_moduleIter->SetModuleState(MODULE_STATE_STARTED); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
3312 // End else if ( FRAMEWORKUNIFIED_NS_NPSERVICE == l_ModuleListIter->name )
3314 switch (l_moduleIter->GetModuleState()) {
3315 case MODULE_STATE_INVALID:
3316 case MODULE_STATE_SKIPPED:
3317 case MODULE_STATE_LAUNCHING:
3318 case MODULE_STATE_LAUNCHED:
3319 case MODULE_STATE_LAUNCH_FAILED:
3320 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
3321 " %s ( Group %d/%s ) is %s, NOT setting to "
3322 "MODULE_STATE_CONNECTED",
3323 l_moduleIter->name.c_str(), l_GroupIter->second.id,
3324 l_GroupIter->second.name.c_str(),
3325 l_moduleIter->ModuleStateStr().c_str()); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
3328 case MODULE_STATE_STARTED:
3329 case MODULE_STATE_START_SENT:
3330 case MODULE_STATE_CONNECTED:
3331 case MODULE_STATE_START_FAILED:
3332 case MODULE_STATE_STOP_FAILED:
3333 case MODULE_STATE_STOP_SENT:
3334 case MODULE_STATE_STOPPED:
3335 case MODULE_STATE_START_PRE_SENT:
3336 case MODULE_STATE_START_PRE_FAILED:
3337 case MODULE_STATE_STARTED_PRE:
3338 case MODULE_STATE_STOP_PRE_SENT:
3339 case MODULE_STATE_STOP_PRE_FAILED:
3340 case MODULE_STATE_STOPPED_PRE:
3341 case MODULE_STATE_START_BACKGROUND_SENT:
3342 case MODULE_STATE_START_BACKGROUND_FAILED:
3343 case MODULE_STATE_STARTED_BACKGROUND:
3344 case MODULE_STATE_STOP_BACKGROUND_SENT:
3345 case MODULE_STATE_STOP_BACKGROUND_FAILED:
3346 case MODULE_STATE_STOPPED_BACKGROUND:
3347 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " %s ( Group %d/%s ) is %s",
3348 l_moduleIter->name.c_str(), l_GroupIter->second.id,
3349 l_GroupIter->second.name.c_str(),
3350 l_moduleIter->ModuleStateStr().c_str());
3351 l_moduleIter->SetModuleState(MODULE_STATE_CONNECTED);
3353 // default: Don't code a 'default' here - let the compiler
3354 // issue a warning ( set via -Wall or -Wswitch ) when the set of
3355 // enumerations changes - then the maintainer will
3356 // automagically know to update this switch statement.
3361 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
3363 } // End of EFrameworkunifiedStatus CSystemManager::ResetModulesStateToConnected(HANDLE hApp)
3365 EFrameworkunifiedStatus CSystemManager::On_CWORD56_HeartBeatRequest(HANDLE hApp) {
3366 FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "+");
3367 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
3369 PCSTR l_senderName = FrameworkunifiedGetMsgSrc(hApp);
3371 SetCmdHist("SS_SM__CWORD56__HEARTBEAT_REQ", m_SMCmdHist, m_SMHistIter, l_senderName);
3373 FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_INFO, __FUNCTION__, " Received from %s", l_senderName);
3374 EPWR_HB_REQ_MSG_STRUCT l_hbReq;
3376 if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < EPWR_HB_REQ_MSG_STRUCT > (hApp, l_hbReq))) {
3377 LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
3380 m_GroupLaunchTimer->StopTimer(m_aTimerIDs[eSM_TIMER__CWORD56__HEARTBEAT_RESPONSE]);
3382 if (l_hbReq.IntervalSec > 0) {
3383 m_GroupLaunchTimer->StartTimer(
3384 m_aTimerIDs[eSM_TIMER__CWORD56__HEARTBEAT_RESPONSE], 0, 0,
3385 l_hbReq.IntervalSec, 0);
3386 } else if (l_hbReq.IntervalSec == 0) { // LCOV_EXCL_BR_LINE 8: As the condition is never false
3387 l_eStatus = FrameworkunifiedSendMsg(m_hPowerServiceSession, SS_SM__CWORD56__HEARTBEAT_RSPN, 0, NULL);
3389 LOG_STATUS(l_eStatus, "FrameworkunifiedSendMsg(m_hPowerServiceSession, SS_SM__CWORD56__HEARTBEAT_RSPN)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
3392 FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "-");
3396 EFrameworkunifiedStatus CSystemManager::On_CWORD56_HeartBeatResponseIntervalTimerExpiry(HANDLE hApp) {
3397 FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "+");
3398 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
3400 SetCmdHist("SM_TIMER__CWORD56__HEARTBEAT_RESPONSE", m_TimerCmdHist, m_TimerHistIter, FrameworkunifiedGetMsgSrc(hApp)); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
3402 l_eStatus = FrameworkunifiedSendMsg(m_hPowerServiceSession, SS_SM__CWORD56__HEARTBEAT_RSPN, 0, NULL);
3404 LOG_STATUS(l_eStatus, "FrameworkunifiedSendMsg(m_hPowerServiceSession, SS_SM__CWORD56__HEARTBEAT_RSPN)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
3406 FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "-");
3410 // EOF of /SS_SystemManager/src/ss_system_manager_callbacks.cpp