Init basesystem source codes.
[staging/basesystem.git] / video_in_hal / systemservice / logger_service / server / src / ss_logger_server_callbacks.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_SS_LoggerService
19 /// \brief    This file contains the callback for Notifications and Protocol
20 ///           commands.
21 ///
22 ///////////////////////////////////////////////////////////////////////////////
23 #include "ss_logger_service_callbacks.h"
24 #include <string.h>
25 #include <boost/bind.hpp>
26 #include <errno.h>
27 #include <native_service/frameworkunified_framework_if.h>
28 #include <native_service/frameworkunified_multithreading.h>
29 #include <system_service/ss_logger_service.h>
30 #include <ss_logger_common.h>
31 #include <system_service/ss_logger_service_notifications.h>
32 #include <system_service/ss_logger_service_protocol.h>
33 #include <native_service/ns_config_parser_if.h>
34 #include <native_service/nslogutil_cmd_if.h>
35 #include <system_service/ss_sm_client_if.h>
36 #include <queue>
37 #include <new>
38 #include <string>
39 #include "ss_logger_error_event.h"
40 #include "loggerservicedebug_loggerservicelog.h"
41 #include "loggerservicedebug_thread_if.h"
42 extern CErrorEvent g_errorEventHandler;
43 extern HANDLE g_thrdEvntLogWriter;
44
45 // Global variables
46 STCanCurrentDateTime g_stDateAndTime = { 0 };
47 UEvtLoggerCommonInfo g_uEvtLoggerCommonInfo;
48 UI_16 g_u16DiagId = 0;
49
50 CLoggerServiceCallbacks::CLoggerServiceCallbacks()
51     : m_pLoggerCfg(NULL),
52       m_pErrorEvent(NULL) {
53   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
54   FrameworkunifiedProtocolCallbackHandler l_protocolHandlers[kNUMBER_PROTOCOL_HANDLERS] =
55       { { SS_LOGGER_MILEAGE_DATA, boost::bind(
56           &CLoggerServiceCallbacks::LoggerServer_SetMileageData, this, _1) },
57           { SS_LOGGER_SET_PARAMS, boost::bind(
58               &CLoggerServiceCallbacks::LoggerServer_SetLoggerParams, this, _1) },
59           { SS_LOGGER_UDP_LOGGING, boost::bind(
60               &CLoggerServiceCallbacks::LoggerServer_UDPLogging, this, _1) },
61           { SS_LOGGERCOPYEVENTUSB, boost::bind(
62               &CLoggerServiceCallbacks::LoggerServer_OnCopyEvntLog, this,_1) },
63           { SS_LOGGERCLEAREVENT, boost::bind(
64               &CLoggerServiceCallbacks::LoggerServer_OnClearEvntLog, this, _1) },
65           { SS_LOGGER_READ_STATL_COUNTER, boost::bind(
66               &CLoggerServiceCallbacks::LoggerServer_OnReadStatCounter, this, _1) },
67           { SS_LOGGER_EVENT_COMMONINFO, boost::bind(
68               &CLoggerServiceCallbacks::LoggerServer_UpdateCommonInfo, this, _1) },
69           { SS_LOGGER__CWORD56__EVENT_INFO, boost::bind(
70               &CLoggerServiceCallbacks::LoggerServer_Handle_CWORD56_Events, this, _1) },
71           { SS_LOGGER_RESET_STATL_COUNTER, boost::bind(
72               &CLoggerServiceCallbacks::LoggerServer_OnResetStatCounter, this, _1) },
73           { SS_LOGGER_SET_VIN, boost::bind(
74               &CLoggerServiceCallbacks::LoggerServer_OnSetVIN, this, _1) },
75           { SS_LOGGERCOPYEMERGENCYLOGS, boost::bind(
76               &CLoggerServiceCallbacks::LoggerServer_OnCopyEmergencyLog, this, _1) },
77           { eSSLoggerCANProtocolIDCANTrigger, boost::bind(
78               &CLoggerServiceCallbacks::LoggerServer_OnCANTrigger, this, _1) },
79           { eSSLoggerCANProtocolIDDTCTrigger, boost::bind(
80               &CLoggerServiceCallbacks::LoggerServer_OnDTCTrigger, this, _1) },
81           { SS_LOGGER_SHUTDOWN_COMPLETE, boost::bind(
82               &CLoggerServiceCallbacks::LoggerServer_On_SHTDWN_Complete, this, _1) },
83           { SS_LOGGER_ENG_READ_NUMOFEVENTS, boost::bind(
84               &CLoggerServiceCallbacks::LoggerServer_OnReadNumberOfEvents, this, _1) },
85           { SS_LOGGER_SET_DIAGID, boost::bind(
86               &CLoggerServiceCallbacks::LoggerServer_OnSetDiagID, this, _1) },
87           { SS_LOGGER_UPLOAD_EVENTLOG, boost::bind(
88               &CLoggerServiceCallbacks::LoggerServer_UploadEventLog, this, _1) } };  // LCOV_EXCL_BR_LINE 11:Unexpected branch
89
90   for (UI_8 i = 0u; i < kNUMBER_PROTOCOL_HANDLERS; i++) {
91     m_protocolHandlers[i].iCmd = l_protocolHandlers[i].iCmd;
92     m_protocolHandlers[i].callBack = l_protocolHandlers[i].callBack;  // LCOV_EXCL_BR_LINE 11:Unexpected branch
93   }
94   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
95 }
96
97 CLoggerServiceCallbacks::~CLoggerServiceCallbacks() {  // LCOV_EXCL_START 14:globle instance
98   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
99   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
100   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
101 }
102 // LCOV_EXCL_STOP
103
104 EFrameworkunifiedStatus CLoggerServiceCallbacks::Initialize(HANDLE f_hApp,
105                                                CLoggerCfg *f_pLoggerCfg,
106                                                CErrorEvent* f_pErrorEvent) {
107   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
108   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
109   m_pLoggerCfg = f_pLoggerCfg;
110   m_pErrorEvent = f_pErrorEvent;
111
112   if ((NULL == m_pLoggerCfg) || (NULL == m_pErrorEvent)) {  // LCOV_EXCL_BR_LINE 200:As it is always TRUE
113     // LCOV_EXCL_START 200:As it is always TRUE
114     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
115     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
116            "NULL pointer passed to Initialize function!!!!!");
117     l_eStatus = eFrameworkunifiedStatusNullPointer;
118     // LCOV_EXCL_STOP
119   } else {
120     // Attach callback : Open Session Request
121     if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedAttachCallbackToDispatcher(f_hApp, FRAMEWORKUNIFIED_ANY_SOURCE, PROTOCOL_OPEN_SESSION_REQ, boost::bind(&CLoggerServiceCallbacks::LoggerServerOnOpenSession, this, _1)))) {  // LCOV_EXCL_BR_LINE 4:NSFW  // NOLINT[whitespace/line_length]
122       // LCOV_EXCL_START 4:NSFW
123       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
124       FRAMEWORKUNIFIEDLOG(
125           ZONE_ERR,
126           __FUNCTION__,
127           "FrameworkunifiedAttachCallbackToDispatcher PROTOCOL_OPEN_SESSION_REQ (FRAMEWORKUNIFIED_ANY_SOURCE) Failed Status:0x%x ",
128           l_eStatus);
129       // LCOV_EXCL_STOP
130     } else if ( eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedRegisterServiceAvailabilityNotification(f_hApp, NTFY_SS_LoggerService_Availability))) {  // LCOV_EXCL_BR_LINE 4:NSFW  // NOLINT[whitespace/line_length]
131       // LCOV_EXCL_START 4:NSFW
132       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
133       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
134              "Failed to set service availability notification:0x%x ", l_eStatus);
135       // LCOV_EXCL_STOP
136     } else {
137     }
138   }
139   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
140   return (l_eStatus);
141 }
142
143 //////////////////////////////////////////
144 //  Function : DevDetectionServerOnOpenSession
145 //  Callback for PROTOCOL_OPEN_SESSION_REQ
146 //////////////////////////////////////////
147 EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServerOnOpenSession(HANDLE hApp) {
148   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
149   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
150   HANDLE l_hClientService = NULL;
151   HANDLE l_hSession = NULL;
152
153   // Get the requester name
154   PCSTR pRequester = FrameworkunifiedGetMsgSrc(hApp);
155   OpenSessionAck tOpenAck;
156
157   if (pRequester) {  // LCOV_EXCL_BR_LINE 4:NSFW
158     l_hClientService = FrameworkunifiedMcOpenSender(hApp, pRequester);
159
160     if (l_hClientService) {  // LCOV_EXCL_BR_LINE 4:NSFW
161       // Create a session
162       l_hSession = FrameworkunifiedCreateSession(hApp, pRequester);
163       UI_32 l_nSessionId = 0;
164       if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher( hApp, pRequester, m_protocolHandlers, kNUMBER_PROTOCOL_HANDLERS, l_hSession))) {  // LCOV_EXCL_BR_LINE 4:NSFW  // NOLINT[whitespace/line_length]
165         // LCOV_EXCL_START 4:NSFW
166         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
167         FRAMEWORKUNIFIEDLOG(
168             ZONE_ERR,
169             __PRETTY_FUNCTION__,
170             "FrameworkunifiedAttachCallbacksToDispatcher ss_logger_server_protocol_handlers Failed Status:0x%x ",
171             l_eStatus);
172         // LCOV_EXCL_STOP
173       }
174
175       l_eStatus = this->m_pErrorEvent->OnOpenSession(hApp, pRequester,
176                                                      l_hSession);
177       if (eFrameworkunifiedStatusOK != l_eStatus) {  // LCOV_EXCL_BR_LINE 200:To ensure success
178         // LCOV_EXCL_START 200:To ensure success
179         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
180         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
181                " Error. m_pErrorEvent->OnOpenSession(%s, %p) returned: %d.",
182                pRequester, l_hSession, l_eStatus);
183         // LCOV_EXCL_STOP
184       }
185
186       // Attach callback : close Session Request
187       if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedAttachCallbackToDispatcher(hApp, pRequester, PROTOCOL_CLOSE_SESSION_REQ, boost::bind(&CLoggerServiceCallbacks::LoggerServerOnCloseSession, this, _1)))) {  // LCOV_EXCL_BR_LINE 4:NSFW  // NOLINT[whitespace/line_length]
188         // LCOV_EXCL_START 4:NSFW
189         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
190         FRAMEWORKUNIFIEDLOG(
191             ZONE_ERR,
192             __FUNCTION__,
193             "FrameworkunifiedAttachCallbackToDispatcher " "PROTOCOL_CLOSE_SESSION_REQ (FRAMEWORKUNIFIED_ANY_SOURCE) Failed Status:0x%x ",
194             l_eStatus);
195         // LCOV_EXCL_STOP
196       }
197
198       l_nSessionId = FrameworkunifiedGetSessionId(l_hSession);
199
200       FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Session id is %d", l_nSessionId);  // LCOV_EXCL_BR_LINE 15:macro
201       // sending the session open
202       tOpenAck.eStatus = eFrameworkunifiedStatusOK;
203       tOpenAck.sessionId = l_nSessionId;
204       tOpenAck.sessionType = 1;
205
206       // Copy session name to data structure
207       strncpy(tOpenAck.cSessionName, FrameworkunifiedGetAppName(hApp),
208               MAX_QUEUE_NAME_SIZE - 1);
209       tOpenAck.cSessionName[MAX_QUEUE_NAME_SIZE - 1] = '\0';
210
211       // send OpenSession ACK
212       if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendMsg(l_hClientService, PROTOCOL_OPEN_SESSION_ACK, sizeof(OpenSessionAck), (PVOID) &tOpenAck))) {  // LCOV_EXCL_BR_LINE 4:NSFW  // NOLINT[whitespace/line_length]
213         // LCOV_EXCL_START 4:NSFW
214         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
215         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
216                "FrameworkunifiedSendMsg PROTOCOL_OPEN_SESSION_ACK Failed Status:0x%x ",
217                l_eStatus);
218         // LCOV_EXCL_STOP
219       } else {
220         l_eStatus = FrameworkunifiedSetSessionHandle(hApp, FrameworkunifiedGetMsgSrc(hApp), l_hSession);
221         LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedSetSessionHandle()");  // LCOV_EXCL_BR_LINE 15:macro
222       }
223     }
224     l_eStatus = FrameworkunifiedMcClose(l_hClientService);
225     LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedMcClose()");  // LCOV_EXCL_BR_LINE 15:macro
226   }
227   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
228
229   return l_eStatus;
230 }
231
232 //////////////////////////////////////////
233 //  Function : DevDetectionServerOnCloseSession
234 //  Callback for PROTOCOL_CLOSE_SESSION_REQ
235 //////////////////////////////////////////
236 EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServerOnCloseSession(HANDLE hApp) {
237   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
238   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
239   HANDLE hSession = NULL;
240   HANDLE l_hClientService = NULL;
241   // Get the requester name
242   PCSTR pRequester = FrameworkunifiedGetMsgSrc(hApp);
243   CloseSessionAck tCloseAck;
244   CloseSessionReq tClose;
245
246   if (pRequester) {  // LCOV_EXCL_BR_LINE 4:NSFW
247     l_hClientService = FrameworkunifiedMcOpenSender(hApp, pRequester);
248     if (l_hClientService) {  // LCOV_EXCL_BR_LINE 4:NSFW
249       // Read the data from the message
250       if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &tClose, sizeof(tClose), eSMRRelease))) {  // LCOV_EXCL_BR_LINE 4:NSFW  // NOLINT[whitespace/line_length]
251         // LCOV_EXCL_START 4:NSFW
252         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
253         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedGetMsgDataOfSize Failed");
254
255         if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedMcClose(l_hClientService))) {
256           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedMcClose failed");
257         }
258         FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
259         return eStatus;
260         // LCOV_EXCL_STOP
261       }
262
263       hSession = FrameworkunifiedGetSessionHandle(hApp, pRequester, tClose.sessionId);
264
265       // Create a list of commands to be detached from the dispatcher
266       UI_32 cmd_array[kNUMBER_PROTOCOL_HANDLERS] = { 0 };
267       for (UI_32 i = 0; i < kNUMBER_PROTOCOL_HANDLERS; i++) {
268         cmd_array[i] = m_protocolHandlers[i].iCmd;
269       }
270
271       if (NULL != hSession) {  // LCOV_EXCL_BR_LINE 4:NSFW
272         // Detach callbacks associated with client
273         if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedDetachCallbacksFromDispatcher(hApp, pRequester, cmd_array, kNUMBER_PROTOCOL_HANDLERS, hSession))) {  // 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(
277               ZONE_ERR,
278               __PRETTY_FUNCTION__,
279               "FrameworkunifiedAttachCallbacksToDispatcher ss_logger_server_protocol_handlers Failed Status:0x%x ",
280               eStatus);
281           // LCOV_EXCL_STOP
282         }
283
284         eStatus = m_pErrorEvent->OnCloseSession(hApp, pRequester, hSession);
285         if (eFrameworkunifiedStatusOK != eStatus) {  // LCOV_EXCL_BR_LINE 200:To ensure success
286           // LCOV_EXCL_START 200:To ensure success
287           AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
288           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
289                  " Error. m_pErrorEvent->OnCloseSession(%s, %p) returned: %d.",
290                  pRequester, hSession, eStatus);
291           // LCOV_EXCL_STOP
292         }
293
294         // API to destroy the session handle and remove it from the Application Framework.
295         // LCOV_EXCL_BR_START 4:NSFW
296         if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedDestroySession(hApp,  // Application Handle
297             hSession))) {  // Session Handle
298         // LCOV_EXCL_BR_STOP
299           // LCOV_EXCL_START 4:NSFW
300           AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
301           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Session destroy failed");
302           // LCOV_EXCL_STOP
303         }
304       }
305       // sending the session close ack
306       tCloseAck.eStatus = eFrameworkunifiedStatusOK;
307       tCloseAck.sessionId = tClose.sessionId;
308
309       // send CloseSession ACK
310       if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedSendMsg(l_hClientService, PROTOCOL_CLOSE_SESSION_ACK, sizeof(CloseSessionAck), (PVOID) &tCloseAck))) {  // LCOV_EXCL_BR_LINE 4:NSFW  // NOLINT[whitespace/line_length]
311         // LCOV_EXCL_START 4:NSFW
312         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
313         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
314                "FrameworkunifiedSendMsg PROTOCOL_CLOSE_SESSION_ACK Failed Status:0x%x ",
315                eStatus);
316         // LCOV_EXCL_STOP
317       }
318       if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedMcClose(l_hClientService))) {  // LCOV_EXCL_BR_LINE 4:NSFW
319         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
320         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedMcClose failed");  // LCOV_EXCL_LINE 15:macro
321       }
322     }
323   }
324   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
325   return eStatus;
326 }
327
328 //////////////////////////////////////////
329 //  Function : LoggerServer_SetMileageData
330 //  Callback for SS_LOGGER_MILEAGE_DATA
331 //////////////////////////////////////////
332 EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_SetMileageData(HANDLE hApp) {
333   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
334   STLOGGER_CANDIAGSTAT MileageInfo_t;
335   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
336   memset(&MileageInfo_t, 0x00, sizeof(STLOGGER_CANDIAGSTAT));
337   if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &MileageInfo_t, sizeof(MileageInfo_t), eSMRRelease))) {  // LCOV_EXCL_BR_LINE 4:NSFW  // NOLINT[whitespace/line_length]
338     // LCOV_EXCL_START 4:NSFW
339     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
340     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " FrameworkunifiedGetMsgDataOfSize Failed");
341     l_eStatus = eFrameworkunifiedStatusFail;
342     // LCOV_EXCL_STOP
343   } else {
344     UI_32 l_mileage = (MileageInfo_t.Odo_MSB_H << 24
345         | MileageInfo_t.Odo_MSB_L << 16 | MileageInfo_t.Odo_LSB_H << 8
346         | MileageInfo_t.Odo_LSB_L);
347     // if value set to SNA
348     if (0xFFFFFFFF != l_mileage) {
349       this->m_pErrorEvent->SetMileage(l_mileage);
350       // Immediate Persist Event Log
351       if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdEvntLogWriter, eThrdCmdMileageData, sizeof(UI_32), &l_mileage))) {  // LCOV_EXCL_BR_LINE 4:NSFW  // NOLINT[whitespace/line_length]
352         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
353         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendChild msg failed:%d", l_eStatus);  // LCOV_EXCL_LINE 15:macro
354       }
355     }
356   }
357   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
358   return l_eStatus;
359 }
360
361 //////////////////////////////////////////
362 //  Function : LoggerServer_SetLoggerParams
363 //  Callback for SS_LOGGER_SET_PARAMS
364 //////////////////////////////////////////
365 EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_SetLoggerParams(HANDLE hApp) {
366   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
367   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
368   STLoggerSetParams l_stLoggerSetParams = { eInvalid_LoggerState, eDevUSB1 };
369
370   if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &l_stLoggerSetParams, sizeof(l_stLoggerSetParams), eSMRRelease))) {  // LCOV_EXCL_BR_LINE 4:NSFW  // NOLINT[whitespace/line_length]
371     // LCOV_EXCL_START 4:NSFW
372     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
373     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedGetMsgDataOfSize Failed");
374     eStatus = eFrameworkunifiedStatusFail;
375     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
376     return eStatus;
377     // LCOV_EXCL_STOP
378   } else {
379     eStatus = m_pLoggerCfg->SetLoggingParams(hApp, l_stLoggerSetParams);
380   }
381
382   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
383   return eStatus;
384 }
385
386 //////////////////////////////////////////
387 //  Function : LoggerServer_SetLoggerParams
388 //  Callback for SS_LOGGER_SET_PARAMS
389 //////////////////////////////////////////
390 EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_UDPLogging(HANDLE hApp) {
391   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
392   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
393   ELOGGER_STAT l_eUDPLoggingStatus = eInvalid_LoggerState;
394
395   if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &l_eUDPLoggingStatus, sizeof(l_eUDPLoggingStatus), eSMRRelease))) {  // LCOV_EXCL_BR_LINE 4:NSFW  // NOLINT[whitespace/line_length]
396     // LCOV_EXCL_START 4:NSFW
397     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
398     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedGetMsgDataOfSize Failed");
399     l_eStatus = eFrameworkunifiedStatusFail;
400     // LCOV_EXCL_STOP
401   } else {
402     l_eStatus = m_pLoggerCfg->SetUDPLogging(hApp, l_eUDPLoggingStatus);
403     LOG_STATUS_IF_ERRORED(  // LCOV_EXCL_BR_LINE 15:macro
404         l_eStatus,
405         "m_pLoggerCfg->SetUDPLogging()");
406   }
407
408   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
409   return (l_eStatus);
410 }
411
412 EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_UpdateCommonInfo(HANDLE hApp) {
413   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
414   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
415
416   if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &g_uEvtLoggerCommonInfo.u_stEvtLoggerCommonInfo, sizeof(g_uEvtLoggerCommonInfo.u_stEvtLoggerCommonInfo), eSMRRelease))) {  // LCOV_EXCL_BR_LINE 4:NSFW  // NOLINT[whitespace/line_length]
417     // LCOV_EXCL_START 4:NSFW
418     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
419     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " FrameworkunifiedGetMsgDataOfSize Failed");
420     eStatus = eFrameworkunifiedStatusFail;
421     // LCOV_EXCL_STOP
422   }
423
424   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
425   return eStatus;
426 }
427
428 EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_Handle_CWORD56_Events(HANDLE hApp) {
429   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
430   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
431   STEventLoggerEventInfo l_stEventLoggingEventInfo;
432   UI_16 l_evtid = 0;
433
434   if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &l_stEventLoggingEventInfo, sizeof(l_stEventLoggingEventInfo), eSMRRelease))) {  // LCOV_EXCL_BR_LINE 4:NSFW  // NOLINT[whitespace/line_length]
435     // LCOV_EXCL_START 4:NSFW
436     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
437     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " FrameworkunifiedGetMsgDataOfSize Failed");
438     eStatus = eFrameworkunifiedStatusFail;
439     // LCOV_EXCL_STOP
440   }
441   l_evtid = static_cast<UI_16>(((l_stEventLoggingEventInfo.EventGroup & 0x00FF) << 8)
442       | (l_stEventLoggingEventInfo.EventIdentifier & 0x00FF));
443   FRAMEWORKUNIFIEDLOG_EVT(ZONE_INFO, l_evtid, 4, l_stEventLoggingEventInfo.EventData[3],
444              l_stEventLoggingEventInfo.EventData[2],
445              l_stEventLoggingEventInfo.EventData[1],
446              l_stEventLoggingEventInfo.EventData[0]);
447
448   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
449   return eStatus;
450 }
451
452 EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnCopyEmergencyLog(
453     HANDLE f_hApp) {
454   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
455   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
456   EDevNumber l_eDevNumber;
457   std::string l_path = "";
458   std::string l_srcName = "";
459
460   if (NULL != f_hApp) {  // LCOV_EXCL_BR_LINE 6: it can't be null.
461     PCSTR l_tmp_srcname = FrameworkunifiedGetMsgSrc(f_hApp);
462     if (NULL != l_tmp_srcname) {  // LCOV_EXCL_BR_LINE 6: it can't be null.
463       l_srcName = l_tmp_srcname;
464     }
465
466     if (eFrameworkunifiedStatusOK
467         == (l_eStatus = FrameworkunifiedGetMsgDataOfSize(f_hApp, &l_eDevNumber,
468                                             sizeof(l_eDevNumber), eSMRRelease))) {
469       switch (l_eDevNumber) {
470         case eEEL_USB1:
471           l_path = m_pLoggerCfg->m_usb0MountPath;
472           break;
473
474         case eEEL_USB2:
475           l_path = m_pLoggerCfg->m_usb1MountPath;
476           break;
477
478         case eEEL_SD:
479           l_path = m_pLoggerCfg->m_sdMountPath;
480           break;
481
482         default:
483           /*send back error response wrong param*/
484           l_eStatus = eFrameworkunifiedStatusInvldParam;
485           break;
486       }
487     } else {
488       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Could not get msg Data.");
489     }
490
491     HANDLE l_hSession = NULL;
492     if (NULL == (l_hSession = FrameworkunifiedGetCurrentSessionHandle(f_hApp))) {  // LCOV_EXCL_BR_LINE 4: NSFW error case.
493       // LCOV_EXCL_START 4: NSFW error case.
494       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
495       l_eStatus = eFrameworkunifiedStatusNullPointer;
496       LOG_ERROR("FrameworkunifiedGetCurrentSessionHandle()");
497       // LCOV_EXCL_STOP
498     } else {
499       m_pErrorEvent->SetDiagSessionHandle(l_hSession);
500     }
501     if (0 == l_srcName.length()) {  // LCOV_EXCL_BR_LINE 6: it can't be 0.
502       // LCOV_EXCL_START 6: it can't be 0.
503       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
504       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
505              " Error. Could not get name of source service.");
506     // LCOV_EXCL_STOP
507       l_eStatus = eFrameworkunifiedStatusInvldHandle;
508     } else if (eFrameworkunifiedStatusOK != l_eStatus) {
509       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
510              " Error. Invalid parameter l_eDevNumber(%d).", l_eDevNumber);
511       l_eStatus = m_pErrorEvent->sendDiagEventErrorResponse(eNO_ERROR_INFO,
512                                                             l_srcName);
513       LOG_STATUS_IF_ERRORED(l_eStatus, "m_pErrorEvent->sendDiagEventErrorResponse(l_srcName)");
514       l_eStatus = eFrameworkunifiedStatusInvldParam;
515     } else if (eFrameworkunifiedStatusOK
516         != (l_eStatus = m_pErrorEvent->SetDiagEventSourceName(l_srcName))) {
517       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
518              " Error. m_pErrorEvent->SetDiagEventSourceName() returned %d.", l_eStatus);
519       l_eStatus = m_pErrorEvent->sendDiagEventErrorResponse(eNO_ERROR_INFO,
520                                                             l_srcName);
521       LOG_STATUS_IF_ERRORED(l_eStatus, "m_pErrorEvent->sendDiagEventErrorResponse(l_srcName)");
522       l_eStatus = eFrameworkunifiedStatusFail;
523     } else if (eFrameworkunifiedStatusOK != (l_eStatus =
524         SendDiagLoggingRequestToSystemManager(l_path))) {  // LCOV_EXCL_BR_LINE 4: NSFW error case.
525       // LCOV_EXCL_START 4: NSFW error case.
526       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
527       /* call System Manager interface*/
528       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
529              " Error. SendDiagLoggingRequestToSystemManager() returned %d.", l_eStatus);
530       l_eStatus = m_pErrorEvent->sendDiagEventErrorResponse(eNO_ERROR_INFO);
531       LOG_STATUS_IF_ERRORED(l_eStatus, "m_pErrorEvent->sendDiagEventErrorResponse()");
532       l_eStatus = eFrameworkunifiedStatusFail;
533       // LCOV_EXCL_STOP
534     } else {
535       FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Log Request passed to SystemManager.");
536     }
537   }
538
539   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
540   return (l_eStatus);
541 }
542
543 EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnCANTrigger(HANDLE f_hApp) {
544   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
545   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
546   l_eStatus = SendCANLoggingRequestToSystemManager();
547   LOG_STATUS_IF_ERRORED(l_eStatus, "SendCANLoggingRequestToSystemManager()");  // LCOV_EXCL_BR_LINE 15:macro
548   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
549   return (l_eStatus);
550 }
551
552 EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnDTCTrigger(HANDLE f_hApp) {
553   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
554   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
555   UI_32 l_dtc;
556   if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedGetMsgDataOfSize(f_hApp, &l_dtc, sizeof(l_dtc), eSMRRelease))) {  // LCOV_EXCL_BR_LINE 4:NSFW  // NOLINT[whitespace/line_length]
557     // LCOV_EXCL_START 4:NSFW
558     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
559     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Could not get msg Data.");
560     // LCOV_EXCL_STOP
561   } else {
562     l_eStatus = SendDTCLoggingRequestToSystemManager(l_dtc);
563     LOG_STATUS_IF_ERRORED(l_eStatus, "SendDTCLoggingRequestToSystemManager(dtc)");  // LCOV_EXCL_BR_LINE 15:macro
564     // Immediate Persist Event Log
565     if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendChild(f_hApp, g_thrdEvntLogWriter, eThrdCmdImmPersistEvtLog, 0x00, NULL))) {  // LCOV_EXCL_BR_LINE 4:NSFW  // NOLINT[whitespace/line_length]
566       // LCOV_EXCL_START 4:NSFW
567       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
568       FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "FrameworkunifiedSendChild msg failed:%X", l_eStatus);
569       // LCOV_EXCL_STOP
570     }
571   }
572   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
573   return (l_eStatus);
574 }
575
576 EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_On_SHTDWN_Complete(
577     HANDLE f_hApp) {
578   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
579   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
580   l_eStatus = LoggerService_OnStop(f_hApp);
581   LOG_STATUS_IF_ERRORED(l_eStatus, "LoggerService_OnStop()");  // LCOV_EXCL_BR_LINE 15:macro
582   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
583   return (l_eStatus);
584 }
585
586 ///////////////////////////////////////////////////////////////////////
587 /// Function :LoggerServer_OnSetVIN
588 ///////////////////////////////////////////////////////////////////////
589 EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnSetVIN(HANDLE hApp) {
590   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
591   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
592   STVIN_NUMBER l_stVIN_Number;
593
594   if (eFrameworkunifiedStatusOK == (l_eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &l_stVIN_Number, sizeof(l_stVIN_Number), eSMRRelease))) {  // LCOV_EXCL_BR_LINE 4:NSFW  // NOLINT[whitespace/line_length]
595     if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdEvntLogWriter, eThrdCmdSetVINnumber, sizeof(STVIN_NUMBER), &l_stVIN_Number))) {  // LCOV_EXCL_BR_LINE 4:NSFW  // NOLINT[whitespace/line_length]
596       // LCOV_EXCL_START 4:NSFW
597       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
598       FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "FrameworkunifiedSendChild msg failed:%X", l_eStatus);
599       // LCOV_EXCL_STOP
600     }
601   } else {
602     // LCOV_EXCL_START 4:NSFW
603     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
604     FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "FrameworkunifiedGetMsgDataOfSize failed errval: %X",
605            l_eStatus);
606     // LCOV_EXCL_STOP
607   }
608
609   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
610   return (l_eStatus);
611 }
612
613 ///////////////////////////////////////////////////////////////////////
614 /// Function :LoggerServer_OnCopyEvntLog
615 ///////////////////////////////////////////////////////////////////////
616 EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnCopyEvntLog(HANDLE hApp) {
617   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
618   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
619
620   TWriteFilesToUsbCmdData l_stCmdData;
621   HANDLE l_hSession = NULL;
622
623   if (hApp != NULL) {  // LCOV_EXCL_BR_LINE 6: it can not be null
624     PCSTR l_tmp_srcname = FrameworkunifiedGetMsgSrc(hApp);
625     if (NULL != l_tmp_srcname) {  // LCOV_EXCL_BR_LINE 6: it can not be null
626       l_stCmdData.stSessiondata.strSrcName = l_tmp_srcname;
627     }
628     if (l_stCmdData.stSessiondata.strSrcName.empty()) {  // LCOV_EXCL_BR_LINE 6: it can not be empty
629       // LCOV_EXCL_START 6: it can not be empty
630       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
631       l_eStatus = eFrameworkunifiedStatusNullPointer;
632       LOG_ERROR("FrameworkunifiedGetMsgSrc()");
633       // LCOV_EXCL_STOP
634     } else if (NULL == (l_hSession = FrameworkunifiedGetCurrentSessionHandle(hApp))) {  // LCOV_EXCL_BR_LINE 6: it can not be null
635       // LCOV_EXCL_START 6: it can not be null
636       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
637       l_eStatus = eFrameworkunifiedStatusNullPointer;
638       LOG_ERROR("FrameworkunifiedGetCurrentSessionHandle()");
639       // LCOV_EXCL_STOP
640     } else {
641       l_stCmdData.stSessiondata.session_id = FrameworkunifiedGetSessionId(l_hSession);
642       if (eFrameworkunifiedStatusOK
643           != (l_eStatus = ReadMsg<EEvtLogUSBDevNumber>(hApp, l_stCmdData.eDevId))) {
644         LOG_ERROR("ReadMsg()");
645       } else {
646         if (eFrameworkunifiedStatusOK
647             != (l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdEvntLogWriter,  // LCOV_EXCL_BR_LINE 4:NSFW
648                                          eThrdCmdWriteEvntFilesToUsb,
649                                          sizeof(TWriteFilesToUsbCmdData),
650                                          &l_stCmdData))) {
651           AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
652           LOG_ERROR("FrameworkunifiedSendChild()");  // LCOV_EXCL_LINE 4:NSFW
653         }
654       }
655     }
656   } else {
657     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
658     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Invalid App handler");  // LCOV_EXCL_LINE 6: it can not be null
659   }
660
661   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
662   return (l_eStatus);
663 }
664
665 ///////////////////////////////////////////////////////////////////////
666 /// Function :LoggerServer_OnClearEvntLog
667 ///////////////////////////////////////////////////////////////////////
668 EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnClearEvntLog(HANDLE hApp) {
669   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
670   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
671
672   if (hApp != NULL) {  // LCOV_EXCL_BR_LINE 200:As it is not always NULL
673     TSessionData l_sessiondata;
674     HANDLE l_hSession = NULL;
675     PCSTR l_tmp_srcname = FrameworkunifiedGetMsgSrc(hApp);  // LCOV_EXCL_BR_LINE 11:Unexpected branch
676     if (NULL != l_tmp_srcname) {  // LCOV_EXCL_BR_LINE 4:NSFW
677       l_sessiondata.strSrcName = l_tmp_srcname;
678     }
679     if (l_sessiondata.strSrcName.empty()) {  // LCOV_EXCL_BR_LINE 4:As it is guaranteed by NSFW and is not always an empty string
680       // LCOV_EXCL_START 4:As it is guaranteed by NSFW and is not always an empty string
681       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
682       l_eStatus = eFrameworkunifiedStatusNullPointer;
683       LOG_ERROR("FrameworkunifiedGetMsgSrc()");
684       // LCOV_EXCL_STOP
685     } else if (NULL == (l_hSession = FrameworkunifiedGetCurrentSessionHandle(hApp))) {  // LCOV_EXCL_BR_LINE 4:NSFW
686       // LCOV_EXCL_START 4:NSFW
687       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
688       l_eStatus = eFrameworkunifiedStatusNullPointer;
689       LOG_ERROR("FrameworkunifiedGetCurrentSessionHandle()");
690       // LCOV_EXCL_STOP
691     } else {
692       l_sessiondata.session_id = FrameworkunifiedGetSessionId(l_hSession);  // LCOV_EXCL_BR_LINE 11:Unexpected branch
693       if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdEvntLogWriter, eThrdCmdClearEvntLogs, sizeof(TSessionData), &l_sessiondata))) {  // LCOV_EXCL_BR_LINE 4:NSFW  // NOLINT[whitespace/line_length]
694         // LCOV_EXCL_START 4:NSFW
695         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
696         LOG_ERROR("FrameworkunifiedSendChild()");
697         // LCOV_EXCL_STOP
698       }
699     }
700   }
701   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
702   return (l_eStatus);
703 }
704
705 ///////////////////////////////////////////////////////////////////////
706 /// Function :LoggerServer_OnReadStatCounter
707 ///////////////////////////////////////////////////////////////////////
708 EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnReadStatCounter(
709     HANDLE hApp) {
710   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
711   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
712
713   if (hApp != NULL) {  // LCOV_EXCL_BR_LINE 6: it can not be null
714     TStatisticalCountersCmd l_stCmdData;
715     HANDLE l_hSession = NULL;
716
717     PCSTR l_tmp_srcname = FrameworkunifiedGetMsgSrc(hApp);
718     if (NULL != l_tmp_srcname) {  // LCOV_EXCL_BR_LINE 6: it can not be null
719       l_stCmdData.stSessiondata.strSrcName = l_tmp_srcname;
720     }
721     if (l_stCmdData.stSessiondata.strSrcName.empty()) {  // LCOV_EXCL_BR_LINE 6: it can not be empty
722       // LCOV_EXCL_START 6: it can not be empty
723       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
724       l_eStatus = eFrameworkunifiedStatusNullPointer;
725       LOG_ERROR("FrameworkunifiedGetMsgSrc()");
726       // LCOV_EXCL_STOP
727     } else if (NULL == (l_hSession = FrameworkunifiedGetCurrentSessionHandle(hApp))) {  // LCOV_EXCL_BR_LINE 6: it can not be null
728       // LCOV_EXCL_START 6: it can not be empty
729       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
730       l_eStatus = eFrameworkunifiedStatusNullPointer;
731       LOG_ERROR("FrameworkunifiedGetCurrentSessionHandle()");
732       // LCOV_EXCL_STOP
733     } else {
734       l_stCmdData.stSessiondata.session_id = FrameworkunifiedGetSessionId(l_hSession);
735       if (eFrameworkunifiedStatusOK
736           != (l_eStatus = ReadMsg<EStatCounterGroupID>(hApp,
737                                                        l_stCmdData.eGroupId))) {
738         LOG_ERROR("ReadMsg()");
739       } else {
740         if (eFrameworkunifiedStatusOK
741             != (l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdEvntLogWriter,  // LCOV_EXCL_BR_LINE 4:NSFW
742                                          eThrdCmdStatisticalCounter,
743                                          sizeof(TStatisticalCountersCmd),
744                                          &l_stCmdData))) {
745           AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
746           LOG_ERROR("FrameworkunifiedSendChild()");// LCOV_EXCL_LINE 4:NSFW
747         }
748       }
749     }
750   }
751
752   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
753   return (l_eStatus);
754 }
755
756 ///////////////////////////////////////////////////////////////////////
757 /// Function :LoggerServer_OnResetStatCounter
758 ///////////////////////////////////////////////////////////////////////
759 EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnResetStatCounter(
760     HANDLE hApp) {
761   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
762   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
763
764   if (hApp != NULL) {  // LCOV_EXCL_BR_LINE 6: it can not be null
765     TStatisticalCountersCmd l_stCmdData;
766     HANDLE l_hSession = NULL;
767     PCSTR l_tmp_srcname = FrameworkunifiedGetMsgSrc(hApp);
768     if (NULL != l_tmp_srcname) {  // LCOV_EXCL_BR_LINE 6: it can not be null
769       l_stCmdData.stSessiondata.strSrcName = l_tmp_srcname;
770     }
771     if (l_stCmdData.stSessiondata.strSrcName.empty()) {  // LCOV_EXCL_BR_LINE 6: it can not be empty
772       // LCOV_EXCL_START 6: it can not be empty
773       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
774       l_eStatus = eFrameworkunifiedStatusNullPointer;
775       LOG_ERROR("FrameworkunifiedGetMsgSrc()");
776       // LCOV_EXCL_STOP
777     } else if (NULL == (l_hSession = FrameworkunifiedGetCurrentSessionHandle(hApp))) {  // LCOV_EXCL_BR_LINE 6: it can not be null
778       // LCOV_EXCL_START 6: it can not be empty
779       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
780       l_eStatus = eFrameworkunifiedStatusNullPointer;
781       LOG_ERROR("FrameworkunifiedGetCurrentSessionHandle()");
782       // LCOV_EXCL_STOP
783     } else {
784       l_stCmdData.stSessiondata.session_id = FrameworkunifiedGetSessionId(l_hSession);
785       if (eFrameworkunifiedStatusOK
786           != (l_eStatus = ReadMsg<EStatCounterGroupID>(hApp,
787                                                        l_stCmdData.eGroupId))) {
788         LOG_ERROR("ReadMsg()");
789       } else {
790         if (eFrameworkunifiedStatusOK
791             != (l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdEvntLogWriter,  // LCOV_EXCL_BR_LINE 4:NSFW
792                                          eThrdCmdResetStatisticalCntrs,
793                                          sizeof(TStatisticalCountersCmd),
794                                          &l_stCmdData))) {
795           AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
796           LOG_ERROR("FrameworkunifiedSendChild()");  // LCOV_EXCL_LINE 4:NSFW
797         }
798       }
799     }
800   }
801   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
802   return (l_eStatus);
803 }
804
805 ///////////////////////////////////////////////////////////////////////
806 /// Function :LoggerServer_OnReadNumberOfEvents
807 ///////////////////////////////////////////////////////////////////////
808 EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnReadNumberOfEvents(
809     HANDLE hApp) {
810   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
811   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
812   TSessionData l_sessiondata;
813   HANDLE l_hSession = NULL;
814
815   l_sessiondata.strSrcName = FrameworkunifiedGetMsgSrc(hApp);
816   if (l_sessiondata.strSrcName.empty()) {  // LCOV_EXCL_BR_LINE 6: it can not be empty
817     // LCOV_EXCL_START 6: it can not be empty
818       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
819     l_eStatus = eFrameworkunifiedStatusNullPointer;
820     LOG_ERROR("FrameworkunifiedGetMsgSrc()");
821     // LCOV_EXCL_STOP
822   } else if (NULL == (l_hSession = FrameworkunifiedGetCurrentSessionHandle(hApp))) {  // LCOV_EXCL_BR_LINE 6: it can not be null
823     // LCOV_EXCL_START 6: it can not be empty
824     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
825     l_eStatus = eFrameworkunifiedStatusNullPointer;
826     LOG_ERROR("FrameworkunifiedGetCurrentSessionHandle()");
827     // LCOV_EXCL_STOP
828   } else {
829     l_sessiondata.session_id = FrameworkunifiedGetSessionId(l_hSession);
830     if (eFrameworkunifiedStatusOK
831         != (l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdEvntLogWriter,  // LCOV_EXCL_BR_LINE 4:NSFW
832                                      eThrdCmdGetNumberOfEventsLogged,
833                                      sizeof(TSessionData), &l_sessiondata))) {
834       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
835       LOG_ERROR("FrameworkunifiedSendChild()");  // LCOV_EXCL_LINE 4:NSFW
836     }
837   }
838
839   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
840   return (l_eStatus);
841 }
842
843 ///////////////////////////////////////////////////////////////////////
844 /// Function :LoggerServer_OnSetDiagID
845 ///////////////////////////////////////////////////////////////////////
846 EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnSetDiagID(HANDLE hApp) {
847   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
848   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
849   UI_16 l_DiagId = 0;
850
851   if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<UI_16>(hApp, l_DiagId))) {  // LCOV_EXCL_BR_LINE 200:To ensure success
852     // LCOV_EXCL_START 200:To ensure success
853     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
854     LOG_ERROR("ReadMsg()");
855     // LCOV_EXCL_STOP
856   } else {
857     g_u16DiagId = l_DiagId;
858   }
859   return l_eStatus;
860 }
861
862 ///////////////////////////////////////////////////////////////////////
863 /// Function :LoggerServer_UploadEventLog
864 ///////////////////////////////////////////////////////////////////////
865 EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_UploadEventLog(HANDLE hApp) {
866   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
867   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
868   TSessionData l_sessiondata;
869   HANDLE l_hSession = NULL;
870
871   PCSTR l_tmp_srcname = FrameworkunifiedGetMsgSrc(hApp);
872   if (NULL != l_tmp_srcname) {  // LCOV_EXCL_BR_LINE 6: it can not be null
873     l_sessiondata.strSrcName = l_tmp_srcname;
874   }
875   if (l_sessiondata.strSrcName.empty()) {  // LCOV_EXCL_BR_LINE 6: it can not be empty
876     // LCOV_EXCL_START 6: it can not be empty
877     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
878     l_eStatus = eFrameworkunifiedStatusNullPointer;
879     LOG_ERROR("FrameworkunifiedGetMsgSrc()");
880     // LCOV_EXCL_STOP
881   } else if (NULL == (l_hSession = FrameworkunifiedGetCurrentSessionHandle(hApp))) {  // LCOV_EXCL_BR_LINE 6: it can not be null
882     // LCOV_EXCL_START 6: it can not be null
883     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
884     l_eStatus = eFrameworkunifiedStatusNullPointer;
885     LOG_ERROR("FrameworkunifiedGetCurrentSessionHandle()");
886     // LCOV_EXCL_STOP
887   } else {
888     l_sessiondata.session_id = FrameworkunifiedGetSessionId(l_hSession);
889     if (eFrameworkunifiedStatusOK
890         != (l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdEvntLogWriter,  // LCOV_EXCL_BR_LINE 4:NSFW
891                                      eThrdCmdUploadEventLog,
892                                      sizeof(TSessionData), &l_sessiondata))) {
893       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
894       LOG_ERROR("FrameworkunifiedSendChild()");  // LCOV_EXCL_LINE 4:NSFW
895     }
896   }
897
898   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
899   return (l_eStatus);
900 }