2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 ///////////////////////////////////////////////////////////////////////////////
18 /// \ingroup tag_SS_LoggerService
19 /// \brief This file supports error event logging.
21 ///////////////////////////////////////////////////////////////////////////////
22 #include "ss_logger_error_event.h"
24 #include <sys/types.h>
26 #include <boost/bind.hpp>
29 #include <native_service/frameworkunified_framework_if.h>
30 #include <system_service/ss_sm_client_if.h>
31 #include <system_service/ss_client_names.h>
32 #include <system_service/ss_logger_service_protocol.h>
33 #include <system_service/ss_logger_service.h>
34 #include <system_service/ss_services.h>
35 #include <system_service/ss_templates.h>
36 #include <stub/el_mem.h>
37 #include <native_service/cl_process.h>
38 #include <stub/Clock_API.h>
40 #include "loggerservicedebug_loggerservicelog.h"
41 #include "loggerservicedebug_thread_if.h"
42 #include "ss_logger_service_callbacks.h"
43 #include "ss_logger_error_event_archive.h"
44 #include "ss_logger_common.h"
45 #include "ss_logger_types.h"
46 #include "ss_logger_fs_directory.h"
48 CErrorEvent::CErrorEvent()
50 m_bIsPrevEventCompleted(true),
51 m_errorEventNtfData(),
53 m_pReaderWriterControl(NULL),
56 m_currentEventTriggerNumber(0),
57 m_diagsessionhandle(NULL),
58 m_thrdEvntLogWriter(NULL),
59 m_sfd(-1) { // LCOV_EXCL_BR_LINE 11:Unexpected branch
60 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
61 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
62 } // LCOV_EXCL_BR_LINE 11:Unexpected branch
64 CErrorEvent::~CErrorEvent() { // LCOV_EXCL_START 14:globle instance
65 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
66 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
67 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
71 EFrameworkunifiedStatus CErrorEvent::Initialize(HANDLE f_hApp, CLoggerCfg *f_pLoggerCfg,
72 CReaderWriterControl *f_pReaderWriterControl,
73 HANDLE f_thrdEvntLogWriter,
74 std::string f_strEvntLogQueWorkerName) {
75 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
76 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
79 m_sfd = CL_ProcessInit();
80 if (m_sfd == -1) { // LCOV_EXCL_BR_LINE 8:Because the process initialization is guaranteed to be successful
81 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
82 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. m_sfd CL_ProcessInit() failed \n."); // LCOV_EXCL_LINE 8:Because the process initialization is guaranteed to be successful
85 SS_LoggerServerEvents l_errorEventStateEvents[] = {
86 SS_LOGGER_SCREENCAPTURE_EVT };
88 FrameworkunifiedProtocolCallbackHandler l_smCallbacks[] = {
89 // Logging Protocol Callbacks
90 { SS_SM_EVENT_ERROR_TO_SSL, boost::bind(&CErrorEvent::OnStartLogging,
92 SS_SM_ERROR_EVENT_LOGGING_START_RSPN, boost::bind(
93 &CErrorEvent::OnLogStartResponse, this, _1) }, {
94 SS_SM_ERROR_EVENT_ARTIFACT_RSPN, boost::bind(
95 &CErrorEvent::OnArtifactResponse, this, _1) } }; // LCOV_EXCL_BR_LINE 11:Unexpected branch
97 FrameworkunifiedProtocolCallbackHandler l_selfCallbacks[] = {
98 // Logging Protocol Callbacks
99 { SS_LOGGER_ERROR_EVENT_ARTIFACT_REQ, boost::bind(
100 &CErrorEvent::OnArtifactRequest, this, _1) }, {
101 SS_SM_ERROR_EVENT_ARTIFACT_RSPN, boost::bind(
102 &CErrorEvent::OnArtifactResponse, this, _1) } }; // LCOV_EXCL_BR_LINE 11:Unexpected branch
104 FrameworkunifiedProtocolCallbackHandler l_requesterCallbacks[] = { {
105 SS_LOGGER_SCREENCAPTURE_EVT_ACK, boost::bind(
106 &CErrorEvent::OnObtainScreenShotResponse, this, _1) } }; // LCOV_EXCL_BR_LINE 11:Unexpected branch
108 FrameworkunifiedProtocolCallbackHandler l_storageThreadCallbacks[] = { {
109 eLoggerStorageThreadCmdOK, boost::bind(&CErrorEvent::OnStorageResponseOk,
111 eLoggerStorageThreadCmdWriteFailed, boost::bind(
112 &CErrorEvent::OnStorageResponseWriteFailed, this, _1) }, {
113 eLoggerStorageThreadCmdNotFound, boost::bind(
114 &CErrorEvent::OnStorageResponseNotFound, this, _1) }, {
115 eLoggerStorageThreadCmdNoWritten, boost::bind(
116 &CErrorEvent::OnStorageResponseNoWritten, this, _1) } }; // LCOV_EXCL_BR_LINE 11:Unexpected branch
117 for (UI_32 i = 0; i < _countof(l_requesterCallbacks); i++) {
118 m_requesterCallbacksVec.push_back(l_requesterCallbacks[i]); // LCOV_EXCL_BR_LINE 11:Unexpected branch
121 if (NULL == f_hApp) { // LCOV_EXCL_BR_LINE 6:As it is not always NULL
122 // LCOV_EXCL_START 6:As it is not always NULL
123 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
124 l_eStatus = eFrameworkunifiedStatusInvldHandle;
126 ZONE_ERR, __FUNCTION__,
127 " Error. Argument f_hApp passed NULL pointer. Initialization failed.");
129 } else if (NULL == (m_thrdEvntLogWriter = f_thrdEvntLogWriter)) { // LCOV_EXCL_BR_LINE 6:As it is not always NULL
130 // LCOV_EXCL_START 6:As it is not always NULL
131 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
132 l_eStatus = eFrameworkunifiedStatusInvldHandle;
134 ZONE_ERR, __FUNCTION__,
135 " Error. Argument f_hApp passed NULL pointer. Initialization failed.");
137 } else if (eFrameworkunifiedStatusOK != (l_eStatus = m_errorEventCfg.Initialize(f_pLoggerCfg))) { // LCOV_EXCL_BR_LINE 200:To ensure success
138 // LCOV_EXCL_START 200:To ensure success
139 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
140 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
141 " Error. m_errorEventCfg.Initialize() returned: %d.", l_eStatus);
143 } else if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(f_hApp, SERVICE_LOGGER, l_selfCallbacks, _countof(l_selfCallbacks)))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
144 // LCOV_EXCL_START 4:NSFW
145 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
149 " Error. FrameworkunifiedAttachCallbacksToDispatcher(SERVICE_SYSMANAGER) returned: %d.",
152 } else if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(f_hApp, SERVICE_SYSMANAGER, l_smCallbacks, _countof(l_smCallbacks)))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
153 // LCOV_EXCL_START 4:NSFW
154 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
158 " Error. FrameworkunifiedAttachCallbacksToDispatcher(SERVICE_SYSMANAGER) returned: %d.",
161 } else if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedDefineStateEvents(f_hApp, &l_errorEventStateEvents, static_cast<UI_32>(_countof(l_errorEventStateEvents))))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
162 // LCOV_EXCL_START 4:NSFW
163 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
167 " Error. FrameworkunifiedDefineStateEvents(SS_LOGGER_SCREENCAPTURE_EVT) returned: %d",
170 } else if (NULL == f_pLoggerCfg) { // LCOV_EXCL_BR_LINE 200:As it is not always NULL
171 // LCOV_EXCL_START 200:As it is not always NULL
172 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
173 l_eStatus = eFrameworkunifiedStatusNullPointer;
174 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. f_pLoggerCfg passed NULL pointer.");
176 } else if (eFrameworkunifiedStatusOK != (l_eStatus = m_loggerPopups.Initialize(f_pLoggerCfg))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
177 // LCOV_EXCL_START 200:To ensure success
178 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
179 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
180 " Error. m_loggerPopups.Initialize(f_pLoggerCfg) returned: %d.",
183 } else if (NULL == f_pReaderWriterControl) { // LCOV_EXCL_BR_LINE 200:As it is not always NULL
184 // LCOV_EXCL_START 200:As it is not always NULL
185 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
186 l_eStatus = eFrameworkunifiedStatusNullPointer;
187 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
188 " Error. Argument f_pReaderWriterControl passed NULL pointer.");
190 } else if (eFrameworkunifiedStatusOK != (l_eStatus = m_loggerStorage.Initialize(f_hApp, AppName, f_pLoggerCfg))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
191 // LCOV_EXCL_START 200:To ensure success
192 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
193 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
194 " Error. m_loggerPopups.Initialize(f_pLoggerCfg) returned: %d.",
197 } else if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher( f_hApp, ERROR_EVENT_STORAGE_QUEUE_NAME, l_storageThreadCallbacks, _countof(l_storageThreadCallbacks)))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
198 // LCOV_EXCL_START 4:NSFW
199 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
203 " Error. FrameworkunifiedAttachCallbacksToDispatcher(ERROR_EVENT_STORAGE_QUEUE_NAME) returned: %d.",
206 } else if (eFrameworkunifiedStatusOK != (l_eStatus = m_loggerCanEvent.Initialize(f_pLoggerCfg))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
207 // LCOV_EXCL_START 200:To ensure success
208 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
209 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
210 " Error. m_loggerCanEvent.Initialize() returned: %d.", l_eStatus);
214 m_pLoggerCfg = f_pLoggerCfg;
215 m_pReaderWriterControl = f_pReaderWriterControl;
216 l_eStatus = m_loggerUtil.Initialize(m_pLoggerCfg); // LCOV_EXCL_BR_LINE 11:Unexpected branch
217 LOG_STATUS_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 5:macro
218 "CLoggerUtil::m_loggerUtil.Initialize(m_pLoggerCfg)");
220 l_pTimer = &m_errorEventTimers[kSSL_ERROR_EVENT_TIMER_LOGGING_START_RSPN];
221 l_pTimer->Initialize(
222 f_hApp, SS_LOGGER_ERROR_EVENT_TIMER_ID_LOGGING_START_RSPN,
223 boost::bind(&CErrorEvent::OnLogStartResponseTimeout, this, _1)); // LCOV_EXCL_BR_LINE 11:Unexpected branch
225 l_pTimer = &m_errorEventTimers[kSSL_ERROR_EVENT_TIMER_ARTIFACT_RSPN];
226 l_pTimer->Initialize(
227 f_hApp, SS_LOGGER_ERROR_EVENT_TIMER_ID_ARTIFACT_RESPONSE,
228 boost::bind(&CErrorEvent::OnArtifactResponseTimeout, this, _1)); // LCOV_EXCL_BR_LINE 11:Unexpected branch
232 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
236 ///////////////////////////////////////////////////////////////////////////
237 // Function : RegisterSessionErrorEvent
238 // brief : Register session event. This function is called within the
239 // context of the System Manager session acknowledgment handler.
240 ///////////////////////////////////////////////////////////////////////////
241 EFrameworkunifiedStatus CErrorEvent::RegisterSessionErrorEvent(HANDLE f_hSession) {
242 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
243 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
245 l_eStatus = FrameworkunifiedRegisterEvent(f_hSession, SS_SM_EVENT_ERROR_TO_SSL);
246 LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedRegisterEvent(SS_SM_EVENT_ERROR_TO_SSL)"); // LCOV_EXCL_BR_LINE 5:macro
248 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
252 ///////////////////////////////////////////////////////////////////////////
253 // Function : OnOpenSession
254 // brief : Called when a requester opens a session with SS_Logger
255 // service. This function attaches error event callbacks
256 // to the dispatcher with the source set to the requester.
257 ///////////////////////////////////////////////////////////////////////////
258 EFrameworkunifiedStatus CErrorEvent::OnOpenSession(HANDLE f_hApp, PCSTR f_pRequesterName,
260 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
261 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
263 l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(f_hApp, f_pRequesterName,
264 &m_requesterCallbacksVec[0],
265 static_cast<UI_32>(m_requesterCallbacksVec.size()),
268 LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedAttachCallbacksToDispatcher(f_hSession)"); // LCOV_EXCL_BR_LINE 5:macro
270 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
274 ///////////////////////////////////////////////////////////////////////////
275 // Function : OnOpenSession
276 // brief : Called when a requester opens a session with SS_Logger
277 // service. This function attaches error event callbacks
278 // to the dispatcher with the source set to the requester.
279 ///////////////////////////////////////////////////////////////////////////
280 EFrameworkunifiedStatus CErrorEvent::OnCloseSession(HANDLE f_hApp, PCSTR f_pRequesterName,
282 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
283 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
284 UI_32 l_cmdIdArr[m_requesterCallbacksVec.size()]; // NOLINT (runtime/arrays)
286 for (UI_32 i = 0; i < m_requesterCallbacksVec.size(); i++) {
287 l_cmdIdArr[i] = m_requesterCallbacksVec[i].iCmd;
290 l_eStatus = FrameworkunifiedDetachCallbacksFromDispatcher(f_hApp, f_pRequesterName,
292 static_cast<UI_32>(m_requesterCallbacksVec.size()),
295 LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedAttachCallbacksToDispatcher()"); // LCOV_EXCL_BR_LINE 5:macro
297 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
301 ///////////////////////////////////////////////////////////////////////////
302 // Function : OnStartLogging
303 // brief : Called by SS_Logger and external services to begin logging
304 // artifact collection. This function sends a logging request
305 // to System Manager. See SS_SM_EVENT_ERROR_TO_SSL.
306 ///////////////////////////////////////////////////////////////////////////
307 EFrameworkunifiedStatus CErrorEvent::OnStartLogging(HANDLE f_hApp) {
308 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
309 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
310 SMErrorEventNtfData l_eventErrorNtfData;
312 INTERFACEUNIFIEDLOG_RECEIVED_FROM(f_hApp); // LCOV_EXCL_BR_LINE 5:macro
314 if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<SMErrorEventNtfData>(f_hApp, l_eventErrorNtfData))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
315 // when failed to ReadMsg, we can't know event-type for action, so nothing is able to do.
316 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
317 LOG_ERROR("ReadMsg()"); // LCOV_EXCL_LINE 200:To ensure success
319 if (TRUE == this->m_pLoggerCfg->IsLoggingEnabled()) { // LCOV_EXCL_BR_LINE 200:As it is always TRUE
320 if (TRUE == m_bIsPrevEventCompleted) {
321 TLoggerErrorEvent l_eventData = l_eventErrorNtfData;
323 if (IsNeedVerify(l_eventData.EventType)) {
324 // if need output log to external storage, check whether device is authenticated or not.
325 VerifyExtStorage(l_eventData);
329 Clock_getSystemTimeY2K38(&m_time, &status);
330 m_currentEventTriggerNumber = m_pLoggerCfg->GetUserInvokedCounter();
331 l_eStatus = m_loggerUtil.checkDestinationAvailable(l_eventData);
332 if (eFrameworkunifiedStatusOK == l_eStatus) {
333 m_bIsPrevEventCompleted = false; /* See timer start / timeout handler below. */
335 m_artifactResponseVec.clear();
337 m_errorEventNtfData = l_eventErrorNtfData; /* Overwrite m_eventErrorNtfData when logging complete. */
338 m_errorEventNtfData.EventBitMask = m_errorEventCfg
339 .GetEventsForErrorEvent(l_eventErrorNtfData.EventType);
340 l_eStatus = SendLogStartRequestToSystemManager(
341 m_errorEventNtfData.EventType);
342 LOG_STATUS_IF_ERRORED(l_eStatus,
343 "SendLogStartRequestToSystemManager()");
344 l_eStatus = m_loggerCanEvent.PublishStartEvent(f_hApp,
345 m_errorEventNtfData);
346 LOG_STATUS_IF_ERRORED(
348 "m_loggerCanEvent.PublishStartEvent(f_hApp,m_errorEventNtfData);");
351 m_errorEventTimers[kSSL_ERROR_EVENT_TIMER_LOGGING_START_RSPN]
352 .Start(m_loggingStartRspnToSec, 0, 0, 0);
353 if (FALSE == result) { // LCOV_EXCL_BR_LINE 200:As it is always TRUE
354 // LCOV_EXCL_START 200:As it is always TRUE
355 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
359 " Error. Failed to start timer kSSL_ERROR_EVENT_TIMER_LOGGING_START_RSPN.");
363 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
364 " Warning. Destination not available. ");
365 m_errorEventNtfData = l_eventErrorNtfData; /* Overwrite m_eventErrorNtfData when logging complete. */
366 m_errorEventNtfData.EventBitMask = m_errorEventCfg
367 .GetEventsForErrorEvent(l_eventErrorNtfData.EventType);
368 l_eStatus = OnStorageResponseNotFound(f_hApp);
369 LOG_STATUS_IF_ERRORED(l_eStatus, "OnStorageResponseNotFound(f_hApp)");
372 // Not-Need Resp to SM, because of keep logging sequance.
373 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
374 " Error. Logging already in progress. Event dropped.");
377 // LCOV_EXCL_START 200:As it is always TRUE
378 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
379 if (l_eventErrorNtfData.isNeedReboot == TRUE) {
380 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
381 "System will reboot soon, so stop logging function.");
382 StopLoggingFunction(f_hApp);
387 "Logging is disabled! Dropping Event. Sending Complete to SS_SystemManager");
388 l_eStatus = SendLogCompleteRequestToSystemManager(eFrameworkunifiedStatusFail);
389 LOG_STATUS_IF_ERRORED(l_eStatus,
390 "SendLogCompleteRequestToSystemManager()");
395 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
399 ///////////////////////////////////////////////////////////////////////////
400 // Function : OnLogStartResponse
401 // brief : Called by System Manager after the acknowledgment of the
402 // logging session start request. This function starts the
403 // artifact collection process. See
404 // SS_SM_ERROR_EVENT_LOGGING_START_RSPN.
405 ///////////////////////////////////////////////////////////////////////////
406 EFrameworkunifiedStatus CErrorEvent::OnLogStartResponse(HANDLE f_hApp) {
407 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
408 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
409 m_errorEventTimers[kSSL_ERROR_EVENT_TIMER_LOGGING_START_RSPN].Stop();
410 m_errorEventCfg.GetArtifactRequestVec(m_errorEventNtfData.EventType,
411 m_artifactRequestVec);
413 l_eStatus = RequestNextArtifact(f_hApp);
414 LOG_STATUS_IF_ERRORED(l_eStatus, "RequestNextArtifact()");
416 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
420 ///////////////////////////////////////////////////////////////////////////
421 // Function : OnLogStartResponseTimeout
422 // brief : Called when / if SM fails to respond to a logging start
423 // request and the logging star response timer expires.
424 ///////////////////////////////////////////////////////////////////////////
425 EFrameworkunifiedStatus CErrorEvent::OnLogStartResponseTimeout(HANDLE f_hApp) {
426 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
427 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
432 " Error. SM failed to respond to a logging start request in the required amount of time.");
434 m_bIsPrevEventCompleted = TRUE;
436 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
440 ///////////////////////////////////////////////////////////////////////////
441 // Function : RequestNextArtifact
442 // brief : This function requests the next artifact from the service
443 // that owns the artifact. If no artifacts remain, this
444 // function performs initiates artifact post processing.
445 ///////////////////////////////////////////////////////////////////////////
446 EFrameworkunifiedStatus CErrorEvent::RequestNextArtifact(HANDLE f_hApp) {
447 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
448 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
452 if (0 != m_artifactRequestVec.size()) {
453 TLoggingArtifact &l_nextArtifact = m_artifactRequestVec.back();
454 l_eStatus = m_loggerPopups.ShowStartPopup(
455 f_hApp, m_errorEventNtfData, &m_artifactRequestVec,
456 m_loggerUtil.getDestination(m_errorEventNtfData));
458 LOG_STATUS_IF_ERRORED(
460 "m_loggerPopups.ShowStartPopup(f_hApp,m_errorEventNtfData,&m_artifactRequestVec )");
463 "Requesting next artifact ID:%d from:%s, with timeout:%d ms.",
464 l_nextArtifact.ArtifactId,
465 l_nextArtifact.Information.OwnerServiceName.c_str(),
466 l_nextArtifact.Information.RequestTimeoutMs);
468 l_timeoutSec = l_nextArtifact.Information.RequestTimeoutMs / 1000;
469 l_timeoutMs = l_nextArtifact.Information.RequestTimeoutMs % 1000;
471 m_errorEventTimers[kSSL_ERROR_EVENT_TIMER_ARTIFACT_RSPN].Start(
472 l_timeoutSec, l_timeoutMs, 0, 0);
473 if (FALSE == result) { // LCOV_EXCL_BR_LINE 200:As it is always TRUE
474 // LCOV_EXCL_START 200:As it is always TRUE
475 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
476 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
477 "Failed to start timer kSSL_ERROR_EVENT_TIMER_ARTIFACT_RSPN.");
480 switch (l_nextArtifact.Information.Cb.Type) {
482 l_eStatus = CheckPathForArtifact(f_hApp, l_nextArtifact);
486 case eCbTypeFunction: {
487 if (l_nextArtifact.Information.Cb.Function == NULL) { // LCOV_EXCL_BR_LINE 200:As it is not always NULL
488 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
489 l_eStatus = eFrameworkunifiedStatusNullPointer; // LCOV_EXCL_LINE 200:As it is not always NULL
491 l_eStatus = l_nextArtifact.Information.Cb.Function(f_hApp,
493 LOG_STATUS_IF_ERRORED(
495 "l_nextArtifact.Information.Cb.Function(f_hApp, l_nextArtifact)");
506 " Error. Unknown artifact or artifact owner for artifact ID:"
507 " %d. Invalid logging artifact configuration likely.",
508 l_nextArtifact.ArtifactId);
513 if ((m_errorEventNtfData.EventType == eErrorEventTypeUserInvokedClearLogs)
514 || (m_errorEventNtfData.EventType
515 == eErrorEventTypeUserInvokedCollectNaviLog)) {
516 l_eStatus = this->OnStorageResponseOk(f_hApp);
520 Clock_getSystemTimeY2K38(&m_time, &status);
521 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
522 " Info. All logging error event artifacts have been collected.");
523 l_eStatus = m_loggerUtil.checkDestinationAvailable(m_errorEventNtfData);
524 LOG_STATUS_IF_ERRORED(
526 "m_loggerUtil.checkDestinationAvailable(m_errorEventNtfData)");
527 if (eFrameworkunifiedStatusOK == l_eStatus) {
528 /* Check one last time after all logs have been collected */
529 /* if we should show popup for archiving and writing to USB */
530 l_eStatus = m_loggerPopups.ShowStartPopup(
531 f_hApp, m_errorEventNtfData, &m_artifactRequestVec,
532 m_loggerUtil.getDestination(m_errorEventNtfData));
533 LOG_STATUS_IF_ERRORED(
535 "m_loggerPopups.ShowStartPopup(f_hApp,m_errorEventNtfData,&m_artifactRequestVec )");
537 l_eStatus = m_loggerUtil.getFilePathAndName(f_hApp, m_errorEventNtfData,
538 m_time, m_archiveDestination);
539 LOG_STATUS_IF_ERRORED(
541 "m_loggerUtil.getFilePathAndName()");
543 std::string destination_path = m_loggerUtil.getDestination(
544 m_errorEventNtfData);
545 if (destination_path.compare(m_pLoggerCfg->m_emmcOutputPath) == 0) {
546 if (eFrameworkunifiedStatusOK
547 != m_loggerUtil.deleteOldEmmcLog(m_archiveDestination,
548 m_errorEventNtfData.EventType)) {
549 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
550 " Error. m_loggerUtil.deleteOldEmmcLog()");
554 l_eStatus = this->m_loggerStorage.Start(m_archiveDestination,
555 this->m_artifactResponseVec,
557 LOG_STATUS_IF_ERRORED(
559 "m_loggerStorage.Start()");
560 if (l_eStatus != eFrameworkunifiedStatusOK) {
561 l_eStatus = this->OnStorageResponseWriteFailed(f_hApp);
562 LOG_STATUS_IF_ERRORED(l_eStatus,
563 "this->OnStorageResponseWriteFailed(f_hApp)");
566 l_eStatus = this->OnStorageResponseNotFound(f_hApp);
567 LOG_STATUS_IF_ERRORED(
569 "this->OnStorageResponseNotFound(f_hApp)");
573 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
577 ///////////////////////////////////////////////////////////////////////////
578 // Function : OnArtifactResponse
579 // brief : This function is called when an artifact has been made ready
580 // by the owning service.
581 ///////////////////////////////////////////////////////////////////////////
582 EFrameworkunifiedStatus CErrorEvent::OnArtifactResponse(HANDLE f_hApp) {
583 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
584 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
585 ARTIFACT_RESPONSE l_artifactResponse;
587 if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<ARTIFACT_RESPONSE>(f_hApp, l_artifactResponse))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
588 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
589 LOG_ERROR("ReadMsg()"); // LCOV_EXCL_LINE 200:To ensure success
591 m_errorEventTimers[kSSL_ERROR_EVENT_TIMER_ARTIFACT_RSPN].Stop();
593 // Prevent processing of artifacts that arrive after the error event logging session has completed.
594 if (m_artifactRequestVec.size() > 0) {
595 TEXT(__FUNCTION__, "Artifact ID:%d received.",
596 l_artifactResponse.ArtifactId);
598 TLoggingArtifact &l_artifactCurr = m_artifactRequestVec.back();
599 if (l_artifactCurr.ArtifactId != l_artifactResponse.ArtifactId) {
602 "Failure collecting current artifact. Expected artifact ID:%d, received artifact ID:%d."
603 " Ignoring received artifact.",
604 l_artifactCurr.ArtifactId, l_artifactResponse.ArtifactId);
606 TLoggingArtifactResponse l_response;
607 l_response.ArtifactId = l_artifactResponse.ArtifactId;
608 l_response.Filepath = l_artifactResponse.FilePathAndName;
609 l_response.Remove = l_artifactCurr.Information.Remove;
610 m_artifactResponseVec.push_back(l_response);
611 m_artifactRequestVec.pop_back(); // Remove received artifact from request vector.
612 l_eStatus = RequestNextArtifact(f_hApp);
613 LOG_STATUS_IF_ERRORED(l_eStatus, "RequestNextArtifact()");
619 " Error. Received spurious artifact ID: %d. No error event logging session active.",
620 l_artifactResponse.ArtifactId); // LCOV_EXCL_BR_LINE 5:macro
624 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
628 ///////////////////////////////////////////////////////////////////////////
629 // Function : OnArtifactResponseTimeout
630 // brief : This function is called when a requested artifact response
631 // fails to arrive in the required amount of time.
632 ///////////////////////////////////////////////////////////////////////////
633 EFrameworkunifiedStatus CErrorEvent::OnArtifactResponseTimeout(HANDLE f_hApp) {
634 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
635 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
637 if (m_artifactRequestVec.size() > 0) { // LCOV_EXCL_BR_LINE 200:As it cannot always be 0
638 TLoggingArtifact &l_artifactCurr = m_artifactRequestVec.back();
640 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
641 " Error. Artifact response timer expired for artifact ID: %d.",
642 l_artifactCurr.ArtifactId);
644 // Remove artifact from request vector.
645 m_artifactRequestVec.pop_back();
647 RequestNextArtifact(f_hApp);
650 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
654 ///////////////////////////////////////////////////////////////////////////
655 // Function : OnArtifactRequest
656 // brief : This function services an artifact request generated by
657 // the error event sub system. The requested artifact will
658 // be one of the artifacts owned by SSL.
659 ///////////////////////////////////////////////////////////////////////////
660 EFrameworkunifiedStatus CErrorEvent::OnArtifactRequest(HANDLE f_hApp) {
661 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
662 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
663 EArtifactId l_requestedArtifactId;
665 if (eFrameworkunifiedStatusOK
666 != (l_eStatus = ReadMsg<EArtifactId>(f_hApp, l_requestedArtifactId))) {
667 LOG_ERROR("ReadMsg()");
669 switch (l_requestedArtifactId) {
670 case eArtifactIdInterfaceunifiedDebugLog:
671 l_eStatus = OnObtainLoggerserviceLogRequest(f_hApp);
672 LOG_STATUS_IF_ERRORED(l_eStatus, "OnObtainLoggerserviceLogRequest()");
675 case eArtifactIdTransmitLog:
676 l_eStatus = OnObtainTransmitLogRequest(f_hApp);
677 LOG_STATUS_IF_ERRORED(l_eStatus, "OnObtainTransmitLogRequest()");
680 case eArtifactIdPerformanceLog:
681 l_eStatus = OnObtainPerformanceLogRequest(f_hApp);
682 LOG_STATUS_IF_ERRORED(l_eStatus, "OnObtainPerformanceLogRequest()");
685 case eArtifactIdScreenShot:
686 l_eStatus = OnObtainScreenShotRequest(f_hApp);
687 LOG_STATUS_IF_ERRORED(l_eStatus, "OnObtainScreenShotRequest()");
690 case eArtifactIdKernelLog:
691 l_eStatus = OnObtainKernelLogInfoRequest(f_hApp);
692 LOG_STATUS_IF_ERRORED(l_eStatus, "OnObtainKernelLogInfoRequest()");
695 case eArtifactIdDRInitialLog:
696 l_eStatus = OnObtainDRInitialLogRequest(f_hApp);
697 LOG_STATUS_IF_ERRORED(l_eStatus, "OnObtainDRInitialLogRequest()");
700 case eArtifactIdDRLocationLog:
701 l_eStatus = OnObtainDRLocationLogRequest(f_hApp);
702 LOG_STATUS_IF_ERRORED(l_eStatus, "OnObtainDRLocationLogRequest()");
705 case eArtifactIdClearAllLog:
706 l_eStatus = OnClearAllLogRequest(f_hApp);
707 LOG_STATUS_IF_ERRORED(l_eStatus, "OnClearAllLogRequest()");
710 case eArtifactIdNaviLog:
711 l_eStatus = OnNaviLogRequest(f_hApp);
712 LOG_STATUS_IF_ERRORED(l_eStatus, "OnNaviLogRequest()");
716 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
717 " Error. Unsupported logging artifact requested: %d.",
718 l_requestedArtifactId);
723 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
727 ///////////////////////////////////////////////////////////////////////////
728 // Function : OnStorageResponseOk
729 // brief : This function services response from the storage thread. It
730 // is called when the logs have been stored successfully.
731 ///////////////////////////////////////////////////////////////////////////
732 EFrameworkunifiedStatus CErrorEvent::OnStorageResponseOk(HANDLE f_hApp) {
733 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
734 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
736 l_eStatus = this->m_loggerPopups.ShowEndPopup(f_hApp, m_errorEventNtfData,
737 m_archiveDestination);
738 LOG_STATUS_IF_ERRORED(
740 "this->m_loggerPopups.ShowEndPopup(f_hApp,m_errorEventNtfData,m_archiveDestination)");
742 if (m_errorEventNtfData.EventType == eErrorEventTypeDiagEvent) {
743 l_eStatus = sendDiagEventResponse();
744 LOG_STATUS_IF_ERRORED(l_eStatus, "sendDiagEventResponse()");
746 if (m_errorEventNtfData.isNeedReboot == TRUE) {
747 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
748 "System will reboot soon, so stop logging function.");
749 StopLoggingFunction(f_hApp);
751 m_bIsPrevEventCompleted = true;
752 l_eStatus = SendLogCompleteRequestToSystemManager(eFrameworkunifiedStatusOK);
754 l_eStatus = m_loggerCanEvent.PublishEndEvent(f_hApp, m_errorEventNtfData,
755 m_currentEventTriggerNumber,
757 LOG_STATUS_IF_ERRORED(l_eStatus, "m_loggerCanEvent.PublishEndEvent();");
758 LOG_STATUS_IF_ERRORED(l_eStatus, "SendLogCompleteRequestToSystemManager()");
759 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
763 ///////////////////////////////////////////////////////////////////////////
764 // Function : OnStorageResponseWriteFailed
765 // brief : This function services response from the storage thread. It
766 // is called when the logs failed to be written to the target
768 ///////////////////////////////////////////////////////////////////////////
769 EFrameworkunifiedStatus CErrorEvent::OnStorageResponseWriteFailed(HANDLE f_hApp) {
770 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
771 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
772 l_eStatus = m_loggerPopups.ShowErrorPopup(f_hApp, m_errorEventNtfData,
773 (UI_16) eWriteToDeviceFailed);
774 LOG_STATUS_IF_ERRORED(
775 l_eStatus, "m_loggerPopups.ShowErrorPopup(f_hApp, eWriteToDeviceFailed)");
777 if (m_errorEventNtfData.EventType == eErrorEventTypeDiagEvent) {
778 sendDiagEventErrorResponse(eDEVICE_WRITE_ERROR);
780 if (m_errorEventNtfData.isNeedReboot == TRUE) {
781 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
782 "System will reboot soon, so stop logging function.");
783 StopLoggingFunction(f_hApp);
785 m_bIsPrevEventCompleted = true;
786 l_eStatus = SendLogCompleteRequestToSystemManager(eFrameworkunifiedStatusFail);
788 l_eStatus = m_loggerCanEvent.PublishErrorEvent(f_hApp, m_errorEventNtfData,
790 m_currentEventTriggerNumber,
792 LOG_STATUS_IF_ERRORED(l_eStatus, "m_loggerCanEvent.PublishErrorEvent();");
794 LOG_STATUS_IF_ERRORED(l_eStatus, "SendLogCompleteRequestToSystemManager()");
795 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
799 ///////////////////////////////////////////////////////////////////////////
800 // Function : OnStorageResponseNotFound
801 // brief : This function services response from the storage thread. It
802 // is called when the logs failed to be written to the target
803 // destination because the target was not found
804 ///////////////////////////////////////////////////////////////////////////
805 EFrameworkunifiedStatus CErrorEvent::OnStorageResponseNotFound(HANDLE f_hApp) {
806 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
807 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
808 l_eStatus = m_loggerPopups.ShowErrorPopup(f_hApp, m_errorEventNtfData,
809 (UI_16) eSelectedDeviceNotFound);
810 LOG_STATUS_IF_ERRORED(
812 "m_loggerPopups.ShowErrorPopup(f_hApp, eSelectedDeviceNotFound)");
814 if (m_errorEventNtfData.EventType == eErrorEventTypeDiagEvent) {
815 l_eStatus = sendDiagEventErrorResponse(eDEVICE_NOT_AVAILABLE);
816 LOG_STATUS_IF_ERRORED(l_eStatus, "sendDiagEventErrorResponse(eDEVICE_NOT_AVAILABLE)");
818 if (m_errorEventNtfData.isNeedReboot == TRUE) {
819 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
820 "System will reboot soon, so stop logging function.");
821 StopLoggingFunction(f_hApp);
823 m_bIsPrevEventCompleted = true;
824 l_eStatus = SendLogCompleteRequestToSystemManager(eFrameworkunifiedStatusFail);
826 l_eStatus = m_loggerCanEvent.PublishErrorEvent(f_hApp, m_errorEventNtfData,
828 m_currentEventTriggerNumber,
830 LOG_STATUS_IF_ERRORED(l_eStatus, "m_loggerCanEvent.PublishErrorEvent();");
832 LOG_STATUS_IF_ERRORED(l_eStatus, "SendLogCompleteRequestToSystemManager()");
833 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
837 ///////////////////////////////////////////////////////////////////////////
838 // Function : OnStorageResponseNoWritten
839 // brief : This function services response from the storage thread. It
840 // is called when no logs where found.
841 ///////////////////////////////////////////////////////////////////////////
842 EFrameworkunifiedStatus CErrorEvent::OnStorageResponseNoWritten(HANDLE f_hApp) {
843 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
844 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
846 l_eStatus = m_loggerPopups.ShowErrorPopup(f_hApp, m_errorEventNtfData,
847 (UI_16) eNoLogToStore);
848 LOG_STATUS_IF_ERRORED(l_eStatus,
849 "m_loggerPopups.ShowErrorPopup(f_hApp, eNoLogToStore)");
851 if (m_errorEventNtfData.EventType == eErrorEventTypeDiagEvent) {
852 l_eStatus = sendDiagEventErrorResponse(eNO_ERROR_INFO);
853 LOG_STATUS_IF_ERRORED(l_eStatus, "sendDiagEventErrorResponse(eNO_ERROR_INFO)");
855 if (m_errorEventNtfData.isNeedReboot == TRUE) {
856 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
857 "System will reboot soon, so stop logging function.");
858 StopLoggingFunction(f_hApp);
860 m_bIsPrevEventCompleted = true;
861 l_eStatus = SendLogCompleteRequestToSystemManager(eFrameworkunifiedStatusOK);
863 l_eStatus = m_loggerCanEvent.PublishErrorEvent(f_hApp, m_errorEventNtfData,
865 m_currentEventTriggerNumber,
867 LOG_STATUS_IF_ERRORED(l_eStatus, "m_loggerCanEvent.PublishErrorEvent();");
869 LOG_STATUS_IF_ERRORED(l_eStatus, "SendLogCompleteRequestToSystemManager()");
870 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
874 EFrameworkunifiedStatus CErrorEvent::sendDiagEventErrorResponse(EELL_ErrorCode f_errCode) {
875 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
876 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
877 if (this->m_ServiceName.length() > 0) {
878 l_eStatus = sendDiagEventErrorResponse(f_errCode, this->m_ServiceName);
879 this->m_ServiceName = "";
882 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
886 EFrameworkunifiedStatus CErrorEvent::sendDiagEventErrorResponse(EELL_ErrorCode f_errCode,
887 std::string f_destName) {
888 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
889 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
891 if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendMsg(m_diagsessionhandle, SS_LOGGERCOPYEMERGENCYLOGS_ERROR_RESP, sizeof(EELL_ErrorCode), &f_errCode))) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
892 // LCOV_EXCL_START 4: NSFW error case.
893 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
894 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
895 "SS_LOGGERCOPYEMERGENCYLOGS_ERROR_RESP Msg send failed = %x",
900 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
904 EFrameworkunifiedStatus CErrorEvent::sendDiagEventResponse(void) {
905 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
906 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
908 if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendMsg(m_diagsessionhandle, SS_LOGGERCOPYEMERGENCYLOGS_SUCCESS_RESP, 0, NULL))) {
909 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
910 "SS_LOGGERCOPYEMERGENCYLOGS_SUCCESS_RESP Msg send failed = %x",
916 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
920 EFrameworkunifiedStatus CErrorEvent::SetDiagEventSourceName(std::string f_serviceName) {
921 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
922 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
923 if ((f_serviceName.length() > 0)
924 && (this->m_ServiceName.length() == 0)) {
925 this->m_ServiceName = f_serviceName;
926 l_eStatus = eFrameworkunifiedStatusOK;
928 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
929 " Error. f_serviceName(%s), m_serviceName(%s)",
930 f_serviceName.c_str(), m_ServiceName.c_str());
933 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
937 void CErrorEvent::SetDiagSessionHandle(HANDLE f_sessionhandle) {
938 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
940 m_diagsessionhandle = f_sessionhandle;
942 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
945 void CErrorEvent::SetMileage(UI_32 f_mileage) {
946 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
947 this->m_loggerUtil.SetMilage(f_mileage);
948 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
951 // LCOV_EXCL_START 200:
952 EFrameworkunifiedStatus CErrorEvent::SaveNaviLog(EPWR_SHUTDOWN_TRIGGER_TYPE errType) {
953 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
954 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
955 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
956 UI_32 l_logMaxNum = 0;
957 std::string l_Filename = "";
961 Clock_getSystemTimeY2K38(&l_time, &status);
962 l_eStatus = m_loggerUtil.getEmmcNaviLogParams(l_time, errType, l_Filename,
965 if (eFrameworkunifiedStatusOK != l_eStatus) {
966 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
967 " Error: getEmmcNaviLogParams NaviLog update failed %d", l_eStatus);
969 if (l_logMaxNum == 0) {
970 /*OutputNaviLogNmlMax or OutputNaviLogErrMax = 0. */
974 " Warning: Not update NaviLog. OutputNaviLogNmlMax or OutputNaviLogErrMax = 0");
978 p = EL_mem_exram_mmap_simple(EL_MEM_ID_NAVI_LOG, PROT_READ | PROT_WRITE,
980 EL_MEM_CACHE_INVALID);
981 if (p == MAP_FAILED) {
982 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
983 "Error : EL_mem_exram_mmap_simple MAP_FAILD");
984 l_eStatus = eFrameworkunifiedStatusFail;
986 fp = fopen(l_Filename.c_str(), "wb");
988 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Could not open file %s",
990 l_eStatus = eFrameworkunifiedStatusAccessError;
992 fwrite(p, sizeof(unsigned char), EL_mem_getLength(EL_MEM_ID_NAVI_LOG),
996 if (0 != EL_mem_exram_munmap(p, EL_mem_getLength(EL_MEM_ID_NAVI_LOG))) {
997 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error : EL_mem_exram_munmap");
1003 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1008 EFrameworkunifiedStatus CErrorEvent::VerifyExtStorage(TLoggerErrorEvent event) {
1009 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1010 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
1013 f_path = m_pLoggerCfg->getUsb0MountPath();
1015 if (eFrameworkunifiedStatusOK == l_eStatus) {
1016 l_eStatus = eFrameworkunifiedStatusFail;
1018 if (eFrameworkunifiedStatusFail == l_eStatus) {
1020 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error : get secure log failed or timeout");
1024 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error : ticket verify timeout.");
1027 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1031 bool CErrorEvent::IsNeedVerify(EErrorEventType type) {
1034 case eErrorEventTypeUserInvokedCollectScreenShot:
1035 case eErrorEventTypeUserInvokedCollectAllLogs:
1036 case eErrorEventTypeUserInvokedCollectInterfaceunifiedLogs:
1037 case eErrorEventTypeInterfaceunifiedEmmcLogs:
1038 case eErrorEventTypeEelExport:
1039 case eErrorEventTypeDiagEvent:
1040 case eErrorEventTypeCanEvent: