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 ///////////////////////////////////////////////////////////////////////////////
23 #include <native_service/cl_lock.h>
24 #include <native_service/cl_process.h>
25 #include <native_service/cl_monitor.h>
27 #include <native_service/frameworkunified_application.h>
28 #include <native_service/frameworkunified_framework_if.h>
29 #include <native_service/frameworkunified_multithreading.h>
30 #include <native_service/frameworkunified_thread_priority.h>
32 #include <native_service/ns_np_service_nor_persistence.h>
33 #include <native_service/ns_np_service_protocol.h>
34 #include <native_service/ns_plogger_if.h>
35 #include <native_service/ns_np_service_if.h>
36 #include <native_service/ns_backup.h>
38 #include <heartbeat/ss_hb_if.h>
40 #include <processlauncher/ProcessLauncher_if.h>
41 #include <processlauncher/ss_sm_process_launcher.h>
42 #include <processlauncher/ss_sm_process_launcher_protocol.h>
44 #include <system_service/ss_system_manager_conf.h>
45 #include <stub/ss_diag.h>
47 #include <system_service/ss_client_names.h>
48 #include <system_service/ss_heartbeat_service_protocol.h>
49 #include <system_service/ss_power_service_if.h>
50 #include <system_service/ss_power_service_notifications.h>
51 #include <system_service/ss_power_service_protocol.h>
52 #include <system_service/ss_services.h>
53 #include <system_service/ss_sm_thread_names.h>
54 #include <system_service/ss_sm_thread_names_local.h>
55 #include <system_service/ss_sm_client_if.h>
56 #include <system_service/ss_string_maps.h>
57 #include <system_service/ss_system_manager_notifications.h>
58 #include <system_service/ss_system_manager_notifications_local.h>
59 #include <system_service/ss_templates.h>
60 #include <system_service/ss_sm_client_if_local.h>
61 #include <system_service/ss_test_clients.h>
62 #include <stub/Clock_API.h>
63 #include <power_hal.h>
70 #include <sys/resource.h>
71 #include <sys/procfs.h>
72 #include <sys/timeb.h>
78 #include <linux/oom.h>
80 #include <sys/types.h>
81 #include <sys/ioctl.h>
83 #include <other_service/itoa.h>
89 #include "ss_sm_signals.h"
90 #include "ss_sm_default_paths.h"
91 #include "ss_sm_systemmanagerlog.h"
92 #include "ss_sm_version.h"
93 #include "ss_system_manager.h"
94 using namespace std; // NOLINT
96 static CSystemManager g_oSystemManger;
98 #define SS_SM_TEMP_FILE_FOR_STORE_LOGS "/var/local/lib/basesystem/nv/BS/ss/system_manager/rwdata/sm_tempStoreLogs"
99 #define TR_USB_PATH "/usr/agl/bin/realtimeUsbLog"
101 // \brief: public structure that is used for logging by NSLogger.
102 FRAMEWORKUNIFIEDLOGPARAM g_FrameworkunifiedLogParams = {
103 FRAMEWORKUNIFIEDLOGOPTIONS,
105 ZONE_TEXT_10, ZONE_TEXT_11, ZONE_TEXT_12,
106 ZONE_TEXT_13, ZONE_TEXT_14, ZONE_TEXT_15,
107 ZONE_TEXT_16, ZONE_TEXT_17, ZONE_TEXT_18,
108 ZONE_TEXT_19, ZONE_TEXT_20, ZONE_TEXT_21,
109 ZONE_TEXT_22, ZONE_TEXT_23, ZONE_TEXT_24,
110 ZONE_TEXT_25, ZONE_TEXT_26, ZONE_TEXT_27,
111 ZONE_TEXT_28, ZONE_TEXT_29, ZONE_TEXT_30,
114 FRAMEWORKUNIFIEDLOGZONES
117 std::string NumberToString(int Number) { // LCOV_EXCL_START 8: dead code
118 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
119 std::ostringstream ss;
125 /* Check if "Mount Point" exsists as Directory */
126 /*****************************************************************************/
128 @ingroup: CSystemManager
129 @brief: No Argument Constructor.
134 /*****************************************************************************/
135 template<typename C, eFrameworkunifiedStatus (C::*M)(HANDLE)> EFrameworkunifiedStatus SysMgrCallback(HANDLE hApp) {
136 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
137 C * pObj = static_cast<C *>(&g_oSystemManger);
139 l_eStatus = (pObj->*M)(hApp);
144 //**************************************************************************
145 // System Manager State String Map *
147 void Init_SS_SMModuleState_StrMap(std::map<SS_SMModuleState, SS_String> & m_strMap) { // NOLINT
148 MAP_ENTRY(m_strMap, SS_SM_READY_TO_LAUNCH_APP);
149 MAP_ENTRY(m_strMap, SS_SM_APPS_LAUNCH_IN_PROGRESS);
150 MAP_ENTRY(m_strMap, SS_SM_APPS_LAUNCHED_READY_TO_START);
151 MAP_ENTRY(m_strMap, SS_SM_APPS_START_IN_PROGRESS);
152 MAP_ENTRY(m_strMap, SS_SM_APPS_START_COMPLETE);
153 MAP_ENTRY(m_strMap, SS_SM_APPS_STOPPING_AT__CWORD56__REQ);
154 MAP_ENTRY(m_strMap, SS_SM_APPS_STOPPING_AT_INTERNAL_REQ);
155 MAP_ENTRY(m_strMap, SS_SM_WAITING_FOR_CRITICAL_APPS_AT__CWORD56__REQ);
156 MAP_ENTRY(m_strMap, SS_SM_WAITING_FOR_CRITICAL_APPS_AT_INTERNAL_REQ);
157 MAP_ENTRY(m_strMap, SS_SM_APPS_PRE_START_IN_PROGRESS);
158 MAP_ENTRY(m_strMap, SS_SM_APPS_PRE_STOP_IN_PROGRESS);
159 MAP_ENTRY(m_strMap, SS_SM_APPS_PRE_RUN_COMPLETE);
160 MAP_ENTRY(m_strMap, SS_SM_APPS_BACKGROUND_START_IN_PROGRESS);
161 MAP_ENTRY(m_strMap, SS_SM_APPS_BACKGROUND_STOP_IN_PROGRESS);
162 MAP_ENTRY(m_strMap, SS_SM_APPS_BACKGROUND_RUN_COMPLETE);
163 } // End of void Init_SS_SMModuleState_StrMap(std::map<SS_SMModuleState,
165 class EnumStringMap<SS_SMModuleState, Init_SS_SMModuleState_StrMap>
166 m_oSS_SMModuleStateStrMap;
167 SS_String GetStr(SS_SMModuleState f_enum) {
168 return m_oSS_SMModuleStateStrMap.GetStr(f_enum); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
169 } // End of SS_String :GetStr(SS_SMModuleState f_enum)
171 // End of System Manager State String Map *
172 //**************************************************************************
174 std::string CSystemManager::m_bootOpt; // NOLINT
176 /*****************************************************************************/
178 @ingroup: CSystemManager
179 @brief: No Argument Constructor.
184 /*****************************************************************************/
185 CSystemManager & CSystemManager::GetInstance() {
186 return g_oSystemManger;
189 /*****************************************************************************/
191 @ingroup: CSystemManager
192 @brief: No Argument Constructor.
197 /*****************************************************************************/
198 CSystemManager::CSystemManager() :
199 m_hHeartbeatThread(INVALID_HANDLE, eSM_ThreadNotExist),
200 m_hProcLauncherThread(INVALID_HANDLE, eSM_ThreadNotExist),
201 m_SystemLaunchProgress(SS_SM_INITIAL_GROUP),
202 m_GroupLaunchTimer(NULL),
203 m_GroupRelaunchCount(0),
204 m_GroupRelaunchLimit(0),
205 m_hPowerServiceSession(NULL),
206 m_ActiveGroupId(SS_SM_INITIAL_GROUP),
207 m_StartUpReason(epswfINVALID),
208 m_DataResetMode(e_SS_SM_DATA_RESET_MODE_NONE),
209 m_ProgUpdateState(SS_SM_PROG_UPDATE_STATE_NONE),
210 m_NextWakeupType(e_SS_SM_NEXT_WAKEUP_TYPE_NONE),
211 m_DramBackupStatus(e_SS_SM_DRAM_BACKUP_NG),
213 m_ResetStatus(e_SS_SM_RESET_STATUS_NONE),
215 m_SMCurrentState(SS_SM_READY_TO_LAUNCH_APP),
217 m_MaxShutdownTime(0),
218 m_NbrDebugDumpRspnRecv(0),
219 m_isRcvModeInfo(FALSE),
220 m_BinaryFilesPath(""),
221 m_ConfigFilesPath(""),
222 m_pfStopCompleteHandler(
223 SysMgrCallback<CSystemManager, &CSystemManager::send_shutdown_complete_response>),
224 m_VersionNumberStruct(0, eFrameworkunifiedStatusErrOther),
226 m_isRstPending(FALSE),
228 m_UsingVMPlayer(FALSE),
229 NVM_VALID_SIGNATURE(0xBA5EBA11),
230 m_lastUserMode(epsumON),
231 m_shutdownTrigger(epssdmsdtINVALID),
232 m_isImmediateReset(FALSE),
233 m_isImmResetReq(FALSE),
234 m_needReNotifyStartPrm(FALSE),
236 m_SSLGroupLaunchMapIterator(NULL),
237 m_ModuleLaunchListIter(NULL),
238 m_bIsNPP_ServicesStarted(FALSE),
239 m_bIsBackupAvail(FALSE),
242 m_NPPStopSent(FALSE),
243 m_userModeChangeReason(epsumcrNOT_AVAILABLE),
244 m__CWORD56_CmdHist(SS_SM__CWORD56__CMD_HIST_SIZE),
245 m_SMCmdHist(SS_SM_CMD_HIST_SIZE),
246 m_TimerCmdHist(SS_SM_TIMER_CMD_HIST_SIZE),
247 m_PubCmdHist(SS_SM_PUB_CMD_HIST_SIZE),
248 m_ErrHist(SS_SM_ERR_HIST_SIZE),
249 m_ClProcessSigFd(-1),
251 m_FreeMemAvailable(0),
252 m_coreFileSizeBytes(0),
253 m_BootMicroResetReason(SS_SM_BOOT_MICRO_RESET_REASON_SELF_RESET),
254 m_errorEventQueueLocked(FALSE),
255 m_isPrevErrEventCompleted(TRUE),
256 m_errorEventResult(eFrameworkunifiedStatusOK),
257 m_requestedArtifactId(eArtifactIdInterfaceunifiedDebugLog) { // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
258 m_InitialBoot = true;
260 m_ResetFactor = PSM_FACTOR_NONE;
262 m_Wake.powerupType = epswsPWRON;
263 m_Wake.up.level = epswlFULLRUN;
265 m_SystemModeInfo.lastUserMode = m_lastUserMode;
266 m_SystemModeInfo.limpHomeCutoff = epslhcINVALID;
267 m_SystemModeInfo.productionMode = epspmINVALID;
268 m_SystemModeInfo.transportMode = epstmINVALID;
269 m_SystemModeInfo.systemMode = epssinfINVALID;
270 m_SystemModeInfo.startupStage = epssusfINVALID;
272 bzero(&m_SMConfig, sizeof(m_SMConfig));
273 bzero(&m_startUpConfirmationMsg, sizeof(m_startUpConfirmationMsg));
274 bzero(&m_HBReport, sizeof(m_HBReport));
276 m__CWORD56_HistIter = m__CWORD56_CmdHist.begin();
277 m_TimerHistIter = m_TimerCmdHist.begin();
278 m_SMHistIter = m_SMCmdHist.begin();
279 m_PubHistIter = m_PubCmdHist.begin();
280 m_ErrHistIter = m_ErrHist.begin();
282 ////******************************************************************////
283 //// Initialization of enum<=>enum and enum=>string maps ////
287 // **** Initialization of powerupType enum maps ****
288 // Map of System Services powerupType to BOOL enum values
289 m_PowerType_to_SSBoolEnumMap[epswsPWRON] = TRUE;
290 m_PowerType_to_SSBoolEnumMap[epswsPWROFF] = FALSE;
292 // Map of System Services powerupType to System Services User Mode enum values
293 m_PowerType_to_SSUserModeEnumMap[epswsPWRON] = epsumON;
294 m_PowerType_to_SSUserModeEnumMap[epswsPWROFF] = epsumOFF;
296 // Map of BOOL to System Services powerupType enum values
297 m_SSBool_to_PowerTypeEnumMap[TRUE] = epswsPWRON;
298 m_SSBool_to_PowerTypeEnumMap[FALSE] = epswsPWROFF;
300 // **** Initialization of User Mode ( aka Last User Mode ) maps ****
301 // Map of BOOL to System Services User Mode enum values
302 m_SSBool_to_SSUserModeEnumMap[FALSE] = epsumOFF;
303 m_SSBool_to_SSUserModeEnumMap[TRUE] = epsumON;
305 // Map of BOOL to System Services User Mode enum values
306 m_SSUserMode_to_SSBoolEnumMap[epsumOFF] = FALSE;
307 m_SSUserMode_to_SSBoolEnumMap[epsumON] = TRUE;
311 //// End of Initialization of enum<=>enum and enum=>string maps ////
312 ////******************************************************************////
314 m_startUpConfirmationMsg.wakeupType = epsstINVALID;
315 m_startUpConfirmationMsg.coldStartRequest = epsscrtINVALID;
316 m_startUpConfirmationMsg.HWVersion = UINT32_MAX;
317 m_startUpConfirmationMsg.matchedHardwareType = UINT32_MAX;
318 m_startUpConfirmationMsg.softwareType = UINT32_MAX;
319 m_startUpConfirmationMsg.imageType = UINT32_MAX;
320 m_startUpConfirmationMsg.majorVersion = UINT32_MAX;
321 m_startUpConfirmationMsg.minorVersion = UINT32_MAX;
323 m_SystemManagerPriority = PR_SS_SYSMANAGER;
326 /*****************************************************************************/
328 @ingroup: CSystemManager
334 /*****************************************************************************/
335 CSystemManager::~CSystemManager() { // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
336 if (NULL != m_pVarCodeStr) {
337 delete[] m_pVarCodeStr; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
341 /*****************************************************************************/
343 @ingroup: CSystemManager
344 @brief: Initialize_memory Memory initialization processing
349 /*****************************************************************************/
350 void CSystemManager::Initialize_memory(HANDLE hApp, bool* l_isInitFail, EFrameworkunifiedStatus* l_eStatus_work, BOOL isIllReset) {
352 EFrameworkunifiedStatus l_eStatus;
354 /// Start Process for Realtime USB Logging
356 PreLaunchModuleParams l_rtuparam;
357 l_rtuparam.LaunchFunc = CreateRtUsb;
358 l_rtuparam.relaunchLimit = 1;
359 l_rtuparam.name = "realtimeUsbLog";
360 l_rtuparam.binaryFileName = TR_USB_PATH;
361 /* l_rtuparam.pid = CreateRtUsb();
362 if (l_rtuparam.pid == 1) {
363 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: CreateRtUsb()");
365 m_PreLaunchModuleList.push_back(l_rtuparam);
368 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
370 int fd = open("/dev/urandom", O_RDONLY); // LCOV_EXCL_BR_LINE 5: standard lib error
371 if (fd == -1) { // LCOV_EXCL_BR_LINE 5: standard lib error
372 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
373 SS_ASERT_ERRNO(0); // LCOV_EXCL_LINE 5: standard lib error
376 ret = static_cast<int>(read(fd, buf, 4)); // LCOV_EXCL_BR_LINE 5: standard lib error
377 if (-1 == ret) { // LCOV_EXCL_BR_LINE 5: standard lib error
378 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
379 SS_ASERT_ERRNO(0); // LCOV_EXCL_LINE 5: standard lib error
380 } else if (4 != ret) { // LCOV_EXCL_BR_LINE 5: standard lib error
381 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
382 SS_ASERT(0); // LCOV_EXCL_LINE 5: standard lib error
384 fprintf(stderr, "WakeupID:%X%X%X%X\n", buf[0], buf[1], buf[2], buf[3]);
385 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "WakeupID:%X%X%X%X", buf[0], buf[1], buf[2], buf[3]);
390 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "bootOpt:%s", m_bootOpt.c_str());
392 *l_eStatus_work = FrameworkunifiedAttachCallbackToDispatcherWithFd(hApp, m_ClProcessSigFd, // LCOV_EXCL_BR_LINE 4: nsfw error
393 SysMgrCallback<CSystemManager, &CSystemManager::OnProcessTermDetected>);
395 if (eFrameworkunifiedStatusOK != *l_eStatus_work) { // LCOV_EXCL_BR_LINE 4: nsfw error
396 // LCOV_EXCL_START 4: nsfw error
397 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
398 LOG_ERROR("FrameworkunifiedAttachCallbackToDispatcherWithFd()");
399 *l_isInitFail = true;
403 pthread_mutex_init(&sm_hist_mutex, NULL);
405 ReadPathFromEnvironmentVariables();
406 ReadUsingVMPlayerEnvironmentVariable();
408 // FIXME : Dump information from power_hal by using
410 if (eFrameworkunifiedStatusOK != (*l_eStatus_work = SetSystemModeInfoStruct())) {
411 LOG_ERROR("SetSystemModeInfoStruct()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
412 *l_isInitFail = true;
415 // Select configuration file for wakeup services
416 BOOL bIsVupMode = (m_SystemModeInfo.systemMode == epssinfPROGRAMMING) ? TRUE : FALSE; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
418 T_SS_SM_INIT_HOOK_IN_PARAM inPrm;
420 std::memset(&inPrm, 0, sizeof(inPrm));
421 inPrm.bIsVupMode = bIsVupMode;
423 if (eFrameworkunifiedStatusOK != (*l_eStatus_work = ss_sm_initHook(hApp, &inPrm, &m_productCustomPrm))) {
424 SS_ASERT_LOG(0, "ERROR: ss_sm_initHook()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
425 *l_isInitFail = true;
428 SetEnvVariableForVupMode(bIsVupMode);
430 // Get the Version Number
431 // GetVersionNumber() will report any errors
432 m_VersionNumberStruct.m_eSystemmanagerStatus = GetVersionNumber(m_VersionNumberStruct.m_VersionNumber);
434 *l_eStatus_work = GetBuildInfo(m_BuildInfoStr);
435 l_eStatus = *l_eStatus_work;
437 LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "GetBuildInfo()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
439 INTERFACEUNIFIEDLOG_WHEN_COMPILED; // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
441 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " %s priority is %d", SERVICE_SYSMANAGER, m_SystemManagerPriority);
442 FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, " %s was compiled at %s @ %s", __FILE__, __DATE__, __TIME__);
444 FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, " Host Processor Software Version is '0x%016llX'",
445 m_VersionNumberStruct.m_VersionNumber);
447 FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, " Host Processor Build Version is '%s'", m_BuildInfoStr.c_str());
449 LogESystemmanagerStatusEnums();
453 /*****************************************************************************/
455 @ingroup: CSystemManager
456 @brief: Initialize_callbacks Callback enrollment process
461 /*****************************************************************************/
462 void CSystemManager::Initialize_callbacks(HANDLE hApp, bool *l_isInitFail, EFrameworkunifiedStatus *l_eStatus_work) {
463 EFrameworkunifiedStatus l_eStatus;
465 m_GroupLaunchTimer = new (std::nothrow) TimerCtrl(eSM_TIMERS_END); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
466 if (NULL == m_GroupLaunchTimer) { // LCOV_EXCL_BR_LINE 5: Because new doesn't pass the failure case
467 // LCOV_EXCL_START 5: Because new doesn't pass the failure case
468 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
469 *l_eStatus_work = eFrameworkunifiedStatusNullPointer;
470 LOG_ERROR("new(std::nothrow)TimerCtrl(eSM_TIMERS_END)");
471 *l_isInitFail = true;
475 // LCOV_EXCL_BR_START 11:unexpected branch // NOLINT(whitespace/line_length)
476 m_GroupLaunchTimer->Initialize(hApp);
477 m_aTimerIDs[eSM_TIMER_GROUP_MONITOR] =
478 m_GroupLaunchTimer->CreateTimer(SysMgrCallback<CSystemManager, &CSystemManager::OnGroupLaunchTimerExpiry>);
479 m_aTimerIDs[eSM_TIMER_PROCESS_LAUNCH_MONITOR] =
480 m_GroupLaunchTimer->CreateTimer(SysMgrCallback<CSystemManager, &CSystemManager::OnProcessLaunchTimerExpiry>);
481 m_aTimerIDs[eSM_TIMER_HEARTBEAT_MONITOR] =
482 m_GroupLaunchTimer->CreateTimer(SysMgrCallback<CSystemManager, &CSystemManager::OnHeartBeatMonitorTimerExpiry>);
483 m_aTimerIDs[eSM_TIMER_PROCESSLAUNCHER_MONITOR] =
484 m_GroupLaunchTimer->CreateTimer(SysMgrCallback<CSystemManager,
485 &CSystemManager::OnProcessLaunchMonitorTimerExpiry>);
486 m_aTimerIDs[eSM_TIMER_CLIENT_START_MONITOR] =
487 m_GroupLaunchTimer->CreateTimer(SysMgrCallback<CSystemManager,
488 &CSystemManager::OnClientStartMonitorTimerExpiry>);
489 m_aTimerIDs[eSM_TIMER_NPP_STATUS_CHECK_MONITOR] =
490 m_GroupLaunchTimer->CreateTimer(SysMgrCallback<CSystemManager,
491 &CSystemManager::OnNPPStatusCheckMonitorTimerExpiry>);
492 m_aTimerIDs[eSM_TIMER__CWORD56__HEARTBEAT_RESPONSE] =
493 m_GroupLaunchTimer->CreateTimer(SysMgrCallback<CSystemManager,
494 &CSystemManager::On_CWORD56_HeartBeatResponseIntervalTimerExpiry>);
495 m_aTimerIDs[eSM_TIMER_LAUNCH_GROUP_TRIGGER_PROC_RESP_TIMER] =
496 m_GroupLaunchTimer->CreateTimer(SysMgrCallback<CSystemManager,
497 &CSystemManager::OnLaunchGroupTriggerProcessResponseTimerExpiry>);
498 m_aTimerIDs[eSM_TIMER_GROUP_LAUNCH_WAIT_TIMER] =
499 m_GroupLaunchTimer->CreateTimer(SysMgrCallback<CSystemManager, &CSystemManager::OnGroupLaunchWaitTimeout>);
500 m_aTimerIDs[eSM_TIMER_MODULE_CONNECT_WAIT_TIMER] =
501 m_GroupLaunchTimer->CreateTimer(SysMgrCallback<CSystemManager, &CSystemManager::OnModuleConnectWaitTimeout>);
502 m_aTimerIDs[eSM_TIMER_START_RESP_MONITOR_WAIT_TIMER] =
503 m_GroupLaunchTimer->CreateTimer(SysMgrCallback<CSystemManager, &CSystemManager::OnStartRespMonitorTimeout>);
504 m_aTimerIDs[eSM_TIMER_SHUTDOWN_COMPLETE_MONITOR] =
505 m_GroupLaunchTimer->CreateTimer(SysMgrCallback<CSystemManager,
506 &CSystemManager::OnShutdownCompleteMonitorTimeout>);
507 m_aTimerIDs[eSM_TIMER_CLIENT_STOP_MONITOR] =
508 m_GroupLaunchTimer->CreateTimer(SysMgrCallback<CSystemManager, &CSystemManager::OnClientStopMonitorTimerExpiry>);
510 FrameworkunifiedProtocolCallbackHandler l_cbArrayAnySource[] = {
511 // Command ID, Call back functions
512 { SS_SM_PROTOCOL_OPEN_SESSION_REQ, SysMgrCallback<CSystemManager, &CSystemManager::OnOpenSession> },
513 { SS_SM_CPU_RESET_REQ, SysMgrCallback<CSystemManager, &CSystemManager::OnCpuResetRequest> }
516 FrameworkunifiedProtocolCallbackHandler l_cbArrayGroupLaunchService[] = {
517 // Command ID, Call back functions
518 { SS_SM_GROUP_LAUNCH_TRIGGER, SysMgrCallback<CSystemManager, &CSystemManager::OnLaunchGroupTriggerProcessResponse> }
521 FrameworkunifiedProtocolCallbackHandler l_cbArrayNPPService[] = {
522 // Command ID, Call back functions
523 { NPS_NPP_READY_EVENT, SysMgrCallback<CSystemManager, &CSystemManager::OnNPPReadyEventCallback> },
524 { NPS_GET_READYSTATUS_ACK, SysMgrCallback<CSystemManager, &CSystemManager::OnNPPReadyStatusCallback> },
525 { NPS_NPP_STOP_ACK, SysMgrCallback<CSystemManager, &CSystemManager::OnNppStopComplete> }
528 FrameworkunifiedProtocolCallbackHandler l_cbArrayPowerService[] = {
529 // Command ID, Call back functions
530 { SS_SM_POWER_REQUEST_MSG, SysMgrCallback<CSystemManager, &CSystemManager::OnPowerRequestCallback> },
531 { SS_SM_WAKEUP_MODULES, SysMgrCallback<CSystemManager, &CSystemManager::OnWakeupCallback> },
532 { SS_SM_SYSTEM_MODE_INFO_REQ, SysMgrCallback<CSystemManager, &CSystemManager::OnSystemModeInfoRequest> },
533 { SS_SM_INITCOMP_REP, SysMgrCallback<CSystemManager, &CSystemManager::OnInitCompReportCallback> },
534 { SS_SM_SHUTDOWN_MODULES, SysMgrCallback<CSystemManager, &CSystemManager::OnShutdownModulesRequest> },
535 { SS_SM_FWD_STARTUP_CONFIRMATION_MSG_REQ,
536 SysMgrCallback<CSystemManager, &CSystemManager::OnSetStartupConfirmationDataRequest> }
539 FrameworkunifiedProtocolCallbackHandler l_cbArraySystemManager[] = {
540 // Command ID, Call back functions
541 { SS_SM_SendTriggerToSelf, SysMgrCallback<CSystemManager, &CSystemManager::OnLaunchGroupSelfTrigger> },
542 { SS_SM_DEBUG_DUMP_RSPN, SysMgrCallback<CSystemManager, &CSystemManager::OnDebugDumpResponseReceived> }
546 #define ATTACH_CBS_TO_DISPATCHER(L_ARRAY, CALLING_SERVICE_NAME) \
547 *l_eStatus_work = l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(hApp, \
548 CALLING_SERVICE_NAME, \
550 static_cast<UI_32>_countof(L_ARRAY)); \
551 if (eFrameworkunifiedStatusOK != l_eStatus) { \
552 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, \
553 " Error: FrameworkunifiedAttachCallbacksToDispatcher(%s) errored: %d/'%s'", \
556 GetStr(l_eStatus).c_str()); \
557 *l_isInitFail = true; \
559 // End of #define ATTACH_CBS_TO_DISPATCHER( CALLING_SERVICE_NAME, L_ARRAY )
561 // LCOV_EXCL_BR_START 15: marco defined above
562 // Note: This macro will exit this function if the embedded fnc errors.
563 ATTACH_CBS_TO_DISPATCHER(l_cbArrayAnySource, FRAMEWORKUNIFIED_ANY_SOURCE);
565 // Note: This macro will exit this function if the embedded fnc errors.
566 ATTACH_CBS_TO_DISPATCHER(l_cbArrayGroupLaunchService, SS_GROUP_LAUNCH_TRIGGER);
568 // Note: This macro will exit this function if the embedded fnc errors.
569 ATTACH_CBS_TO_DISPATCHER(l_cbArrayNPPService, FRAMEWORKUNIFIED_NS_NPSERVICE);
571 // Note: This macro will exit this function if the embedded fnc errors.
572 ATTACH_CBS_TO_DISPATCHER(l_cbArrayPowerService, SERVICE_POWER);
574 // Note: This macro will exit this function if the embedded fnc errors.
575 ATTACH_CBS_TO_DISPATCHER(l_cbArraySystemManager, SERVICE_SYSMANAGER);
580 // LCOV_EXCL_BR_START 11:unexpected branch // NOLINT(whitespace/line_length)
581 snprintf(pathBuf, sizeof(pathBuf), "/proc/%d/oom_score_adj", getpid());
582 std::ofstream fo(pathBuf);
583 fo << OOM_SCORE_ADJ_MIN << endl;
586 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "set OOM_SCORE_ADJ_MIN(SS_SysManager/%d)", getpid());
589 #undef ATTACH_CBS_TO_DISPATCHER
591 // LCOV_EXCL_BR_START 4: nsfw error
592 *l_eStatus_work = FrameworkunifiedSubscribeNotificationWithCallback(hApp, NTFY_BackupMgr_Availability,
593 SysMgrCallback<CSystemManager, &CSystemManager::OnBackupMgrAvailCallback>);
595 if (eFrameworkunifiedStatusOK != *l_eStatus_work) { // LCOV_EXCL_BR_LINE 4: nsfw error
596 // LCOV_EXCL_START 4: nsfw error
597 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
598 LOG_ERROR("FrameworkunifiedSubscribeNotificationWithCallback()");
599 *l_isInitFail = true;
603 if (eFrameworkunifiedStatusOK != (*l_eStatus_work = ErrorEventInit(hApp))) { // LCOV_EXCL_BR_LINE 6: function do not return error
604 // LCOV_EXCL_START 6: function do not return error
605 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
606 LOG_ERROR("ErrorEventInit()");
607 *l_isInitFail = true;
611 #ifndef SS_SM_SKIP_HEARTBEAT_INIT
612 // LCOV_EXCL_BR_START 6: function do not return error, expect nsfw error
613 if (eFrameworkunifiedStatusOK != (*l_eStatus_work = init_Heartbeat(hApp))) {
615 // LCOV_EXCL_START 6: function do not return error, expect nsfw error
616 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
617 LOG_ERROR("init_HeartBeat()");
618 *l_isInitFail = true;
622 #warning Test code - NOT calling init_Heartbeat(hApp)
623 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: NOT calling init_Heartbeat(hApp)");
625 #undef SS_SM_SKIP_HEARTBEAT_INIT
627 // LCOV_EXCL_BR_START 6: function do not return error, expect nsfw error
628 if (eFrameworkunifiedStatusOK != (*l_eStatus_work = init_process_launcher(hApp))) {
630 // LCOV_EXCL_START 6: function do not return error, expect nsfw error
631 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
632 LOG_ERROR("init_process_launcher()");
633 *l_isInitFail = true;
637 // LCOV_EXCL_BR_START 6: function do not return error, expect init error
638 if (eFrameworkunifiedStatusOK != (*l_eStatus_work = start_process_launching(hApp))) {
640 // LCOV_EXCL_START 6: function do not return error, expect init error
641 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
642 LOG_ERROR("start_process_launching()");
643 *l_isInitFail = true;
647 // LCOV_EXCL_BR_START 6: function do not return error, expect nsfw error
648 if (eFrameworkunifiedStatusOK != (*l_eStatus_work = init_sysmem_monitor(hApp))) {
650 // LCOV_EXCL_START 6: function do not return error, expect nsfw error
651 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
652 LOG_ERROR("init_sysmem_monitor()");
653 *l_isInitFail = true;
657 /// Internal thread monitoring start
658 // LCOV_EXCL_BR_START 11:unexpected branch // NOLINT(whitespace/line_length)
659 m_GroupLaunchTimer->StartTimer(m_aTimerIDs[eSM_TIMER_HEARTBEAT_MONITOR],
660 SS_HEARTBEAT_MONITOR_TIMER_CONFIG, 0,
661 SS_HEARTBEAT_MONITOR_TIMER_CONFIG, 0);
663 m_GroupLaunchTimer->StartTimer(
664 m_aTimerIDs[eSM_TIMER_PROCESSLAUNCHER_MONITOR],
665 SS_PROCESSLAUNCHER_MONITOR_TIMER_CONFIG, 0,
666 SS_PROCESSLAUNCHER_MONITOR_TIMER_CONFIG, 0);
668 m_GroupLaunchTimer->StartTimer(
669 m_aTimerIDs[eSM_TIMER_NPP_STATUS_CHECK_MONITOR],
670 SS_NPP_STATUS_CHECK_MONITOR_TIME_SEC, 0,
671 SS_NPP_STATUS_CHECK_MONITOR_TIME_SEC, 0);
676 /*****************************************************************************/
678 @ingroup: CSystemManager
679 @brief: Initialization
684 /*****************************************************************************/
685 EFrameworkunifiedStatus CSystemManager::Initialize(HANDLE hApp) {
686 bool l_isInitFail = false;
687 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
689 PsmFactorT l_startup_factor;
691 // Need to call Lock System Initialize API once in the system
692 ret = CL_LockSystemInit();
694 fprintf(stderr, "SS_SysManager/%s/Error: CL_LockSystemInit() errored: %d\n", __FUNCTION__, ret);
697 ret = CL_LockProcessInit();
699 fprintf(stderr, "SS_SysManager/%s/Error: CL_LockProcessInit() errored: %d\n", __FUNCTION__, ret);
703 ret = PsmGetStartupFactor(hApp, &l_startup_factor);
705 if ((static_cast<UI_32>(l_startup_factor) & PSM_RESET_HISTORY) == PSM_RESET_HISTORY) {
706 DGCODE_RET_API l_ret = DGCODE_RET_ERROR;
707 uint64_t l_SystemResetRobCode = 0;
708 DGCODE_ROB_SSR_INFO l_info;
709 if (l_startup_factor == PSM_FACTOR_AGL_WITH_HISTORY) {
710 l_SystemResetRobCode = 0x2219; // AGL cause
711 } else if (l_startup_factor == PSM_FACTOR_TIER1_WITH_HISTORY) {
712 l_SystemResetRobCode = 0x221A; // Tier1 cause
713 } else if (l_startup_factor == PSM_FACTOR_USER_WITH_HISTORY) {
714 l_SystemResetRobCode = 0x8027; // USER cause
719 if (l_SystemResetRobCode != 0) {
720 memset(&l_info, 0x00, sizeof(DGCODE_ROB_SSR_INFO));
722 l_ret = Diag_PutRoBInfo(hApp, l_SystemResetRobCode, &l_info);
723 if (l_ret == DGCODE_RET_ERROR) {
724 LOG_ERROR("Diag_PutRoBInfo()");
729 (void)fprintf(stderr, "SS_SysManager/%s/ERROR:start-up factor not get\n", __FUNCTION__);
732 m_isIlgReset = (false == GetSyscomPowerStatusInfo(hApp)) ? TRUE : FALSE;
733 if (m_isIlgReset || ("elog" == m_bootOpt)) {
734 fprintf(stderr, "SS_SysManager/%s/Error: ILGRST LOG SAVE\n", __func__);
735 StoreDebugLogs(hApp, SS_STORELOGS_ILLEGAL);
737 StoreDebugLogs(hApp, SS_STORELOGS_ACCOFFON);
740 if (m_isIlgReset == TRUE) {
741 // overwrite AGL_ILLRESET_FLAG.
742 uint32_t tmp = static_cast<uint32_t>(m_isIlgReset);
743 if (PowerHalSetResetInfo(AGL_ILLRESET_FLAG, tmp)) {
744 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
745 "Could not set AGL_ILLRESET_FLAG to power_hal");
748 // keep last value of AGL_ILLRESET_FLAG.
751 FRAMEWORKUNIFIED_SET_ZONES();
752 NsLogSetLogMethod(LPRINT | LMSGQ);
753 // FRAMEWORKUNIFIEDLOG can not be used until this line
755 m_ClProcessSigFd = CL_ProcessInit(); // LCOV_EXCL_BR_LINE 4: nsfw error
756 if (m_ClProcessSigFd == -1) { // LCOV_EXCL_BR_LINE 4: nsfw error
757 // LCOV_EXCL_START 4: nsfw error
758 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
759 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: CL_ProcessInit()");
764 ret = CL_MonitorInit(CL_MONITOR_INIT_SYSTEM);
766 fprintf(stderr, "SS_SysManager/%s/Error: CL_MonitorInit() errored: %d\n", __FUNCTION__, ret);
770 // Threads MUST NOT be started until this line
771 // ===== Initialization No.1
772 Initialize_memory(hApp, &l_isInitFail, &l_eStatus, m_isIlgReset);
774 // ===== Initialization No.2
775 Initialize_callbacks(hApp, &l_isInitFail, &l_eStatus);
777 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
782 EFrameworkunifiedStatus CSystemManager::SetEnvVariableForVupMode(BOOL bIsVupMode) {
783 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
784 const CHAR SmVupModeEnvVariable[] = "SM_VUP_MODE";
785 const CHAR *l_pValue = bIsVupMode ? "y" : "n"; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
787 if (0 != setenv(SmVupModeEnvVariable, l_pValue, 1)) { // LCOV_EXCL_BR_LINE 5: standard lib error
788 // LCOV_EXCL_START 5: standard lib error
789 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
791 l_eStatus = eFrameworkunifiedStatusFail;
798 int CSystemManager::CreateRtUsb(void) {// LCOV_EXCL_START 8: dead code
799 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
803 ret = mkdir("/var/run", 0775);
804 if ((ret < 0) && (errno != EEXIST)) {
809 case 0: /* child process */
811 struct sched_param param;
814 exec = const_cast<char *>(TR_USB_PATH);
815 param.sched_priority = 0;
816 policy = SCHED_OTHER;
817 if (sched_setscheduler(getpid(), policy, ¶m) < 0) {
821 if (setpriority(PRIO_PROCESS, getpid(), 0) < 0) {
826 if (execlp(exec, exec, NULL) < 0) {
838 default: /* parent process */
846 bool CSystemManager::StoreDebugLogs(const HANDLE h_app,
847 SS_STORELOGS_OPE_TYPE type) {
848 bool isMountRamd = false;
849 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
852 if (!GetDramPowerStatusInfo(h_app)) {
854 } else if (access(SS_SM_TEMP_FILE_FOR_STORE_LOGS, F_OK) == 0) {
855 fprintf(stderr, "SS_SysManager/%s/Error: Skip StoreDebugLogs\n", __FUNCTION__);
861 if (type == SS_STORELOGS_ILLEGAL) {
862 UI_32 l_ErrLogCount = 0;
863 if (PowerHalGetResetInfo(AGL_ERRLOG_COUNTER, &l_ErrLogCount)) {
864 fprintf(stderr, "SS_SysManager/%s/Error: "
865 "Could not read AGL_ERRLOG_COUNTER from power_hal\n", __FUNCTION__);
869 if (l_ErrLogCount >= SS_SM_ERR_LOGGING_LIMIT) {
870 fprintf(stderr, "SS_SysManager/%s/Error: "
871 "Skip StoreDebugLogs by continuous error l_ErrLogCount=%lu\n",
872 __FUNCTION__, l_ErrLogCount);
877 if (PowerHalSetResetInfo(AGL_ERRLOG_COUNTER, l_ErrLogCount)) {
878 // Just logging, don't go to ERROR.
879 fprintf(stderr, "SS_SysManager/%s/Error: "
880 "Could not write AGL_ERRLOG_COUNTER to power_hal\n", __FUNCTION__);
882 } else if (type == SS_STORELOGS_ACCOFFON) {
883 if (0 != unlink(SS_LOGGER_SAVE_INTERFACEUNIFIEDLOG_FLAG)) {
884 fprintf(stderr, "SS_SysManager/%s/Error: ACCOFFON LOG SAVE\n", __FUNCTION__);
892 int fd = open(SS_SM_TEMP_FILE_FOR_STORE_LOGS,
893 O_CREAT | O_TRUNC | O_RDWR, 00664);
894 if (-1 == fd) { // LCOV_EXCL_BR_LINE 5:fd must not be -1
895 fprintf(stderr, "SS_SysManager/%s/Error: Failed open %s errno: %d\n",
896 __FUNCTION__, SS_SM_TEMP_FILE_FOR_STORE_LOGS, errno);
901 FRAMEWORKUNIFIED_SET_ZONES(); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
902 NsLogSetLogMethod(LPRINT | LMSGQ);
904 if (eFrameworkunifiedStatusOK != (l_eStatus = SS_LoggerStoreLogs(type))) { // LCOV_EXCL_BR_LINE 200: always return OK
905 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
906 fprintf(stderr, "SS_SysManager/%s/Error: SS_LoggerStoreDebugLogs() errored: %d\n", __FUNCTION__, l_eStatus); // LCOV_EXCL_LINE 200: always return OK // NOLINT(whitespace/line_length)
908 // Close accessing the RAMD by FRAMEWORKUNIFIEDLOG for RAMD initialization
911 if (0 != unlink(SS_SM_TEMP_FILE_FOR_STORE_LOGS)) {
912 SS_ASERT_ERRNO(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
916 } else if (pid == -1) { // LCOV_EXCL_BR_LINE 5:fork error case
917 // LCOV_EXCL_START 5:fork error case
918 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
919 fprintf(stderr, "SS_SysManager/%s/Error: ASSERT %d\n", __FUNCTION__, __LINE__);
922 if (-1 == waitpid(pid, NULL, 0)) { // LCOV_EXCL_BR_LINE 5:waitpid error case
923 // LCOV_EXCL_START 5:waitpid error case
924 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
925 fprintf(stderr, "SS_SysManager/%s/Error: ASSERT %d\n", __FUNCTION__, __LINE__);
933 #define SS_SM_SCAC_DEVICE_NODE "/dev/scac_driver"
934 #define SS_SM_SCAC_CMD_SHUTDOWN 0x3000
936 EFrameworkunifiedStatus CSystemManager::SecureChipOff() {
937 static bool isOffDone = false;
938 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
943 fd = open(SS_SM_SCAC_DEVICE_NODE, O_RDWR);
945 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "open(%s) ERR", SS_SM_SCAC_DEVICE_NODE);
946 l_eStatus = eFrameworkunifiedStatusFail;
948 res = ioctl(fd, SS_SM_SCAC_CMD_SHUTDOWN);
949 if (res < 0) { // LCOV_EXCL_BR_LINE 5: standard lib error
950 // LCOV_EXCL_START 5: standard lib error
951 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
952 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "ioctl(SS_SM_SCAC_CMD_SHUTDOWN) ERR");
953 l_eStatus = eFrameworkunifiedStatusFail;
962 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "Skip Chip Off");
968 UI_32 CSystemManager::InProgressStateToSendMsg() const {
969 UI_32 l_iCmd = SS_SYSTEM_MANAGER_PROTOCOL_ENDING_INDEX;
970 switch (m_SMCurrentState) {
971 case SS_SM_APPS_PRE_START_IN_PROGRESS:
972 l_iCmd = SS_SM_PRE_START;
974 case SS_SM_APPS_PRE_STOP_IN_PROGRESS:
975 l_iCmd = SS_SM_PRE_STOP;
977 case SS_SM_APPS_BACKGROUND_START_IN_PROGRESS:
978 l_iCmd = SS_SM_BACKGROUND_START;
980 case SS_SM_APPS_BACKGROUND_STOP_IN_PROGRESS:
981 l_iCmd = SS_SM_BACKGROUND_STOP;
983 case SS_SM_APPS_START_IN_PROGRESS:
984 l_iCmd = SS_SM_START;
992 SMModuleState CSystemManager::InProgressStateToState() const {
993 SMModuleState l_state = MODULE_STATE_INVALID;
994 switch (m_SMCurrentState) {
995 case SS_SM_APPS_PRE_START_IN_PROGRESS:
996 l_state = MODULE_STATE_STARTED_PRE;
998 case SS_SM_APPS_PRE_STOP_IN_PROGRESS:
999 l_state = MODULE_STATE_STOPPED_PRE;
1001 case SS_SM_APPS_BACKGROUND_START_IN_PROGRESS:
1002 l_state = MODULE_STATE_STARTED_BACKGROUND;
1004 case SS_SM_APPS_BACKGROUND_STOP_IN_PROGRESS:
1005 l_state = MODULE_STATE_STOPPED_BACKGROUND;
1007 case SS_SM_APPS_START_IN_PROGRESS:
1008 l_state = MODULE_STATE_STARTED;
1016 ///////////////////////////////////////////////////////////////////////////////
1017 /// \ingroup SetSystemModeInfoStruct
1018 /// Read ( or initialize ) NVM and set the SystemModeInfo structure
1020 /// \return EFrameworkunifiedStatus
1021 /// Success ==> eFrameworkunifiedStatusOK
1022 /// Failure ==> Other values
1023 ///////////////////////////////////////////////////////////////////////////////
1024 EFrameworkunifiedStatus CSystemManager::SetSystemModeInfoStruct() {
1025 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1026 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
1028 if (m_UsingVMPlayer) {
1029 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " 'm_UsingVMPlayer' is True,"
1030 " using default SystemModeInfo values");
1031 m_SystemModeInfo.limpHomeCutoff = epslhcDISABLED;
1032 m_SystemModeInfo.productionMode = epspmDISABLED;
1033 m_SystemModeInfo.transportMode = epstmDISABLED;
1034 m_SystemModeInfo.systemMode = epssinfNORMAL;
1035 m_DataResetMode = e_SS_SM_DATA_RESET_MODE_NONE;
1037 m_ProgUpdateState = SS_SM_PROG_UPDATE_STATE_NONE;
1038 // Don't change the m_SystemModeInfo.startupStage.
1039 // It is set dynamically as System Manager initializes the _CWORD102_.
1042 if (PowerHalGetResetInfo(AGL_RESET_COUNTER, &m_ResetCount)) {
1043 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1044 "Could not read AGLRESET_COUNTER from power_hal, assume to 0");
1048 if (PowerHalGetResetInfo(AGL_PROGUPDATE_STATE, &m_ProgUpdateState)) {
1049 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1050 "Could not read AGL_PROGUPDATE_STATE from power_hal, "
1051 "assume to SS_SM_PROG_UPDATE_STATE_NONE");
1052 m_ProgUpdateState = SS_SM_PROG_UPDATE_STATE_NONE;
1055 if (PowerHalGetResetInfo(AGL_DATARESET_STATE, &tmp)) {
1056 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1057 "Could not read AGL_DATARESET_STATE from power_hal, "
1058 "assume to e_SS_SM_DATA_REESET_MODE_NONE");
1059 m_DataResetMode = e_SS_SM_DATA_RESET_MODE_NONE;
1061 m_DataResetMode = static_cast<ESMDataResetModeInfo>(tmp);
1063 m_SystemModeInfo.systemMode = epssinfNORMAL;
1064 } // End else ! m_UsingVMPlayer
1066 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1068 } // End of EFrameworkunifiedStatus CSystemManager::SetSystemModeInfoStruct()
1070 ///////////////////////////////////////////////////////////////////////////////
1071 /// \ingroup ClearDramBackupInfo
1076 /// \return EFrameworkunifiedStatus
1077 /// Success ==> eFrameworkunifiedStatusOK
1078 /// Failure ==> Other values
1079 ///////////////////////////////////////////////////////////////////////////////
1080 EFrameworkunifiedStatus CSystemManager::ClearDramBackupInfo(HANDLE hApp) {
1081 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
1083 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1085 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "PsmClrRamJudgeFlgPower()");
1086 ret = PsmClrRamJudgeFlgPower(hApp);
1087 if (ret != 0) { // LCOV_EXCL_BR_LINE 11: Excluded due to gcov constraints (others)
1088 SS_ASERT_ERRNO(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1089 l_eStatus = eFrameworkunifiedStatusFail;
1092 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1096 ///////////////////////////////////////////////////////////////////////////////
1097 /// \ingroup CloseApplication
1098 /// Process request to close Application
1103 /// \return EFrameworkunifiedStatus
1104 /// Success ==> eFrameworkunifiedStatusOK
1105 /// Failure ==> Other values
1106 ///////////////////////////////////////////////////////////////////////////////
1107 EFrameworkunifiedStatus CSystemManager::CloseApplication(HANDLE hApp) { // LCOV_EXCL_START 6: Because the condition cannot be set
1108 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1109 EFrameworkunifiedStatus l_eStatus;
1111 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1113 if (eFrameworkunifiedStatusOK
1114 != (l_eStatus = FrameworkunifiedPublishServiceAvailability(hApp, FALSE))) {
1115 LOG_ERROR("FrameworkunifiedPublishServiceAvailability(hApp,FALSE)");
1116 } else if (eFrameworkunifiedStatusOK != (l_eStatus =
1117 FrameworkunifiedUnRegisterServiceAvailabilityNotification(hApp))) {
1118 LOG_ERROR("FrameworkunifiedUnRegisterServiceAvailabilityNotification(hApp)");
1120 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Successful");
1123 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1125 } // End of EFrameworkunifiedStatus CSystemManager::CloseApplication(HANDLE hApp)
1128 ///////////////////////////////////////////////////////////////////////////////
1129 /// \ingroup SMStateStartCompleteEntry
1130 /// entry for SM module state(SS_SM_APPS_START_COMPLETE)
1134 /// \return EFrameworkunifiedStatus
1135 ///////////////////////////////////////////////////////////////////////////////
1136 VOID CSystemManager::SMStateStartCompleteEntry(HANDLE hApp) {
1137 EFrameworkunifiedStatus l_eStatus;
1139 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
1140 "All %d groups have been sent system_manager protocol message, sending Start Complete to _CWORD56_",
1141 m_SystemStarter.get_id());
1142 CALL_AND_LOG_STATUS_IF_ERRORED( // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1143 send_power_request_complete_response(hApp, "Startup")); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1145 CALL_AND_LOG_STATUS(PublishPowerOnOffNotification(hApp)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1147 if (m_InitialBoot == true) {
1148 m_InitialBoot = false;
1150 const ESMServiceWakeupStatus l_svcWupStatus = e_SS_SM_SVC_WAKEUP_STATUS_COMPLETE;
1152 CALL_AND_LOG_STATUS( // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1153 FrameworkunifiedNPPublishNotification(hApp, NTFY_SSServiceWakeupStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1154 &l_svcWupStatus, sizeof(ESMServiceWakeupStatus))); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1156 // If all modules are restarted, a passive warning will be issued
1157 // indicating that Heartbeat is already running.
1159 UI_32 l_list_num = static_cast<UI_32>(m_HBList.size());
1160 if (SS_MAX_NUM_MODULES < l_list_num) {
1161 l_list_num = SS_MAX_NUM_MODULES;
1162 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
1163 " Warn: SS_MAX_NUM_MODULES '%d' < m_HBList.size '%d'",
1164 SS_MAX_NUM_MODULES, l_list_num);
1167 CHAR send_data[sizeof(l_list_num)
1168 + (l_list_num * SS_SM_HB_MAX_PROC_NAME_SIZE)
1169 + sizeof(m_SMConfig.HBConfig)];
1170 CHAR* p_prm = &send_data[0];
1172 memcpy(p_prm, reinterpret_cast<char *>(&m_SMConfig.HBConfig), sizeof(m_SMConfig.HBConfig));
1173 p_prm = p_prm + sizeof(m_SMConfig.HBConfig);
1174 memcpy(p_prm, reinterpret_cast<char *>(&l_list_num), sizeof(l_list_num));
1175 p_prm = p_prm + sizeof(l_list_num);
1177 for (UI_32 i = 0; i < l_list_num; i++) {
1178 snprintf(p_prm, SS_SM_HB_MAX_PROC_NAME_SIZE, "%s", m_HBList[i].c_str());
1179 p_prm = p_prm + SS_SM_HB_MAX_PROC_NAME_SIZE;
1181 l_eStatus = SendRequestToHeartBeat(hApp, SS_HEARTBEAT_START, &send_data, static_cast<UI_32>(sizeof(send_data))); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
1182 LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "SendRequestToHeartBeat()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1184 m_DataResetMode = e_SS_SM_DATA_RESET_MODE_NONE;
1186 uint32_t tmp = static_cast<uint32_t>(m_DataResetMode);
1187 if (PowerHalSetResetInfo(AGL_DATARESET_STATE, tmp)) {
1188 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1189 "Could not set AGL_DATARESET_STATE to power_hal");
1193 m_ProgUpdateState = SS_SM_PROG_UPDATE_STATE_NONE;
1194 if (PowerHalSetResetInfo(AGL_PROGUPDATE_STATE, m_ProgUpdateState)) {
1195 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1196 "Could not set AGL_PROGUPDATE_STATE to power_hal");
1199 m_isIlgReset = FALSE;
1201 uint32_t tmp = static_cast<uint32_t>(m_isIlgReset);
1202 if (PowerHalSetResetInfo(AGL_ILLRESET_FLAG, tmp)) {
1203 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1204 "Could not set AGL_ILLRESET_FLAG to power_hal");
1208 if (access(SS_SM_TEMP_FILE_FOR_STORE_LOGS, F_OK) == 0) {
1209 SS_ASERT_ERRNO(0 == unlink(SS_SM_TEMP_FILE_FOR_STORE_LOGS)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1213 for (vector<std::string>::iterator protectedSvc =
1214 m_productCustomPrm.protectedSvcs.begin();
1215 protectedSvc != m_productCustomPrm.protectedSvcs.end();
1217 ModuleLaunchListIter l_ModuleListIter;
1218 l_eStatus = GetModuleIterator(protectedSvc->c_str(), l_ModuleListIter);
1219 if (eFrameworkunifiedStatusOK == l_eStatus) {
1220 if ((l_ModuleListIter->IsModuleState(MODULE_STATE_STARTED))
1221 || (l_ModuleListIter->IsModuleState(MODULE_STATE_LAUNCHED)
1222 && !l_ModuleListIter->is_start_required)) {
1225 snprintf(pathBuf, 128, "/proc/%d/oom_score_adj", l_ModuleListIter->pid); // NOLINT
1226 std::ofstream fo(pathBuf); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
1227 fo << OOM_SCORE_ADJ_MIN << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
1228 fo.close(); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
1229 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "set OOM_SCORE_ADJ_MIN(%s/%d)",
1230 l_ModuleListIter->name.c_str(), l_ModuleListIter->pid);
1232 SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1237 for (vector<std::string>::iterator groupRelaunchSvc =
1238 m_productCustomPrm.groupRelaunchSvcs.begin();
1239 groupRelaunchSvc != m_productCustomPrm.groupRelaunchSvcs.end();
1240 groupRelaunchSvc++) {
1241 ModuleLaunchListIter l_ModuleListIter;
1242 l_eStatus = GetModuleIterator(groupRelaunchSvc->c_str(), l_ModuleListIter);
1243 if (eFrameworkunifiedStatusOK == l_eStatus) {
1244 if ((l_ModuleListIter->IsModuleState(MODULE_STATE_STARTED))
1245 || (l_ModuleListIter->IsModuleState(MODULE_STATE_LAUNCHED)
1246 && !l_ModuleListIter->is_start_required)) {
1247 GroupRelaunchModuleParams l_param; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
1248 l_param.name = l_ModuleListIter->name.c_str();
1249 m_GroupRelaunchModuleList.push_back(l_param);
1251 if (l_ModuleListIter->retry_cnt > m_GroupRelaunchLimit) {
1252 m_GroupRelaunchLimit = l_ModuleListIter->retry_cnt;
1255 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "GroupRelaunchSvcs:%s(%d)",
1256 l_ModuleListIter->name.c_str(), l_ModuleListIter->pid);
1258 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "%s is not Launched", groupRelaunchSvc->c_str());
1261 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "%s is not exist", groupRelaunchSvc->c_str());
1264 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "GroupRelaunchLimit:%d", m_GroupRelaunchLimit);
1266 SendDeferMsg(hApp); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
1267 } // End of VOID CSystemManager::SMStateStartCompleteEntry()
1269 ///////////////////////////////////////////////////////////////////////////////
1270 /// \ingroup SMStateEntry
1271 /// entry for SM module state
1275 /// \return EFrameworkunifiedStatus
1276 ///////////////////////////////////////////////////////////////////////////////
1277 VOID CSystemManager::SMStateEntry(HANDLE hApp, SS_SMModuleState l_SMState) {
1278 switch (l_SMState) {
1279 case SS_SM_APPS_START_COMPLETE:
1280 case SS_SM_APPS_PRE_RUN_COMPLETE:
1281 case SS_SM_APPS_BACKGROUND_RUN_COMPLETE:
1282 SMStateStartCompleteEntry(hApp);
1287 } // End of VOID CSystemManager::SMStateEntry(SS_SMModuleState l_SMState)
1289 ///////////////////////////////////////////////////////////////////////////////
1290 /// \ingroup SMStateExit
1291 /// exit for SM module state
1295 /// \return EFrameworkunifiedStatus
1296 ///////////////////////////////////////////////////////////////////////////////
1297 VOID CSystemManager::SMStateExit(HANDLE hApp, SS_SMModuleState l_SMState) {
1298 switch (l_SMState) {
1299 case SS_SM_APPS_START_COMPLETE:
1304 } // End of VOID CSystemManager::SMStateExit(SS_SMModuleState l_SMState)
1306 ///////////////////////////////////////////////////////////////////////////////
1307 /// \ingroup SMSetState
1308 /// set module state
1312 /// \return EFrameworkunifiedStatus
1313 ///////////////////////////////////////////////////////////////////////////////
1314 VOID CSystemManager::SMSetState(HANDLE hApp, SS_SMModuleState l_SMNewState) {
1315 // FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1316 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "%s -> %s",
1317 GetStr(m_SMCurrentState).c_str(), GetStr(l_SMNewState).c_str());
1319 if (l_SMNewState != m_SMCurrentState) {
1320 SMStateExit(hApp, m_SMCurrentState);
1322 m_SMCurrentState = l_SMNewState;
1324 SMStateEntry(hApp, m_SMCurrentState);
1326 // FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1329 ///////////////////////////////////////////////////////////////////////////////
1330 /// \ingroup register_all_notification_callbacks
1331 /// register all notifications and callbacks with NP_NPS
1332 /// this function gets called when NP_NPS reply launch complete
1336 /// \return EFrameworkunifiedStatus
1337 ///////////////////////////////////////////////////////////////////////////////
1338 EFrameworkunifiedStatus CSystemManager::register_all_notification_callbacks(HANDLE hApp) {
1339 EFrameworkunifiedStatus l_eStatus;
1340 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1342 FrameworkunifiedNotificationsList userModeNotificationsBOOL[] = { {
1343 NTFY_SSSystemMgrPowerOnOff, sizeof(BOOL), eFrameworkunifiedStateVar }, {
1344 NTFY_SSSystemMgrUserMode, sizeof(BOOL), eFrameworkunifiedStateVar } };
1346 FrameworkunifiedNotificationsList userModeNotificationsStruct[] = { {
1347 NTFY_SSSystemMgrPowerOnOff,
1348 sizeof(T_SS_SM_UserModeOnOffNotification_Struct), eFrameworkunifiedStateVar }, {
1349 NTFY_SSSystemMgrUserMode,
1350 sizeof(T_SS_SM_UserModeOnOffNotification_Struct), eFrameworkunifiedStateVar } };
1352 FrameworkunifiedNotificationsList sm_notifications[] = {
1353 { NTFY_SSSystemMgrStartUpType, sizeof(EPWR_SC_WAKEUP_TYPE), eFrameworkunifiedStateVar },
1354 { NTFY_SSSystemMgrDataReset, sizeof(ESMDataResetType), eFrameworkunifiedStateVar },
1355 { NTFY_SSSystemMgrShutdownStarted, 0, eFrameworkunifiedStateVar },
1356 { NTFY_SSServiceWakeupStatus, sizeof(ESMServiceWakeupStatus), eFrameworkunifiedStateVar },
1357 { NTFY_SSNeedAplRestart, 0, eFrameworkunifiedStateVar } };
1359 if (m_SMConfig.UMConfig.IsUserModeNotificationABOOL) {
1360 l_eStatus = FrameworkunifiedNPRegisterNotifications(hApp, userModeNotificationsBOOL,
1361 static_cast<UI_32>(_countof(userModeNotificationsBOOL)));
1363 l_eStatus = FrameworkunifiedNPRegisterNotifications(hApp,
1364 userModeNotificationsStruct,
1365 static_cast<UI_32>(_countof(userModeNotificationsStruct)));
1368 if (eFrameworkunifiedStatusOK != l_eStatus) {
1369 LOG_ERROR("FrameworkunifiedNPRegisterNotifications(userModeNotifications)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1370 } else if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedNPRegisterNotifications(hApp, sm_notifications, static_cast<UI_32>(_countof(sm_notifications))))) { // LCOV_EXCL_BR_LINE 4:NSFW error case //NOLINT (whitespace/line_length)
1371 // LCOV_EXCL_START 4: nsfw error code
1372 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1373 LOG_ERROR("FrameworkunifiedNPRegisterNotifications(sm_notifications)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1375 } else if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedRegisterServiceAvailabilityNotification(hApp, NTFY_SSSystemMgrAvailability))) { // LCOV_EXCL_BR_LINE 4:NSFW error case //NOLINT (whitespace/line_length)
1376 // LCOV_EXCL_START 4: nsfw error code
1377 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1378 LOG_ERROR("FrameworkunifiedRegisterServiceAvailabilityNotification(" // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1379 NTFY_SSSystemMgrAvailability ")"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1381 } else if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedPublishServiceAvailability(hApp, TRUE))) { // LCOV_EXCL_BR_LINE 4:NSFW error case //NOLINT (whitespace/line_length)
1382 // LCOV_EXCL_START 4: nsfw error code
1383 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1384 LOG_ERROR("FrameworkunifiedPublishServiceAvailability('NTFY_SSSystemMgrAvailability ', TRUE)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1387 LOG_SUCCESS("FrameworkunifiedPublishServiceAvailability('NTFY_SSSystemMgrAvailability ', TRUE)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1389 REC_HIST_IF_SUCCESSFUL(NTFY_SSSystemMgrAvailability, m_PubCmdHist, // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1390 m_PubHistIter, "", l_eStatus); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1393 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1397 ///////////////////////////////////////////////////////////////////////////////
1403 ///////////////////////////////////////////////////////////////////////////////
1404 EFrameworkunifiedStatus CSystemManager::init_Heartbeat(HANDLE hApp) {
1405 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
1406 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1408 FrameworkunifiedProtocolCallbackHandler hb_protocol_callbacks[] = { {
1409 SS_HEARTBEAT_PERIODIC_RESP, SysMgrCallback<CSystemManager,
1410 &CSystemManager::OnHeartBeatThreadHeartbeatResponse> }, {
1411 SS_HEARTBEAT_ERROR_DETECTED, SysMgrCallback<CSystemManager,
1412 &CSystemManager::OnHeartBeatErrorDetected> }, {
1413 SS_HEARTBEAT_AVAIL_CHECK_RESP, SysMgrCallback<CSystemManager,
1414 &CSystemManager::OnCheckAvailResponse> } }; // LCOV_EXCL_BR_LINE 11:unexpected branch
1416 // Subscribe to Notifications (All required notifications)
1417 if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(hApp, SS_SMHeartbeat, hb_protocol_callbacks, static_cast<UI_32>(_countof(hb_protocol_callbacks))))) { // LCOV_EXCL_BR_LINE 4:NSFW error case //NOLINT (whitespace/line_length)
1418 // LCOV_EXCL_START 4: nsfw error
1419 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1420 LOG_ERROR("FrameworkunifiedAttachCallbacksToDispatcher(hb_notification_handlers)");
1422 } else if (NULL == (m_hHeartbeatThread.m_ThreadHdl = FrameworkunifiedCreateChildThreadWithPriority(hApp, SS_SMHeartbeat, HBThreadStart, HBThreadStop, PR_SMHEARTBEAT))) { // LCOV_EXCL_BR_LINE 4:NSFW error case //NOLINT (whitespace/line_length)
1423 // LCOV_EXCL_START 4: nsfw error
1424 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1425 l_eStatus = eFrameworkunifiedStatusThreadNotExist;
1426 m_hHeartbeatThread.m_ThreadState = eSM_ThreadNotExist;
1427 LOG_ERROR("FrameworkunifiedCreateChildThreadWithPriority(hApp, SS_SMHeartbeat)");
1429 } else if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedStartChildThread(hApp, m_hHeartbeatThread.m_ThreadHdl, 0, NULL))) { // LCOV_EXCL_BR_LINE 4:NSFW error case //NOLINT (whitespace/line_length)
1430 // LCOV_EXCL_START 4: nsfw error
1431 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1432 m_hHeartbeatThread.m_ThreadState = eSM_ThreadNotExist;
1433 LOG_ERROR("FrameworkunifiedStartChildThread(SS_SMHeartbeat)");
1436 m_hHeartbeatThread.m_ThreadState = eSMThreadIsFine;
1439 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1443 EFrameworkunifiedStatus CSystemManager::init_sysmem_monitor(HANDLE hApp) {
1444 EFrameworkunifiedStatus l_eStatus;
1445 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1447 FrameworkunifiedProtocolCallbackHandler sysmem_protocol_callbacks[] = { {
1448 eSysMemThrdCmd_SYS_LOW_MEMORY, SysMgrCallback<CSystemManager,
1449 &CSystemManager::OnLowSystemMemory> } }; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
1450 // LCOV_EXCL_BR_START 4: For setting the initialization conditions at SystemManager startup
1451 if (eFrameworkunifiedStatusOK
1452 != (l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(
1454 m_SysMemMonitor.GetThreadName().c_str(), sysmem_protocol_callbacks,
1455 static_cast<UI_32>(_countof(sysmem_protocol_callbacks))))) {
1456 // LCOV_EXCL_BR_STOP
1457 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1458 LOG_ERROR("FrameworkunifiedAttachCallbacksToDispatcher()"); // LCOV_EXCL_LINE 4: For setting the initialization conditions at SystemManager startup
1460 m_SysMemMonitor.SetSLMConfigData(m_SMConfig.SLMConfig); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
1461 l_eStatus = m_SysMemMonitor.Initialize(hApp); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
1462 LOG_ERROR_REC_HIST_IF_ERRORED // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup
1463 (l_eStatus, "m_SysMemMonitor.Initialize(hApp);"); // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup
1466 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1470 ///////////////////////////////////////////////////////////////////////////////
1476 ///////////////////////////////////////////////////////////////////////////////
1477 EFrameworkunifiedStatus CSystemManager::OnGroupLaunchTimerExpiry(HANDLE hThread) { // LCOV_EXCL_START 6: Because the condition cannot be set
1478 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1479 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
1480 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1481 UI_32 l_launchID = m_oSystemLauncher.get_id();
1483 FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, " Received from group %d", l_launchID);
1484 REC_HIST_IF_SUCCESSFUL("SM_TIMER_GROUP_MONITOR", m_TimerCmdHist,
1485 m_TimerHistIter, "TIMER", l_eStatus);
1487 LogGroupModulesState(l_launchID,
1488 " Group launch timer expired, processing next group.");
1490 if (NULL == hThread) {
1491 l_eStatus = eFrameworkunifiedStatusInvldParam;
1492 LOG_ERROR("NULL == hThread");
1494 // FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Timer expired for group id,%d",m_oSystemLauncher.get_id());
1495 if (!m_oSystemLauncher.is_end()) {
1496 l_launchID = m_oSystemLauncher.advance_id();
1497 if (eFrameworkunifiedStatusOK != (l_eStatus = OnLaunchGroup(hThread))) {
1498 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1499 " Error: OnLaunchGroup(%d) errored: %d/'%s'", l_launchID,
1500 l_eStatus, GetStr(l_eStatus).c_str());
1505 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1507 } // End of EFrameworkunifiedStatus CSystemManager::OnGroupLaunchTimerExpiry( HANDLE hThread )
1510 ///////////////////////////////////////////////////////////////////////////////
1516 ///////////////////////////////////////////////////////////////////////////////
1517 EFrameworkunifiedStatus CSystemManager::FindNameOfTerminatedProcess(SI_32 f_pid, SS_String &f_ModuleName) {
1518 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusDbRecNotFound;
1519 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1521 GroupLaunchMapIter l_GroupIterator = m_MapProclaunchGrps.begin();
1522 if (l_GroupIterator == m_MapProclaunchGrps.end()) { // LCOV_EXCL_BR_LINE 200: Group Map cannot be empty
1523 // LCOV_EXCL_START 200: Group Map cannot be empty
1524 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1525 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error : Group Map empty"); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
1526 l_eStatus = eFrameworkunifiedStatusInvldParam;
1529 BOOL l_bModuleFound = FALSE;
1530 for (; (FALSE == l_bModuleFound)
1531 && (l_GroupIterator != m_MapProclaunchGrps.end());
1532 l_GroupIterator++) {
1533 ModuleLaunchListIter l_ModuleListIterator =
1534 l_GroupIterator->second.modules.begin();
1535 for (; (FALSE == l_bModuleFound)
1536 && (l_ModuleListIterator
1537 != l_GroupIterator->second.modules.end());
1538 l_ModuleListIterator++) {
1539 if (l_ModuleListIterator->pid == f_pid) {
1540 l_bModuleFound = TRUE;
1541 f_ModuleName = l_ModuleListIterator->name;
1542 l_eStatus = eFrameworkunifiedStatusOK;
1547 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1550 ///////////////////////////////////////////////////////////////////////////////
1556 ///////////////////////////////////////////////////////////////////////////////
1557 EFrameworkunifiedStatus CSystemManager::GetBinaryNameOfProcess(SS_String f_ModuleQueueName,
1558 SS_String &f_ModuleBinaryName) {
1559 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1560 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
1561 ModuleLaunchListIter l_moduleIter;
1563 f_ModuleBinaryName = "";
1564 l_eStatus = GetModuleIterator(f_ModuleQueueName.c_str(), l_moduleIter);
1565 if (eFrameworkunifiedStatusOK != l_eStatus) {
1566 LOG_ERROR("GetModuleIterator()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1568 size_t l_pos = l_moduleIter->path.find_last_of("\\/");
1569 if (std::string::npos == l_pos) { // LCOV_EXCL_BR_LINE 5: stdlib error case.
1570 // LCOV_EXCL_START 5: stdlib error case.
1571 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1572 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1573 " Error. Unable to parse binary name from path %s.",
1574 l_moduleIter->path.c_str());
1577 f_ModuleBinaryName = l_moduleIter->path.substr(l_pos + 1);
1578 l_eStatus = eFrameworkunifiedStatusOK;
1582 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1586 ///////////////////////////////////////////////////////////////////////////////
1592 ///////////////////////////////////////////////////////////////////////////////
1593 EFrameworkunifiedStatus CSystemManager::init_process_launcher(HANDLE hApp) {
1594 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1595 EFrameworkunifiedStatus l_eStatus;
1598 FrameworkunifiedProtocolCallbackHandler process_launcher_protocol_callbacks[] = {
1599 // Command ID, Call back functions
1600 { ePLThrdCmd_LAUNCH_MODULE_RESP, SysMgrCallback<CSystemManager,
1601 &CSystemManager::OnModuleLaunchResponse> },
1602 { ePLThrdCmd_TERMINATE_MODULE_RESP, SysMgrCallback<CSystemManager,
1603 &CSystemManager::OnTerminateModuleResponse> },
1604 { ePLThrdCmd_RELAUNCH_MODULE_RESP, SysMgrCallback<CSystemManager,
1605 &CSystemManager::OnReLaunchModuleResponse> },
1606 { ePLThrdCmd_THREAD_STATUS_RESP, SysMgrCallback<CSystemManager,
1607 &CSystemManager::OnProcessLauncherThreadHeartbeatResponse> } }; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
1609 // setup call backs for my children
1610 if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(hApp, SS_SMLauncher, process_launcher_protocol_callbacks, static_cast<UI_32>(_countof(process_launcher_protocol_callbacks))))) { // LCOV_EXCL_BR_LINE 4:NSFW error case //NOLINT (whitespace/line_length)
1611 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1612 LOG_ERROR("FrameworkunifiedAttachCallbacksToDispatcher()"); // LCOV_EXCL_LINE 4: For setting the initialization conditions at SystemManager startup
1613 //////// Create Writer Child Threads handles the writing of data
1614 } else if (NULL == (m_hProcLauncherThread.m_ThreadHdl = FrameworkunifiedCreateChildThreadWithPriority(hApp, SS_SMLauncher, ProcessLauncherOnStart, ProcessLauncherOnStop, PR_SMPROCLAUNCH))) { // LCOV_EXCL_BR_LINE 4:NSFW error case //NOLINT (whitespace/line_length)
1615 // LCOV_EXCL_START 4: For setting the initialization conditions at SystemManager startup
1616 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1617 l_eStatus = eFrameworkunifiedStatusNullPointer;
1618 m_hProcLauncherThread.m_ThreadState = eSM_ThreadNotExist;
1619 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1620 " Error: FrameworkunifiedCreateChildThreadWithPriority(%s) errored: %d/'%s'",
1621 SS_SMLauncher, l_eStatus, GetStr(l_eStatus).c_str());
1623 } else if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedStartChildThread(hApp, m_hProcLauncherThread.m_ThreadHdl, sizeof(UI_32), &TODO))) { // LCOV_EXCL_BR_LINE 4:NSFW error case //NOLINT (whitespace/line_length)
1624 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1625 m_hProcLauncherThread.m_ThreadState = // LCOV_EXCL_LINE 4: For setting the initialization conditions at SystemManager startup
1626 eSM_ThreadNotExist; // LCOV_EXCL_LINE 4: For setting the initialization conditions at SystemManager startup
1627 LOG_ERROR("FrameworkunifiedStartChildThread()"); // LCOV_EXCL_LINE 4: For setting the initialization conditions at SystemManager startup
1629 m_hProcLauncherThread.m_ThreadState = eSMThreadIsFine;
1631 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1635 EFrameworkunifiedStatus CSystemManager::OnGroupLaunchWaitTimeout(HANDLE hApp) {
1636 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1637 EFrameworkunifiedStatus l_eStatus;
1638 SetCmdHist("SM_TIMER_GROUP_LAUNCH_WAIT_TIMER", m_TimerCmdHist, m_TimerHistIter, FrameworkunifiedGetMsgSrc(hApp)); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
1639 CALL_AND_LOG_STATUS(OnLaunchGroup(hApp)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1640 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1644 ///////////////////////////////////////////////////////////////////////////////
1650 ///////////////////////////////////////////////////////////////////////////////
1651 EFrameworkunifiedStatus CSystemManager::OnModuleLaunchResponse(HANDLE hApp) {
1652 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1653 EFrameworkunifiedStatus l_eStatus;
1654 INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
1655 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(hApp));
1657 GroupLaunchMapIter l_GroupIter;
1658 ModuleLaunchListIter l_ModuleIter;
1659 UI_32 l_launchID = m_oSystemLauncher.get_id();
1661 l_eStatus = PerformModuleLaunchRespProcessing(hApp, l_GroupIter, l_ModuleIter, "ML");
1662 if (eFrameworkunifiedStatusOK != l_eStatus) {
1663 LOG_ERROR("PerformModuleLaunchRespProcessing()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1664 } else if (l_GroupIter->second.id == l_launchID) {
1665 BOOL IsGroupLaunchComplete = TRUE;
1666 // Search the group for any module that has not completed launching.
1667 for (l_ModuleIter = l_GroupIter->second.modules.begin();
1668 IsGroupLaunchComplete && (l_ModuleIter != l_GroupIter->second.modules.end());
1670 IsGroupLaunchComplete = !l_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHING);
1673 if (IsGroupLaunchComplete) {
1674 m_GroupLaunchTimer->StopTimer(m_aTimerIDs[eSM_TIMER_GROUP_MONITOR]);
1675 l_GroupIter->second.launch_complete = TRUE;
1676 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "Group%d LaunchComp", l_GroupIter->second.id);
1678 if (!m_oSystemLauncher.is_end()) {
1679 l_launchID = m_oSystemLauncher.advance_id();
1680 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "Next group:%d", l_launchID);
1681 if (FALSE == l_GroupIter->second.grp_wait_for_trigger) {
1682 UI_32 l_Sec = (l_GroupIter->second.grp_launch_wait) / (1000 * 1000);
1685 l_mSec = ((l_GroupIter->second.grp_launch_wait) % (1000 * 1000)) / 1000;
1687 l_mSec = (l_GroupIter->second.grp_launch_wait) / 1000;
1689 m_GroupLaunchTimer->StartTimer(
1690 m_aTimerIDs[eSM_TIMER_GROUP_LAUNCH_WAIT_TIMER], l_Sec, l_mSec, 0, 0);
1692 // Start the timer for group trigger... added for optimization
1693 m_GroupLaunchTimer->StartTimer(
1694 m_aTimerIDs[eSM_TIMER_LAUNCH_GROUP_TRIGGER_PROC_RESP_TIMER],
1695 SS_LAUNCH_GROUP_TRIGGER_TIMER_CONFIG, 0, 0, 0);
1699 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Group %d/%s LaunchIncomp", l_launchID,
1700 l_GroupIter->second.name.c_str());
1703 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
1704 " '%s' ( Group %d/%s ) Launch Response received late - "
1705 "group id is now %d", l_ModuleIter->name.c_str(),
1706 l_GroupIter->second.id, l_GroupIter->second.name.c_str()
1709 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1713 EFrameworkunifiedStatus CSystemManager::OnReLaunchModuleResponse(HANDLE hApp) {
1714 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1715 EFrameworkunifiedStatus l_eStatus;
1716 INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1717 FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(hApp));
1719 GroupLaunchMapIter l_GroupIter;
1720 ModuleLaunchListIter l_ModuleIter;
1722 l_eStatus = PerformModuleLaunchRespProcessing(hApp, l_GroupIter, l_ModuleIter, "RL");
1723 LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "PerformModuleLaunchRespProcessing()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
1725 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1727 } // End of EFrameworkunifiedStatus CSystemManager::OnReLaunchModuleResponse( HANDLE hApp )
1730 EFrameworkunifiedStatus CSystemManager::PerformModuleLaunchRespProcessing(HANDLE hApp,
1731 GroupLaunchMapIter & f_GroupIter, ModuleLaunchListIter & f_ModuleIter,
1733 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1734 EFrameworkunifiedStatus l_eStatus;
1735 T_ProcessLaunchResp l_LaunchRespData;
1738 // Check hApp ptr, msg size, msg reception, read msg if all ok. *
1739 // Report any errors found. *
1741 if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < T_ProcessLaunchResp > (hApp, l_LaunchRespData))) { // LCOV_EXCL_BR_LINE 4: nsfw error // NOLINT(whitespace/line_length)
1742 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1743 LOG_ERROR("ReadMsg()"); // LCOV_EXCL_LINE 4: nsfw error
1745 BOOL b_DidModuleLaunch = FALSE;
1746 f_GroupIter = l_LaunchRespData.groupIterator;
1747 f_ModuleIter = l_LaunchRespData.moduleIterator;
1748 SS_String l_ModulePath = l_LaunchRespData.path;
1750 FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "%s(%d)", l_LaunchRespData.name, l_LaunchRespData.pid);
1752 if (l_LaunchRespData.pid == -1) {
1753 f_ModuleIter->pid = -1;
1755 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: Process launch failed: %s, %s",
1756 f_ModuleIter->name.c_str(), l_ModulePath.c_str());
1759 /// If PID is -1, launch had failed. Add logic to do necessary action.
1761 f_ModuleIter->SetModuleState(MODULE_STATE_LAUNCH_FAILED);
1762 } else if (l_LaunchRespData.pid == 0x7FFFFFFF) {
1763 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, " Warning: '%s', '%s' already launched",
1764 f_ModuleIter->name.c_str(), l_ModulePath.c_str());
1766 b_DidModuleLaunch = TRUE;
1768 f_ModuleIter->pid = l_LaunchRespData.pid;
1769 b_DidModuleLaunch = TRUE;
1772 if (b_DidModuleLaunch) {
1774 // Module state could already be MODULE_STATE_CONNECTED if
1775 // module process ran before process launcher thread completed;
1776 // don't overwrite/reset the MODULE_STATE_CONNECTED state.
1777 if (f_ModuleIter->IsModuleState(MODULE_STATE_LAUNCHING)) {
1778 f_ModuleIter->SetModuleState(MODULE_STATE_LAUNCHED);
1781 l_eStatus = f_ModuleIter->GetPriority(f_ModuleIter->current_priority);
1782 if (eFrameworkunifiedStatusOK != l_eStatus) {
1783 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, " Warning: f_ModuleIter->GetPriority( "
1784 "f_ModuleIter->current_priority ) returned %d/'%s'. "
1785 "Setting 'current_priority' = 'configuration_priority' %d.",
1786 l_eStatus, GetStr(l_eStatus).c_str(),
1787 f_ModuleIter->configuration_priority);
1788 f_ModuleIter->current_priority = f_ModuleIter->configuration_priority;
1789 l_eStatus = eFrameworkunifiedStatusOK;
1793 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1795 } // End of EFrameworkunifiedStatus CSystemManager::PerformModuleLaunchRespProcessing(
1797 ///////////////////////////////////////////////////////////////////////////////
1798 /// \ingroup OnTerminateModuleResponse
1800 /// \param HANDLE hApp
1802 /// \return EFrameworkunifiedStatus
1803 ///////////////////////////////////////////////////////////////////////////////
1804 EFrameworkunifiedStatus CSystemManager::OnTerminateModuleResponse(HANDLE hApp) {
1805 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1806 EFrameworkunifiedStatus l_eStatus;
1807 T_ProcessLauncherTerminationResp l_TerminateRespData;
1808 INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1809 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, " from %s", FrameworkunifiedGetMsgSrc(hApp));
1812 // Check hApp ptr, msg size, msg reception, read msg if all ok. *
1813 // Report any errors found. *
1815 if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < T_ProcessLauncherTerminationResp
1816 > (hApp, l_TerminateRespData))) {
1817 LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
1819 ModuleLaunchListIter l_ModuleIter = l_TerminateRespData.moduleIterator;
1821 SS_String l_ModulePath = m_BinaryFilesPath + l_ModuleIter->path;
1823 if ((0 == strcmp(l_ModulePath.c_str(), l_TerminateRespData.path))
1824 && (0 == strcmp(l_ModuleIter->arguments.c_str(),
1825 l_TerminateRespData.args))) {
1826 l_ModuleIter->pid = 0;
1827 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " %s Termination successful",
1828 l_ModuleIter->name.c_str());
1830 if (0 != strcmp(l_ModulePath.c_str(), l_TerminateRespData.path)) {
1831 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1832 " Error: ModuleIter->path != l_TerminateRespData.path"
1833 " \" '%s' != '%s' \"", l_ModuleIter->path.c_str(),
1834 l_TerminateRespData.path);
1836 if (0 != strcmp(l_ModuleIter->arguments.c_str(),
1837 l_TerminateRespData.args)) {
1838 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: ModuleIter->arguments != "
1839 "l_TerminateRespData.args, \" '%s' != '%s' \"",
1840 l_ModuleIter->arguments.c_str(), l_TerminateRespData.args);
1845 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1847 } // End of EFrameworkunifiedStatus CSystemManager::OnTerminateModuleResponse( HANDLE hApp )
1849 ///////////////////////////////////////////////////////////////////////
1850 /// \ingroup ReadPathAndFileNameEnvironmentVariables
1855 ///////////////////////////////////////////////////////////////////////////////
1856 VOID CSystemManager::ReadPathFromEnvironmentVariables() {
1857 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
1858 CHAR *l_pEnvVariable = NULL;
1860 // read Path from environment variable
1861 if (NULL == (l_pEnvVariable = std::getenv(BaseDirPathEnvVariable))) {
1862 // Environment variable not set, set it to default path
1863 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Using Default path for Binary Files : %s", DefaultBasePath);
1864 m_BinaryFilesPath = DefaultBasePath;
1866 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Using Default path for Config Files : %s%s",
1867 DefaultBasePath, DefaultConfigFilesPath);
1868 m_ConfigFilesPath = DefaultBasePath;
1870 // set path of binary files
1871 m_BinaryFilesPath = l_pEnvVariable;
1873 // set path of configuration files
1874 m_ConfigFilesPath = l_pEnvVariable;
1876 // set path of configuration files
1877 m_ConfigFilesPath += DefaultConfigFilesPath;
1879 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1883 ///////////////////////////////////////////////////////////////////////
1884 /// \ingroup GetConfigDataFileNameFromEnvironmentVariable
1888 /// \return SS_String
1889 ///////////////////////////////////////////////////////////////////////////////
1890 SS_String CSystemManager::ReadLaunchConfigFileNameFromEnvironmentVariable() {
1891 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1892 CHAR *l_pEnvVariable = NULL;
1893 SS_String l_FileName;
1895 // read Launch Config File Name from environment variable
1896 // LCOV_EXCL_BR_START 5: standard lib error
1897 if (NULL == (l_pEnvVariable = std::getenv(LaunchConfigFileNameEnvVariable))) {
1898 // LCOV_EXCL_BR_STOP
1899 // Environment variable not set, set it to default file name
1900 // LCOV_EXCL_START 5: standard lib error
1901 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1902 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Using Default Launch Configuration file : %s",
1903 DefaultLaunchConfigFileName);
1904 l_FileName = DefaultLaunchConfigFileName;
1907 l_FileName = l_pEnvVariable;
1910 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Using Launch Configuration file: %s", l_FileName.c_str());
1912 SS_String retStr = m_ConfigFilesPath + l_FileName; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
1913 if (access(retStr.c_str(), F_OK) != 0) { // LCOV_EXCL_BR_LINE 5: standard lib error
1914 // LCOV_EXCL_START 5: standard lib error
1915 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1916 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "no found %s", retStr.c_str());
1923 ///////////////////////////////////////////////////////////////////////
1924 /// \ingroup GetConfigDataFileNameFromEnvironmentVariable
1928 /// \return SS_String
1929 ///////////////////////////////////////////////////////////////////////////////
1930 SS_String CSystemManager::ReadConfigDataFileNameFromEnvironmentVariable() {
1931 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1932 CHAR *l_pEnvVariable = NULL;
1933 SS_String l_FileName = "";
1935 // read SM Config Data File Name from environment variable
1936 // LCOV_EXCL_BR_START 5: standard lib error
1937 if (NULL == (l_pEnvVariable = std::getenv(SMConfigDataFileNameEnvVariable))) {
1938 // LCOV_EXCL_BR_STOP 5: standard lib error
1939 // LCOV_EXCL_START 5: standard lib error
1940 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1941 // Environment variable not set, set it to default file name
1942 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Using Default Configuration Data file : %s", DefaultSMConfigFileName);
1943 l_FileName = DefaultSMConfigFileName;
1946 l_FileName = l_pEnvVariable;
1949 SS_String retStr = m_ConfigFilesPath + l_FileName; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
1950 if (access(retStr.c_str(), F_OK) != 0) { // LCOV_EXCL_BR_LINE 5: standard lib error
1951 // LCOV_EXCL_START 5: standard lib error
1952 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1953 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "no found %s", retStr.c_str());
1957 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1961 ///////////////////////////////////////////////////////////////////////
1962 /// \ingroup ReadUsingVMPlayerEnvironmentVariable
1967 ///////////////////////////////////////////////////////////////////////////////
1968 VOID CSystemManager::ReadUsingVMPlayerEnvironmentVariable() {
1969 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1970 CHAR *l_pEnvVariable = std::getenv(UsingVMPlayerVariable);
1971 m_UsingVMPlayer = (NULL != l_pEnvVariable);
1972 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " %sunning on a VMPlayer",
1973 m_UsingVMPlayer ? "R" : "Not r");
1974 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1976 } // End of VOID CSystemManager::ReadUsingVMPlayerEnvironmentVariable()
1978 ///////////////////////////////////////////////////////////////////////////////
1984 ///////////////////////////////////////////////////////////////////////////////
1985 EFrameworkunifiedStatus CSystemManager::start_process_launching(HANDLE hApp) {
1986 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1987 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
1989 SS_String l_SMConfigFile(ReadConfigDataFileNameFromEnvironmentVariable());
1990 SMConfigParams SMConfigData;
1991 SS_String l_LaunchConfigFile(ReadLaunchConfigFileNameFromEnvironmentVariable()); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
1992 SysMgrConfiguration l_launchConfig;
1994 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Reading %s Configuration Data from %s",
1995 SERVICE_SYSMANAGER, l_SMConfigFile.c_str());
1997 l_bIsGoodRc = SMConfigData.LoadSMConfigParameters(m_SMConfig, l_SMConfigFile);
1999 if (!l_bIsGoodRc) { // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup
2000 // LCOV_EXCL_START 6: For setting the initialization conditions at SystemManager startup
2001 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2002 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2003 " Error: SMConfigData.LoadSMConfigParameters(m_SMConfig, "
2004 " %s) returned FALSE", l_SMConfigFile.c_str());
2005 l_eStatus = eFrameworkunifiedStatusFileLoadError;
2008 SMSetState(hApp, SS_SM_APPS_LAUNCH_IN_PROGRESS); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2009 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Reading Launch Configuration Data from %s",
2010 l_LaunchConfigFile.c_str());
2012 SS_String l_launchOrderName = "DEFAULT"; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2013 LaunchOrderedVector l_OrderList;
2015 l_bIsGoodRc = l_launchConfig.LoadParametersCfg(m_MapProclaunchGrps,
2016 m_MapProcNames, l_OrderList, l_launchOrderName, l_LaunchConfigFile);
2018 if (l_OrderList.size() != 0) { // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup
2019 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2020 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "wakeup order:%s",
2021 l_launchOrderName.c_str());
2023 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "wakeup order:DEFAULT");
2026 if (!l_bIsGoodRc) { // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup
2027 // LCOV_EXCL_START 6: For setting the initialization conditions at SystemManager startup
2028 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2029 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: l_launchConfig.LoadParametersCfg( "
2030 "m_MapProclaunchGrps, m_MapProcNames, %s ) returned FALSE",
2031 l_LaunchConfigFile.c_str());
2032 l_eStatus = eFrameworkunifiedStatusFileLoadError;
2035 m_SystemLaunchProgress = SS_SM_INITIAL_GROUP;
2036 // l_launchConfig.PrintAllInfo( m_MapProclaunchGrps );
2038 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " System Launch Started");
2039 // Don't use DynamicLaunch because its dependency on the services table is complex
2040 SS_SOURCE source_type = SS_SOURCE_FM;
2042 m_oSystemLauncher.configure_dynamic_launch(source_type, m_MapProclaunchGrps, l_OrderList);
2043 m_oSystemLauncher.copyDynOrderedVector(m_SystemStarter);
2044 // m_SystemStarter.print_info();
2046 // start the timer upon successful launching of first process
2047 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
2048 "Starting Module Connection Timeout timer with %d sec period",
2049 m_SMConfig.MCConfig.ModuleConnectionTimeOutSec);
2050 m_GroupLaunchTimer->StartTimer(
2051 m_aTimerIDs[eSM_TIMER_MODULE_CONNECT_WAIT_TIMER],
2052 m_SMConfig.MCConfig.ModuleConnectionTimeOutSec, 0,
2053 m_SMConfig.MCConfig.ModuleConnectionTimeOutSec, 0); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2054 CALL_AND_LOG_STATUS(OnLaunchGroup(hApp)); // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup
2058 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2063 EFrameworkunifiedStatus CSystemManager::GetLastSourceInfo(SS_SOURCE &source_type) { // LCOV_EXCL_START 8: Because the condition cannot be set
2064 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2065 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
2066 EFrameworkunifiedStatus l_eStatus;
2068 CHAR LastSource[64 + 1] = { '\0' };
2069 l_eStatus = NPSynchronousReadPersistentData(SERVICE_AS_MODE,
2070 NTFY_SSLastSourceType, LastSource, static_cast<UI_32>(sizeof(LastSource) - 1));
2071 if (eFrameworkunifiedStatusOK != l_eStatus) {
2072 LOG_ERROR("NPSynchronousReadPersistentData("
2073 SERVICE_AS_MODE "," NTFY_SSLastSourceType);
2075 std::string tempstr(LastSource);
2076 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " String got from persistence %s", LastSource);
2077 UI_32 pos = static_cast<UI_32>(tempstr.find("_"));
2078 std::string tempstr2 = tempstr.substr(0, pos);
2079 UI_64 value = strtoull(tempstr2.c_str(), 0, 10);
2080 source_type = static_cast<SS_SOURCE>((UI_32)(value >> 32) & 0x0000FFFF);
2082 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2086 EFrameworkunifiedStatus CSystemManager::OnLaunchGroupTriggerProcessResponse(HANDLE hApp) {
2087 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2088 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
2089 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
2090 INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp);
2093 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(hApp));
2094 SetCmdHist("SS_SM_GROUP_LAUNCH_TRIGGER", m_SMCmdHist, m_SMHistIter, FrameworkunifiedGetMsgSrc(hApp));
2095 // stop group launch trigger process response timer
2096 m_GroupLaunchTimer->StopTimer(m_aTimerIDs[eSM_TIMER_LAUNCH_GROUP_TRIGGER_PROC_RESP_TIMER]);
2098 if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < UI_32 > (hApp, l_groupID))) {
2099 LOG_ERROR("ReadMsg()");
2101 SS_SOURCE source_type = SS_SOURCE_NA;
2102 l_eStatus = GetLastSourceInfo(source_type);
2104 if ((SS_SOURCE_AM == source_type) || (SS_SOURCE_FM == source_type)
2105 || (SS_SOURCE_FM_DAB == source_type) || (SS_SOURCE_SDARS == source_type)) {
2106 if (l_groupID == m_oSystemLauncher.get_id()) {
2107 CALL_AND_LOG_STATUS(OnLaunchGroup(hApp));
2109 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2110 " Error: Received Group ID %d != Sys Mgr Group ID %d", l_groupID,
2111 m_oSystemLauncher.get_id());
2112 l_eStatus = eFrameworkunifiedStatusInvldParam;
2114 } else { // media is last source
2115 CALL_AND_LOG_STATUS(OnLaunchGroup(hApp));
2119 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2123 EFrameworkunifiedStatus CSystemManager::OnLaunchGroupTriggerProcessResponseTimerExpiry(HANDLE hApp) {
2124 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2125 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
2126 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
2127 INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp);
2128 REC_HIST_IF_SUCCESSFUL("SM_TIMER_LAUNCH_GROUP_TRIGGER", m_TimerCmdHist,
2129 m_TimerHistIter, FrameworkunifiedGetMsgSrc(hApp), l_eStatus);
2130 CALL_AND_LOG_STATUS(OnLaunchGroup(hApp));
2132 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2136 ///////////////////////////////////////////////////////////////////////////////
2142 ///////////////////////////////////////////////////////////////////////////////
2143 EFrameworkunifiedStatus CSystemManager::OnLaunchGroupSelfTrigger(HANDLE hApp) {
2144 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2145 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
2146 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
2148 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(hApp));
2150 REC_HIST_IF_SUCCESSFUL("SS_SM_SendTriggerToSelf", m_SMCmdHist, m_SMHistIter,
2151 FrameworkunifiedGetMsgSrc(hApp), l_eStatus);
2153 CALL_AND_LOG_STATUS(OnLaunchGroup(hApp));
2155 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2160 ///////////////////////////////////////////////////////////////////////////////
2166 ///////////////////////////////////////////////////////////////////////////////
2167 EFrameworkunifiedStatus CSystemManager::OnLaunchGroup(HANDLE hApp) {
2168 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
2169 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
2170 GroupLaunchMapIter l_GroupIter;
2171 UI_32 l_launch_ID = m_oSystemLauncher.get_id();
2173 // FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Launching group %d", l_launch_ID );
2175 l_GroupIter = m_MapProclaunchGrps.find(l_launch_ID);
2177 if (l_GroupIter->second.launch_complete == FALSE) { // LCOV_EXCL_BR_LINE 6: Because it is not called for a condition that results in "TRUE"
2178 // FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__
2179 // , " m_bIsNPP_ServicesStarted ? %s, group.id: %d, Launch_Group: %d"
2180 // , m_bIsNPP_ServicesStarted ? "Yes" : "No"
2181 // , l_GroupIter->second.id
2182 // , m_SystemLaunchProgress );
2184 if ((m_bIsNPP_ServicesStarted && m_bIsBackupAvail) || (l_GroupIter->second.id <= 2)) { // LCOV_EXCL_BR_LINE 6: Because it is not called for the condition that results in "FALSE" // NOLINT(whitespace/line_length)
2185 ModuleLaunchListIter l_ModuleListIterator = l_GroupIter->second.modules.begin();
2186 if (l_ModuleListIterator != l_GroupIter->second.modules.end()) { // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup // NOLINT(whitespace/line_length)
2187 // FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "GRPLCH,(start),%d,%s",
2188 // l_GroupIter->second.id,l_GroupIter->second.name.c_str());
2190 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "Launching Group%d/%s",
2191 l_GroupIter->second.id, l_GroupIter->second.name.c_str());
2192 SS_String l_ModulePath;
2193 for (; l_ModuleListIterator != l_GroupIter->second.modules.end(); l_ModuleListIterator++) {
2194 if (l_ModuleListIterator->IsModuleState(MODULE_STATE_INVALID)) {
2195 char l_cFormat[] = "SendRequestToLauncher(%s, "
2196 "ePLThrdCmd_LAUNCH_MODULE_REQST)";
2197 char l_cBuf[sizeof(l_cFormat) + MAX_NAME_SIZE_APP];
2198 snprintf(l_cBuf, sizeof(l_cBuf), l_cFormat,
2199 l_ModuleListIterator->name.c_str());
2201 l_eStatus = SendRequestToLauncher(hApp, l_ModuleListIterator, // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2202 ePLThrdCmd_LAUNCH_MODULE_REQST, // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2203 "ePLThrdCmd_LAUNCH_MODULE_REQST"); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2205 if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup // NOLINT(whitespace/line_length)
2206 // LCOV_EXCL_START 6: For setting the initialization conditions at SystemManager startup // NOLINT(whitespace/line_length)
2207 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2208 l_ModuleListIterator->SetModuleState(
2209 MODULE_STATE_LAUNCH_FAILED);
2210 SetCmdHist(l_cBuf, m_ErrHist, m_ErrHistIter,
2211 GetStr(l_eStatus).c_str());
2214 l_ModuleListIterator->SetModuleState(MODULE_STATE_LAUNCHING);
2217 l_ModulePath = (m_BinaryFilesPath + l_ModuleListIterator->path); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2218 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
2219 " Not launching %s: module state is %s",
2220 l_ModulePath.c_str(),
2221 l_ModuleListIterator->ModuleStateStr().c_str());
2225 // LCOV_EXCL_BR_START 6: For setting the initialization conditions at SystemManager startup // NOLINT(whitespace/line_length)
2227 l_GroupIter->second.grp_wait_for_trigger) {
2228 // LCOV_EXCL_BR_STOP
2229 m_GroupLaunchTimer->StartTimer(m_aTimerIDs[eSM_TIMER_GROUP_MONITOR],
2230 SS_GROUP_LAUNCH_TIMER_CONFIG, 0, 0, 0); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2235 if (m_oSystemLauncher.is_end()) { // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup // NOLINT(whitespace/line_length)
2236 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "System Launch Completed");
2238 if (epssusSYSTEM_SERVICES_STARTED == m_SystemModeInfo.startupStage) {
2239 // If startupStage == SYSTEM_SERVICES_STARTED, a notification is requested because there are SVCs required for notification to the _CWORD56_.
2240 l_eStatus = SendSystemModeInfoResponse(hApp, epssusALL_SERVICES_LAUNCHED);
2241 LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
2242 "UpdateStartupStageState_SendSystemModeInfoResponse" // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
2243 "( epssusALL_SERVICES_LAUNCHED )"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
2246 m_SystemModeInfo.startupStage = epssusALL_SERVICES_LAUNCHED;
2248 if (is_current_state(SS_SM_APPS_LAUNCH_IN_PROGRESS)) {
2249 SMSetState(hApp, SS_SM_APPS_LAUNCHED_READY_TO_START);
2251 // SysMgrConfiguration config;
2252 // config.PrintAllInfo( m_MapProclaunchGrps );
2255 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2257 } // End of EFrameworkunifiedStatus CSystemManager::OnLaunchGroup(HANDLE hApp)
2259 ///////////////////////////////////////////////////////////////////////////////
2260 /// \ingroup OnProcessLaunchTimerExpiry
2262 /// \param HANDLE hApp
2264 /// \return EFrameworkunifiedStatus
2265 ///////////////////////////////////////////////////////////////////////////////
2266 EFrameworkunifiedStatus CSystemManager::OnProcessLaunchTimerExpiry(HANDLE hApp) { // LCOV_EXCL_START 8: Because the condition cannot be set
2267 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2268 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
2269 // ToDo 2013_05_17 Jay When used ? Dead code ? Don't see a StartTimer call.
2270 REC_HIST_IF_SUCCESSFUL("SM_TIMER_PROCESS_LAUNCH_MONITOR", m_TimerCmdHist,
2271 m_TimerHistIter, FrameworkunifiedGetMsgSrc(hApp), l_eStatus);
2272 m_GroupLaunchTimer->StopTimer(m_aTimerIDs[eSM_TIMER_PROCESS_LAUNCH_MONITOR]);
2273 return eFrameworkunifiedStatusOK;
2277 ///////////////////////////////////////////////////////////////////////////////
2278 /// \ingroup OnHeartBeatMonitorTimerExpiry
2280 /// \param HANDLE hApp
2282 /// \return EFrameworkunifiedStatus
2283 ///////////////////////////////////////////////////////////////////////////////
2284 EFrameworkunifiedStatus CSystemManager::OnHeartBeatMonitorTimerExpiry(HANDLE hApp) {
2285 FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "+");
2286 FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_INFO, __FUNCTION__, " Received from %s", FrameworkunifiedGetMsgSrc(hApp));
2287 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
2288 REC_HIST_IF_SUCCESSFUL("SM_TIMER_HEARTBEAT_MONITOR", m_TimerCmdHist, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
2289 m_TimerHistIter, FrameworkunifiedGetMsgSrc(hApp), l_eStatus); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
2291 // LCOV_EXCL_BR_START 4: nsfw error
2292 if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendChild(hApp, m_hHeartbeatThread.m_ThreadHdl,
2293 SS_HEARTBEAT_PERIODIC_STATUS_REQ, 0, NULL))) {
2294 // LCOV_EXCL_BR_STOP 4: nsfw error
2295 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2296 LOG_ERROR("FrameworkunifiedSendChild(m_hHeartbeatThread.m_ThreadHdl, " // LCOV_EXCL_LINE 4: nsfw error
2297 "SS_HEARTBEAT_PERIODIC_STATUS_REQ)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2299 m_hHeartbeatThread.m_ThreadState = eSMWaitForHeartbeat;
2302 FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "-");
2306 ///////////////////////////////////////////////////////////////////////////////
2307 /// \ingroup SystemManagerDebugDump
2308 /// implement post mortem function
2313 ///////////////////////////////////////////////////////////////////////////////
2315 VOID CSystemManager::SystemManagerDebugDump(HANDLE hApp) {
2316 std::stringstream l_debugDumpBuf;
2319 // LCOV_EXCL_BR_START 11:unexpected branch // NOLINT(whitespace/line_length)
2320 l_debugDumpBuf << FrameworkunifiedGetAppName(hApp) << "/" << endl
2321 << " <SYSTEM MANAGER DUMP DATA> " << endl << endl << " ***internals*** " << endl
2322 << endl << " SM state: "
2323 << GetStr(m_SMCurrentState).c_str() << endl << " SM startup reason: "
2324 << GetStr(m_StartUpReason).c_str() << endl << " SM shutdown reason: "
2325 << GetStr(m_shutdownTrigger).c_str() << endl << " LUM: "
2326 << GetStr(m_lastUserMode).c_str() << endl << " TPM: "
2327 << GetStr(m_SystemModeInfo.transportMode).c_str() << endl << " LPH: "
2328 << GetStr(m_SystemModeInfo.limpHomeCutoff).c_str() << endl << " PMode: "
2329 << GetStr(m_SystemModeInfo.productionMode).c_str() << endl << " ActiveGroup: "
2330 << m_ActiveGroupId << endl << " m_MaxShutdownTime: " << m_MaxShutdownTime
2331 << endl << " NPP: " << (m_bIsNPP_ServicesStarted ? "Started" : "notStarted")
2333 << endl << " ***Error history***" << endl;
2334 // LCOV_EXCL_BR_STOP
2336 for (i = m_ErrHist.begin(); i != m_ErrHist.end(); ++i) {
2337 l_debugDumpBuf << endl << " " << i->m_cmd.c_str() << " @ " << i->m_time // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2338 << "ms EC:" << i->m_sender.c_str() << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2341 l_debugDumpBuf << endl << " ***_CWORD56_ command history***" << endl;
2343 for (i = m__CWORD56_CmdHist.begin(); i != m__CWORD56_CmdHist.end(); ++i) {
2344 l_debugDumpBuf << endl << " " << i->m_cmd.c_str() << " @ " << i->m_time << "ms" << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2347 l_debugDumpBuf << endl << " ***Timer history***" << endl;
2349 for (i = m_TimerCmdHist.begin(); i != m_TimerCmdHist.end(); ++i) {
2350 l_debugDumpBuf << endl << " " << i->m_cmd.c_str() << " @ " << i->m_time << "ms" << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2353 l_debugDumpBuf << endl << " ***SM message history***" << endl;
2355 for (i = m_SMCmdHist.begin(); i != m_SMCmdHist.end(); ++i) {
2356 l_debugDumpBuf << endl << " " << i->m_cmd.c_str() << " @ " << i->m_time << "ms " // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2357 << i->m_sender.c_str() << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2360 l_debugDumpBuf << endl << " ***Publishshing history***" << endl;
2362 for (i = m_PubCmdHist.begin(); i != m_PubCmdHist.end(); ++i) {
2363 l_debugDumpBuf << endl << " " << i->m_cmd.c_str() << " @ " << i->m_time << "ms " // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2364 << i->m_sender.c_str() << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2367 l_debugDumpBuf << endl << " ***SM start table***" << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2369 // LCOV_EXCL_BR_START 11:unexpected branch // NOLINT(whitespace/line_length)
2370 l_debugDumpBuf << endl
2371 << " index | name | start required? | isOKFlag | Module state | start sent "
2372 "| start resposne received |start delta | stop sent | reply received | stop delta | PID"
2374 // LCOV_EXCL_BR_STOP
2376 for (UI_32 k = 1u; (k <= m_MapProclaunchGrps.size()); k++) {
2377 GroupLaunchMapIter l_GroupIterator = m_MapProclaunchGrps.find(k);
2379 if (l_GroupIterator != m_MapProclaunchGrps.end()) {
2380 ModuleLaunchListIter l_ModuleListIterator = l_GroupIterator->second.modules.begin();
2382 for (int i = 1u; l_ModuleListIterator != l_GroupIterator->second.modules.end();
2383 l_ModuleListIterator++, i++) {
2384 // LCOV_EXCL_BR_START 11:unexpected branch // NOLINT(whitespace/line_length)
2385 std::string sIsOKFlag = GetModuleCondition(l_ModuleListIterator) ? " " : // 'blank' means OK
2386 "X"; // 'X' means state mismatch
2388 l_debugDumpBuf << " " << std::setw(2) << std::right << i << " | "
2389 << std::setw(24) << std::left << l_ModuleListIterator->name.c_str()
2390 << " | " << std::setw(5) << std::left
2391 << (l_ModuleListIterator->is_start_required ? "TRUE" : "FALSE")
2393 << " | " << sIsOKFlag.c_str() << " | " << std::setw(24) << std::left
2394 << l_ModuleListIterator->ModuleStateStr().c_str() << " | "
2395 << l_ModuleListIterator->m_startReason.GetInitial() << " | "
2396 << l_ModuleListIterator->m_startReason.GetFinal() << " | "
2397 << std::setw(3) << std::right
2398 << static_cast<SI_16>(l_ModuleListIterator->m_startReason.GetDelta())
2399 << "ms" << " | " << l_ModuleListIterator->m_stopReason.GetInitial()
2400 << " | " << l_ModuleListIterator->m_stopReason.GetFinal() << " | "
2402 << static_cast<SI_16>(l_ModuleListIterator->m_stopReason.GetDelta())
2403 << "ms" << " | " << l_ModuleListIterator->pid << endl;
2404 // LCOV_EXCL_BR_STOP
2409 l_debugDumpBuf << endl << " ***Heartbeat information***" << endl;
2411 l_debugDumpBuf << endl << " Entire State:" << m_HBReport.eEntireState << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2413 l_debugDumpBuf << endl << " Number of Modules:" << m_HBReport.nNumOfModules << endl;
2415 for (UI_32 j = 0; j < m_HBReport.nNumOfModules; j++) { // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2416 // LCOV_EXCL_START 6: Because the applicable variable cannot be changed from the external API (only evaluated by the initial value)
2417 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2418 if (0 != m_HBReport.tModuleList[j].HeartBeatRetryCount) {
2419 l_debugDumpBuf << endl << " " << m_HBReport.tModuleList[j].ProcQueueName << ","
2420 << m_HBReport.tModuleList[j].ProcHBState << ", "
2421 << m_HBReport.tModuleList[j].HeartBeatRetryCount << endl;
2426 std::string l_debugDumpStr = l_debugDumpBuf.str();
2428 SendDebugDumpResponseToSystemManager(l_debugDumpStr); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2431 ///////////////////////////////////////////////////////////////////////////////
2432 /// \ingroup OnProcessLaunchMonitorTimerExpiry
2433 /// This sends request to launcher thread to confirm that it
2434 /// is still responsive.
2436 /// \param [in] hApp
2437 /// HANDLE - Handle of the Client Application
2440 /// EFrameworkunifiedStatus - success or error
2441 ///////////////////////////////////////////////////////////////////////////////
2442 EFrameworkunifiedStatus CSystemManager::OnProcessLaunchMonitorTimerExpiry(HANDLE hApp) {
2443 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
2444 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Received from %s", FrameworkunifiedGetMsgSrc(hApp));
2445 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
2447 REC_HIST_IF_SUCCESSFUL("TIMER_PROCESSLAUNCHER_MONITOR", m_TimerCmdHist, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
2448 m_TimerHistIter, FrameworkunifiedGetMsgSrc(hApp), l_eStatus); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
2450 // LCOV_EXCL_BR_START 4: nsfw error
2451 if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendChild(hApp, m_hProcLauncherThread.m_ThreadHdl,
2452 ePLThrdCmd_THREAD_STATUS_REQST, 0, NULL))) {
2453 // LCOV_EXCL_BR_STOP 4: nsfw error
2454 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2455 LOG_ERROR("FrameworkunifiedSendChild(m_hProcLauncherThread.m_ThreadHdl," // LCOV_EXCL_LINE 4: nsfw error
2456 "ePLThrdCmd_THREAD_STATUS_REQST)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2458 m_hProcLauncherThread.m_ThreadState = eSMWaitForHeartbeat;
2461 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2465 ///////////////////////////////////////////////////////////////////////////////
2466 /// \ingroup SendRequestToLauncher
2467 /// This function is used for sending request to launcher thread from
2470 /// \param HANDLE hApp
2471 /// ModuleLaunchListIter f_ModuleListIterator => iterator node from map for the module
2472 /// ESMPLThreadCommandIds f_CommandId => command id to send
2473 /// SS_String f_ModulePath => Path of the Module
2476 /// EFrameworkunifiedStatus - success or error
2477 ///////////////////////////////////////////////////////////////////////////////
2478 EFrameworkunifiedStatus CSystemManager::PerformLaunchProcedure(HANDLE hApp,
2479 ModuleLaunchListIter f_ModuleIterator, SS_String & f_stopCompName) {
2480 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
2482 SS_String s_ModuleStatus2;
2484 // Register for Stop Complete notification
2485 if (!f_ModuleIterator->shutdown_critical) {
2486 s_ModuleStatus2 = "is not shutdown_critical";
2487 // LCOV_EXCL_BR_START 6: For setting the initialization conditions at SystemManager startup
2489 } else if (eFrameworkunifiedStatusOK != (l_eStatus =
2490 FrameworkunifiedSubscribeNotificationWithCallback(
2492 f_stopCompName.c_str(),
2493 SysMgrCallback<CSystemManager, &CSystemManager::OnModuleStopCompleteNotification>))) {
2494 // LCOV_EXCL_BR_STOP
2495 // LCOV_EXCL_START 6: For setting the initialization conditions at SystemManager startup
2496 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2497 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2498 " Error: FrameworkunifiedSubscribeNotificationWithCallback(hApp, %s) errored: %d/'%s'",
2499 f_stopCompName.c_str(), l_eStatus, GetStr(l_eStatus).c_str());
2501 s_ModuleStatus2 = "is shutdown_critical but errored";
2504 s_ModuleStatus2 = f_stopCompName + " is now registered"; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2507 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "%s", s_ModuleStatus2.c_str());
2512 ///////////////////////////////////////////////////////////////////////////////
2513 /// \ingroup PerformTerminateProcedure
2514 /// Perform Procedure for Service Terminate.
2516 /// \param HANDLE hApp
2517 /// ModuleLaunchListIter f_ModuleListIterator => iterator node from map for the module
2518 /// SS_String & f_availabilityName => Availability Name
2519 /// SS_String & f_stopCompName => Stop Complete Notification Name
2522 /// EFrameworkunifiedStatus - success or error
2523 ///////////////////////////////////////////////////////////////////////////////
2524 EFrameworkunifiedStatus CSystemManager::PerformTerminateProcedure(HANDLE hApp,
2525 ModuleLaunchListIter f_ModuleIterator, SS_String & f_availabilityName,
2526 SS_String & f_stopCompName) {
2527 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
2530 f_ModuleIterator->SetModuleState(MODULE_STATE_INVALID);
2531 f_ModuleIterator->pid = 0;
2532 if (NULL != f_ModuleIterator->hsession) { // LCOV_EXCL_BR_LINE 200:hsession must not be NULL.
2533 l_eStatus = FrameworkunifiedMcClose(f_ModuleIterator->hsession); // LCOV_EXCL_BR_LINE 4: nsfw error
2534 if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 4: nsfw error
2535 // LCOV_EXCL_START 4: nsfw error
2536 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2537 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: FrameworkunifiedMcClose(%s) errored: %d/'%s'",
2538 f_ModuleIterator->name.c_str(), l_eStatus, GetStr(l_eStatus).c_str());
2541 f_ModuleIterator->hsession = NULL;
2545 if (f_ModuleIterator->is_start_required) {
2546 // Initialize Availability
2547 HANDLE pPublishMq = McOpenSender(FRAMEWORKUNIFIED_NS_NPSERVICE); // LCOV_EXCL_BR_LINE 4: nsfw error
2548 if (NULL == pPublishMq) { // LCOV_EXCL_BR_LINE 4: nsfw error
2549 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2550 SS_ASERT(0); // LCOV_EXCL_LINE 4: nsfw error
2552 ServiceAvailability tServiceAvailability;
2554 snprintf(tServiceAvailability.cServiceName, MAX_NAME_SIZE_APP, "%s",
2555 f_ModuleIterator->name.c_str());
2556 tServiceAvailability.eServiceAvailability = eFrameworkunifiedServiceNotAvailable;
2558 l_eStatus = NPPublishNotification(pPublishMq, f_ModuleIterator->name.c_str(), // LCOV_EXCL_BR_LINE 4: nsfw error
2559 f_availabilityName.c_str(), &tServiceAvailability, // LCOV_EXCL_BR_LINE 4: nsfw error
2560 sizeof(tServiceAvailability)); // LCOV_EXCL_BR_LINE 4: nsfw error
2561 if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 4: nsfw error
2562 // LCOV_EXCL_START 4: nsfw error
2563 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2564 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: NPPublishNotification(%s)",
2565 f_availabilityName.c_str());
2569 l_eStatus = McClose(pPublishMq); // LCOV_EXCL_BR_LINE 4: nsfw error
2570 if (eFrameworkunifiedStatusOK != l_eStatus) {
2571 // LCOV_EXCL_START 4: nsfw error
2572 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2573 SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2579 if (f_ModuleIterator->shutdown_critical) {
2580 // Unregister Stop Complete notification
2581 if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedUnsubscribeNotificationWithCallback(hApp, f_stopCompName.c_str()))) { // LCOV_EXCL_BR_LINE 4: nsfw error // NOLINT(whitespace/line_length)
2582 // LCOV_EXCL_START 4: nsfw error
2583 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2584 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2585 " Error: FrameworkunifiedUnsubscribeNotificationWithCallback(hApp, %s) errored: %d/'%s'",
2586 f_stopCompName.c_str(), l_eStatus, GetStr(l_eStatus).c_str());
2589 SS_String s_ModuleStatus2 = f_stopCompName + " is now unregistered ";
2590 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "%s", s_ModuleStatus2.c_str());
2597 ///////////////////////////////////////////////////////////////////////////////
2598 /// \ingroup SendRequestToLauncher
2599 /// This function is used for sending request to launcher thread from
2602 /// \param HANDLE hApp
2603 /// ModuleLaunchListIter f_ModuleListIterator => iterator node from map for the module
2604 /// ESMPLThreadCommandIds f_CommandId => command id to send
2605 /// SS_String f_ModulePath => Path of the Module
2608 /// EFrameworkunifiedStatus - success or error
2609 ///////////////////////////////////////////////////////////////////////////////
2610 EFrameworkunifiedStatus CSystemManager::SendRequestToLauncher(HANDLE hApp,
2611 ModuleLaunchListIter f_ModuleIterator, ESMPLThreadCommandIds f_CommandId,
2612 SS_String f_CommandIdStr) {
2613 EFrameworkunifiedStatus l_eStatus;
2614 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
2615 SS_String l_ModulePath = m_BinaryFilesPath + f_ModuleIterator->path;
2617 T_ProcessLauncherLaunchReq l_ModuleLaunchReq = { };
2618 strcpy(l_ModuleLaunchReq.name, f_ModuleIterator->name.c_str()); // NOLINT
2619 strcpy(l_ModuleLaunchReq.path, l_ModulePath.c_str()); // NOLINT
2620 strncpy(l_ModuleLaunchReq.args, f_ModuleIterator->arguments.c_str(), // NOLINT
2621 sizeof(l_ModuleLaunchReq.args) - 1);
2622 strcpy(l_ModuleLaunchReq.logging_mask, // NOLINT
2623 f_ModuleIterator->logging_msk_str.c_str());
2624 l_ModuleLaunchReq.priority = f_ModuleIterator->configuration_priority;
2625 l_ModuleLaunchReq.cpu_assign = f_ModuleIterator->cpu_assign;
2626 l_ModuleLaunchReq.groupIterator = m_MapProclaunchGrps.find(
2627 f_ModuleIterator->group_id);
2628 l_ModuleLaunchReq.moduleIterator = f_ModuleIterator;
2630 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
2631 "Queue:%s, path:%s, args:%s, lmsk:%s, prio:%d, cmd:%s", l_ModuleLaunchReq.name,
2632 l_ModuleLaunchReq.path, l_ModuleLaunchReq.args, l_ModuleLaunchReq.logging_mask,
2633 l_ModuleLaunchReq.priority, f_CommandIdStr.c_str());
2635 if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendChild(hApp, m_hProcLauncherThread.m_ThreadHdl, f_CommandId, sizeof(l_ModuleLaunchReq), reinterpret_cast<void *>(&l_ModuleLaunchReq)))) { // LCOV_EXCL_BR_LINE 4: Because an initialization condition is set at SystemManager startup and the branching condition cannot be satisfied // NOLINT(whitespace/line_length)
2636 // LCOV_EXCL_START 4: Because an initialization condition is set at SystemManager startup and the branching condition cannot be satisfied
2637 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2638 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2639 " Error: FrameworkunifiedSendChild( %s, %s ) errored: %d/'%s'", l_ModulePath.c_str(),
2640 f_CommandIdStr.c_str(), l_eStatus, GetStr(l_eStatus).c_str());
2643 SS_String l_availabilityName = f_ModuleIterator->name + "/Availability"; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2644 SS_String l_stopCompName = f_ModuleIterator->name + "/StopComp"; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2645 // Perform command-specific processing
2646 switch (f_CommandId) { // LCOV_EXCL_BR_LINE 6: Because the case is fixed on the call from the SystemManager::Initialize
2647 // LCOV_EXCL_START 6: Because the case is fixed on the call from the SystemManager::Initialize
2648 case ePLThrdCmd_RELAUNCH_MODULE_REQST:
2649 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2650 l_eStatus = PerformTerminateProcedure(hApp, f_ModuleIterator,
2651 l_availabilityName, l_stopCompName);
2652 if (eFrameworkunifiedStatusOK != l_eStatus) {
2656 l_eStatus = PerformLaunchProcedure(hApp, f_ModuleIterator, l_stopCompName);
2657 if (eFrameworkunifiedStatusOK != l_eStatus) {
2663 case ePLThrdCmd_LAUNCH_MODULE_REQST:
2664 l_eStatus = PerformLaunchProcedure(hApp, f_ModuleIterator, l_stopCompName);
2665 if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup
2666 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2667 SS_ASERT(0); // LCOV_EXCL_LINE 6: For setting the initialization conditions at SystemManager startup
2671 case ePLThrdCmd_TERMINATE_MODULE_REQST:
2672 l_eStatus = PerformTerminateProcedure(hApp, f_ModuleIterator,
2673 l_availabilityName, l_stopCompName); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2674 if (eFrameworkunifiedStatusOK != l_eStatus) {
2675 SS_ASERT(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2679 // LCOV_EXCL_START 6: Because the case is fixed on the call from the SystemManager::Initialize
2680 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2681 case ePLThrdCmd_LAUNCH_MODULE_RESP:
2682 case ePLThrdCmd_MODULE_STATUS_REQST:
2683 case ePLThrdCmd_RELAUNCH_MODULE_RESP:
2684 case ePLThrdCmd_TERMINATE_MODULE_RESP:
2685 case ePLThrdCmd_THREAD_STATUS_REQST:
2686 case ePLThrdCmd_THREAD_STATUS_RESP:
2687 case ePLThrdCmd_NONE:
2689 // default: Don't code a 'default' here - let the compiler
2690 // issue a warning ( set via -Wall or -Wswitch ) when the set of
2691 // enumerations changes - then the maintainer will
2692 // automagically know to update this switch statement.
2697 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2699 } // End of EFrameworkunifiedStatus CSystemManager::SendRequestToLauncher(
2701 ///////////////////////////////////////////////////////////////////////////////
2702 /// \ingroup RemoveModuleEntryFromHB
2703 /// This function is called to send module information to heart beat thread
2704 /// which is to be removed from its list of services to be monitored.
2706 /// \param HANDLE hApp,
2707 /// const CHAR *f_ModuleName => Module Name
2710 /// EFrameworkunifiedStatus - success or error
2711 ///////////////////////////////////////////////////////////////////////////////
2712 EFrameworkunifiedStatus CSystemManager::RemoveModuleEntryFromHB(HANDLE hApp, const CHAR *f_ModuleName) {
2713 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
2714 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
2716 HBListIter l_HBIter = std::find(m_HBList.begin(), m_HBList.end(), f_ModuleName);
2717 if (l_HBIter != m_HBList.end()) {
2718 m_HBList.erase(l_HBIter);
2721 TSMRequestMessage l_ModuleDetails;
2722 strncpy(l_ModuleDetails.pstModuleName, f_ModuleName,
2723 sizeof(l_ModuleDetails.pstModuleName) - 1);
2724 l_ModuleDetails.pstModuleName[sizeof(l_ModuleDetails.pstModuleName) - 1] = '\0';
2725 l_eStatus = SendRequestToHeartBeat(hApp, SS_HEARTBEAT_DELETE_MODULE_ENTRY,
2726 &l_ModuleDetails, sizeof(TSMRequestMessage));
2728 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2731 ///////////////////////////////////////////////////////////////////////////////
2732 /// \ingroup OnHeartBeatThreadHeartbeatResponse
2733 /// This function gets called when heart beat thread replies the
2734 /// heart beat query sent by the System Manager.
2735 /// \param [in] hApp
2736 /// HANDLE - Handle of the Client Application
2739 /// EFrameworkunifiedStatus - success or error
2740 ///////////////////////////////////////////////////////////////////////////////
2741 EFrameworkunifiedStatus CSystemManager::OnHeartBeatThreadHeartbeatResponse(HANDLE hApp) {
2742 FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_INFO, __FUNCTION__, "HeartBeat HeartBeat Received");
2743 m_hHeartbeatThread.m_ThreadState = eSMThreadIsFine;
2744 return eFrameworkunifiedStatusOK;
2747 ///////////////////////////////////////////////////////////////////////////////
2748 /// \ingroup OnCheckAvailResponse
2749 /// This function gets service's availability status from HBThread
2750 /// \param [in] hApp
2751 /// HANDLE - Handle of the Client Application
2754 /// EFrameworkunifiedStatus - success or error
2755 ///////////////////////////////////////////////////////////////////////////////
2756 EFrameworkunifiedStatus CSystemManager::OnCheckAvailResponse(HANDLE hApp) {
2757 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
2758 THbAvailCheck result;
2760 if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < THbAvailCheck > (hApp, result))) {
2761 LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_tempaltes.h // NOLINT(whitespace/line_length)
2762 } else if (result.isOk == FALSE) {
2764 return eFrameworkunifiedStatusOK;
2767 ///////////////////////////////////////////////////////////////////////////////
2768 /// \ingroup OnProcessLauncherThreadHeartbeatResponse
2769 /// This function gets called when launcher thread replies the
2770 /// heart beat query sent by the System Manager.
2771 /// \param [in] hApp
2772 /// HANDLE - Handle of the Client Application
2775 /// EFrameworkunifiedStatus - success or error
2776 ///////////////////////////////////////////////////////////////////////////////
2777 EFrameworkunifiedStatus CSystemManager::OnProcessLauncherThreadHeartbeatResponse(HANDLE hApp) {
2778 FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_INFO, __FUNCTION__, "ProcessLaunch HeartBeat Received");
2779 m_hProcLauncherThread.m_ThreadState = eSMThreadIsFine;
2780 return eFrameworkunifiedStatusOK;
2783 ///////////////////////////////////////////////////////////////////////////////
2784 /// \ingroup RegisterCallbacksForRequester
2785 /// Register callbacks for External Protocol commands
2790 /// \return EFrameworkunifiedStatus
2791 /// Success ==> eFrameworkunifiedStatusOK
2792 /// Failure ==> Other values
2793 ///////////////////////////////////////////////////////////////////////////////
2794 EFrameworkunifiedStatus CSystemManager::RegisterCallbacksForRequester(HANDLE hApp, PCSTR f_pRequester) {
2795 EFrameworkunifiedStatus l_eStatus;
2796 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
2798 // Attach Session Protocol messages.
2799 FrameworkunifiedProtocolCallbackHandler l_sm_protocol_handlers[] = {
2800 // Command ID, Call back functions
2801 { SS_SM_START_COMPL_RSPN,
2802 SysMgrCallback<CSystemManager, &CSystemManager::OnModuleStartCompleteResponse> },
2803 { SS_SM_STOP_COMPL_RSPN,
2804 SysMgrCallback<CSystemManager, &CSystemManager::OnModuleStopCompleteResponse> },
2805 { SS_SM_PRE_START_COMPL_RSPN,
2806 SysMgrCallback<CSystemManager, &CSystemManager::OnModuleStartCompleteResponse> },
2807 { SS_SM_PRE_STOP_COMPL_RSPN,
2808 SysMgrCallback<CSystemManager, &CSystemManager::OnModuleStartCompleteResponse> },
2809 { SS_SM_BACKGROUND_START_COMPL_RSPN,
2810 SysMgrCallback<CSystemManager, &CSystemManager::OnModuleStartCompleteResponse> },
2811 { SS_SM_BACKGROUND_STOP_COMPL_RSPN,
2812 SysMgrCallback<CSystemManager, &CSystemManager::OnModuleStartCompleteResponse> },
2813 { SS_SM_GET_START_EXT_INFO, SysMgrCallback<CSystemManager,
2814 &CSystemManager::OnGetStartExtInfo> },
2815 { SS_SM_GET_STOP_EXT_INFO, SysMgrCallback<CSystemManager,
2816 &CSystemManager::OnGetStopExtInfo> },
2817 { SS_SM_CRNT_STATE_QUERY, SysMgrCallback<CSystemManager,
2818 &CSystemManager::OnCurrentSMStateQuery> },
2819 { SS_SM_DATA_RESET_MODE_SET_REQ, SysMgrCallback<CSystemManager,
2820 &CSystemManager::OnSetDataResetModeRequest> },
2821 { SS_SM_PROG_UPDATE_STATE_SET_REQ, SysMgrCallback<CSystemManager,
2822 &CSystemManager::OnSetProgUpdateStateRequest> },
2824 { SS_SM__CWORD56__HEARTBEAT_REQ, SysMgrCallback<CSystemManager,
2825 &CSystemManager::On_CWORD56_HeartBeatRequest> },
2826 { SS_SM_NEXT_WAKEUP_TYPE_SET_REQ, SysMgrCallback<CSystemManager,
2827 &CSystemManager::OnSetNextWakeupTypeRequest> },
2828 // Error Event Logging
2829 { SS_SM_ERROR_EVENT_LOGGING_START_REQ, SysMgrCallback<CSystemManager,
2830 &CSystemManager::OnLoggingStartRequest> },
2831 { SS_SM_ERROR_EVENT_ARTIFACT_REQ, SysMgrCallback<CSystemManager,
2832 &CSystemManager::OnErrorEventArtifactRequest> },
2833 { SS_SM_ERROR_EVENT_LOGGING_COMPLETE, SysMgrCallback<CSystemManager,
2834 &CSystemManager::OnErrorEventLoggingComplete> },
2835 { SS_SM_DEBUG_DUMP_RSPN, SysMgrCallback<CSystemManager,
2836 &CSystemManager::OnDebugDumpResponseReceived> },
2837 { SS_SM_PROPAGATE_SYSTEM_ERROR, SysMgrCallback<CSystemManager,
2838 &CSystemManager::OnPropagateSystemError> },
2839 { SS_SM_BOOT_MICRO_RESET_NTF, SysMgrCallback<CSystemManager,
2840 &CSystemManager::OnBootMicroResetNotification> },
2841 { SS_SM_BOOT_MICRO_LOG_RSP, SysMgrCallback<CSystemManager,
2842 &CSystemManager::OnBootMicroLogResponse> },
2843 { SS_SM_USER_INVOKED_LOG_REQ, SysMgrCallback<CSystemManager,
2844 &CSystemManager::OnUserInvokedLoggingRequest> },
2845 { SS_SM_ERROR_EVENT_EEL_EXPORT_REQ, SysMgrCallback<CSystemManager,
2846 &CSystemManager::OnEelExportRequest> },
2847 { SS_SM_ERROR_EVENT_INTERFACEUNIFIED_EMMC_LOGS_REQ, SysMgrCallback<CSystemManager,
2848 &CSystemManager::OnSystemmanagerEmmcLogsRequest> },
2849 { SS_SM_ERROR_EVENT_CLR_LOGS_REQ, SysMgrCallback<CSystemManager,
2850 &CSystemManager::OnSystemmanagerClearLogsRequest> },
2851 { SS_SM_ERROR_EVENT_DIAG_LOG_REQ, SysMgrCallback<CSystemManager,
2852 &CSystemManager::OnDiagLoggingRequest> },
2853 { SS_SM_ERROR_EVENT_CAN_LOG_REQ, SysMgrCallback<CSystemManager,
2854 &CSystemManager::OnCANLoggingRequest> } }; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2856 l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(hApp, f_pRequester,
2857 l_sm_protocol_handlers, static_cast<UI_32>(_countof(l_sm_protocol_handlers))); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
2859 if (eFrameworkunifiedStatusOK != l_eStatus) {
2860 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2861 " Error: FrameworkunifiedAttachCallbacksToDispatcher(%s) errored: %d/'%s'", f_pRequester,
2862 l_eStatus, GetStr(l_eStatus).c_str());
2864 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2866 } // End of EFrameworkunifiedStatus CSystemManager::RegisterCallbacksForRequester( HANDLE hApp, PCSTR f_pRequester)
2868 ///////////////////////////////////////////////////////////////////////////////
2869 /// \ingroup open_session_with_sm_test_client
2870 /// Process request to open session with sm test client
2875 /// \return EFrameworkunifiedStatus
2876 /// Success ==> eFrameworkunifiedStatusOK
2877 /// Failure ==> Other values
2878 ///////////////////////////////////////////////////////////////////////////////
2879 EFrameworkunifiedStatus CSystemManager::open_session_with_sm_test_client(HANDLE hApp, PCSTR pRequester) {
2880 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
2881 UI_32 const l_ui32DefaultSessionID = 0;
2882 OpenSessionAck tOpenAck = { };
2885 * Here pRequester is SMTesteClient with whom session is opened and its handle is stored in m_hPowerServiceSession handle.
2886 * This case comes only while testing SystemManager through SMTestClient (PowerService should not be running).
2888 // Validate session handle
2889 if (NULL == m_hPowerServiceSession) {
2890 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2891 " Error: Session Handle NULL, calling FrameworkunifiedMcOpenSender for %s", pRequester);
2893 m_hPowerServiceSession = FrameworkunifiedMcOpenSender(hApp, pRequester);
2895 // Set the Session Handle for Framework so FrameworkunifiedSendResponse won't error due to a null
2898 // LCOV_EXCL_BR_START 4:NSFW's error
2899 if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSetSessionHandle(hApp,
2900 pRequester, // [in] PCSTR - Name of the associated service name
2901 m_hPowerServiceSession))) { // [in] HANDLE - Session handle
2902 // LCOV_EXCL_BR_STOP
2903 // LCOV_EXCL_START 4:NSFW's error
2904 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2905 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2906 " Error: FrameworkunifiedSetSessionHandle(%s) errored: %d/'%s'", pRequester,
2907 l_eStatus, GetStr(l_eStatus).c_str());
2908 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2914 if (m_hPowerServiceSession == NULL) { // LCOV_EXCL_BR_LINE 200:m_hPowerServiceSession must not be NULL
2915 // LCOV_EXCL_START 200:m_hPowerServiceSession must not be NULL
2916 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2917 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2918 " Error: Invalid Session Handle to service (%s) ", pRequester);
2921 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Session opened with %s", pRequester);
2923 // Copy session name to data structure
2924 strncpy(tOpenAck.cSessionName, FrameworkunifiedGetAppName(hApp),
2925 sizeof(tOpenAck.cSessionName) - 1);
2926 tOpenAck.eStatus = eFrameworkunifiedStatusOK;
2927 tOpenAck.sessionId = l_ui32DefaultSessionID;
2929 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "About to send Open Session ACK");
2930 // send OpenSession ACK
2931 // LCOV_EXCL_BR_START 4:NSFW's error
2932 if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendMsg(m_hPowerServiceSession,
2933 PROTOCOL_OPEN_SESSION_ACK, sizeof(OpenSessionAck),
2934 (PVOID) & tOpenAck))) {
2935 // LCOV_EXCL_BR_STOP
2936 // LCOV_EXCL_START 4:NSFW's error
2937 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
2938 LOG_ERROR("FrameworkunifiedSendMsg(PROTOCOL_OPEN_SESSION_ACK)");
2940 // Close the message queue handle
2941 if (NULL != m_hPowerServiceSession) {
2942 CALL_AND_LOG_STATUS_IF_ERRORED(FrameworkunifiedMcClose(m_hPowerServiceSession));
2943 m_hPowerServiceSession = NULL;
2947 CALL_AND_LOG_STATUS_IF_ERRORED(RegisterCallbacksForRequester(hApp, pRequester));
2949 } // end of else block of if(l_ModuleListIterator->hsession == NULL)
2951 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
2955 ///////////////////////////////////////////////////////////////////////////////
2956 /// \ingroup OnOpenSession
2957 /// Process request to open session
2962 /// \return EFrameworkunifiedStatus
2963 /// Success ==> eFrameworkunifiedStatusOK
2964 /// Failure ==> Other values
2965 ///////////////////////////////////////////////////////////////////////////////
2966 EFrameworkunifiedStatus CSystemManager::OnOpenSession(HANDLE hApp) {
2967 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
2968 INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2969 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
2970 UI_32 const l_ui32DefaultSessionID = 0;
2971 UI_32 const l_ui32DefaultSessionType = 0;
2972 OpenSessionAck tOpenAck = { };
2973 PCSTR pRequester = FrameworkunifiedGetMsgSrc(hApp);
2974 FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "%s", pRequester);
2976 ModuleLaunchListIter l_ModuleListIter;
2978 REC_HIST_IF_SUCCESSFUL("PROTOCOL_OPEN_SESSION_REQ", m_SMCmdHist, m_SMHistIter, // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
2979 FrameworkunifiedGetMsgSrc(hApp), l_eStatus); // LCOV_EXCL_BR_LINE 15: marco defined in ss_system_manager.h // NOLINT(whitespace/line_length)
2981 l_eStatus = GetModuleIterator(pRequester, l_ModuleListIter);
2983 if (eFrameworkunifiedStatusOK != l_eStatus) {
2984 // Special handling for open session request from SMTestClient.
2985 if ((0 == strcmp(TC_SysManager, pRequester))) {
2986 open_session_with_sm_test_client(hApp, pRequester);
2988 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error: %s not found in Group Launch Map",
2992 /**********************************************************************/
2993 if (0 != l_ModuleListIter->pid) {
2994 UI_32 l_ClientPriority;
2995 l_eStatus = l_ModuleListIter->GetPriority(l_ClientPriority);
2997 if (eFrameworkunifiedStatusOK != l_eStatus) {
2998 LOG_ERROR("l_ModuleListIter->GetPriority( l_ClientPriority )"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
2999 } else if (l_ClientPriority != l_ModuleListIter->configuration_priority) {
3000 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, " Changing %s's priority from %d to %d",
3001 pRequester, l_ClientPriority,
3002 l_ModuleListIter->configuration_priority);
3003 CALL_AND_LOG_STATUS_IF_ERRORED( // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
3004 l_ModuleListIter->SetPriority( // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
3005 l_ModuleListIter->configuration_priority)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
3008 /**********************************************************************/
3010 // ToDo Jay 2013 Jan 09 REPLACE WITH CORRECT SERVICE / SESSION HANDLE
3012 // validate session handle
3013 if (NULL == l_ModuleListIter->hsession) {
3014 // LCOV_EXCL_BR_START 4: nsfw error
3015 if (NULL == (l_ModuleListIter->hsession = FrameworkunifiedMcOpenSender(hApp, pRequester))) {
3016 // LCOV_EXCL_BR_STOP 4: nsfw error
3017 // LCOV_EXCL_START 4: nsfw error
3018 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
3019 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
3020 " Error: FrameworkunifiedMcOpenSender(App %s, %s) returned NULL",
3021 FrameworkunifiedGetAppName(hApp), pRequester);
3022 return eFrameworkunifiedStatusInvldHandle;
3027 * Currently System Manager does not support multiple sessions from same client.
3028 * When a client gets restarted after Crash or after missing HeartBeat, System Manager
3029 * would receive OpenSession request from that client even when System Manager already
3030 * has a open session with that client.
3032 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
3033 " Warning: Repeated Session Opening Request from %s", pRequester);
3035 if (eFrameworkunifiedStatusOK != (l_eStatus = RegisterCallbacksForRequester(hApp, pRequester))) {
3036 // Close the message queue handle
3037 if (NULL != l_ModuleListIter->hsession) { // LCOV_EXCL_BR_LINE 6: Due to NULL checking
3038 if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedMcClose(l_ModuleListIter->hsession))) {
3039 LOG_ERROR("FrameworkunifiedMcClose()"); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
3041 l_ModuleListIter->hsession = NULL;
3043 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
3047 // Copy session name to data structure
3048 strncpy(tOpenAck.cSessionName, FrameworkunifiedGetAppName(hApp), sizeof(tOpenAck.cSessionName) - 1);
3049 tOpenAck.eStatus = eFrameworkunifiedStatusOK;
3050 tOpenAck.sessionId = l_ui32DefaultSessionID;
3051 tOpenAck.sessionType = l_ui32DefaultSessionType;
3053 // send OpenSession ACK
3054 // LCOV_EXCL_BR_START 4: nsfw error
3055 if (eFrameworkunifiedStatusOK
3056 != (l_eStatus = FrameworkunifiedSendMsg(l_ModuleListIter->hsession,
3057 SS_SM_PROTOCOL_OPEN_SESSION_ACK, sizeof(OpenSessionAck),
3058 (PVOID) & tOpenAck))) { // LCOV_EXCL_BR_STOP
3059 // LCOV_EXCL_START 4: nsfw error
3060 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
3061 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
3062 " Error: FrameworkunifiedSendMsg( %s, SS_SM_PROTOCOL_OPEN_SESSION_ACK)"
3063 " errored: %d/'%s'", l_ModuleListIter->name.c_str(), l_eStatus,
3064 GetStr(l_eStatus).c_str());
3066 if (NULL != l_ModuleListIter->hsession) {
3067 // Close the message queue handle
3068 if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedMcClose(l_ModuleListIter->hsession))) {
3069 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
3070 " Error: FrameworkunifiedMcClose(%s) errored: %d/'%s'",
3071 l_ModuleListIter->name.c_str(), l_eStatus,
3072 GetStr(l_eStatus).c_str());
3073 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
3075 l_ModuleListIter->hsession = NULL;
3079 // Store PowerService session handle in class so it can be accessed faster
3080 // to use opened session while replying to PowerService.
3081 if ((0 == strcmp(SERVICE_POWER, pRequester))) {
3082 m_hPowerServiceSession = l_ModuleListIter->hsession;
3085 l_ModuleListIter->SetModuleState(MODULE_STATE_CONNECTED);
3087 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " SM State: %s, %s.is_start_required: %s",
3088 GetStr(m_SMCurrentState).c_str(), l_ModuleListIter->name.c_str(),
3089 GetStr(l_ModuleListIter->is_start_required).c_str());
3091 if (l_ModuleListIter->is_start_required
3092 && ((SS_SM_APPS_START_IN_PROGRESS == m_SMCurrentState)
3093 || (SS_SM_APPS_START_COMPLETE == m_SMCurrentState))) {
3094 T_SS_SM_START_DataStructType f_startupData(m_StartUpReason,
3095 m_PowerType_to_SSBoolEnumMap[m_Wake.powerupType], m_DataResetMode,
3096 m_startUpConfirmationMsg.securityStatus,
3097 m_startUpConfirmationMsg.wakeupType, m_DramBackupStatus,
3098 m_ResetStatus, m_ResetCount);
3099 const UI_32 l_iCmd = InProgressStateToSendMsg();
3100 if (l_iCmd != SS_SYSTEM_MANAGER_PROTOCOL_ENDING_INDEX) {
3101 CALL_AND_LOG_STATUS_IF_ERRORED(l_ModuleListIter->SendMsgAndUpdateState(l_iCmd, &f_startupData)); // LCOV_EXCL_BR_LINE 11: Gcov constraints (because exception-handling routes are automatically generated) // NOLINT(whitespace/line_length)
3107 if (eFrameworkunifiedStatusOK == l_eStatus) {
3108 std::string l_Subscriber;
3109 l_Subscriber = FrameworkunifiedGetMsgSrc(hApp);
3111 // check if the heart beat subscriber is already in list
3112 HBListIter l_HBIter = std::find(m_HBList.begin(), m_HBList.end(), l_Subscriber);
3113 if (l_HBIter == m_HBList.end()) {
3114 m_HBList.push_back(l_Subscriber);
3116 if (m_SMCurrentState == SS_SM_APPS_START_COMPLETE) {
3117 TSMRequestMessage l_ModuleDetails;
3118 snprintf(l_ModuleDetails.pstModuleName, sizeof(l_ModuleDetails.pstModuleName),
3119 "%s", l_Subscriber.c_str());
3120 l_eStatus = SendRequestToHeartBeat(hApp, SS_HEARTBEAT_APPEND_MODULE_ENTRY,
3121 &l_ModuleDetails, sizeof(TSMRequestMessage));
3122 LOG_ERROR_REC_HIST_IF_ERRORED(l_eStatus, "SendRequestToHeartBeat()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
3126 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
3130 ///////////////////////////////////////////////////////////////////////
3131 /// ConstructGetResultResponse
3134 //////////////////////////////////////////////////////////////////////
3135 EFrameworkunifiedStatus CSystemManager::add_state_information_to_response(CHAR *f_MessageResponse) const {
3136 const CHAR ReadyToLaunchAppDescription[] = "_READY_TO_LAUNCH:";
3137 const CHAR StartInProgressDescription[] = "_START_IN_PROGRESS:";
3138 const CHAR LaunchInProgressDescription[] = "_LAUNCH_IN_PROGRESS:";
3139 const CHAR LaunchedReadyToStartDescription[] = "_READY_TO_START:";
3140 const CHAR StopInProgressDescription[] = "_STOP_IN_PROGRESS:";
3141 const CHAR StartCompleteDescription[] = "_START_COMPLETED:";
3142 const CHAR WaitingForCriticalAppsToStopDescription[] = "_WAITING_FOR_CRITICAL_APPS_TO_STOP:";
3143 const CHAR PreStartInProgressDescription[] = "_PRE_START_IN_PROGRESS:";
3144 const CHAR PreStopInProgressDescription[] = "_PRE_STOP_IN_PROGRESS:";
3145 const CHAR PreRunCompleteDescription[] = "_PRE_RUN_COMPLETE:";
3146 const CHAR BackgroundStartInProgressDescription[] = "_BACKGROUND_START_IN_PROGRESS:";
3147 const CHAR BackgroundStopInProgressDescription[] = "_BACKGROUND_STOP_IN_PROGRESS:";
3148 const CHAR BackgroundRunCompleteDescription[] = "_BACKGROUND_RUN_COMPLETE:";
3149 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
3150 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
3154 std::map<SS_SMModuleState, std::string> StateMap; // State Map
3155 StateMap[SS_SM_READY_TO_LAUNCH_APP] = ReadyToLaunchAppDescription;
3156 StateMap[SS_SM_APPS_LAUNCH_IN_PROGRESS] = LaunchInProgressDescription;
3157 StateMap[SS_SM_APPS_LAUNCHED_READY_TO_START] = LaunchedReadyToStartDescription;
3158 StateMap[SS_SM_APPS_START_IN_PROGRESS] = StartInProgressDescription;
3159 StateMap[SS_SM_APPS_START_COMPLETE] = StartCompleteDescription;
3160 StateMap[SS_SM_APPS_STOPPING_AT__CWORD56__REQ] = StopInProgressDescription;
3161 StateMap[SS_SM_APPS_STOPPING_AT_INTERNAL_REQ] = StopInProgressDescription;
3162 StateMap[SS_SM_WAITING_FOR_CRITICAL_APPS_AT_INTERNAL_REQ] =
3163 WaitingForCriticalAppsToStopDescription;
3164 StateMap[SS_SM_WAITING_FOR_CRITICAL_APPS_AT__CWORD56__REQ] =
3165 WaitingForCriticalAppsToStopDescription;
3166 StateMap[SS_SM_APPS_PRE_START_IN_PROGRESS] = PreStartInProgressDescription;
3167 StateMap[SS_SM_APPS_PRE_STOP_IN_PROGRESS] = PreStopInProgressDescription;
3168 StateMap[SS_SM_APPS_PRE_RUN_COMPLETE] = PreRunCompleteDescription;
3169 StateMap[SS_SM_APPS_BACKGROUND_START_IN_PROGRESS] = BackgroundStartInProgressDescription;
3170 StateMap[SS_SM_APPS_BACKGROUND_STOP_IN_PROGRESS] = BackgroundStopInProgressDescription;
3171 StateMap[SS_SM_APPS_BACKGROUND_RUN_COMPLETE] = BackgroundRunCompleteDescription;
3173 itoa(m_SMCurrentState, l_Buffer, 16);
3174 while (l_Buffer[l_Index]) {
3175 l_Buffer[l_Index] = toupper(l_Buffer[l_Index]);
3179 if (SS_SM_MAX_RESP_MSG_SIZE > (strlen(f_MessageResponse) + sizeof(l_Buffer)
3180 + StateMap[m_SMCurrentState].length() + 1)) {
3181 strncat(f_MessageResponse, l_Buffer, sizeof(l_Buffer));
3182 strncat(f_MessageResponse, StateMap[m_SMCurrentState].c_str(),
3183 StateMap[m_SMCurrentState].length());
3185 eStatus = eFrameworkunifiedStatusFail;
3188 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
3192 ///////////////////////////////////////////////////////////////////////
3193 /// ConstructGetResultResponse
3196 //////////////////////////////////////////////////////////////////////
3197 EFrameworkunifiedStatus CSystemManager::construct_get_result_response(CHAR *f_MessageResponse) {
3198 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
3199 const EFrameworkunifiedStatus eStatus = add_state_information_to_response(f_MessageResponse);
3200 if (eFrameworkunifiedStatusOK == eStatus) {
3201 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Response Constructed");
3204 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
3208 ///////////////////////////////////////////////////////////////////////
3209 /// REC_HIST_IF_SUCCESSFUL / SetCmdHist
3212 //////////////////////////////////////////////////////////////////////
3213 void CSystemManager::SetCmdHist(std::string cmd, cmdHist &hist, cmdHistIter &it, std::string sender) {
3214 UI_64 l_time = 0XDEAD;
3215 CTimeSpan* timerClass = new (std::nothrow) CTimeSpan(); // LCOV_EXCL_BR_LINE 5: Because new cannot fail
3216 if (NULL == timerClass) { // LCOV_EXCL_BR_LINE 5: Because new cannot fail
3217 // LCOV_EXCL_START 5: Because new cannot fail
3218 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
3219 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
3220 " 'new (std::nothrow) CTimeSpan()' returned NULL, "
3221 "'it->m_time' being set to 0xDEAD");
3224 l_time = timerClass->GetTimeMilliseconds();
3227 pthread_mutex_lock(&sm_hist_mutex);
3229 it->m_time = l_time;
3231 it->m_sender = sender;
3234 if (it != hist.end()) { // LCOV_EXCL_BR_LINE 5: std: because it is a member of a vector and it is difficult to create a failing condition
3238 pthread_mutex_unlock(&sm_hist_mutex);
3240 delete timerClass; // LCOV_EXCL_BR_LINE 5: Because the delete cannot fail
3243 ///////////////////////////////////////////////////////////////////////
3244 /// OnCurrentPowerStateQuery
3247 //////////////////////////////////////////////////////////////////////
3248 EFrameworkunifiedStatus CSystemManager::OnCurrentSMStateQuery(HANDLE hApp) {
3249 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
3250 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
3251 INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp);
3252 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "Received from %s", FrameworkunifiedGetMsgSrc(hApp));
3254 SS_SMCurrentState l_CurrentState;
3256 REC_HIST_IF_SUCCESSFUL("SS_SM_CRNT_STATE_QUERY", m_SMCmdHist, m_SMHistIter,
3257 FrameworkunifiedGetMsgSrc(hApp), l_eStatus);
3258 if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < SS_SMCurrentState > (hApp, l_CurrentState))) {
3259 LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
3261 construct_get_result_response(l_CurrentState.respMsgString);
3263 ModuleLaunchListIter l_ModuleListIter;
3264 PCSTR l_moduleName = FrameworkunifiedGetMsgSrc(hApp);
3265 if (eFrameworkunifiedStatusOK != (l_eStatus = GetModuleIterator(l_moduleName, l_ModuleListIter))) { // LCOV_EXCL_BR_LINE 200: can not be other value // NOLINT (whitespace/line_length)
3266 // LCOV_EXCL_START 200: can not be other value
3267 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
3268 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
3269 " Error: Module %s not found in Group Launch Map", l_moduleName);
3271 } else if (l_ModuleListIter->hsession != NULL) { // LCOV_EXCL_BR_LINE 200: can not be NULL // NOLINT (whitespace/line_length)
3272 if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendMsg(l_ModuleListIter->hsession, // LCOV_EXCL_BR_LINE 4: nsfw error
3273 SS_SM_CRNT_STATE_QUERY_RSPN, sizeof(SS_SMCurrentState),
3274 (PVOID) & l_CurrentState))) {
3275 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
3276 LOG_ERROR("FrameworkunifiedSendMsg(SS_SM_CRNT_STATE_QUERY_RSPN)"); // LCOV_EXCL_LINE 4: nsfw error
3279 // LCOV_EXCL_START 200: can not be NUL
3280 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
3281 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " NULL == hsession; %s not connected yet",
3282 l_ModuleListIter->name.c_str());
3287 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
3291 EFrameworkunifiedStatus CSystemManager::GetVersionNumber(SS_VersionNumberType & f_VersionNumber) {
3292 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
3293 EFrameworkunifiedStatus l_eStatus;
3295 CSMVersion cVersion;
3296 if (eFrameworkunifiedStatusOK != (l_eStatus = cVersion.get_version(f_VersionNumber))) { // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup // NOLINT(whitespace/line_length)
3297 LOG_ERROR("cVersion.get_version()"); // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup // NOLINT(whitespace/line_length)
3299 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
3301 } // End of EFrameworkunifiedStatus CSystemManager::GetVersionNumber( SS_VersionNumberType
3303 EFrameworkunifiedStatus CSystemManager::GetBuildInfo(std::string &f_BuildInfoStr) {
3304 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
3305 EFrameworkunifiedStatus l_eStatus;
3307 CSMVersion cVersion;
3308 if (eFrameworkunifiedStatusOK != (l_eStatus = cVersion.get_build_info(f_BuildInfoStr))) { // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup // NOLINT(whitespace/line_length)
3309 LOG_ERROR("cVersion.get_build_info()"); // LCOV_EXCL_BR_LINE 6:For setting the initialization conditions at SystemManager startup // NOLINT(whitespace/line_length)
3311 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
3313 } // End of EFrameworkunifiedStatus CSystemManager::GetBuildInfo(std::string)
3315 bool CSystemManager::GetDramPowerStatusInfo(const HANDLE h_app) {
3316 PsmDramStsT l_dram_sts = PSM_DRAM_STS_NORMAL;
3319 // Checking dram power status.
3320 if (PsmGetDramPowerSupplyAbnormalityCheckResultPower(h_app, &l_dram_sts))
3323 if (l_dram_sts == PSM_DRAM_STS_NORMAL)
3329 bool CSystemManager::GetDramStoreStatusInfo(const HANDLE h_app) {
3330 PsmSysupDramT l_dram1 = PSM_SYSUP_DRAM_NORMAL;
3331 PsmSysupDramT l_dram2 = PSM_SYSUP_DRAM_NORMAL;
3332 PsmSysupDramT l_dram3 = PSM_SYSUP_DRAM_NORMAL;
3333 PsmStartStatusT l_sts = PSM_START_STATUS_FACTRESET;
3337 // Checking factory shipment status
3338 if (PsmGetStartStatusPower(h_app, &l_sts))
3341 if (l_sts == PSM_START_STATUS_FACTRESET) {
3346 // Checking dram power
3347 if (!GetDramPowerStatusInfo(h_app))
3350 // Checking dram status.
3351 if (PsmGetDramBackupStatusPower(h_app, &l_dram1, &l_dram2, &l_dram3))
3354 // l_dram2 and l_dram3 would be ignored.
3355 if (l_dram1 == PSM_SYSUP_DRAM_NORMAL)
3358 if (l_dram2 == PSM_SYSUP_DRAM_SFTERRSR)
3365 bool CSystemManager::GetSyscomPowerStatusInfo(const HANDLE h_app) {
3366 PsmComStsT l_syscom_sts = PSM_COM_STS_NORMAL;
3369 if (PsmGetSyscomStatusPower(h_app, &l_syscom_sts))
3372 if (l_syscom_sts == PSM_COM_STS_NORMAL)
3378 EFrameworkunifiedStatus CSystemManager::OnSetStartupConfirmationDataRequest(HANDLE hApp) {
3379 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
3380 INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
3381 FRAMEWORKUNIFIEDLOG(ZONE_PERFORMANCE, __FUNCTION__, "from %s", FrameworkunifiedGetMsgSrc(hApp));
3382 EFrameworkunifiedStatus l_eStatus;
3383 Pwr_ServiceSetInterface tServiceSetIf;
3385 // Check hApp ptr, msg size, msg reception, read msg if all ok. *
3386 // Report any errors found. *
3388 if (eFrameworkunifiedStatusOK
3389 != (l_eStatus = ReadMsg < Pwr_ServiceSetInterface > (hApp, tServiceSetIf))) { // LCOV_EXCL_BR_LINE 4:NSFW's error
3390 // LCOV_EXCL_START 4:NSFW's error
3391 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
3392 LOG_ERROR("ReadMsg()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
3395 m_startUpConfirmationMsg = tServiceSetIf.data.startupConfirmationMsg;
3396 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " %s Startup Confirmation data:", FrameworkunifiedGetMsgSrc(hApp));
3397 SYSTEMMANAGERLOG_StartupConfirmationMsg(m_startUpConfirmationMsg); // LCOV_EXCL_BR_LINE 15: marco defined in ns_logger_if.h // NOLINT(whitespace/line_length)
3398 DGCODE_RET_API l_ret = DGCODE_RET_ERROR;
3400 l_ret = Diag_StartupAllStatusOfDTC();
3401 if (l_ret == DGCODE_RET_ERROR) {
3402 LOG_ERROR("Diag_StartupAllStatusOfDTC()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
3405 if ((e_SS_SM_NEXT_WAKEUP_TYPE_COLD == m_NextWakeupType) && (epsstCOLDSTART != m_startUpConfirmationMsg.wakeupType)) { // LCOV_EXCL_BR_LINE 6: Because the above formula cannot be set to true // NOLINT(whitespace/line_length)
3406 // LCOV_EXCL_START 6: Because the condition cannot be set
3407 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
3408 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "WakeupType Change to Cold by Svc Request");
3409 m_startUpConfirmationMsg.wakeupType = epsstCOLDSTART;
3413 m_ResetStatus = ((m_isIlgReset == TRUE) ?
3414 e_SS_SM_RESET_STATUS_NG :
3415 ((m_isImmediateReset == TRUE) ?
3416 e_SS_SM_RESET_STATUS_IMMEDIATE : e_SS_SM_RESET_STATUS_NONE));
3417 if (e_SS_SM_RESET_STATUS_NG == m_ResetStatus) {
3418 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
3419 "ResetStatus NG illRst:%s lastErr:Not Support",
3420 m_isIlgReset ? "TRUE" : "FALSE");
3422 if (PowerHalSetResetInfo(AGL_RESET_COUNTER, m_ResetCount)) {
3423 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
3424 "Could not back up m_ResetCount(%lu) to power_hal", m_ResetCount);
3428 m_DramBackupStatus =
3429 ((epsstWARMSTART != m_startUpConfirmationMsg.wakeupType)
3430 || (e_SS_SM_DATA_RESET_MODE_FACTORY == m_DataResetMode)
3431 || (GetDramStoreStatusInfo(hApp) == false)) ?
3432 e_SS_SM_DRAM_BACKUP_NG : e_SS_SM_DRAM_BACKUP_OK;
3434 if (e_SS_SM_DRAM_BACKUP_NG == m_DramBackupStatus) {
3435 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
3436 "DramBackup NG wakeupType:%s dataResetMode:%s",
3437 (epsstWARMSTART == m_startUpConfirmationMsg.wakeupType) ?
3439 (e_SS_SM_DATA_RESET_MODE_FACTORY == m_DataResetMode) ?
3440 "FACTORY" : "NotFactory");
3443 if (m_needReNotifyStartPrm) { // LCOV_EXCL_BR_LINE 6: Because the condition cannot be satisfied from the external API
3444 // LCOV_EXCL_BR_START 6: Because both sides are not FALSE
3445 if (e_SS_SM_DRAM_BACKUP_NG == m_DramBackupStatus) {
3446 // LCOV_EXCL_BR_STOP
3447 m_DramBackupStatus = e_SS_SM_DRAM_BACKUP_NG;
3451 if (m_needReNotifyStartPrm) { // LCOV_EXCL_BR_LINE 6: Because the condition cannot be satisfied from the external API
3452 if (e_SS_SM_RESET_STATUS_NG == m_ResetStatus) {
3453 // do nothing, keep m_ResetStatus.
3454 } else if (e_SS_SM_RESET_STATUS_IMMEDIATE == m_ResetStatus) {
3455 // do nothing, keep m_ResetStatus.
3457 m_ResetStatus = e_SS_SM_RESET_STATUS_NONE;
3460 if (epsstWARMSTART != m_startUpConfirmationMsg.wakeupType) { // LCOV_EXCL_BR_LINE 6: Because the above condition cannot be satisfied // NOLINT(whitespace/line_length)
3461 m_startUpConfirmationMsg.wakeupType = epsstCOLDSTART;
3465 CALL_AND_LOG_STATUS(ClearDramBackupInfo(hApp)); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
3467 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "\n"
3469 "dramBackupStatus = %s\n"
3471 "dataResetMode = %s\n"
3472 "resetStatus = %s\n"
3474 "progUpdateState = %d",
3475 (m_DramBackupStatus == e_SS_SM_DRAM_BACKUP_OK) ? "OK" : "NG",
3476 (m_startUpConfirmationMsg.wakeupType == epsstWARMSTART) ? "WARM" : "COLD",
3477 (m_DataResetMode == e_SS_SM_DATA_RESET_MODE_FACTORY) ? "FACT" :
3478 (m_DataResetMode == e_SS_SM_DATA_RESET_MODE_USER) ? "USER" :
3479 (m_DataResetMode == e_SS_SM_DATA_RESET_MODE_PROGUPDATE) ? "PROG" : "NONE",
3480 (m_ResetStatus == e_SS_SM_RESET_STATUS_IMMEDIATE) ? "IMM" :
3481 (m_ResetStatus == e_SS_SM_RESET_STATUS_NONE) ? "NONE" : "NG", m_ResetCount,
3484 if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedNPPublishNotification(hApp, NTFY_SSSystemMgrStartUpType, &m_startUpConfirmationMsg.wakeupType, sizeof(EPWR_SC_WAKEUP_TYPE)))) { // LCOV_EXCL_BR_LINE 4:NSFW error case //NOLINT (whitespace/line_length)
3485 // LCOV_EXCL_START 4: nsfw error
3486 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
3487 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
3488 " Error: FrameworkunifiedNPPublishNotification(%s, %s) errored: %d/'%s'",
3489 NTFY_SSSystemMgrStartUpType,
3490 GetStr(m_startUpConfirmationMsg.wakeupType).c_str(), l_eStatus,
3491 GetStr(l_eStatus).c_str());
3494 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " FrameworkunifiedNPPublishNotification(%s, %s) successful",
3495 NTFY_SSSystemMgrStartUpType,
3496 GetStr(m_startUpConfirmationMsg.wakeupType).c_str());
3498 // LCOV_EXCL_BR_START 200: As there are no cases other than eFrameworkunifiedStatusOK
3499 REC_HIST_IF_SUCCESSFUL("SM/StartUpType",
3500 m_PubCmdHist, m_PubHistIter, "", l_eStatus);
3501 // LCOV_EXCL_BR_STOP
3505 EFrameworkunifiedStatus l_responseStatus = l_eStatus;
3507 ModuleLaunchListIter l_ModuleListIter;
3508 PCSTR l_moduleName = FrameworkunifiedGetMsgSrc(hApp);
3509 if (eFrameworkunifiedStatusOK != (l_eStatus = GetModuleIterator(l_moduleName, l_ModuleListIter))) {
3510 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
3511 " Error: Module %s not found in Group Launch Map", l_moduleName);
3512 } else if (l_ModuleListIter->hsession != NULL) {
3513 if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendMsg(l_ModuleListIter->hsession, // LCOV_EXCL_BR_LINE 4:NSFW's error
3514 SS_SM_FWD_START_CONFIRMATION_MSG_RESP, sizeof(EFrameworkunifiedStatus),
3515 (PVOID) & l_responseStatus))) {
3516 // LCOV_EXCL_START 4:NSFW's error
3517 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
3518 LOG_ERROR("FrameworkunifiedSendMsg(SS_SM_FWD_START_CONFIRMATION_MSG_RESP)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
3522 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " NULL == hsession; %s not connected yet", l_ModuleListIter->name.c_str());
3524 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
3526 } // End of EFrameworkunifiedStatus CSystemManager::OnSetStartupConfirmationDataRequest( HANDLE hApp )
3528 EFrameworkunifiedStatus CSystemManager::GetTimeStamp(std::string& TimeStamp) {
3529 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
3530 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
3532 CHAR format[256] = { '\0' };
3533 CHAR l_format[256] = { '\0' };
3534 struct timeb timebuf;
3539 Clock_getSystemTimeY2K38(&time, &status);
3540 CLOCK_RETURN clock_ret = Clock_CnvSecToDateY2K38(&time, &theTime);
3542 if (CLOCK_OK != clock_ret) {
3543 return eFrameworkunifiedStatusNullPointer;
3546 sprintf(l_format, "GMT Time,%04d-%02d-%02d %02d:%02d:%02d.%hu\n", // NOLINT
3547 theTime.tm_year + 1900, theTime.tm_mon + 1, theTime.tm_mday,
3548 theTime.tm_hour, theTime.tm_min, theTime.tm_sec, timebuf.millitm);
3550 struct timespec timeSpec;
3552 if (0 != clock_gettime(CLOCK_MONOTONIC, &timeSpec)) {
3553 SS_ASERT_ERRNO(0); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length)
3555 time_t timeInSecs = timeSpec.tv_sec;
3556 sprintf(format, "Elaps Time,%ld:%02ld:%02ld\n", (timeInSecs / 3600), // NOLINT
3557 ((timeInSecs % 3600) / 60), (timeInSecs % 60));
3561 TimeStamp.assign(format);
3562 TimeStamp.append(l_format);
3564 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
3568 VOID CSystemManager::SYSTEMMANAGERLOG_StartupConfirmationMsg(EPWR_SC_MSG_STRUCT & f_scMsg) {
3569 std::stringstream l_enumStr;
3571 l_enumStr << " HostProcSoftVer:" << hex << std::setw(16) << std::setfill('0')
3572 << m_VersionNumberStruct.m_VersionNumber << endl;
3573 l_enumStr << " _CWORD56_ Boot Mode:" << GetStr(f_scMsg._CWORD56_BootMode) << endl; // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
3574 l_enumStr << " wakeupType :" << GetStr(f_scMsg.wakeupType); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
3576 FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "%s", l_enumStr.str().c_str());
3577 } // End of VOID CSystemManager::SYSTEMMANAGERLOG_StartupConfirmationMsg( EPWR_SC_MSG_STRUCT & f_scMsg )
3579 VOID CSystemManager::LogESystemmanagerStatusEnums() {
3580 #define INITIAL_INDEX eFrameworkunifiedStatusEmptyMediaList
3581 #define FINAL_INDEX eFrameworkunifiedStatusErrNoEINTR
3583 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
3584 std::stringstream l_enumStr;
3585 for (int i = INITIAL_INDEX; i <= FINAL_INDEX; i++) {
3586 // LCOV_EXCL_BR_START 11:unexpected branch // NOLINT(whitespace/line_length)
3587 l_enumStr << "\n" << "0x" << std::setfill('0') << std::setw(8) << hex << i
3588 << "/" << std::setfill(' ') << std::setw(2) << dec << i << ": "
3589 << GetStr(static_cast<EFrameworkunifiedStatus>(i));
3590 // LCOV_EXCL_BR_STOP
3593 std::string l_logMsg = l_enumStr.str();
3594 SystemmanagerLogString(ZONE_INFO, __FUNCTION__, l_logMsg); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
3595 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
3597 #undef INITIAL_INDEX
3599 } // End of VOID CSystemManager::LogESystemmanagerStatusEnums()
3601 VOID CSystemManager::LogProtocolIDs() {
3602 #define INITIAL_INDEX SS_SYSTEM_MANAGER_PROTOCOL_BEGINNING_INDEX
3603 #define FINAL_INDEX SS_SYSTEM_MANAGER_PROTOCOL_ENDING_INDEX
3605 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
3606 std::stringstream l_enumStr;
3607 for (int i = INITIAL_INDEX; i <= FINAL_INDEX; i++) {
3608 // LCOV_EXCL_BR_START 11:unexpected branch // NOLINT(whitespace/line_length)
3609 l_enumStr << "\n" << "0x" << std::setfill('0') << std::setw(8) << hex << i
3610 << "/" << std::setfill(' ') << std::setw(2) << dec << i << ": "
3611 << GetStr(static_cast<SS_SystemManagerProtocol>(i));
3612 // LCOV_EXCL_BR_STOP
3615 std::string l_logMsg = l_enumStr.str();
3616 SystemmanagerLogString(ZONE_INFO, __FUNCTION__, l_logMsg); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length)
3617 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
3619 #undef INITIAL_INDEX
3621 } // End of VOID CSystemManager::LogProtocolIDs()
3623 VOID CSystemManager::SystemmanagerLogString(TFrameworkunifiedZone f_zone, PCSTR f_func, std::string &f_text) {
3624 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
3626 UI_32 l_msgLenMax = MAX_QUEUE_MSG_SIZE - 512; // Leave space for the appending of
3627 // the NSLog date/time/service/line string.
3629 if (f_text.at(f_text.length() - 1) == '\n') { // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup
3630 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
3631 f_text.erase(f_text.length() - 1); // LCOV_EXCL_LINE 6: For setting the initialization conditions at SystemManager startup
3634 while (l_offset < f_text.size()) {
3635 UI_32 l_charsRem = static_cast<UI_32>(f_text.size() - l_offset);
3636 UI_32 l_msgLen = (l_charsRem > l_msgLenMax) ? // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup
3637 l_msgLenMax : l_charsRem; // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup
3638 std::string l_msgStr = f_text.substr(l_offset, l_msgLen);
3639 size_t l_newLinePos = l_msgStr.find_last_of("\n", l_msgLen);
3640 if ((l_newLinePos != std::string::npos) && (l_charsRem > l_msgLenMax)) { // LCOV_EXCL_BR_LINE 6: For setting the initialization conditions at SystemManager startup // NOLINT(whitespace/line_length)
3641 // LCOV_EXCL_START 6: For setting the initialization conditions at SystemManager startup
3642 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
3643 l_msgStr = f_text.substr(l_offset, l_newLinePos);
3644 l_offset += static_cast<UI_32>(l_newLinePos);
3647 l_offset += l_msgLen;
3650 FRAMEWORKUNIFIEDLOG(f_zone, f_func, l_msgStr.c_str());
3652 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
3653 } // LCOV_EXCL_BR_LINE 10: Final line
3655 // End of /SS_SystemManager/src/ss_system_manager.cpp