Fix the path to the host specific system configurations
[staging/basesystem.git] / service / system / logger_service / server / src / loggerservice_application.cpp
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 ///////////////////////////////////////////////////////////////////////////////
18 /// \ingroup  tag_NS_InterfaceunifiedLogCapture
19 /// \brief    This file contains the standard set functions called by the NS
20 //            dispatcher on application initialization, cleanup and wakeup.
21 ///
22 ///////////////////////////////////////////////////////////////////////////////
23 // System Headers
24 #include <sys/types.h>
25 #include <sys/wait.h>
26 #include <sys/stat.h>
27 #include <unistd.h>
28 #include <fcntl.h>
29 #include <native_service/frameworkunified_application.h>
30 #include <native_service/frameworkunified_framework_if.h>
31 #include <native_service/frameworkunified_service_protocol.h>
32 #include <native_service/frameworkunified_types.h>
33 #include <native_service/cl_process.h>
34
35 #include <native_service/nslogutil_cmd_if.h>
36 #include <native_service/ns_np_service.h>
37 #include <native_service/ns_np_service_protocol.h>
38
39 #include <loggerservicedebug_loggerservicelog.h>
40 #include <loggerservicedebug_thread_if.h>
41 #include <loggerservicedebug_writer_Evntworker.h>
42
43 #include <native_service/frameworkunified_timer.h>
44 #include <ss_logger_device_detection.h>
45
46 #include <ss_logger_cfg.h>
47 #include <system_service/ss_logger_service_notifications.h>
48 #include <system_service/ss_logger_service.h>
49 #include <ss_logger_service_callbacks.h>
50
51 #include <system_service/ss_sm_client_if.h>
52
53 #include <system_service/ss_system_manager_if.h>
54 #include <system_service/ss_system_manager_protocol.h>
55 #include <system_service/ss_system_manager_notifications.h>
56
57 #include <system_service/ss_devicedetection_service_notifications.h>
58 #include <system_service/ss_devicedetection_service_ifc.h>
59 #include <system_service/ss_services.h>
60 #include <ss_logger_error_event.h>
61 #include <ss_logger_reader_writer_control.h>
62 #include <ss_logger_common.h>
63 #include <stub/pfdrec_thread_ifc.h>
64 #include <system_service/ss_templates.h>
65 #include <system_service/ss_logger_store_logs.h>
66 #include <queue>
67 #include <string>
68
69 // const definitions
70 #define TMPFS_PATH "/tmp"
71
72 #define SYS_ILLEGAL_LOG_DELAY_TIME  ( 20 * 1000 )
73 const CHAR LOGGERSERVICELOGGER_SETPARAMS[] = TMPFS_PATH "/loggerservicelogger_setparams.log";
74 const CHAR Counter_LOG_PATH_FN[] = TMPFS_PATH "/loggerservice_counter.log";
75 const CHAR Mileage_LOG_PATH_FN[] = TMPFS_PATH "/loggerservice_mileage.log";
76
77 const CHAR g_strLogQueWriterWorkerName[] = "pdg.LogQueWriter";
78 const CHAR g_strTransmitQueWriterWorkerName[] = "pdg.TransmitQueWriter";
79 const CHAR g_strUdpQueWriterWorkerName[] = "pdg.UdpQueWriter";
80 const CHAR g_strEvntLogQueWorkerName[] = "pdg.EvntLogQue";
81
82 // handles to writer threads
83 static HANDLE g_thrdLogWriter = NULL;  // Var. that holds the child handle to the Log Writer thread
84 static HANDLE g_thrdTxWriter = NULL;  // Var. that holds the child handle to the Tx Writer thread
85
86 /// Event_logger
87 HANDLE g_thrdEvntLogWriter = NULL;  // Var. that holds the child handle to the EVNTLOGGER Writer thread
88 static TEvntWriterInfo Evntlog_wi = { };
89 TUploadEventLogResp g_stUploadEventLogResp;
90
91 // global variable to store the service status
92 ELOGGERSERVICESTATUS g_eLoggerServiceStatus = eLSInit;
93
94 // class to usb and reader threads
95 LoggerserviceDebugChildThread g_loggerservicedebug_threads;
96
97 /// Device Detection Class Instance
98 DeviceDetectionServiceIf g_devDetect_t;
99
100 CLoggerCfg g_loggerCfg;
101 CErrorEvent g_errorEventHandler;
102 CLoggerServiceCallbacks g_serviceCallbacks;
103 CLoggerDeviceDetection g_deviceDetection;
104 CReaderWriterControl g_ReaderWriterControl;
105 CPFDRECThread g_PFDRECThread;
106
107 /// Decide the function NormalStartupProcess execution
108 static bool g_normal_startup_status = false;
109
110 /// Callbacks for messages that will be received and processed by this module
111 static EFrameworkunifiedStatus OnUsbEject(HANDLE hApp);
112
113 static EFrameworkunifiedStatus OnUsbStoreLogs(HANDLE hApp);
114
115 static EFrameworkunifiedStatus SMSessionAckCb(HANDLE hApp);
116
117 /// Positive Response Call backs from child thread for  statistical counter read
118 static EFrameworkunifiedStatus cbStatisticalCounterSuccessResp(HANDLE hApp);
119
120 /// Error Response Call backs from child thread for  statistical counter read
121 static EFrameworkunifiedStatus cbStatisticalCounterErrorResp(HANDLE hApp);
122
123 /// Response Call backs from child thread for  clear event logs
124 static EFrameworkunifiedStatus cbClearEventLogsResponse(HANDLE hApp);
125
126 /// Response Call backs from child thread for  copying event logs to USB
127 static EFrameworkunifiedStatus cbCopyEventLogsUSBResponse(HANDLE hApp);
128
129 /// Response Call backs from child thread for Reading number of events logged
130 static EFrameworkunifiedStatus cbReadNumbOfEventsResponse(HANDLE hApp);
131
132 /// Response Call backs from child thread for Upload eventlog
133 static EFrameworkunifiedStatus cbUploadEventLogResponse(HANDLE hApp);
134
135 /// Notificatin from SystemManager when All Services wakeup completed
136 static EFrameworkunifiedStatus cbServiceWakeupStatus(HANDLE hApp);
137
138
139 /// generate SYS_ILG_LOG
140 static EFrameworkunifiedStatus SysIllegalLogTimer_OnInterval(HANDLE hApp);
141
142
143 /// Call back tables for response from event logger child thread
144 FrameworkunifiedProtocolCallbackHandler evtLogChildThread_handler[] = { {  // LCOV_EXCL_BR_LINE 11:Unexpected branch
145     eThrdCmdStatisticalCounterSuccessResp, cbStatisticalCounterSuccessResp }, {
146     eThrdCmdStatisticalCounterErrorResp, cbStatisticalCounterErrorResp }, {
147     eThrdCmdCopyEventLogUSBResponse, cbCopyEventLogsUSBResponse }, {
148     eThrdCmdClearEventLogResponse, cbClearEventLogsResponse }, {
149     eThrdCmdNumberOfEventsLoggedResponse, cbReadNumbOfEventsResponse }, {
150     eThrdCmdUploadEventLogResponse, cbUploadEventLogResponse } };
151
152 //////////////////////////////////////////
153 //  Function : FrameworkunifiedOnInitialization
154 //////////////////////////////////////////
155 EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE hApp) {
156   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
157   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
158
159   // 1. Register Srv Availability Notification
160   if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedRegisterServiceAvailabilityNotification(hApp, NTFY_SS_LoggerService_Availability))) {  // LCOV_EXCL_BR_LINE 4:NSFW  // NOLINT[whitespace/line_length]
161     // LCOV_EXCL_START 4:NSFW
162     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
163     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
164            "Failed to set service availability notification:0x%x ", l_eStatus);
165     // LCOV_EXCL_STOP
166   }
167
168   // 2. Publish Service not available
169   if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedPublishServiceAvailability(hApp, FALSE))) {  // LCOV_EXCL_BR_LINE 4:NSFW  // NOLINT[whitespace/line_length]
170     // LCOV_EXCL_START 4:NSFW
171     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
172     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
173            "Failed to set service availability notification:%d ", l_eStatus);
174     // LCOV_EXCL_STOP
175   }
176
177   l_eStatus = g_loggerCfg.Initialize(hApp);
178   LOG_STATUS_IF_ERRORED(l_eStatus, "g_loggerCfg.Initialize()");  // LCOV_EXCL_BR_LINE 15: macro
179
180   std::string l_cfgFilePathAndName =
181       "/etc/basesystem/BS/ss/logger_service/rodata/ss_logger.cfg";
182   if (eFrameworkunifiedStatusOK != (l_eStatus = g_loggerCfg.Load(l_cfgFilePathAndName))) {  // LCOV_EXCL_BR_LINE 200:To ensure success
183     // LCOV_EXCL_START 200:To ensure success
184     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
185     FRAMEWORKUNIFIEDLOG(
186         ZONE_ERR, __FUNCTION__,
187         " Error. Failed to load SS_Logger configuration from %s with error: %d",
188         l_cfgFilePathAndName.c_str(), l_eStatus);
189     // LCOV_EXCL_STOP
190   } else if (eFrameworkunifiedStatusOK != (l_eStatus = g_loggerCfg.Validate())) {
191     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
192            " Error. Configuration validation failed with error: %d.",
193            l_eStatus);
194   }
195
196   g_loggerCfg.Print();  // LCOV_EXCL_BR_LINE 11:Unexpected branch
197
198   l_eStatus = g_deviceDetection.Initialize(hApp, &g_loggerCfg);  // LCOV_EXCL_BR_LINE 11:Unexpected branch
199   LOG_STATUS_IF_ERRORED(l_eStatus, "g_deviceDetection.Initialize");  // LCOV_EXCL_BR_LINE 15: macro
200
201   l_eStatus = g_ReaderWriterControl.Initialize(&g_loggerCfg);  // LCOV_EXCL_BR_LINE 11:Unexpected branch
202   LOG_STATUS_IF_ERRORED(l_eStatus, "g_ReaderWriterControl.Initialize()");  // LCOV_EXCL_BR_LINE 15: macro
203
204   if (NULL == (g_thrdEvntLogWriter = FrameworkunifiedCreateChildThreadWithPriority( hApp, g_strEvntLogQueWorkerName, EvntWriterWorkerOnStart, EvntWriterWorkerOnStop, frameworkunified::framework::CFrameworkunifiedThreadPriorities::GetPriority(std::string(g_strEvntLogQueWorkerName))))) {  // LCOV_EXCL_BR_LINE 4:NSFW  // NOLINT[whitespace/line_length]
205     // LCOV_EXCL_START 4:NSFW
206     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
207     FRAMEWORKUNIFIEDLOG(
208         ZONE_ERR,
209         __FUNCTION__,
210         "FrameworkunifiedCreateChildThreadWithPriority Failed Status:0x%x for thread create of %s",
211         l_eStatus, g_strEvntLogQueWorkerName);
212     return (l_eStatus);
213     // LCOV_EXCL_STOP
214   } else {
215     FRAMEWORKUNIFIEDLOG(  // LCOV_EXCL_BR_LINE 15: macro
216         ZONE_INFO,
217         __FUNCTION__,
218         "FrameworkunifiedCreateChildThreadWithPriority Success Status: for thread create of %s",
219         g_strEvntLogQueWorkerName);  // LCOV_EXCL_BR_LINE 15: macro
220   }
221
222   l_eStatus = g_errorEventHandler.Initialize(hApp, &g_loggerCfg,  // LCOV_EXCL_BR_LINE 11:Unexpected branch
223                                              &g_ReaderWriterControl,
224                                              g_thrdEvntLogWriter,
225                                              g_strEvntLogQueWorkerName);  // LCOV_EXCL_BR_LINE 11:Unexpected branch
226   if (eFrameworkunifiedStatusOK != l_eStatus) {  // LCOV_EXCL_BR_LINE 200:To ensure success
227     // LCOV_EXCL_START 200:To ensure success
228     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
229     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
230            " Error. g_errorEventHandler.Initialize() returned: %d.", l_eStatus);
231     // LCOV_EXCL_STOP
232   }
233   l_eStatus = g_serviceCallbacks.Initialize(hApp, &g_loggerCfg,
234                                             &g_errorEventHandler);  // LCOV_EXCL_BR_LINE 11:Unexpected branch
235   LOG_STATUS_IF_ERRORED(l_eStatus, "g_serviceCallbacks.Initialize()");  // LCOV_EXCL_BR_LINE 15: macro
236
237   // Callback to Event log child Thread
238   l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(
239       hApp, g_strEvntLogQueWorkerName, evtLogChildThread_handler,
240       _countof(evtLogChildThread_handler));  // LCOV_EXCL_BR_LINE 11:Unexpected branch
241   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,  // LCOV_EXCL_BR_LINE 15: macro
242          "Status of callback for child thread attach:%X", l_eStatus);  // LCOV_EXCL_BR_LINE 15: macro
243
244   // setup call backs for my children
245   FrameworkunifiedAttachCallbackToDispatcher(hApp, AppName, eThrdCmdUsbEject, OnUsbEject);  // LCOV_EXCL_BR_LINE 11:Unexpected branch
246   FrameworkunifiedAttachCallbackToDispatcher(hApp, AppName, eThrdCmdUsbStoreLogs,
247                                 OnUsbStoreLogs);
248
249   // Publications
250   FrameworkunifiedNotificationsList publish_notifs[] = {
251   // Notifications name,length, state
252       { NTFY_LOGGER_SETCONTROLMASK, sizeof(CHANGELOGPARAMS), eFrameworkunifiedStateVar } };
253
254   // Indicate to Notification Service what I will be Publishing!
255   if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedNPRegisterNotifications(hApp, publish_notifs, _countof(publish_notifs)))) {  // LCOV_EXCL_BR_LINE 4:NSFW  // NOLINT[whitespace/line_length]
256     // LCOV_EXCL_START 4:NSFW
257     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
258     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
259            "FrameworkunifiedNPRegisterNotifications Failed Status:0x%x ", l_eStatus);
260     return (l_eStatus);
261     // LCOV_EXCL_STOP
262   }
263
264   /// Start the Writer threads
265   strncpy(Evntlog_wi.mileage_filename, Mileage_LOG_PATH_FN,
266           Evntlog_wi.FN_LEN - 1);
267   Evntlog_wi.mileage_filename[Evntlog_wi.FN_LEN - 1] = '\0';
268   strncpy(Evntlog_wi.base_cnt_filename, Counter_LOG_PATH_FN,
269           Evntlog_wi.FN_LEN - 1);
270   Evntlog_wi.base_cnt_filename[Evntlog_wi.FN_LEN - 1] = '\0';
271   Evntlog_wi.max_filelen = g_loggerCfg.m_logMaxFileSize;
272
273   if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedStartChildThread(hApp, g_thrdEvntLogWriter, sizeof(Evntlog_wi), &Evntlog_wi))) {  // LCOV_EXCL_BR_LINE 4:NSFW  // NOLINT[whitespace/line_length]
274     // LCOV_EXCL_START 4:NSFW
275     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
276     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
277            "Fail to Start Writer Worker thread. Status:0x%x", l_eStatus);
278     // LCOV_EXCL_STOP
279   }
280
281   l_eStatus = RegisterSMSessionAckCallback(SMSessionAckCb);  // LCOV_EXCL_BR_LINE 11:Unexpected branch
282   LOG_STATUS_IF_ERRORED(l_eStatus, "RegisterSMSessionAckCallback()");  // LCOV_EXCL_BR_LINE 15: macro
283
284   l_eStatus = g_PFDRECThread.Initialize(hApp);  // LCOV_EXCL_BR_LINE 11:Unexpected branch
285   LOG_STATUS_IF_ERRORED(l_eStatus, "g_PFDRECThread.Initialize()");  // LCOV_EXCL_BR_LINE 15: macro
286
287   // Publish Service available this can also be published from FrameworkunifiedOnStart callback
288   if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedPublishServiceAvailability(hApp, TRUE))) {  // LCOV_EXCL_BR_LINE 4:NSFW
289     // LCOV_EXCL_START 4:NSFW
290     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
291     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
292            "Failed to set service availability notification:0x%x ", l_eStatus);
293     // LCOV_EXCL_STOP
294   }
295
296 l_eStatus = FrameworkunifiedSubscribeNotificationWithCallback(hApp, NTFY_SSServiceWakeupStatus, cbServiceWakeupStatus);  // LCOV_EXCL_BR_LINE 11:Unexpected branch
297     LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedSubscribeNotificationWithCallback()");  // LCOV_EXCL_BR_LINE 15: macro
298
299   // Set Service status to init
300   g_eLoggerServiceStatus = eLSInit;
301
302   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
303   return (l_eStatus);
304 }
305
306 static void *accOffOnCollect(void* param) {
307   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
308   SS_LoggerStoreLogs(SS_STORELOGS_ACCOFFON_PRESS);
309   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
310   return NULL;
311 }
312
313 // Normal startup process
314 static EFrameworkunifiedStatus NormalStartupProcess(HANDLE hApp) {
315   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
316
317   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
318
319   if (false == g_normal_startup_status) {
320     T_SS_SM_START_DataStructType prm;
321
322     l_eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &prm, sizeof(T_SS_SM_START_DataStructType), eSMRRetain);
323     if (eFrameworkunifiedStatusOK != l_eStatus) {
324       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "Failed PasGetMsgDataOfSize() [%d]", l_eStatus);
325     }
326
327     if (prm.resetStatus == e_SS_SM_RESET_STATUS_NG) {
328       HANDLE timer =
329           FrameworkunifiedAttachTimerCallback(hApp, SYS_ILLEGAL_LOG_DELAY_TIME, 0, SysIllegalLogTimer_OnInterval);
330       if (timer == NULL) {
331         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, " Failed to register timer.");
332       }
333     }
334
335     if (0 == access("/tmp/accoffon", F_OK)) {
336       pthread_t threadAccOffOn;
337       pthread_create( &threadAccOffOn, NULL, accOffOnCollect, NULL);
338     }
339
340     if (g_eLoggerServiceStatus == eLSStop) {
341       // Publish Service available this can also be published from FrameworkunifiedOnStart callback
342       if (eFrameworkunifiedStatusOK
343           != (l_eStatus = FrameworkunifiedPublishServiceAvailability(hApp, TRUE))) {
344         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
345                "Failed to set service availability notification:0x%x ",
346                l_eStatus);
347       }
348
349       // Start the Writer threads
350       if (eFrameworkunifiedStatusOK
351           != (l_eStatus = FrameworkunifiedStartChildThread(hApp, g_thrdEvntLogWriter,
352                                               sizeof(Evntlog_wi), &Evntlog_wi))) {
353         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
354                "Fail to Start Writer Worker thread. Status:0x%x", l_eStatus);
355       }
356     }
357     // Set Service status to init
358     g_eLoggerServiceStatus = eLSStart;
359
360     // Set normal_startup_status flag (true)
361     g_normal_startup_status = true;
362   }
363
364   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
365   return l_eStatus;
366 }
367
368 /**
369  * EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE hApp)
370  * @brief Used to .
371  *
372  * @param hApp Handle to the SS_Power Framework Obj.
373  *
374  * @return method status of completion or failure.
375  */
376 EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE hApp) {
377   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
378
379   EFrameworkunifiedStatus l_eStatus = NormalStartupProcess(hApp);
380
381   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
382   return l_eStatus;
383 }
384
385 /**
386  * EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE hApp)
387  * @brief Used to .
388  *
389  * @param hApp Handle to the SS_Power Framework Obj.
390  *
391  * @return method status of completion or failure.
392  */
393 EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE hApp) {
394   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
395
396   EFrameworkunifiedStatus l_eStatus = NormalStartupProcess(hApp);
397
398   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
399   return l_eStatus;
400 }
401
402 /**
403  * EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE hApp)
404  * @brief Used to .
405  *
406  * @param hApp Handle to the SS_Power Framework Obj.
407  *
408  * @return method status of completion or failure.
409  */
410 EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE hApp) {
411   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
412
413   EFrameworkunifiedStatus l_eStatus = NormalStartupProcess(hApp);
414
415   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
416   return l_eStatus;
417 }
418
419 static EFrameworkunifiedStatus SysIllegalLogTimer_OnInterval(HANDLE hApp) {  // LCOV_EXCL_START 200: There is no SUBCP_STS_COMNG case
420   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
421   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
422   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
423   l_eStatus = SS_LoggerStoreLogs(SS_STORELOGS_SYS_ILLEGAL);
424   if (l_eStatus != eFrameworkunifiedStatusOK) {
425     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, " Failed SS_LoggerStoreLogs()");
426   }
427   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
428   return l_eStatus;
429 }
430 // LCOV_EXCL_STOP
431
432 /**
433  * EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE hApp)
434  * @brief Used to .
435  *
436  * @param hApp Handle to the SS_Power Framework Obj.
437  *
438  * @return method status of completion.
439  */
440 EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE hApp) {
441   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
442   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
443   return eFrameworkunifiedStatusOK;
444 }
445
446 /**
447  * EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE hApp)
448  * @brief Used to .
449  *
450  * @param hApp Handle to the SS_Power Framework Obj.
451  *
452  * @return method status of completion.
453  */
454 EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE hApp) {
455   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
456   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
457   return eFrameworkunifiedStatusOK;
458 }
459
460 /**
461  * EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE hApp)
462  * @brief Used to .
463  *
464  * @param hApp Handle to the SS_Power Framework Obj.
465  *
466  * @return method status of completion or failure.
467  */
468 EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE hApp) {
469   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
470   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
471
472   /*Get stop factor form hApp*/
473   T_SS_SM_STOP_DataStructType errorType;
474
475   // LCOV_EXCL_BR_START 4: NSFW error
476   if (eFrameworkunifiedStatusOK
477       != FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID) &errorType, sizeof(errorType),
478                              eSMRRelease)) {
479   // LCOV_EXCL_BR_STOP
480     // LCOV_EXCL_START 4: NSFW error
481     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
482     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
483            " FrameworkunifiedGetMsgDataOfSize failed with error");
484     // LCOV_EXCL_STOP
485   } else {
486     EFrameworkunifiedStatus loggerserviceRet = SS_LoggerStoreLogs(SS_STORELOGS_INTERFACEUNIFIEDLOG);
487     LOG_STATUS_IF_ERRORED(loggerserviceRet, "Fail to save Loggerservice Log");
488     EFrameworkunifiedStatus naviLog_status = g_errorEventHandler.SaveNaviLog(
489         errorType.shutdownTrigger);
490     LOG_STATUS_IF_ERRORED(naviLog_status, "Fail to save Navi Log");
491   }
492   StopLoggingFunction(hApp);
493
494   if (g_eLoggerServiceStatus == eLSStart) {  // LCOV_EXCL_BR_LINE 200: g_eLoggerServiceStatus must be eLSStart on ACC-OFF
495     LoggerService_OnStop(hApp);
496   }
497
498   // Set normal_startup_status flag (false)
499   g_normal_startup_status = false;
500
501   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
502   return (l_eStatus);
503 }
504
505 /**
506  * EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE hApp)
507  * @brief Used to .
508  *
509  * @param hApp Handle to the SS_Power Framework Obj.
510  *
511  * @return method status of completion or failure.
512  */
513 EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE hApp) {  // LCOV_EXCL_START 8:dead code
514   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
515   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
516
517   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
518   return eFrameworkunifiedStatusOK;
519 }
520 // LCOV_EXCL_STOP
521
522 /**
523  * EFrameworkunifiedStatus LoggerService_OnStop(HANDLE hApp)
524  * @brief Logger Stop is called on Shutdown complete cmd
525  *
526  * @param hApp Handle to the SS_Power Framework Obj.
527  *
528  * @return method status of completion or failure.
529  */
530 EFrameworkunifiedStatus LoggerService_OnStop(HANDLE hApp) {
531   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
532   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
533
534   // Set Service status to init
535   g_eLoggerServiceStatus = eLSStop;
536
537   /// Start the Writer threads
538   if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedStopChildThread(hApp, g_thrdEvntLogWriter, sizeof(Evntlog_wi), &Evntlog_wi))) {  // LCOV_EXCL_BR_LINE 4:NSFW  // NOLINT[whitespace/line_length]
539     // LCOV_EXCL_START 4:NSFW
540     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
541     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
542            "Fail to Start Writer Worker thread. Status:0x%x", l_eStatus);
543     // LCOV_EXCL_STOP
544   } else {
545     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__,
546            "Successful in Sending Stop to ChildThread");
547   }
548
549   // Publish Service available this can also be published from FrameworkunifiedOnStart callback
550   if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedPublishServiceAvailability(hApp, FALSE))) {  // LCOV_EXCL_BR_LINE 4:NSFW  // NOLINT[whitespace/line_length]
551     // LCOV_EXCL_START 4:NSFW
552     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
553     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
554            "Failed to set service availability notification:0x%x ", l_eStatus);
555     // LCOV_EXCL_STOP
556   }
557
558   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
559   return (l_eStatus);
560 }
561
562 EFrameworkunifiedStatus SMSessionAckCb(HANDLE hApp) {
563   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
564   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
565   HANDLE l_hSession;
566
567   INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp);  // LCOV_EXCL_BR_LINE 15: macro
568
569   l_hSession = FrameworkunifiedGetOpenSessionHandle(hApp);
570
571   if (NULL == l_hSession) {  // LCOV_EXCL_BR_LINE 4:NSFW
572     // LCOV_EXCL_START 4:NSFW
573     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
574     FRAMEWORKUNIFIEDLOG(
575         ZONE_ERR, __FUNCTION__,
576         " Error. FrameworkunifiedGetSessionHandle() returned a NULL session handle. "
577         "Error events originating from System Manager will not be detected.");
578     // LCOV_EXCL_STOP
579   } else {
580     l_eStatus = FrameworkunifiedSetSessionHandle(hApp, FrameworkunifiedGetMsgSrc(hApp), l_hSession);
581     LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedSetSessionHandle()");  // LCOV_EXCL_BR_LINE 15: macro
582
583     l_eStatus = g_errorEventHandler.RegisterSessionErrorEvent(l_hSession);
584     LOG_STATUS_IF_ERRORED(l_eStatus,  // LCOV_EXCL_BR_LINE 15: macro
585                           "g_errorEventHandler.RegisterSessionErrorEvent()");
586   }
587
588   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
589   return (l_eStatus);
590 }
591
592 EFrameworkunifiedStatus FrameworkunifiedOnWakeup(HANDLE hApp) {  // LCOV_EXCL_START 8:dead code
593   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
594   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
595   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
596
597   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
598   return (l_eStatus);
599 }
600 // LCOV_EXCL_STOP
601
602 //////////////////////////////////////////
603 //  Function : FrameworkunifiedOnShutdown
604 //////////////////////////////////////////
605 EFrameworkunifiedStatus FrameworkunifiedOnShutdown(HANDLE hApp) {  // LCOV_EXCL_START 8:dead code
606   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
607   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
608   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
609
610   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
611   return (l_eStatus);
612 }
613 // LCOV_EXCL_STOP
614
615 //////////////////////////////////////////
616 //  Function : FrameworkunifiedOnEShutdown
617 //////////////////////////////////////////
618 EFrameworkunifiedStatus FrameworkunifiedOnEShutdown(HANDLE hApp) {  // LCOV_EXCL_START 8:dead code
619   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
620   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
621   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
622
623   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
624   return (l_eStatus);
625 }
626 // LCOV_EXCL_STOP
627
628 //////////////////////////////////////////
629 //  Function : FrameworkunifiedOnDebugDump
630 //////////////////////////////////////////
631 EFrameworkunifiedStatus FrameworkunifiedOnDebugDump(HANDLE hApp) {
632   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
633   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
634
635   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
636   return (l_eStatus);
637 }
638
639 ////////////////////////////////////////////////////////////////////////////////////////////
640 /// HACK! mb20100701
641 /// \todo Add behavior to this function
642 ////////////////////////////////////////////////////////////////////////////////////////////
643 EFrameworkunifiedStatus FrameworkunifiedOnDestroy(HANDLE hApp) {  // LCOV_EXCL_START 14:For process termination processing
644   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
645   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
646
647   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
648   return eFrameworkunifiedStatusNotImplemented;
649 }
650 // LCOV_EXCL_STOP
651
652 EFrameworkunifiedStatus OnUsbEject(HANDLE hApp) {  // LCOV_EXCL_START 7:debug code
653   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
654   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
655   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
656
657   if (g_loggerservicedebug_threads.Running(
658       LoggerserviceDebugChildThread::kLoggerserviceDebugCaptureLogScript)) {
659     g_loggerservicedebug_threads.Stop(LoggerserviceDebugChildThread::kLoggerserviceDebugCaptureLogScript);
660     FRAMEWORKUNIFIEDLOG(
661         ZONE_INFO,
662         __FUNCTION__,
663         "Stopped Thread: %s",
664         g_loggerservicedebug_threads.Name(
665             LoggerserviceDebugChildThread::kLoggerserviceDebugCaptureLogScript));
666   }
667
668   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
669   return (l_eStatus);
670 }
671 // LCOV_EXCL_STOP
672
673 EFrameworkunifiedStatus OnUsbStoreLogs(HANDLE hApp) {  // LCOV_EXCL_START 7:debug code
674   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
675   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
676   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
677   TThrdCaptureLogsEvt evt = { };
678   if (eFrameworkunifiedStatusOK
679       != (l_eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &evt, sizeof(evt)))) {
680     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedGetMsgDataOfSize Failed Status:0x%x ",
681            l_eStatus);
682     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
683     return l_eStatus;
684   }
685
686   l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdLogWriter, eThrdCmdWriterStop, 0, NULL);
687   l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdTxWriter, eThrdCmdWriterStop, 0, NULL);
688
689   l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdLogWriter, eThrdCmdWriteFilesToUsb,
690                            sizeof(evt), &evt);
691   l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdTxWriter, eThrdCmdWriteFilesToUsb,
692                            sizeof(evt), &evt);
693
694   l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdLogWriter, eThrdCmdWriterResume, 0,
695                            NULL);
696   l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdTxWriter, eThrdCmdWriterResume, 0, NULL);
697
698   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
699   return (l_eStatus);
700 }
701 // LCOV_EXCL_STOP
702
703 ///////////////////////////////////////////////////////////////////////
704 /// Function :cbStatisticalCounterPosResponse
705 ///////////////////////////////////////////////////////////////////////
706 // LCOV_EXCL_START 8:dead code
707 EFrameworkunifiedStatus cbStatisticalCounterSuccessResp(HANDLE hApp) {
708   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
709   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
710   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
711
712   TStatisticalCntCmdSuccessResp l_stCmdSuccessResp;
713   SS_loggerserviceprotocol l_eResponseCmd;
714   HANDLE l_hSession = NULL;
715   if (eFrameworkunifiedStatusOK
716       != (l_eStatus = ReadMsg<TStatisticalCntCmdSuccessResp>(hApp,
717                                                              l_stCmdSuccessResp))) {
718     LOG_ERROR("ReadMsg()");
719   } else {
720     if (NULL
721         != (l_hSession = FrameworkunifiedGetSessionHandle(
722             hApp, l_stCmdSuccessResp.stSessiondata.strSrcName.c_str(),
723             l_stCmdSuccessResp.stSessiondata.session_id))) {
724       l_eResponseCmd = SS_LOGGER_READ_STATL_COUNTER_SUCCESS_RESP;
725       if (eFrameworkunifiedStatusOK
726           != (l_eStatus = FrameworkunifiedSendMsg(l_hSession, l_eResponseCmd,
727                                      sizeof(SStatisticalCounter),
728                                      &l_stCmdSuccessResp.stBuffer))) {
729         LOG_ERROR("FrameworkunifiedSendMsg()");
730       }
731     } else {
732       l_eStatus = eFrameworkunifiedStatusInvldHandle;
733       LOG_ERROR("FrameworkunifiedGetSessionHandle()");
734     }
735   }
736
737   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
738   return (l_eStatus);
739 }
740 // LCOV_EXCL_STOP
741
742 ///////////////////////////////////////////////////////////////////////
743 /// Function :cbStatisticalCounterErrResponse
744 ///////////////////////////////////////////////////////////////////////
745 // LCOV_EXCL_START 8:dead code
746 EFrameworkunifiedStatus cbStatisticalCounterErrorResp(HANDLE hApp) {
747   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
748   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
749   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
750
751   TSessionData l_stSessiondata;
752   SS_loggerserviceprotocol l_eResponseCmd;
753   HANDLE l_hSession = NULL;
754   if (eFrameworkunifiedStatusOK
755       != (l_eStatus = ReadMsg<TSessionData>(hApp, l_stSessiondata))) {
756     LOG_ERROR("ReadMsg()");
757   } else {
758     if (NULL
759         != (l_hSession = FrameworkunifiedGetSessionHandle(hApp,
760                                              l_stSessiondata.strSrcName.c_str(),
761                                              l_stSessiondata.session_id))) {
762       l_eResponseCmd = SS_LOGGER_READ_STATL_COUNTER_ERROR_RESP;
763       if (eFrameworkunifiedStatusOK
764           != (l_eStatus = FrameworkunifiedSendMsg(l_hSession, l_eResponseCmd, 0x00, NULL))) {
765         LOG_ERROR("FrameworkunifiedSendMsg()");
766       }
767     } else {
768       l_eStatus = eFrameworkunifiedStatusInvldHandle;
769       LOG_ERROR("FrameworkunifiedGetSessionHandle()");
770     }
771   }
772
773   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
774   return (l_eStatus);
775 }
776 // LCOV_EXCL_STOP
777
778 ///////////////////////////////////////////////////////////////////////
779 /// Function :cbClearEventLogsResponse
780 ///////////////////////////////////////////////////////////////////////
781 // LCOV_EXCL_START 8:dead code
782 EFrameworkunifiedStatus cbClearEventLogsResponse(HANDLE hApp) {
783   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
784   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
785   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
786   TClearEvntLogCmdResponse l_stCmdResponse;
787   HANDLE l_hSession = NULL;
788   SS_loggerserviceprotocol l_eResponseCmd;
789
790   if (eFrameworkunifiedStatusOK
791       != (l_eStatus = ReadMsg<TClearEvntLogCmdResponse>(hApp, l_stCmdResponse))) {
792     LOG_ERROR("ReadMsg()");
793   } else {
794     if (NULL
795         != (l_hSession = FrameworkunifiedGetSessionHandle(
796             hApp, l_stCmdResponse.stSessiondata.strSrcName.c_str(),
797             l_stCmdResponse.stSessiondata.session_id))) {
798       if (l_stCmdResponse.u8Response == (UI_8) CLEAR_EVENT_LOG_SUCCESS) {
799         l_eResponseCmd = SS_LOGGERCLEAREVENT_SUCCESS_RESP;
800       } else {
801         l_eResponseCmd = SS_LOGGERCLEAREVENT_ERROR_RESP;
802       }
803
804       if (eFrameworkunifiedStatusOK
805           != (l_eStatus = FrameworkunifiedSendMsg(l_hSession, l_eResponseCmd, 0x00, NULL))) {
806         LOG_ERROR("FrameworkunifiedSendMsg()");
807       }
808     } else {
809       l_eStatus = eFrameworkunifiedStatusInvldHandle;
810       LOG_ERROR("FrameworkunifiedGetSessionHandle()");
811     }
812   }
813   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
814   return (l_eStatus);
815 }
816 // LCOV_EXCL_STOP
817
818 ///////////////////////////////////////////////////////////////////////
819 /// Function :cbCopyEventLogsUSBResponse
820 ///////////////////////////////////////////////////////////////////////
821 // LCOV_EXCL_START 8:dead code
822 EFrameworkunifiedStatus cbCopyEventLogsUSBResponse(HANDLE hApp) {
823   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
824   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
825   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
826   TWriteFilesToUsbCmdResponse l_stCmdResponse;
827   HANDLE l_hSession = NULL;
828   SS_loggerserviceprotocol l_eResponseCmd;
829   EEvtLoggerErrorCode l_eResponseCode;
830
831   if (eFrameworkunifiedStatusOK
832       != (l_eStatus = ReadMsg<TWriteFilesToUsbCmdResponse>(hApp,
833                                                            l_stCmdResponse))) {
834     LOG_ERROR("ReadMsg()");
835   } else {
836     if (NULL
837         != (l_hSession = FrameworkunifiedGetSessionHandle(
838             hApp, l_stCmdResponse.stSessiondata.strSrcName.c_str(),
839             l_stCmdResponse.stSessiondata.session_id))) {
840       if (l_stCmdResponse.u8Response == (UI_8) COPY_EVT_USB_SUCCESS) {
841         l_eResponseCmd = SS_LOGGERCOPYEVENTUSB_SUCCESS_RESP;
842         l_eResponseCode = NO_ERROR_INFO;
843       } else {
844         l_eResponseCmd = SS_LOGGERCOPYEVENTUSB_ERROR_RESP;
845         l_eResponseCode = (EEvtLoggerErrorCode) l_stCmdResponse.u8Response;
846       }
847
848       if (eFrameworkunifiedStatusOK
849           != (l_eStatus = FrameworkunifiedSendMsg(l_hSession, l_eResponseCmd,
850                                      sizeof(EEvtLoggerErrorCode),
851                                      &l_eResponseCode))) {
852         LOG_ERROR("FrameworkunifiedSendMsg()");
853       }
854     } else {
855       l_eStatus = eFrameworkunifiedStatusInvldHandle;
856       LOG_ERROR("FrameworkunifiedGetSessionHandle()");
857     }
858   }
859   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
860   return (l_eStatus);
861 }
862 // LCOV_EXCL_STOP
863
864 // LCOV_EXCL_START 8:dead code
865 EFrameworkunifiedStatus cbReadNumbOfEventsResponse(HANDLE hApp) {
866   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
867   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
868   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
869   UI_16 l_NumOfEvents = 0;
870   TEvntsLogged l_stNumberOfEvtsLogged;
871   HANDLE l_hsession = NULL;
872
873   if (eFrameworkunifiedStatusOK
874       != (l_eStatus = ReadMsg<TEvntsLogged>(hApp, l_stNumberOfEvtsLogged))) {
875     LOG_ERROR("ReadMsg()");
876   } else {
877     l_NumOfEvents = l_stNumberOfEvtsLogged.u16numberofeventslogged;
878     if (NULL
879         != (l_hsession = FrameworkunifiedGetSessionHandle(
880             hApp, l_stNumberOfEvtsLogged.stSessiondata.strSrcName.c_str(),
881             l_stNumberOfEvtsLogged.stSessiondata.session_id))) {
882       if (eFrameworkunifiedStatusOK
883           != (l_eStatus = FrameworkunifiedSendMsg(l_hsession,
884                                      SS_LOGGER_ENG_READ_NUMOFEVENTS_RESP,
885                                      sizeof(UI_16), &l_NumOfEvents))) {
886         LOG_ERROR("FrameworkunifiedSendMsg()");
887       }
888     } else {
889       l_eStatus = eFrameworkunifiedStatusNullPointer;
890       LOG_ERROR("FrameworkunifiedGetSessionHandle()");
891     }
892   }
893
894   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
895   return (l_eStatus);
896 }
897 // LCOV_EXCL_STOP
898
899 // LCOV_EXCL_START 8:dead code
900 EFrameworkunifiedStatus cbUploadEventLogResponse(HANDLE hApp) {
901   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
902   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
903   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
904   HANDLE l_hsession = NULL;
905
906   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "UploadEventLog Response Msg Len = %d",
907          FrameworkunifiedGetMsgLength(hApp));
908   if (eFrameworkunifiedStatusOK
909       != (l_eStatus = ReadMsg<TUploadEventLogResp>(hApp, g_stUploadEventLogResp))) {
910     LOG_ERROR("ReadMsg()");
911   } else {
912     if (NULL
913         != (l_hsession = FrameworkunifiedGetSessionHandle(
914             hApp, g_stUploadEventLogResp.stSessiondata.strSrcName.c_str(),
915             g_stUploadEventLogResp.stSessiondata.session_id))) {
916       if (eFrameworkunifiedStatusOK
917           != (l_eStatus = FrameworkunifiedSendMsg(l_hsession, SS_LOGGER_UPLOAD_EVENTLOG_RESP,
918                                      sizeof(STEventLogPersistBuffer),
919                                      &g_stUploadEventLogResp.stEventLogBuffer))) {
920         LOG_ERROR("FrameworkunifiedSendMsg()");
921       }
922     } else {
923       l_eStatus = eFrameworkunifiedStatusNullPointer;
924       LOG_ERROR("FrameworkunifiedGetSessionHandle()");
925     }
926   }
927
928   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
929   return (l_eStatus);
930 }
931 // LCOV_EXCL_STOP
932
933 EFrameworkunifiedStatus cbServiceWakeupStatus(HANDLE hApp) {
934   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
935   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
936
937   l_eStatus = g_errorEventHandler.CreateKernelLog(hApp,
938                                                   SS_LOGGER_KBOOTLOG_CREATE);
939   LOG_STATUS_IF_ERRORED(l_eStatus, "CreateKernelLog(SS_LOGGER_KBOOTLOG_CREATE)");
940
941   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
942   return (l_eStatus);
943 }
944
945 void StopLoggingFunction(HANDLE hApp) {
946   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
947   // PFDRECThread Stop
948   EFrameworkunifiedStatus l_eStatus = g_PFDRECThread.Finalize(hApp);
949   LOG_STATUS_IF_ERRORED(l_eStatus, "g_PFDRECThread.Finalize()");
950
951   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
952 }