common_library: gettid is multiple declaration in cl_error
[staging/basesystem.git] / video_in_hal / systemservice / interface_unified / library / src / ss_logger_service_ifc.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_SystemServices_Logger
19 /// \brief    This file supports the _CWORD77_ logger service.
20 ///
21 ///////////////////////////////////////////////////////////////////////////////
22 #include "system_service/ss_logger_service_ifc.h"
23 #include <string.h>
24 #include <native_service/frameworkunified_application.h>
25 #include <native_service/frameworkunified_framework_if.h>
26 #include <native_service/frameworkunified_types.h>
27 #include <native_service/frameworkunified_framework_types.h>
28 #include <string>
29 #include "system_service/ss_logger_service_protocol.h"
30 #include "system_service/ss_logger_service_notifications.h"
31 #include "system_service/ss_logger_service.h"
32 #include "system_service/ss_logger_service_local.h"
33 #include "system_service/ss_services.h"
34 #include "ss_logger_service_if_interfaceunifiedlog.h"
35
36 LoggerServiceIf::LoggerServiceIf()
37     : m_hApp(NULL),
38       m_hService(NULL),
39       m_hSession(NULL) {
40 }
41
42 LoggerServiceIf::~LoggerServiceIf() {
43   CloseSessionRequest();  // if the session is still connected
44
45   m_hService = NULL;
46   m_hSession = NULL;
47   m_hApp = NULL;
48 }  // LCOV_EXCL_BR_LINE 10:Because destructor
49
50 EFrameworkunifiedStatus LoggerServiceIf::NotifyOnLoggerServiceAvailability(
51     CbFuncPtr f_pCallBackFn) {
52   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
53   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
54   if (NULL != m_hApp && NULL != f_pCallBackFn) {
55     // Subscriptions
56     FrameworkunifiedNotificationCallbackHandler g_aryLogger_Notif_Cbs[] = {
57     // Notifications name,              Call back function
58         { NTFY_SS_LoggerService_Availability, f_pCallBackFn }, };
59
60     if (0 != strcmp(SERVICE_LOGGER, FrameworkunifiedGetAppName(m_hApp))) {
61       // Subscribe and attach call backs to notifications
62       if (eFrameworkunifiedStatusOK
63           != (eStatus = FrameworkunifiedSubscribeNotificationsWithCallback(
64               m_hApp, g_aryLogger_Notif_Cbs, _countof(g_aryLogger_Notif_Cbs)))) {
65         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
66                "FrameworkunifiedAttachNotificationCallbacksToDispatcher Failed Status:0x%x ",
67                eStatus);
68       }
69     }
70   }
71   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
72   return eStatus;
73 }
74
75 EFrameworkunifiedStatus LoggerServiceIf::NotifyOnOpenSessionAck(CbFuncPtr f_pCallBackFn) {
76   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
77   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
78   if (NULL != m_hApp && NULL != f_pCallBackFn) {
79     if (eFrameworkunifiedStatusOK
80         != (eStatus = FrameworkunifiedAttachCallbackToDispatcher(m_hApp,
81         SERVICE_LOGGER,
82                                                     PROTOCOL_OPEN_SESSION_ACK,
83                                                     f_pCallBackFn))) {
84       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
85              "FrameworkunifiedAttachCallbackToDispatcher Failed Status:0x%x ", eStatus);
86     }
87   }
88   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
89   return eStatus;
90 }
91
92 EFrameworkunifiedStatus LoggerServiceIf::NotifyOnCloseSessionAck(CbFuncPtr f_pCallBackFn) {
93   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
94   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
95
96   if (NULL != m_hApp && NULL != f_pCallBackFn) {
97     if (eFrameworkunifiedStatusOK
98         != (eStatus = FrameworkunifiedAttachCallbackToDispatcher(m_hApp,
99         SERVICE_LOGGER,
100                                                     PROTOCOL_CLOSE_SESSION_ACK,
101                                                     f_pCallBackFn))) {
102       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
103              "FrameworkunifiedAttachCallbackToDispatcher Failed Status:0x%x ", eStatus);
104     }
105   }
106
107   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
108   return eStatus;
109 }
110
111 BOOL LoggerServiceIf::Initialize(HANDLE hApp) {
112   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
113   BOOL l_eStatus = TRUE;
114
115   if (NULL != hApp) {
116     m_hApp = hApp;
117   } else {
118     l_eStatus = FALSE;  //  eFrameworkunifiedStatusInvldHandle;
119   }
120   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
121   return l_eStatus;
122 }
123
124 EFrameworkunifiedStatus LoggerServiceIf::OpenSessionRequest() {
125   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
126   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
127   if (NULL != m_hApp) {
128     // if the session is there then we need to close it first!
129     if (NULL != m_hService) {
130       CloseSessionRequest();
131       m_hService = NULL;
132     }
133     BOOL l_bServiceAvailable = FrameworkunifiedIsServiceAvailable(m_hApp);
134     if (FALSE == l_bServiceAvailable) {
135       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "Service is unavailable");
136       l_eStatus = eFrameworkunifiedStatusFail;
137     } else {
138       // Now open the service.
139       if (l_bServiceAvailable
140           && (NULL != (m_hService = OpenService()))) {  // LCOV_EXCL_BR_LINE 8:Because bServiceAvailable is always TRUE
141         // [DM: TODO] Check if we need to open a session with some data sent to Server.
142         UI_32 l_pTestData = 1;
143         if (eFrameworkunifiedStatusOK
144             != (l_eStatus = FrameworkunifiedOpenSessionWithData(m_hService,
145                                                    (PVOID) &l_pTestData,
146                                                    sizeof(UI_32)))) {
147           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
148                  "FrameworkunifiedOpenSessionWithData Failed, errval :%d", l_eStatus);
149         }
150       } else {
151         l_eStatus = eFrameworkunifiedStatusFail;
152         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
153                "FrameworkunifiedOpenService Failed, errval :%d", l_eStatus);
154       }
155     }
156   }
157   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
158   return l_eStatus;
159 }
160
161 HANDLE LoggerServiceIf::OpenService() {
162   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
163   HANDLE l_hService = NULL;
164
165   if (NULL == (l_hService = FrameworkunifiedOpenService(m_hApp, SERVICE_LOGGER))) {
166     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
167            "FrameworkunifiedOpenService : Failed to open Logger Service");
168   }
169   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
170   return l_hService;
171 }
172
173 EFrameworkunifiedStatus LoggerServiceIf::DecodeOpenSessionResponse() {
174   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
175   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
176   std::string l_strSessionName;
177   if (NULL != m_hService
178       && NULL != m_hApp) {  // LCOV_EXCL_BR_LINE 8:Because there is no case where m_hApp is NULL and m_hService is not NULL
179     if (NULL == (m_hSession = FrameworkunifiedGetOpenSessionHandle(m_hApp))) {
180       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
181              "Error in extracting OpenSessionAck response.");
182       l_eStatus = eFrameworkunifiedStatusFail;
183     } else {
184       l_eStatus = eFrameworkunifiedStatusOK;
185       l_strSessionName = FrameworkunifiedGetSessionName(m_hSession);
186       if (l_strSessionName.empty()) {
187         l_eStatus = eFrameworkunifiedStatusFail;
188         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "SessionName is empty");
189       } else {
190         if (eFrameworkunifiedStatusOK
191             != (FrameworkunifiedSetSessionHandle(m_hApp, l_strSessionName.c_str(), m_hSession))) {
192           l_eStatus = eFrameworkunifiedStatusFail;
193           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedSetSessionHandle() failed");
194         }
195       }
196     }
197   }
198
199   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
200   return l_eStatus;
201 }
202
203 EFrameworkunifiedStatus LoggerServiceIf::CloseSessionRequest() {
204   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
205   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
206
207   if (NULL != m_hService && NULL != m_hSession) {
208     if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedCloseSession(m_hService, m_hSession))) {
209       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedCloseSession Failed");
210     }
211     m_hSession = NULL;  // clear our session handle
212   }
213   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
214   return l_eStatus;
215 }
216
217 EFrameworkunifiedStatus LoggerServiceIf::RegisterForLoggerEvent(
218     SS_LoggerServerEvents f_eLoggerEvent, CbFuncPtr f_pCallBackFn) {
219   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
220   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
221
222   if (NULL != m_hSession && NULL != f_pCallBackFn) {
223     if (eFrameworkunifiedStatusOK
224         != (eStatus = FrameworkunifiedAttachCallbackToDispatcher(m_hApp,
225         SERVICE_LOGGER,
226                                                     f_eLoggerEvent,
227                                                     f_pCallBackFn, m_hSession))) {
228       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
229              "FrameworkunifiedAttachCallbackToDispatcher Failed Status:0x%x ", eStatus);
230     }
231
232     // client registers for the event
233     if (eFrameworkunifiedStatusOK
234         != (eStatus = FrameworkunifiedRegisterEvent(m_hSession, f_eLoggerEvent))) {
235       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedRegisterEvents Failed Status:0x%x",
236              eStatus);
237     }
238     FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "FrameworkunifiedRegisterEvents Status:0x%x", eStatus);
239   }
240   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
241   return eStatus;
242 }
243
244 EFrameworkunifiedStatus LoggerServiceIf::UnRegisterForLoggerEvent(
245     SS_LoggerServerEvents f_eLoggerEvent) {
246   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
247   EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusInvldHandle;
248
249   if (NULL != m_hSession) {
250     eStatus = eFrameworkunifiedStatusOK;
251   }
252   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
253   return eStatus;
254 }
255
256 ////////////////////////////////////////////////////////////////////////////////////////////
257 /// SendDiagStat
258 /// API to send CAN Diagnostic status data(it has mileage info) to Logger Service
259 /// (Command: SS_LOGGER_MILEAGE_DATA)
260 ///
261 /// \return status
262 ///         EFrameworkunifiedStatus - success or error
263 ////////////////////////////////////////////////////////////////////////////////////////////
264
265 EFrameworkunifiedStatus LoggerServiceIf::SendDiagStat(STLOGGER_CANDIAGSTAT *pCanDiagStat_t) {
266   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
267   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
268   STLOGGER_CANDIAGSTAT l_candiagstat;
269
270   memcpy(&l_candiagstat, pCanDiagStat_t, sizeof(STLOGGER_CANDIAGSTAT));
271
272   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Before Valid Session");
273   if (NULL != m_hService && NULL != m_hSession) {
274     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Entered Valid Session");
275     if (eFrameworkunifiedStatusOK
276         != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER_MILEAGE_DATA,
277                                    sizeof(STLOGGER_CANDIAGSTAT), &l_candiagstat))) {
278       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
279     }
280     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Msg Send Successfully");
281   }
282   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
283   return l_eStatus;
284 }
285
286 ///////////////////////////////////////////////////////////////////////
287 /// Function :LoggerIf_CANGetCurrentDateAndTime
288 ///////////////////////////////////////////////////////////////////////
289 EFrameworkunifiedStatus LoggerServiceIf::LoggerIf_CANGetCurrentDateAndTime(
290     STCanCurrentDateTime stDateAndTime) {
291   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
292   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
293
294   if (NULL != m_hService && NULL != m_hSession) {
295     if (eFrameworkunifiedStatusOK
296         != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER_SET_DATETIME,
297                                    sizeof(stDateAndTime), &stDateAndTime))) {
298       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
299     }
300   }
301   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
302   return l_eStatus;
303 }
304
305 ///////////////////////////////////////////////////////////////////////
306 /// Function :LoggerIf_CANSetVIN
307 ///////////////////////////////////////////////////////////////////////
308 EFrameworkunifiedStatus LoggerServiceIf::LoggerIf_CANSetVIN(STVIN_NUMBER& stVinNumber) {
309   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
310   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
311
312   stVinNumber.VINstr[stVinNumber.VIN_LEN - 1] = '\0';
313
314   if (NULL != m_hService && NULL != m_hSession) {
315     if (eFrameworkunifiedStatusOK
316         != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER_SET_VIN,
317                                    sizeof(STVIN_NUMBER), &stVinNumber))) {
318       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg() Failed with error: %X",
319              l_eStatus);
320     }
321   } else {
322     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Service or Session Handle NULL");
323   }
324   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
325   return l_eStatus;
326 }
327
328 ////////////////////////////////////////////////////////////////////////////////////////////
329 /// LoggerIf_SetLoggerParams
330 /// API is to inform Logger Service about the device selected to store the logs
331 /// and about Enable/Disable Logging.
332 /// (Command: SS_LOGGER_SET_PARAMS)
333 ///
334 /// \return status
335 ///         EFrameworkunifiedStatus - success or error
336 ////////////////////////////////////////////////////////////////////////////////////////////
337 EFrameworkunifiedStatus LoggerServiceIf::LoggerIf_SetLoggerParams(ELOGGER_STAT eLoggerStatus,
338                                                      EDEV_TYPE eDevType) {
339   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
340   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
341   STLoggerSetParams l_stLoggerParams;
342
343   l_stLoggerParams.Logger_State = eLoggerStatus;
344   l_stLoggerParams.Device_Type = eDevType;
345
346   if (NULL != m_hService && NULL != m_hSession) {
347     if (eFrameworkunifiedStatusOK
348         != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER_SET_PARAMS,
349                                    sizeof(STLoggerSetParams), &l_stLoggerParams))) {
350       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
351     }
352   }
353   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
354   return l_eStatus;
355 }
356
357 ////////////////////////////////////////////////////////////////////////////////////////////
358 /// LoggerIf_UDPLogging
359 /// API is to inform Logger Service about UDP logging
360 /// and about Enable/Disable Logging.
361 /// (Command: SS_LOGGER_UDP_LOGGING)
362 ///
363 /// \return status
364 ///         EFrameworkunifiedStatus - success or error
365 ////////////////////////////////////////////////////////////////////////////////////////////
366 EFrameworkunifiedStatus LoggerServiceIf::LoggerIf_UDPLogging(ELOGGER_STAT eLoggerStatus) {
367   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
368   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
369
370   if (NULL != m_hService && NULL != m_hSession) {
371     if (eFrameworkunifiedStatusOK
372         != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER_UDP_LOGGING,
373                                    sizeof(ELOGGER_STAT), &eLoggerStatus))) {
374       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
375     }
376   }
377   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
378   return l_eStatus;
379 }
380
381 EFrameworkunifiedStatus LoggerServiceIf::LoggerIf_ScreenCaptureEventACK(
382     STScreenCaptureEvt stScreenCaptureInfo) {
383   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
384   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
385
386   if (NULL != m_hSession) {
387     if (eFrameworkunifiedStatusOK
388         != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER_SCREENCAPTURE_EVT_ACK,
389                                    sizeof(stScreenCaptureInfo),
390                                    &stScreenCaptureInfo))) {
391       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
392     } else {
393       FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Screen shot ACK sent successfully.");
394     }
395   } else {
396     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
397            "Error. m_hSession is NULL. Screen shot capture ACK not sent.");
398   }
399   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
400   return l_eStatus;
401 }
402
403 ///////////////////////////////////////////////////////////////////////
404 /// Function :LoggerIf_EventLoggingCommonInfo
405 ///////////////////////////////////////////////////////////////////////
406 EFrameworkunifiedStatus LoggerServiceIf::LoggerIf_EventLoggingCommonInfo(
407     STEventLoggerCommonInfo stEventCommonInfo) {
408   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
409   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
410
411   if (NULL != m_hService && NULL != m_hSession) {
412     if (eFrameworkunifiedStatusOK
413         != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER_EVENT_COMMONINFO,
414                                    sizeof(stEventCommonInfo),
415                                    &stEventCommonInfo))) {
416       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
417     }
418   }
419   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
420   return l_eStatus;
421 }
422
423 ///////////////////////////////////////////////////////////////////////
424 /// Function :LoggerIf_EventLoggingEventInfo
425 ///////////////////////////////////////////////////////////////////////
426 EFrameworkunifiedStatus LoggerServiceIf::LoggerIf_EventLoggingEventInfo(
427     STEventLoggerEventInfo stEventInfo) {
428   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
429   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
430
431   if (NULL != m_hService && NULL != m_hSession) {
432     if (eFrameworkunifiedStatusOK
433         != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER__CWORD56__EVENT_INFO,
434                                    sizeof(stEventInfo), &stEventInfo))) {
435       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
436     }
437   }
438   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
439   return l_eStatus;
440 }
441
442 ///////////////////////////////////////////////////////////////////////
443 /// Function :LoggerIf_EventLoggingResetInfo
444 /// (Command: SS_LOGGER__CWORD56__RESET_INFO)
445 ///////////////////////////////////////////////////////////////////////
446 EFrameworkunifiedStatus LoggerServiceIf::LoggerIf_EventLoggingResetInfo(
447     STEventLoggerResetInfo stResetInfo) {
448   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
449   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
450
451   if (NULL != m_hService && NULL != m_hSession) {
452     if (eFrameworkunifiedStatusOK
453         != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER__CWORD56__RESET_INFO,
454                                    sizeof(stResetInfo), &stResetInfo))) {
455       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
456     }
457   }
458   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
459   return l_eStatus;
460 }
461
462 ///////////////////////////////////////////////////////////////////////
463 /// Function :LoggerIf_EventLoggingResetInfo
464 /// (Command: SS_LOGGER_DIAGDTC_ACTIVE)
465 ///////////////////////////////////////////////////////////////////////
466 EFrameworkunifiedStatus LoggerServiceIf::LoggerIf_PersistEventLogOnActiveDTC(void) {
467   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
468   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
469
470   if (NULL != m_hService && NULL != m_hSession) {
471     if (eFrameworkunifiedStatusOK
472         != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER_DIAGDTC_ACTIVE, 0x00,
473                                    NULL))) {
474       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
475     }
476   }
477   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
478   return l_eStatus;
479 }
480
481 ///////////////////////////////////////////////////////////////////////
482 /// Function :LoggerIf_EventLoggingResetInfo
483 /// (Command: SS_LOGGER_SHUTDOWN_COMPLETE)
484 ///////////////////////////////////////////////////////////////////////
485 EFrameworkunifiedStatus LoggerServiceIf::LoggerIf_Shutdown_Complete(void) {
486   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
487   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
488
489   if (NULL != m_hService && NULL != m_hSession) {
490     if (eFrameworkunifiedStatusOK
491         != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER_SHUTDOWN_COMPLETE,
492                                    0x00, NULL))) {
493       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
494     }
495   }
496   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
497   return l_eStatus;
498 }
499
500 ///////////////////////////////////////////////////////////////////////
501 /// Function :StoreEventLogsToUSB
502 ///////////////////////////////////////////////////////////////////////
503 EFrameworkunifiedStatus LoggerServiceIf::StoreEventLogsToUSB(
504     EEvtLogUSBDevNumber eUSBDevNumber) {
505
506   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
507
508   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
509
510   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
511          "Copy the Event logs in to USB command received:%X", eUSBDevNumber);
512
513   if (NULL != m_hSession) {
514     if (eFrameworkunifiedStatusOK
515         != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGERCOPYEVENTUSB,
516                                    sizeof(EEvtLogUSBDevNumber), &eUSBDevNumber))) {
517       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
518     }
519   } else {
520     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Session failed");
521   }
522
523   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
524   return l_eStatus;
525 }
526
527 ///////////////////////////////////////////////////////////////////////
528 /// Function :StoreEmergencyErrorLogsToUSB
529 ///////////////////////////////////////////////////////////////////////
530 EFrameworkunifiedStatus LoggerServiceIf::StoreEmergencyErrorLogsToUSB(
531     EDevNumber eDevNumber) {
532
533   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
534
535   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
536
537   FRAMEWORKUNIFIEDLOG(
538       ZONE_INFO, __FUNCTION__,
539       "Copy the Emergency Error logs in to External Device command received:%X",
540       eDevNumber);
541
542   if (NULL != m_hSession) {
543     if (eFrameworkunifiedStatusOK
544         != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGERCOPYEMERGENCYLOGS,
545                                    sizeof(EDevNumber), &eDevNumber))) {
546       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
547     }
548   } else {
549     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Session failed");
550   }
551   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
552   return l_eStatus;
553 }
554
555 ///////////////////////////////////////////////////////////////////////
556 /// Function :ClearEventLogs
557 ///////////////////////////////////////////////////////////////////////
558 EFrameworkunifiedStatus LoggerServiceIf::ClearEventLogs(void) {
559   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
560
561   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
562
563   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Request for clearing the event logs");
564
565   if (NULL != m_hSession) {
566     if (eFrameworkunifiedStatusOK
567         != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGERCLEAREVENT, 0, NULL))) {
568       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
569     }
570   } else {
571     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Session failed");
572   }
573   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
574   return l_eStatus;
575 }
576
577 ///////////////////////////////////////////////////////////////////////
578 /// Function :ReadStatisticalCounter
579 ///////////////////////////////////////////////////////////////////////
580 EFrameworkunifiedStatus LoggerServiceIf::ReadStatisticalCounter(
581     EStatCounterGroupID eCounterGroup) {
582   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
583
584   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
585
586   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
587          "Request to read the statistical counter for group ID:%X",
588          eCounterGroup);
589
590   if (NULL != m_hSession) {
591     if (eFrameworkunifiedStatusOK
592         != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER_READ_STATL_COUNTER,
593                                    sizeof(EStatCounterGroupID), &eCounterGroup))) {
594       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
595     }
596   } else {
597     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Session failed");
598   }
599   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
600   return l_eStatus;
601 }
602
603 ///////////////////////////////////////////////////////////////////////
604 /// Function :ReadStatisticalCounter
605 ///////////////////////////////////////////////////////////////////////
606 EFrameworkunifiedStatus LoggerServiceIf::ResetStatisticalCounter(
607     EStatCounterGroupID eCounterGroup) {
608
609   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
610
611   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
612
613   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
614          "Request to reset the statistical counter for group ID:%X",
615          eCounterGroup);
616
617   if (NULL != m_hSession) {
618     if (eFrameworkunifiedStatusOK
619         != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER_RESET_STATL_COUNTER,
620                                    sizeof(EStatCounterGroupID), &eCounterGroup))) {
621       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
622     }
623   } else {
624     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Session failed");
625   }
626   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
627   return l_eStatus;
628 }
629
630 ///////////////////////////////////////////////////////////////////////
631 /// Function LoggerServiceIf::StartDTCLoggingToEmmc
632 ///////////////////////////////////////////////////////////////////////
633 EFrameworkunifiedStatus LoggerServiceIf::StartDTCLoggingToEmmc(UI_32 f_dtc) {
634   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
635   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
636   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Request to start logging for DTC:0x%4X",
637          f_dtc);
638   l_eStatus = this->SendMessage(eSSLoggerCANProtocolIDDTCTrigger,
639                                 (UI_32) sizeof(f_dtc), &f_dtc);
640   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
641   return l_eStatus;
642 }
643
644 ///////////////////////////////////////////////////////////////////////
645 /// Function LoggerServiceIf::StartCANLogging
646 ///////////////////////////////////////////////////////////////////////
647 EFrameworkunifiedStatus LoggerServiceIf::StartCANLogging(void) {
648   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
649   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
650   FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Request to start CAN logging.");
651   l_eStatus = this->SendMessage(eSSLoggerCANProtocolIDCANTrigger, 0, NULL);
652   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
653   return l_eStatus;
654 }
655
656 ///////////////////////////////////////////////////////////////////////
657 /// Function LoggerServiceIf::RegisterLoggingStartNotification
658 ///////////////////////////////////////////////////////////////////////
659 EFrameworkunifiedStatus LoggerServiceIf::RegisterLoggingStartNotification(
660     CbFuncPtr f_pCallBackFn) {
661   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
662   EFrameworkunifiedStatus l_eStatus;
663
664   if (NULL == this->m_hApp) {
665     l_eStatus = eFrameworkunifiedStatusNullPointer;
666     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "(NULL == this->m_hApp)");
667   } else if (NULL == f_pCallBackFn) {
668     l_eStatus = eFrameworkunifiedStatusNullPointer;
669     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "(NULL == f_pCallBackFn)");
670   } else {
671     l_eStatus = FrameworkunifiedSubscribeToSessionEventWithCallback(this->m_hApp,
672                                                        eSSLoggerCANEventStart,
673                                                        f_pCallBackFn,
674                                                        this->m_hSession);
675     if (eFrameworkunifiedStatusOK != l_eStatus) {
676       FRAMEWORKUNIFIEDLOG(
677           ZONE_ERR,
678           __FUNCTION__,
679           "FrameworkunifiedSubscribeToSessionEventWithCallback(eSSLoggerCANEventStart) returned %X",
680           l_eStatus);
681     }
682   }
683
684   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
685   return (l_eStatus);
686 }
687
688 ///////////////////////////////////////////////////////////////////////
689 /// Function LoggerServiceIf::RegisterLoggingStartNotification
690 ///////////////////////////////////////////////////////////////////////
691 EFrameworkunifiedStatus LoggerServiceIf::RegisterLoggingFinishNotification(
692     CbFuncPtr f_pCallBackFn) {
693   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
694   EFrameworkunifiedStatus l_eStatus;
695
696   if (NULL == this->m_hApp) {
697     l_eStatus = eFrameworkunifiedStatusNullPointer;
698     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "(NULL == this->m_hApp)");
699   } else if (NULL == f_pCallBackFn) {
700     l_eStatus = eFrameworkunifiedStatusNullPointer;
701     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "(NULL == f_pCallBackFn)");
702   } else {
703     l_eStatus = FrameworkunifiedSubscribeToSessionEventWithCallback(
704         this->m_hApp, eSSLoggerCANEventFinished, f_pCallBackFn,
705         this->m_hSession);
706
707     if (eFrameworkunifiedStatusOK != l_eStatus) {
708       FRAMEWORKUNIFIEDLOG(
709           ZONE_ERR,
710           __FUNCTION__,
711           "FrameworkunifiedSubscribeToSessionEventWithCallback(eSSLoggerCANEventFinished) returned %X",
712           l_eStatus);
713     }
714   }
715
716   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
717   return (l_eStatus);
718 }
719
720 ///////////////////////////////////////////////////////////////////////
721 /// Function :SendMessage
722 ///////////////////////////////////////////////////////////////////////
723 EFrameworkunifiedStatus LoggerServiceIf::SendMessage(UI_32 f_cmdID, UI_32 f_size,
724                                         void* f_pData) {
725   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
726   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldHandle;
727
728   if ((NULL != m_hSession)
729       && ((f_pData != NULL) || (f_size == 0))) {  // LCOV_EXCL_BR_LINE 8:Because there is no case where f_pData is NULL and f_size is not 0
730     if (eFrameworkunifiedStatusOK
731         != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, f_cmdID, f_size, f_pData))) {
732       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed");
733     }
734   } else {
735     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Session failed");
736   }
737   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
738   return l_eStatus;
739 }
740
741 ///////////////////////////////////////////////////////////////////////
742 /// Function :LoggerIf_SetDiagID
743 ///////////////////////////////////////////////////////////////////////
744 EFrameworkunifiedStatus LoggerServiceIf::LoggerIf_SetDiagID(UI_16 f_u16DiagID) {
745   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
746   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
747
748   if (NULL != m_hSession) {
749     if (eFrameworkunifiedStatusOK
750         != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER_SET_DIAGID,
751                                    sizeof(UI_16), &f_u16DiagID))) {
752       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed %d", l_eStatus);
753     }
754   } else {
755     l_eStatus = eFrameworkunifiedStatusNullPointer;
756     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Session failed");
757   }
758   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
759   return l_eStatus;
760 }
761
762 ///////////////////////////////////////////////////////////////////////
763 /// Function :LoggerIf_UploadEventLog
764 ///////////////////////////////////////////////////////////////////////
765 EFrameworkunifiedStatus LoggerServiceIf::LoggerIf_UploadEventLog() {
766   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
767   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
768
769   if (NULL != m_hSession) {
770     if (eFrameworkunifiedStatusOK
771         != (l_eStatus = FrameworkunifiedSendMsg(m_hSession, SS_LOGGER_UPLOAD_EVENTLOG, 0x00,
772                                    NULL))) {
773       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendMsg Failed %d", l_eStatus);
774     }
775   } else {
776     l_eStatus = eFrameworkunifiedStatusNullPointer;
777     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Session failed");
778   }
779   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
780   return l_eStatus;
781 }  // LCOV_EXCL_BR_LINE 10:Because the last line