summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorToshikazuOhiwa <toshikazu_ohiwa@mail.toyota.co.jp>2020-03-30 09:39:24 +0900
committerToshikazuOhiwa <toshikazu_ohiwa@mail.toyota.co.jp>2020-03-30 09:39:24 +0900
commit91f5345046f18f406071befd62e0e05322a5a1de (patch)
tree74fb8e365988ae7aef69711a053a50045977abbd
parent706ad73eb02caf8532deaf5d38995bd258725cb8 (diff)
ss-loggerservice branch
-rw-r--r--logger_service/LICENSE177
-rw-r--r--logger_service/Makefile.server19
-rw-r--r--logger_service/server/Makefile33
-rw-r--r--logger_service/server/SS_LoggerService.conf_bin4
-rw-r--r--logger_service/server/cfg/logrotate.conf7
-rw-r--r--logger_service/server/cfg/syslog.conf4
-rw-r--r--logger_service/server/include/loggerservicedebug_loggerservicelog.h81
-rw-r--r--logger_service/server/include/loggerservicedebug_thread_if.h319
-rw-r--r--logger_service/server/include/loggerservicedebug_writer_Evntworker.h211
-rw-r--r--logger_service/server/include/readerWriter/reader/mem_reader.h51
-rw-r--r--logger_service/server/include/readerWriter/reader/queue_reader.h49
-rw-r--r--logger_service/server/include/readerWriter/reader/reader.h52
-rw-r--r--logger_service/server/include/readerWriter/reader_writer.h77
-rw-r--r--logger_service/server/include/readerWriter/reader_writer_cfg.h35
-rw-r--r--logger_service/server/include/readerWriter/writer/cached_file_writer.h45
-rw-r--r--logger_service/server/include/readerWriter/writer/file_writer.h51
-rw-r--r--logger_service/server/include/readerWriter/writer/udp_file_writer.h54
-rw-r--r--logger_service/server/include/readerWriter/writer/udp_writer.h63
-rw-r--r--logger_service/server/include/readerWriter/writer/writer.h56
-rw-r--r--logger_service/server/include/ss_logger_cfg.h172
-rw-r--r--logger_service/server/include/ss_logger_common.h115
-rw-r--r--logger_service/server/include/ss_logger_device_detection.h66
-rw-r--r--logger_service/server/include/ss_logger_error_event.h156
-rw-r--r--logger_service/server/include/ss_logger_error_event_archive.h77
-rw-r--r--logger_service/server/include/ss_logger_error_event_can_evt_reply.h48
-rw-r--r--logger_service/server/include/ss_logger_error_event_cfg.h132
-rw-r--r--logger_service/server/include/ss_logger_error_event_storage.h82
-rw-r--r--logger_service/server/include/ss_logger_fs_directory.h108
-rw-r--r--logger_service/server/include/ss_logger_popups.h51
-rw-r--r--logger_service/server/include/ss_logger_reader_writer_control.h49
-rw-r--r--logger_service/server/include/ss_logger_scrshot.h30
-rw-r--r--logger_service/server/include/ss_logger_service_callbacks.h96
-rw-r--r--logger_service/server/include/ss_logger_types.h52
-rw-r--r--logger_service/server/include/ss_logger_util.h127
-rw-r--r--logger_service/server/lib/Makefile62
-rw-r--r--logger_service/server/lib/ss_logger_store_logs.cpp2270
-rw-r--r--logger_service/server/lib/ss_logger_store_logs_loggerservicelog.h96
-rw-r--r--logger_service/server/realtimeUsbLog/Makefile22
-rw-r--r--logger_service/server/realtimeUsbLog/realtimeUsbLog.conf_bin4
-rw-r--r--logger_service/server/realtimeUsbLog/src/Makefile77
-rw-r--r--logger_service/server/realtimeUsbLog/src/loggerservice_main.cpp103
-rw-r--r--logger_service/server/realtimeUsbLog/src/ss_logger_realtime_usb.cpp722
-rw-r--r--logger_service/server/realtimeUsbLog/work/Makefile23
-rw-r--r--logger_service/server/realtimeUsbLog/work_debug/Makefile19
-rw-r--r--logger_service/server/screenShot/Makefile53
-rw-r--r--logger_service/server/screenShot/ss_logger_scrshot.cpp89
-rw-r--r--logger_service/server/src/cached_file_writer.cpp79
-rw-r--r--logger_service/server/src/file_writer.cpp122
-rw-r--r--logger_service/server/src/loggerservice_application.cpp1161
-rw-r--r--logger_service/server/src/loggerservice_main.cpp59
-rw-r--r--logger_service/server/src/loggerservicedebug_child_thread.cpp134
-rw-r--r--logger_service/server/src/loggerservicedebug_writer_Evntworker.cpp1362
-rw-r--r--logger_service/server/src/mem_reader.cpp125
-rw-r--r--logger_service/server/src/mod_version.c49
-rw-r--r--logger_service/server/src/queue_reader.cpp101
-rw-r--r--logger_service/server/src/reader.cpp86
-rw-r--r--logger_service/server/src/reader_writer.cpp282
-rw-r--r--logger_service/server/src/ss_logger_cfg.cpp707
-rw-r--r--logger_service/server/src/ss_logger_device_detection.cpp209
-rw-r--r--logger_service/server/src/ss_logger_error_event.cpp1047
-rw-r--r--logger_service/server/src/ss_logger_error_event_archive.cpp413
-rw-r--r--logger_service/server/src/ss_logger_error_event_can_evt_reply.cpp147
-rw-r--r--logger_service/server/src/ss_logger_error_event_cfg.cpp348
-rw-r--r--logger_service/server/src/ss_logger_error_event_responses.cpp764
-rw-r--r--logger_service/server/src/ss_logger_error_event_storage.cpp628
-rw-r--r--logger_service/server/src/ss_logger_fs_directory.cpp236
-rw-r--r--logger_service/server/src/ss_logger_popups.cpp176
-rw-r--r--logger_service/server/src/ss_logger_reader_writer_control.cpp151
-rw-r--r--logger_service/server/src/ss_logger_server_callbacks.cpp900
-rw-r--r--logger_service/server/src/ss_logger_util.cpp1273
-rw-r--r--logger_service/server/src/testapps/fopen0
-rw-r--r--logger_service/server/src/testapps/testapps.log0
-rw-r--r--logger_service/server/src/testapps/testapps.tar.gz0
-rw-r--r--logger_service/server/src/udp_file_writer.cpp161
-rw-r--r--logger_service/server/src/udp_writer.cpp295
-rw-r--r--logger_service/server/src/writer.cpp86
-rw-r--r--logger_service/server/work/Makefile128
-rw-r--r--system_service.mk44
78 files changed, 17562 insertions, 0 deletions
diff --git a/logger_service/LICENSE b/logger_service/LICENSE
new file mode 100644
index 00000000..f433b1a5
--- /dev/null
+++ b/logger_service/LICENSE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/logger_service/Makefile.server b/logger_service/Makefile.server
new file mode 100644
index 00000000..66600f7a
--- /dev/null
+++ b/logger_service/Makefile.server
@@ -0,0 +1,19 @@
+#
+# @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+SUBDIRS := server
+
+include ../system_service.mk
diff --git a/logger_service/server/Makefile b/logger_service/server/Makefile
new file mode 100644
index 00000000..8c5c4871
--- /dev/null
+++ b/logger_service/server/Makefile
@@ -0,0 +1,33 @@
+#
+# @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+SUBDIRS += lib work
+
+SUBDIRS += realtimeUsbLog
+
+all:
+
+install-data:install_cfg
+
+install_cfg:
+ install -d -m 775 $(DESTDIR)/usr/agl/conf/syslogd
+ install -m 644 -t $(DESTDIR)/usr/agl/conf/syslogd cfg/syslog.conf
+ install -d -m 775 $(DESTDIR)/usr/agl/share/logrotate
+ install -m 644 -t $(DESTDIR)/usr/agl/share/logrotate cfg/logrotate.conf
+
+
+
+include ../../system_service.mk
diff --git a/logger_service/server/SS_LoggerService.conf_bin b/logger_service/server/SS_LoggerService.conf_bin
new file mode 100644
index 00000000..440d361f
--- /dev/null
+++ b/logger_service/server/SS_LoggerService.conf_bin
@@ -0,0 +1,4 @@
+/usr/agl/bin|${OSW_reldbg}
+debug|dbg
+release|rel
+product|rel
diff --git a/logger_service/server/cfg/logrotate.conf b/logger_service/server/cfg/logrotate.conf
new file mode 100644
index 00000000..b7daffc3
--- /dev/null
+++ b/logger_service/server/cfg/logrotate.conf
@@ -0,0 +1,7 @@
+# /etc/logrotate.conf - Configuration file for logrotate(8)
+/ramd/log/frameworkunifiedlog/syslog/syslog.log {
+maxsize 200K
+size 200K
+rotate 1
+create
+}
diff --git a/logger_service/server/cfg/syslog.conf b/logger_service/server/cfg/syslog.conf
new file mode 100644
index 00000000..097ebabf
--- /dev/null
+++ b/logger_service/server/cfg/syslog.conf
@@ -0,0 +1,4 @@
+# /etc/syslog.conf - Configuration file for syslogd(8)
+#selector action
+daemon,user,local0.* /ramd/log/frameworkunifiedlog/syslog/syslog.log
+
diff --git a/logger_service/server/include/loggerservicedebug_loggerservicelog.h b/logger_service/server/include/loggerservicedebug_loggerservicelog.h
new file mode 100644
index 00000000..1564fb5d
--- /dev/null
+++ b/logger_service/server/include/loggerservicedebug_loggerservicelog.h
@@ -0,0 +1,81 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_LogTraceSender
+/// \brief This file supports AGL application logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_LOGGERSERVICEDEBUG_LOGGERSERVICELOG_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_LOGGERSERVICEDEBUG_LOGGERSERVICELOG_H_
+#include <native_service/ns_logger_if.h>
+
+#define ZONE_INIT ZONEMASK(10)
+#define ZONE_FUNC ZONEMASK(11)
+#define ZONE_MEM ZONEMASK(12)
+#define ZONE_13 ZONEMASK(13)
+#define ZONE_14 ZONEMASK(14)
+#define ZONE_15 ZONEMASK(15)
+#define ZONE_16 ZONEMASK(16)
+#define ZONE_17 ZONEMASK(17)
+#define ZONE_18 ZONEMASK(18)
+#define ZONE_19 ZONEMASK(19)
+#define ZONE_20 ZONEMASK(20)
+#define ZONE_21 ZONEMASK(21)
+#define ZONE_22 ZONEMASK(22)
+#define ZONE_23 ZONEMASK(23)
+#define ZONE_24 ZONEMASK(24)
+#define ZONE_25 ZONEMASK(25)
+#define ZONE_PRD_INFO3 ZONEMASK(26)
+#define ZONE_PRD_INFO2 ZONEMASK(27)
+#define ZONE_PRD_INFO1 ZONEMASK(28)
+#define ZONE_INFO ZONEMASK(29)
+#define ZONE_WARN ZONEMASK(30)
+#define ZONE_ERR ZONEMASK(31)
+
+#define ZONE_TEXT_10 "Init"
+#define ZONE_TEXT_11 "Function"
+#define ZONE_TEXT_12 "Memory"
+#define ZONE_TEXT_13 ""
+#define ZONE_TEXT_14 ""
+#define ZONE_TEXT_15 ""
+#define ZONE_TEXT_16 ""
+#define ZONE_TEXT_17 ""
+#define ZONE_TEXT_18 ""
+#define ZONE_TEXT_19 ""
+#define ZONE_TEXT_20 ""
+#define ZONE_TEXT_21 ""
+#define ZONE_TEXT_22 ""
+#define ZONE_TEXT_23 ""
+#define ZONE_TEXT_24 ""
+#define ZONE_TEXT_25 ""
+#define ZONE_TEXT_26 "Product Info3"
+#define ZONE_TEXT_27 "Product Info2"
+#define ZONE_TEXT_28 "Product Info1"
+#define ZONE_TEXT_29 "Info"
+#define ZONE_TEXT_30 "Warning"
+#define ZONE_TEXT_31 "Error"
+
+#ifndef FRAMEWORKUNIFIEDLOGOPTIONS
+#define FRAMEWORKUNIFIEDLOGOPTIONS(LMSGQ) // LPRINT , LMSGQ, LSLOGGER
+#endif
+
+#ifndef FRAMEWORKUNIFIEDLOGAPPZONES
+#define FRAMEWORKUNIFIEDLOGAPPZONES ZONE_INFO, ZONE_FUNC, ZONE_ERR, ZONE_WARN, ZONE_PRD_INFO1, ZONE_PRD_INFO2, ZONE_PRD_INFO3
+#endif
+
+extern const CHAR AppName[];
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_LOGGERSERVICEDEBUG_LOGGERSERVICELOG_H_
diff --git a/logger_service/server/include/loggerservicedebug_thread_if.h b/logger_service/server/include/loggerservicedebug_thread_if.h
new file mode 100644
index 00000000..8203a68f
--- /dev/null
+++ b/logger_service/server/include/loggerservicedebug_thread_if.h
@@ -0,0 +1,319 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_LogTraceSender
+/// \brief This file supports the logging thread interface.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_LOGGERSERVICEDEBUG_THREAD_IF_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_LOGGERSERVICEDEBUG_THREAD_IF_H_
+
+#include <pthread.h>
+#ifdef AGL_STUB
+#else
+#include <sys/neutrino.h>
+#include <sys/dispatch.h>
+#endif
+#include <errno.h>
+#include <sched.h>
+#include <stdio.h>
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_thread_priority.h>
+#include <system_service/ss_logger_service.h>
+#include <system_service/ss_logger_service_local.h>
+#include <string>
+#include "loggerservicedebug_loggerservicelog.h"
+
+typedef std::string ThreadName; //< service name
+
+typedef enum _EThreadCommandIds {
+ eThrdCmdUsbEject = 5463, ///< USB eject --> frameworkunifieddebug
+ eThrdCmdUsbCaptureLogs, ///< USB Capture log --> frameworkunifieddebug
+ eThrdCmdUsbStoreLogs, ///< USB Store log --> frameworkunifieddebug
+ eThrdCmdWriteFilesToUsb, ///< frameworkunifieddebug --> Writer
+ eThrdCmdWriteDataToFile, ///< Reader --> Writer
+ eThrdCmdWriterStop, ///< frameworkunifieddebug --> Writer (Stop writing to the file)
+ eThrdCmdWriterResume, ///< frameworkunifieddebug --> Writer (Continue writing to the file)
+ eThrdCmdCaptureLogScriptExit, ///< LogCaptureScript - > frameworkunifieddebug
+ eThrdCmdWriteEvntFilesToUsb, ///< Wreite Event files to USB
+ eThrdCmdcopytofile,
+ eThrdCmdClearEvntLogs, ///< Clear event logs
+ eThrdCmdStatisticalCounter, ///< Read statistical counter
+ eThrdCmdStatisticalCounterSuccessResp, ///< Statistical counter positiv Response from child thread
+ eThrdCmdStatisticalCounterErrorResp, ///< Statistical counter Negative Response from child thread
+ eThrdCmdResetStatisticalCntrs,
+ eThrdCmdCopyEventLogUSBResponse, ///< Copy event logs to usb response from child thread
+ eThrdCmdClearEventLogResponse, ///< Clear event logs response fromchild thread
+ eThrdCmdPersistLogs, ///< Statistical counter Response fromchild thread
+ eThrdCmdSetVINnumber,
+ eThrdCmdImmPersistEvtLog,
+ eThrdCmdMileageData,
+ eThrdCmdGetNumberOfEventsLogged,
+ eThrdCmdNumberOfEventsLoggedResponse,
+ eThrdCmdUploadEventLog,
+ eThrdCmdUploadEventLogResponse,
+ eThrdCmdCopyEvntLogToTmp,
+ eThrdCmdCopyEvntLogToTmpResponse
+} EThreadCommandIds;
+
+typedef struct _TThrdWriteDataToFileEvt {
+ static const UI_32 LN_LEN = 1024;
+ CHAR line[LN_LEN];
+ UI_32 length;
+} TThrdWriteLogDataToFileEvt, TThrdWriteTransmitDataToFileEvt;
+
+typedef struct _TThrdWriteFilesToUsbEvt {
+ static const UI_32 LOC_PATH_LEN = 256;
+ CHAR location[LOC_PATH_LEN]; ///< full path where files should be copied too
+ UI_32 loc_len;
+} TThrdWriteLogFilesToUsbEvt, TThrdWriteTransmitFilesToUsbEvt;
+
+typedef struct _TThrdCaptureLogsEvt {
+ static const UI_32 FN_LEN = 256;
+ CHAR location[FN_LEN];
+ CHAR parse_fn[FN_LEN]; ///< full path an name of the file that should be parsed for event actions.
+} TThrdCaptureLogsEvt;
+
+// Structure to hold the USB device informaton
+typedef struct _TThrdEvtLogStore {
+ BOOL IsDeviceAvailable;
+ static const UI_32 FN_LEN = 256;
+ CHAR location[FN_LEN];
+ CHAR parse_fn[FN_LEN]; ///< full path an name of the file that should be parsed for event actions.
+} TThrdEvtLogStore;
+
+typedef struct _TInitFlag {
+ UI_8 mileage_flagbit :1;
+ UI_8 statcounter_flagbit :1;
+ UI_8 eventlog_flagbit :1;
+ UI_8 reghandlers_flagbit :1;
+} TInitFlag;
+
+typedef struct _TSessionData {
+ std::string strSrcName;
+ UI_32 session_id;
+} TSessionData;
+
+typedef struct _TEvntNumber {
+ TSessionData stSessiondata;
+ UI_16 u16numberofeventslogged;
+} TEvntsLogged;
+
+typedef struct _TWriteFilesToUsbCmdData {
+ TSessionData stSessiondata;
+ EEvtLogUSBDevNumber eDevId;
+} TWriteFilesToUsbCmdData;
+
+typedef struct _TWriteFilesToUsbCmdResponse {
+ TSessionData stSessiondata;
+ UI_8 u8Response;
+} TWriteFilesToUsbCmdResponse;
+
+typedef struct _TClearEvntLogCmdResponse {
+ TSessionData stSessiondata;
+ UI_8 u8Response;
+} TClearEvntLogCmdResponse;
+
+typedef struct _TStatisticalCountersCmd {
+ TSessionData stSessiondata;
+ EStatCounterGroupID eGroupId;
+} TStatisticalCountersCmd;
+
+typedef struct _TStatisticalCntCmdSuccessResp {
+ TSessionData stSessiondata;
+ SStatisticalCounter stBuffer;
+} TStatisticalCntCmdSuccessResp;
+
+typedef struct _TUploadEventLogResp {
+ TSessionData stSessiondata;
+ STEventLogPersistBuffer stEventLogBuffer;
+} TUploadEventLogResp;
+
+typedef struct _TEventLogCopyStatus {
+ static const UI_8 FilePathSize = 64;
+ CHAR EventLogFilePath[FilePathSize];
+ UI_8 status;
+} TEventLogCopyStatus;
+
+typedef enum _ECaptureLogScriptResp {
+ ekCLSStatusCompleteSuccessful,
+ ekCLSStatusInitError,
+ ekCLSStatusExecuteError,
+ ekCLSStatusCopyError,
+ ekCLSStatusChmodError,
+} ECaptureLogScriptResp;
+
+class ThreadWrapper {
+ public:
+
+ ThreadWrapper(const char* t_name, void* (*routine)(void*), void* arg) { // LCOV_EXCL_START 8:ThreadWrapper class is never used
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ pthread_attr_t attr;
+ struct sched_param params;
+
+ if (EOK != pthread_attr_init(&attr)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: pthread_attr_init failed errno: %d", errno);
+ }
+ if (EOK != pthread_attr_getschedparam(&attr, &params)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: pthread_attr_getschedparam failed errno: %d", errno);
+ }
+ SI_32 prio = frameworkunified::framework::CFrameworkunifiedThreadPriorities::GetPriority(
+ std::string(t_name));
+ if (-1 != prio) {
+ params.sched_priority = prio;
+ if (EOK != pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: pthread_attr_setinheritsched failed errno: %d", errno);
+ }
+ if (EOK != pthread_attr_setschedparam(&attr, &params)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: pthread_attr_setschedparam failed errno: %d", errno);
+ }
+ }
+
+ if (EOK != pthread_create(&m_thread, &attr, routine, arg)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: pthread_create failed errno: %d",
+ errno);
+ }
+ }
+ // LCOV_EXCL_STOP
+
+
+ ~ThreadWrapper() { // LCOV_EXCL_START 8:ThreadWrapper class is never used
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+// todo: Need a clean way to cleanup thread in case class closes
+ }
+ // LCOV_EXCL_STOP
+
+
+ operator pthread_t() const { // LCOV_EXCL_START 8:ThreadWrapper class is never used
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return m_thread;
+ }
+ // LCOV_EXCL_STOP
+
+ private:
+ pthread_t m_thread;
+};
+
+
+class CChild {
+ public:
+ CChild(const char* parentsName, const char * sendDataToQue,
+ const char * clientsName, void* (*routine)(void*),
+ const char * sendToUdpQue = "")
+ : m_clientName(clientsName),
+ m_parentName(parentsName),
+ m_sendDataToQueuName(sendDataToQue),
+ m_sendDataToUdpQueName(sendToUdpQue),
+ m_barInit(InitBarrier()),
+ m_thread(clientsName, routine, reinterpret_cast<void*>(this)) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ }
+ // LCOV_EXCL_STOP
+
+ void Join() { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (EOK != pthread_join(m_thread, NULL)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: pthread_join failed errno: %d",
+ errno);
+ }
+ }
+ // LCOV_EXCL_STOP
+
+ const char * ParentName() { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return m_parentName.c_str();
+ }
+ // LCOV_EXCL_STOP
+
+ const char * ClientName() { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return m_clientName.c_str();
+ }
+ // LCOV_EXCL_STOP
+
+ const char * SendDataToQue() { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return m_sendDataToQueuName.c_str();
+ }
+ // LCOV_EXCL_STOP
+
+ const char * SendDataToUdpQueue() { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return m_sendDataToUdpQueName.c_str();
+ }
+ // LCOV_EXCL_STOP
+
+ bool IsValidWaitBarrier() { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (m_barInit) {
+ int wbret = pthread_barrier_wait(&m_barrier);
+ return ( PTHREAD_BARRIER_SERIAL_THREAD == wbret) || (0 == wbret);
+ }
+
+ return false;
+ }
+ // LCOV_EXCL_STOP
+
+ private:
+ bool InitBarrier() { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ /// Note: the count value should match the number of threads that are readers and usb notifiers
+ return (EOK == pthread_barrier_init(&m_barrier, NULL, 2) ? true : false);
+ }
+ // LCOV_EXCL_STOP
+
+ private:
+ ThreadName m_clientName;
+ ThreadName m_parentName;
+ ThreadName m_sendDataToQueuName;
+ ThreadName m_sendDataToUdpQueName;
+ bool m_barInit;
+ ThreadWrapper m_thread;
+ pthread_barrier_t m_barrier;
+};
+
+class LoggerserviceDebugChildThread {
+ public:
+ typedef enum e {
+ kLoggerserviceDebugLogQueReader,
+ kLoggerserviceDebugTransmitQueReader,
+ kLoggerservicePerformanceLogQueReader,
+ kLoggerserviceDebugCaptureLogScript,
+ kLoggerserviceDebugEventLogque,
+ kLoggerserviceDebugMax
+ } ELoggerserviceDebugThreads;
+
+ LoggerserviceDebugChildThread();
+ virtual ~LoggerserviceDebugChildThread();
+ BOOL Start(ELoggerserviceDebugThreads id, const char* parentsName,
+ const char * sendDataToQue, void* (*routine)(void*),
+ const char * sendToUdpQue = "");
+ void Stop(ELoggerserviceDebugThreads id);
+ void StopAll();
+ const char * Name(ELoggerserviceDebugThreads id);
+ void LiftWaitBarrier(ELoggerserviceDebugThreads id);
+ BOOL Running(ELoggerserviceDebugThreads id) const;
+ private:
+ ThreadName names[kLoggerserviceDebugMax];
+ CChild * threads[kLoggerserviceDebugMax];
+};
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_LOGGERSERVICEDEBUG_THREAD_IF_H_
diff --git a/logger_service/server/include/loggerservicedebug_writer_Evntworker.h b/logger_service/server/include/loggerservicedebug_writer_Evntworker.h
new file mode 100644
index 00000000..70dc1bea
--- /dev/null
+++ b/logger_service/server/include/loggerservicedebug_writer_Evntworker.h
@@ -0,0 +1,211 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_LogTraceSender
+/// \brief frameworkunifieddebug writer thread class, handles writing a log file
+/// all really done by my_writer class.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_LOGGERSERVICEDEBUG_WRITER_EVNTWORKER_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_LOGGERSERVICEDEBUG_WRITER_EVNTWORKER_H_
+
+#include <stdlib.h>
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_multithreading.h>
+#include <system_service/ss_devicedetection_service_ifc.h>
+#include <native_service/ns_logger_if.h>
+#include <native_service/ns_eventlogger.h>
+#include <map>
+#include <iostream>
+#include <deque>
+#include "loggerservicedebug_thread_if.h"
+
+
+// File path names for Evnet and counter logs
+extern const CHAR DEBUG_EVNTLOG_PATH_FN[];
+extern const CHAR g_strEvntLogQueWorkerName[];
+extern const CHAR DEBUG_LOG_PATH_FN[];
+extern const CHAR Counter_LOG_PATH_FN[];
+extern const CHAR Counter_LOG_PATH_STARTFN[];
+extern const CHAR Counter_LOG_PATH_SHUTFN[];
+extern const CHAR Mileage_LOG_PATH_FN[];
+
+typedef struct _TevntWriterInfo {
+ static const UI_32 FN_LEN = 256;
+ UI_32 max_filelen;
+ CHAR base_cnt_filename[FN_LEN];
+ CHAR mileage_filename[FN_LEN];
+} TEvntWriterInfo;
+
+typedef enum _eDatatype_ {
+ COMMON_DATA,
+ EVENT_SPECIFIC_DATA
+} EDatatype_SS;
+
+typedef enum _eSystemPhase_ {
+ STARTUP_SS = 0x21,
+ NORMAL_SS = 0x22,
+ SHUTDOWN_SS = 0x23
+} ESystemPhase_SS;
+
+#pragma pack(1)
+typedef struct _stLogEventFull_ {
+ UI_32 ts;
+ UI_8 grp_ID;
+ UI_8 event_id;
+ UI_8 data[4];
+ ESystemPhase_SS phase;
+ UI_16 cnt_ID;
+ EDatatype_SS typeofdata;
+} st_LogEvent_full;
+#pragma pack(0)
+
+// Deque to hold the Event information
+typedef std::deque<st_LogEvent_ss> DEQUE_Event_Type;
+
+// Map to hold the Counter information on phase
+typedef std::map<UI_16, UI_32> Counter;
+
+/*Map to hold the all the counter information */
+typedef std::map<EStatCounterGroupID, Counter> CounterInformation;
+
+class CEvntWriterWorker {
+ public:
+ CEvntWriterWorker();
+ CEvntWriterWorker(TEvntWriterInfo & wi); // NOLINT (runtime/references)
+ virtual ~CEvntWriterWorker();
+ // initialize the object
+ EFrameworkunifiedStatus Initialize(HANDLE hThread);
+
+ /// Copy event logs to USB request from parent thread
+ EFrameworkunifiedStatus OnCmdWriteEventFilesToUsb(HANDLE hThread);
+
+ /// Event logging request from NS logger
+ EFrameworkunifiedStatus OnCmdEventLog(UI_8* pbuf);
+
+ /// Clear event logs request from parent thread
+ EFrameworkunifiedStatus OnCmdClearEventLogs(HANDLE hThread);
+
+ /// Read statistical counter request from parent thread
+ EFrameworkunifiedStatus OnCmdReadStatisticalCounter(HANDLE hThread);
+
+ /// Read statistical counter based on counter group ID
+ EFrameworkunifiedStatus ReadStatisticalCounter(EStatCounterGroupID eStatCounterGroupID,
+ SStatisticalCounter& buffer); // NOLINT (runtime/references)
+
+ /// Reset statistical counter request from parent thread
+ EFrameworkunifiedStatus OnCmdResetStatisticalCounter(HANDLE hThread);
+
+ /// Reset statistical counter based on counter group ID
+ EFrameworkunifiedStatus ResetStatisticalCounter(EStatCounterGroupID eStatCounterGroupID);
+
+ EFrameworkunifiedStatus OnCmdStop(HANDLE hThread);
+
+ EFrameworkunifiedStatus OnCmdStart(HANDLE hThread);
+
+ /// Counter logging request from NS logger
+ EFrameworkunifiedStatus OnCmdIncrcount(UI_8* pbuf);
+
+ /// Event and Counter logging request from NS logger
+ EFrameworkunifiedStatus OnCmdIncrwriteevent(UI_8* pbuf);
+
+ /// Reading counter value from file based on phase
+ EFrameworkunifiedStatus readCountFromFile(PCSTR filename);
+
+ /// Writing counter value from file based on phase
+ EFrameworkunifiedStatus writeCountToFile(PCSTR filename);
+
+ /// Writing event value from file based on phase
+ EFrameworkunifiedStatus write_event_to_file(const CHAR* filename);
+
+ /// Copy event files to USB based onUSB device number
+ UI_8 copy_event_files_to_usb(TThrdEvtLogStore *pStUSBIndo);
+
+ /// Functioncall to populate the counter value to map
+ VOID OnCmdIncrcount_phase(st_LogCount *cnt);
+
+ /// Function call to populate the event value to deque
+ VOID OnCmdWriteEventLogs(st_LogEvent_ss *ev);
+
+ /// Set the VIN number
+ EFrameworkunifiedStatus OnCmdSetVIN(HANDLE hThread);
+
+ /// Get the VIN number
+ VOID OnCmdGetVIN(STVIN_NUMBER& f_stVIN_Number); // NOLINT (runtime/references)
+
+ /// Functional call to write events from deque to local buffer
+ VOID write_events_to_buffer(STEventLogPersistBuffer* f_stEvtLogBuf);
+
+ /// Functional call to read events from buffer to deque
+ VOID read_events_from_buffer(STEventLogPersistBuffer* f_stEvtLogBuf);
+
+ /// Functional call to immediate persist event log
+ EFrameworkunifiedStatus immediate_persist_event_log(HANDLE hThread);
+
+ /// Functional call to set mileage information in Evt thread space
+ EFrameworkunifiedStatus EvtThd_SetMileage(HANDLE hThread);
+
+ /// Functional call to write mileage data to file for persisting
+ EFrameworkunifiedStatus write_mileage_to_file(const CHAR* filename);
+
+ /// Functional call to read mileage data from persistent file during startup
+ EFrameworkunifiedStatus read_mileage_from_file(const CHAR* filename);
+
+ EFrameworkunifiedStatus OnCmdReadNumberOfEventsLogged(HANDLE hThread);
+
+ EFrameworkunifiedStatus EventLogRegisterCbHandlers(HANDLE hThread);
+
+ EFrameworkunifiedStatus OnCmdUploadEventLog(HANDLE hThread);
+
+ EFrameworkunifiedStatus OnCmdCopyEvntLogToTmp(HANDLE hThread);
+ /// Static Members for Event and counter logging
+ static CounterInformation counter;
+ static DEQUE_Event_Type deque_event_info;
+
+ private:
+ STVIN_NUMBER m_stVINnumber;
+ UI_32 m_u32MileageData;
+ UI_32 m_u32NumberEventsLogged;
+ TUploadEventLogResp m_stUploadEventLogResp;
+ EFrameworkunifiedStatus counterIncrementByValue(EStatCounterGroupID group, UI_16 id,
+ UI_32 value);
+ EFrameworkunifiedStatus writeGroupToFile(FILE *fp, EStatCounterGroupID group);
+};
+
+/// Event logging Child thread start and shut down functions
+EFrameworkunifiedStatus EvntWriterWorkerOnStart(HANDLE hThread);
+EFrameworkunifiedStatus EvntWriterWorkerOnStop(HANDLE hThread);
+
+/// USBdevice detectioncall backs
+EFrameworkunifiedStatus DD_USBSrvDetectionCallBack(HANDLE hApp);
+EFrameworkunifiedStatus DD_USBServiceAvailabilityCallBack(HANDLE hThread);
+EFrameworkunifiedStatus DD_USBOpenSessionAckCallBack(HANDLE hThread);
+EFrameworkunifiedStatus DD_USBCloseSessionAckCallBack(HANDLE hApp);
+
+inline void u16copy(PUI_8 pDest, UI_16 Source) {
+ *(pDest++) = (UI_8) (Source & 0x00FF);
+ *(pDest++) = (UI_8) ((Source & 0xFF00) >> 8);
+}
+inline void u32copy(PUI_8 pDest, UI_32 Source) {
+ *(pDest++) = (UI_8) (Source & 0x000000FF);
+ *(pDest++) = (UI_8) ((Source & 0x0000FF00) >> 8);
+ *(pDest++) = (UI_8) ((Source & 0x00FF0000) >> 16);
+ *(pDest++) = (UI_8) ((Source & 0xFF000000) >> 24);
+}
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_LOGGERSERVICEDEBUG_WRITER_EVNTWORKER_H_
diff --git a/logger_service/server/include/readerWriter/reader/mem_reader.h b/logger_service/server/include/readerWriter/reader/mem_reader.h
new file mode 100644
index 00000000..4d37242d
--- /dev/null
+++ b/logger_service/server/include/readerWriter/reader/mem_reader.h
@@ -0,0 +1,51 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * mem_reader.h
+ *
+ * Created on: Oct 22, 2013
+ */
+
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_MEM_READER_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_MEM_READER_H_
+
+#include <native_service/ns_sharedmem.h>
+#include <native_service/ns_sharedmem_reader.h>
+#include <string>
+#include "reader.h"
+
+namespace ReaderWriter {
+class CMemReader : public ReaderWriter::CReader {
+ public:
+ CMemReader();
+ virtual ~CMemReader();
+ EFrameworkunifiedStatus Initialize(CLoggerCfg* f_pLoggerCfg, std::string f_name,
+ UI_32 f_maxSize);
+ EFrameworkunifiedStatus Read(UI_8* f_data, UI_32 f_length, SI_32& f_bytesRead); // NOLINT (runtime/references)
+ EFrameworkunifiedStatus ReadToFile(std::string f_fileName, UI_32& f_Written); // NOLINT (runtime/references)
+ EFrameworkunifiedStatus Open(void);
+ BOOL IsOpen(void);
+ void Close();
+ EFrameworkunifiedStatus ResetPosition(void);
+
+ private:
+ CNSSharedMemReader* m_pSharedBuf;
+ UI_32 m_sharedBufSize;
+};
+} // namespace ReaderWriter
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_MEM_READER_H_
diff --git a/logger_service/server/include/readerWriter/reader/queue_reader.h b/logger_service/server/include/readerWriter/reader/queue_reader.h
new file mode 100644
index 00000000..3706d642
--- /dev/null
+++ b/logger_service/server/include/readerWriter/reader/queue_reader.h
@@ -0,0 +1,49 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_QUEUE_READER_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_QUEUE_READER_H_
+
+#include <mqueue.h>
+#include <native_service/frameworkunified_types.h>
+#include <string>
+#include "reader.h"
+
+namespace ReaderWriter {
+
+class CQueueReader : public CReader {
+ public:
+ CQueueReader();
+ virtual ~CQueueReader();
+ EFrameworkunifiedStatus Initialize(CLoggerCfg* f_pLoggerCfg, std::string f_name,
+ UI_32 f_maxSize);
+ EFrameworkunifiedStatus Read(UI_8 *f_data, UI_32 f_length, SI_32 &f_bytesRead); // NOLINT (runtime/references)
+ BOOL IsOpen(void);
+ EFrameworkunifiedStatus Open(void);
+ void Close();
+ private:
+ mqd_t m_handle;
+ std::string m_queName;
+};
+
+} // namespace ReaderWriter
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_QUEUE_READER_H_
diff --git a/logger_service/server/include/readerWriter/reader/reader.h b/logger_service/server/include/readerWriter/reader/reader.h
new file mode 100644
index 00000000..269cd8aa
--- /dev/null
+++ b/logger_service/server/include/readerWriter/reader/reader.h
@@ -0,0 +1,52 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_READER_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_READER_H_
+#include <native_service/frameworkunified_types.h>
+#include <string>
+#include "readerWriter/reader_writer_cfg.h"
+#include "ss_logger_cfg.h"
+
+namespace ReaderWriter {
+
+class CReader {
+ public:
+ CReader();
+ virtual ~CReader();
+
+ static CReader* OpenReader(CLoggerCfg* f_pLoggerCfg, EReaderType f_type,
+ std::string f_name, UI_32 f_maxSize);
+ virtual EFrameworkunifiedStatus Initialize(CLoggerCfg* f_pLoggerCfg, std::string f_name,
+ UI_32 f_maxSize) = 0;
+ virtual BOOL IsOpen(void) = 0;
+ virtual EFrameworkunifiedStatus Open(void) = 0;
+ virtual EFrameworkunifiedStatus Read(UI_8* f_data, UI_32 f_length, SI_32& f_bytesRead) = 0; // NOLINT (runtime/references)
+ virtual EFrameworkunifiedStatus ReadToFile(std::string f_fileName, UI_32& f_Written); // NOLINT (runtime/references)
+
+ virtual void Close() = 0;
+ virtual EFrameworkunifiedStatus ResetPosition(void);
+
+ protected:
+ CLoggerCfg * m_pLoggerCfg;
+};
+} // namespace ReaderWriter
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_READER_H_
diff --git a/logger_service/server/include/readerWriter/reader_writer.h b/logger_service/server/include/readerWriter/reader_writer.h
new file mode 100644
index 00000000..44c37bd4
--- /dev/null
+++ b/logger_service/server/include/readerWriter/reader_writer.h
@@ -0,0 +1,77 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_WRITER_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_WRITER_H_
+
+#include <pthread.h>
+#include <native_service/frameworkunified_types.h>
+#include <string>
+#include "readerWriter/reader_writer_cfg.h"
+#include "readerWriter/reader/reader.h"
+#include "readerWriter/writer/writer.h"
+
+namespace ReaderWriter {
+
+class CReaderWriter {
+ public:
+ CReaderWriter();
+ virtual ~CReaderWriter();
+
+ EFrameworkunifiedStatus Initialize(CLoggerCfg* f_pLoggerCfg, EReaderType f_readerType,
+ std::string f_readerName, UI_32 f_readerMaxSize,
+ EWriterType f_writerType, std::string f_writer1Name,
+ UI_32 f_writer1MaxSize);
+ EFrameworkunifiedStatus Initialize(CLoggerCfg* f_pLoggerCfg, EReaderType f_readerType,
+ std::string f_readerName, UI_32 f_readerMaxSize,
+ EWriterType f_writerType, std::string f_writer1Name,
+ UI_32 f_writer1MaxSize, std::string f_writer2Name,
+ UI_32 f_writer2MaxSize);
+ EFrameworkunifiedStatus Start(std::string f_readerName);
+ EFrameworkunifiedStatus Stop();
+ void ThreadFunction(CReaderWriter* l_pObj);
+ void Cleanup(CReaderWriter* l_pObj);
+ EFrameworkunifiedStatus FlushCache(std::string f_filename);
+ EFrameworkunifiedStatus UpdateLoggingParameters(void);
+
+ private:
+ void Pause(void);
+ void Resume(void);
+ static void* ThreadFunctionWrapper(void* param);
+
+ static void CleanupWrapper(void* param);
+ CLoggerCfg* m_pLoggerCfg;
+ CReader* m_reader;
+ CWriter* m_writer;
+ BOOL m_running;
+ pthread_t m_thread;
+ pthread_barrier_t m_barrier;
+ std::string m_readerName;
+
+ pthread_mutex_t m_writeMutex;
+ pthread_mutex_t m_pauseMutex;
+ pthread_cond_t m_condVariable;
+ BOOL m_paused;
+};
+
+} // namespace ReaderWriter
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_WRITER_H_
diff --git a/logger_service/server/include/readerWriter/reader_writer_cfg.h b/logger_service/server/include/readerWriter/reader_writer_cfg.h
new file mode 100644
index 00000000..bc6602b5
--- /dev/null
+++ b/logger_service/server/include/readerWriter/reader_writer_cfg.h
@@ -0,0 +1,35 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_WRITER_CFG_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_WRITER_CFG_H_
+namespace ReaderWriter {
+typedef enum _ERWType {
+ eReaderWriterTypeFile,
+ eReaderWriterTypeQueue,
+ eReaderWriterTypeUdp,
+ eReaderWriterTypeUdpAndFile, // Only for writer | pass filename and queueName
+ eReaderWriterTypeMem,
+ eReaderWriterTypeInvalid
+} EReaderType, EWriterType;
+}
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_READER_WRITER_CFG_H_
diff --git a/logger_service/server/include/readerWriter/writer/cached_file_writer.h b/logger_service/server/include/readerWriter/writer/cached_file_writer.h
new file mode 100644
index 00000000..06d7bbce
--- /dev/null
+++ b/logger_service/server/include/readerWriter/writer/cached_file_writer.h
@@ -0,0 +1,45 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_CACHED_FILE_WRITER_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_CACHED_FILE_WRITER_H_
+
+#include <native_service/frameworkunified_types.h>
+#include "file_writer.h"
+
+#define CACHED_BLOCK_SIZE (UI_32)(4*1024)
+
+namespace ReaderWriter {
+
+class CCachedFileWriter : public CFileWriter {
+ public:
+ CCachedFileWriter();
+ virtual ~CCachedFileWriter();
+ EFrameworkunifiedStatus Write(UI_8 *f_data, UI_32 f_length, SI_32 &f_bytesWritten); // NOLINT (runtime/references)
+ EFrameworkunifiedStatus FlushCache(void);
+ private:
+ UI_8 m_buffer[CACHED_BLOCK_SIZE ];
+ UI_32 m_index;
+};
+
+} // namespace ReaderWriter
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_CACHED_FILE_WRITER_H_
diff --git a/logger_service/server/include/readerWriter/writer/file_writer.h b/logger_service/server/include/readerWriter/writer/file_writer.h
new file mode 100644
index 00000000..190232b5
--- /dev/null
+++ b/logger_service/server/include/readerWriter/writer/file_writer.h
@@ -0,0 +1,51 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_FILE_WRITER_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_FILE_WRITER_H_
+#include <native_service/frameworkunified_types.h>
+#include <string>
+#include "writer.h"
+
+namespace ReaderWriter {
+
+class CFileWriter : public CWriter {
+ public:
+ CFileWriter();
+ virtual ~CFileWriter();
+ EFrameworkunifiedStatus Initialize(CLoggerCfg* f_pLoggerCfg, std::string f_Name1,
+ UI_32 f_size1, std::string f_Name2, UI_32 f_size2);
+ EFrameworkunifiedStatus Write(UI_8 *f_data, UI_32 f_length, SI_32 &f_bytesWritten); // NOLINT (runtime/references)
+ void Close();
+ BOOL IsOpen(void);
+ EFrameworkunifiedStatus Open(void);
+ protected:
+ EFrameworkunifiedStatus WriteData(UI_8 *f_data, UI_32 f_length, SI_32 &f_bytesWritten); // NOLINT (runtime/references)
+ private:
+ int m_FileHandle;
+ off_t m_fileposn;
+ UI_32 m_maxFileSize;
+ std::string m_filename;
+};
+
+} // namespace ReaderWriter
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_FILE_WRITER_H_
diff --git a/logger_service/server/include/readerWriter/writer/udp_file_writer.h b/logger_service/server/include/readerWriter/writer/udp_file_writer.h
new file mode 100644
index 00000000..095ca352
--- /dev/null
+++ b/logger_service/server/include/readerWriter/writer/udp_file_writer.h
@@ -0,0 +1,54 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_UDP_FILE_WRITER_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_UDP_FILE_WRITER_H_
+#include <native_service/frameworkunified_types.h>
+#include <string>
+#include "writer.h"
+#include "udp_writer.h"
+#include "file_writer.h"
+
+namespace ReaderWriter {
+
+class CUdpFileWriter : public CWriter {
+ public:
+ CUdpFileWriter();
+ virtual ~CUdpFileWriter();
+ EFrameworkunifiedStatus Initialize(CLoggerCfg* f_pLoggerCfg, std::string f_Name1,
+ UI_32 f_size1, std::string f_Name2, UI_32 f_size2);
+ EFrameworkunifiedStatus Write(UI_8 *f_data, UI_32 f_length, SI_32 &f_bytesWritten); // NOLINT (runtime/references)
+ void Close();
+ BOOL IsOpen(void);
+ EFrameworkunifiedStatus Open(void);
+ EFrameworkunifiedStatus FlushCache(void);
+ EFrameworkunifiedStatus UpdateLoggingParameters(void);
+ private:
+ CUdpWriter *m_pUdpWriter;
+ CFileWriter *m_pFileWriter;
+ CLoggerCfg* m_pLoggerCfg;
+ std::string m_ipAddress;
+ UI_32 m_port;
+ std::string m_FileName;
+ UI_32 m_FileSize;
+};
+} // namespace ReaderWriter
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_UDP_FILE_WRITER_H_
diff --git a/logger_service/server/include/readerWriter/writer/udp_writer.h b/logger_service/server/include/readerWriter/writer/udp_writer.h
new file mode 100644
index 00000000..34923e82
--- /dev/null
+++ b/logger_service/server/include/readerWriter/writer/udp_writer.h
@@ -0,0 +1,63 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_UDP_WRITER_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_UDP_WRITER_H_
+
+#include <netinet/in.h>
+#include <string>
+#include "writer.h"
+
+#define REMOTE_IP_PORT 3500
+namespace ReaderWriter {
+#define UDP_MAX_LENGTH (UI_32)1024*4
+#define UDP_CACHED_BLOCK_SIZE (UI_32)1024*4
+#define SEND_RETRY_VALUE (UI_8) 5
+
+#define OWN_ADDRESS "169.254.80.8"
+class CUdpWriter : public CWriter {
+ public:
+ CUdpWriter();
+ virtual ~CUdpWriter();
+ EFrameworkunifiedStatus Initialize(CLoggerCfg* f_pLoggerCfg, std::string f_Name1,
+ UI_32 f_size1, std::string f_Name2, UI_32 f_size2);
+
+ EFrameworkunifiedStatus Write(UI_8 *f_data, UI_32 f_length, SI_32 &f_bytesWritten); // NOLINT (runtime/references)
+ void Close();
+ EFrameworkunifiedStatus UpdateLoggingParameters(void);
+ BOOL IsOpen(void);
+ EFrameworkunifiedStatus Open(void);
+ EFrameworkunifiedStatus FlushCache(void);
+ private:
+ EFrameworkunifiedStatus WriteData(UI_8 *f_data, UI_32 f_length, SI_32 &f_bytesWritten); // NOLINT (runtime/references)
+
+ int m_SocketHandle;
+ sockaddr_in m_oSAInfo;
+ std::string m_IPAddress;
+ UI_32 m_index;
+ UI_32 m_port;
+ BOOL m_InitialTimeElapsed;
+ UI_8 m_buffer[UDP_CACHED_BLOCK_SIZE];
+};
+
+} // namespace ReaderWriter
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_UDP_WRITER_H_
diff --git a/logger_service/server/include/readerWriter/writer/writer.h b/logger_service/server/include/readerWriter/writer/writer.h
new file mode 100644
index 00000000..d5a397f2
--- /dev/null
+++ b/logger_service/server/include/readerWriter/writer/writer.h
@@ -0,0 +1,56 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_WRITER_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_WRITER_H_
+#include <native_service/frameworkunified_types.h>
+#include <string>
+#include "readerWriter/reader_writer_cfg.h"
+#include "ss_logger_cfg.h"
+
+namespace ReaderWriter {
+
+class CWriter {
+ public:
+ CWriter();
+ virtual ~CWriter();
+
+ static CWriter* OpenWriter(CLoggerCfg* f_pLoggerCfg, EReaderType f_type,
+ std::string f_Name1, UI_32 f_size1,
+ std::string f_Name2, UI_32 f_size2);
+ virtual EFrameworkunifiedStatus Initialize(CLoggerCfg* f_pLoggerCfg, std::string f_Name1,
+ UI_32 f_size1, std::string f_Name2,
+ UI_32 f_size2) = 0;
+ virtual EFrameworkunifiedStatus Write(UI_8 *f_data, UI_32 f_length,
+ SI_32 &f_bytesWritten) = 0; // NOLINT (runtime/references)
+ virtual void Close() = 0;
+ virtual EFrameworkunifiedStatus FlushCache(void);
+ virtual EFrameworkunifiedStatus UpdateLoggingParameters(void);
+ virtual BOOL IsOpen(void) = 0;
+ virtual EFrameworkunifiedStatus Open(void) = 0;
+
+ protected:
+ CLoggerCfg * m_pLoggerCfg;
+};
+
+} // namespace ReaderWriter
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_READERWRITER_WRITER_WRITER_H_
diff --git a/logger_service/server/include/ss_logger_cfg.h b/logger_service/server/include/ss_logger_cfg.h
new file mode 100644
index 00000000..3e8da800
--- /dev/null
+++ b/logger_service/server/include/ss_logger_cfg.h
@@ -0,0 +1,172 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief Provide support for SS Logger module configuration.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_CFG_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_CFG_H_
+
+///////////////////////////////////////////////////////////////////////////////
+// INCLUDES
+///////////////////////////////////////////////////////////////////////////////
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/ns_config_parser_if.h>
+#include <native_service/ns_logger_if.h>
+#include <system_service/ss_templates.h>
+#include <system_service/ss_logger_service.h>
+#include <system_service/ss_logger_service_local.h>
+#include <string>
+#include <vector>
+#include "loggerservicedebug_loggerservicelog.h"
+
+///////////////////////////////////////////////////////////////////////////////
+// CONFIGURATION CLASS DEFINITION
+///////////////////////////////////////////////////////////////////////////////
+/*Default values for the storage thread*/
+#define ERROR_EVENT_STORAGE_QUEUE_NAME "/SSLoggerStrage"
+#define ERROR_EVENT_STORAGE_PRIORITY (UI_8)30
+#define ERROR_EVENT_STORAGE_SLEEP_TIME (useconds_t)50000
+#define ERROR_EVENT_STORAGE_SLEEP_AFTER (UI_8)5
+
+#if ENABLE_PRODUCTION_BUILD == 1
+#define SS_LOGGER_DEFAULT_VALUE eDeactivate
+#else
+#define SS_LOGGER_DEFAULT_VALUE eActivate
+#endif
+
+#define LOGGERSERVICELOG_EMMC_COUNTER_MAX 99999u
+
+struct SLoggerStorageInfo {
+ SLoggerStorageInfo()
+ : Name(ERROR_EVENT_STORAGE_QUEUE_NAME),
+ Priority(ERROR_EVENT_STORAGE_PRIORITY),
+ Timeout(ERROR_EVENT_STORAGE_SLEEP_TIME),
+ TimeoutAfter(ERROR_EVENT_STORAGE_SLEEP_AFTER) { // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ }
+ std::string Name;
+ SI_32 Priority;
+ SI_32 Timeout;
+ SI_32 TimeoutAfter;
+};
+
+enum EInsertEventType {
+ eInsertEventEELStorage,
+ eInsertEventEELActive,
+ eInsertEventLoggerserviceEmmcLogs,
+ eInsertEventInvalid
+};
+
+class CLoggerCfg {
+ public:
+ CLoggerCfg(void) noexcept;
+ ~CLoggerCfg(void);
+
+ EFrameworkunifiedStatus Initialize(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus Load(const std::string &f_filePathAndName);
+ EFrameworkunifiedStatus Validate(void);
+ void Print(void);
+
+ EFrameworkunifiedStatus SetLoggingParams(HANDLE f_hApp,
+ STLoggerSetParams f_stLoggerSetParams) noexcept;
+
+ EFrameworkunifiedStatus SetUDPLogging(HANDLE f_hApp, ELOGGER_STAT f_eUDPLoggingStatus)
+ noexcept;
+
+ EFrameworkunifiedStatus PersistLoggingParam(HANDLE f_hApp);
+ std::string getEmmcOutputPath(void);
+ std::string getEmmcOutputNaviLogPath(void);
+ std::string getUsb0MountPath(void);
+ std::string getUsb1MountPath(void);
+ std::string getSdMountPath(void);
+ std::string getDeviceName(void);
+ void setUsb0MountPath(std::string &f_deviceMountpath); // NOLINT (runtime/references)
+ EFrameworkunifiedStatus GetUserInvokedDestination(std::string &f_dest); // NOLINT (runtime/references)
+
+ EFrameworkunifiedStatus GetEmmcDestination(std::string &f_dest); // NOLINT (runtime/references)
+ EFrameworkunifiedStatus GetEmmcNaviLogDestination(std::string &f_dest); // NOLINT (runtime/references)
+
+ UI_32 GetUserInvokedCounter(void);
+ EFrameworkunifiedStatus GetIncrementAndPersistUserInvokedCounter(HANDLE f_hApp,
+ UI_32 &f_counter); // NOLINT (runtime/references)
+
+ EFrameworkunifiedStatus GetAndIncrementEmmcCounter(UI_32 &f_counter) noexcept; // NOLINT (runtime/references)
+ EFrameworkunifiedStatus RefreshEmmcCounter(UI_32 &f_counter) noexcept; // NOLINT (runtime/references)
+
+ void ResetEmmcCounter(void);
+
+ SI_32 m_logMaxFileSize;
+ UI_32 m_logMask[ZONE_MASK_ARRAY_ELTS];
+ SI_32 m_performanceLogMaxFileSize;
+ SI_32 m_emmcOutputMax;
+ SI_32 m_emmcOutputErrMax;
+ SI_32 m_emmcOutputGrpRelaunchMax;
+ SI_32 m_emmcOutputNaviLogMax;
+ SI_32 m_emmcOutputNaviLogNmlMax;
+ SI_32 m_emmcOutputNaviLogErrMax;
+
+ std::string m_emmcOutputPath;
+ std::string m_emmcOutputNaviLogPath;
+ std::string m_usb0MountPath;
+ std::string m_usb1MountPath;
+ std::string m_sdMountPath;
+
+ EDEV_TYPE GetConnectedDevice(std::string f_devPath);
+ EInsertEventType GetInsertEventType(std::string f_relPath);
+
+ std::string GetEELActivateRelPath(void);
+ std::string GetDebugFolderContentRelPath(void);
+ std::string GetEELExportRelPath(void);
+
+ BOOL IsUDPLoggingEnabled(void);
+ void AddLoggingParamCB(CbFuncPtr f_fp);
+
+ EFrameworkunifiedStatus GetLoggerStorageInfo(SLoggerStorageInfo &f_info); // NOLINT (runtime/references)
+ BOOL IsLoggingEnabled(void);
+ EFrameworkunifiedStatus EelActivateLogging(HANDLE f_hApp);
+
+ private:
+ void UpdateLoggingStatus(void) noexcept;
+ std::vector<CbFuncPtr> m_LoggingCallBack;
+ void GetHighestEmmcCounterValue(UI_32 &f_counter); // NOLINT (runtime/references)
+
+ EDEV_TYPE m_eDevType;
+ UI_32 m_UserInvokedLoggingNumber;
+ UI_32 m_EmmcCounter;
+ ELOGGER_STAT m_eLoggerUDPLoggingStatus;
+ BOOL m_udpEnvFlag;
+ ELOGGER_STAT m_eLoggerStatus;
+
+ std::string m_EELStorageRelPath;
+
+ std::string m_EELActivateRelPath;
+
+ std::string m_LoggerserviceEmmcLogsRelPath;
+
+ EFrameworkunifiedStatus SetandPersistLoggingParams(HANDLE f_hApp,
+ STLoggerSetAllParams f_Params,
+ BOOL f_InitCall);
+ SLoggerStorageInfo m_loggerStorageInfo;
+
+ void RemoveCarriageReturn(std::string &f_str); // NOLINT (runtime/references)
+};
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_CFG_H_
+
diff --git a/logger_service/server/include/ss_logger_common.h b/logger_service/server/include/ss_logger_common.h
new file mode 100644
index 00000000..2cf5958e
--- /dev/null
+++ b/logger_service/server/include/ss_logger_common.h
@@ -0,0 +1,115 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief This file contains the callback for Notifications and Protocol
+/// commands.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+/** @addtogroup BaseSystem
+ * @{
+ */
+/** @addtogroup system_service
+ * @ingroup BaseSystem
+ * @{
+ */
+/** @addtogroup logger_service
+ * @ingroup system_service
+ * @{
+ */
+
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_COMMON_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_COMMON_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_types.h>
+
+const CHAR DEBUG_LOG_PATH_DIR[] = "/tmp/frameworkunifiedlog";
+const CHAR DEBUG_LOG_PATH_FN[] = "/tmp/frameworkunified_debug.log";
+const CHAR TRANSMIT_LOG_PATH_FN[] = "/tmp/interfaceunified_transmit.log";
+const CHAR PERFORMANCE_LOG_PATH_FN[] = "/tmp/frameworkunified_performance.log";
+const CHAR DRINITIAL_LOG_PATH_FN[] = "/tmp/loggerservice_drinitial.log";
+const CHAR DRLOCATION_LOG_PATH_FN[] = "/tmp/loggerservice_drlocation.log";
+const CHAR KERNEL_LOG_PATH_FN[] = "/tmp/kernel.log";
+const CHAR KERNEL_BOOT_LOG_PATH_FN[] = "/ramd/log/frameworkunifiedlog/kernelboot.log";
+
+const UI_32 PERFORMANCELOG_FILE_SZ = 256 * 1024;
+
+#define CLEAR_LOG_PATH_FN "/nv/log/frameworkunifiedlog/"
+#define NULLCHAR '\0'
+
+#define DEBUG_USB_PATH "/mnt/sda1"
+#define KERNEL_LOG_PATH_DIR "kernellog"
+
+template<typename C, EFrameworkunifiedStatus (C::*M)(HANDLE)>
+class cpp_callback {
+ public:
+ static CallbackFunctionPtr set(void* pInst) {
+ if (pInst == NULL)
+ throw;
+ ms_pInst = pInst;
+ return &cpp_callback::call;
+ }
+ static EFrameworkunifiedStatus call(HANDLE y) {
+ if (ms_pInst == NULL)
+ return eFrameworkunifiedStatusFault;
+ C* c = static_cast<C*>(ms_pInst);
+ return (c->*M)(y);
+ }
+ private:
+ static void* ms_pInst;
+};
+
+template<typename C, EFrameworkunifiedStatus (C::*M)(HANDLE)>
+void* cpp_callback<C, M>::ms_pInst = NULL;
+
+typedef enum _LoggerServiceStatus {
+ eLSInit,
+ eLSStart,
+ eLSStop,
+} ELOGGERSERVICESTATUS;
+
+typedef enum {
+ SS_LOGGER_KLOG_GET, /* type : get kernel.log */
+ SS_LOGGER_KBOOTLOG_CREATE /* type : create kernelboot.log */
+} SS_LOGGER_KLOG_OPE_TYPE;
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// \ingroup StopLoggingFunction
+/// \~english @par Summary
+/// Stop the logging function.
+/// \~english @param [in] hApp
+/// HANDLE - Application handle
+/// \~english @retval
+/// None
+/// \~english @par Detail
+/// - The API stops the logging function.\n
+/// \n
+/// - Include ss_logger_common.h
+/// - Library libSS_SystemIfUnified.so
+/// \~english @par Classification
+/// Public
+/// \~english @see
+/// None
+////////////////////////////////////////////////////////////////////////////////////////////
+void StopLoggingFunction(HANDLE hApp);
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_COMMON_H_
+
+/** @}*/ // end of LoggerService
+/** @}*/ // end of SystemService
+/** @}*/ // end of BaseSystem
diff --git a/logger_service/server/include/ss_logger_device_detection.h b/logger_service/server/include/ss_logger_device_detection.h
new file mode 100644
index 00000000..0522c9ea
--- /dev/null
+++ b/logger_service/server/include/ss_logger_device_detection.h
@@ -0,0 +1,66 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_InterfaceunifiedLogCapture
+/// \brief This file supports USB logging threads.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_DEVICE_DETECTION_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_DEVICE_DETECTION_H_
+
+#include <system_service/ss_devicedetection_service_notifications.h>
+#include <system_service/ss_devicedetection_service_ifc.h>
+#include "ss_logger_cfg.h"
+#include "ss_logger_util.h"
+
+extern const char * USB_INSERTED_RULE;
+
+// USB device is ejected
+extern const CHAR USB_EJECTED_RULE[];
+
+// The trigger event file (/log/retrievelog.evt) file is found on USB
+extern const CHAR USB_CAPTURE_LOG_EVENT_RULE[];
+
+// When the command to update system with script is executed all the console
+// output will be redirected to this file on /tmp folder. later it will be
+// moved to USB stick
+extern const CHAR CAPTURE_LOG_FILENAME[];
+
+//
+extern const SI_32 INVALID_FD;
+class CLoggerDeviceDetection {
+ public:
+ CLoggerDeviceDetection();
+ ~CLoggerDeviceDetection();
+
+ EFrameworkunifiedStatus Initialize(HANDLE hApp, CLoggerCfg *f_pLoggerCfg);
+ EFrameworkunifiedStatus DD_ServiceAvailabilityCallBack(HANDLE hApp);
+ EFrameworkunifiedStatus DD_OpenSessionAckCallBack(HANDLE hApp);
+ EFrameworkunifiedStatus DD_CloseSessionAckCallBack(HANDLE hApp);
+ EFrameworkunifiedStatus DD_CloseSessionWithDevDetectionSrv(HANDLE hApp);
+ EFrameworkunifiedStatus DD_MediaDetectCallBack(HANDLE hApp);
+
+ EFrameworkunifiedStatus OnStop(void);
+ private:
+ CLoggerCfg *m_pLoggerCfg;
+
+ /// Device Detection Class Instance
+ DeviceDetectionServiceIf m_devDetect;
+
+ CLoggerUtil *m_loggerUtil;
+};
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_DEVICE_DETECTION_H_
diff --git a/logger_service/server/include/ss_logger_error_event.h b/logger_service/server/include/ss_logger_error_event.h
new file mode 100644
index 00000000..80b6bd8a
--- /dev/null
+++ b/logger_service/server/include/ss_logger_error_event.h
@@ -0,0 +1,156 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief This file supports error event logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_H_
+
+#include <time.h>
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <system_service/ss_system_types.h>
+#include <system_service/ss_system_timer.h>
+#include <system_service/ss_system_manager_protocol.h>
+#include <string>
+#include <vector>
+#include "ss_logger_popups.h"
+#include "ss_logger_common.h"
+#include "ss_logger_reader_writer_control.h"
+#include "ss_logger_error_event_cfg.h"
+#include "ss_logger_cfg.h"
+#include "ss_logger_util.h"
+#include "readerWriter/reader_writer.h"
+#include "readerWriter/reader_writer_cfg.h"
+#include "ss_logger_error_event_storage.h"
+#include "ss_logger_error_event_can_evt_reply.h"
+
+class CErrorEvent {
+ public:
+ CErrorEvent();
+ ~CErrorEvent();
+
+ EFrameworkunifiedStatus Initialize(HANDLE f_hApp, CLoggerCfg *f_pLoggerCfg,
+ CReaderWriterControl *f_pReaderWriterControl,
+ HANDLE f_thrdEvntLogWriter,
+ std::string f_strEvntLogQueWorkerName);
+
+ EFrameworkunifiedStatus RegisterSessionErrorEvent(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus OnOpenSession(HANDLE f_hApp, PCSTR f_pRequesterName,
+ HANDLE f_hSession);
+
+ EFrameworkunifiedStatus OnCloseSession(HANDLE f_hApp, PCSTR f_pRequesterName,
+ HANDLE f_hSession);
+
+ EFrameworkunifiedStatus StartLogging(HANDLE f_hApp, EErrorEventType f_eventType);
+
+ EFrameworkunifiedStatus sendDiagEventErrorResponse(EELL_ErrorCode f_errCode);
+
+ EFrameworkunifiedStatus sendDiagEventErrorResponse(EELL_ErrorCode f_errCode,
+ std::string f_destName);
+
+ EFrameworkunifiedStatus sendDiagEventResponse(void);
+
+ EFrameworkunifiedStatus SetDiagEventSourceName(std::string f_serviceName);
+
+ void SetMileage(UI_32 f_mileage);
+
+ void SetDiagSessionHandle(HANDLE hSession);
+
+ EFrameworkunifiedStatus SaveNaviLog(EPWR_SHUTDOWN_TRIGGER_TYPE errorType);
+ EFrameworkunifiedStatus CreateKernelLog(HANDLE f_hApp, SS_LOGGER_KLOG_OPE_TYPE type);
+
+ private:
+ typedef enum {
+ kSSL_ERROR_EVENT_TIMER_LOGGING_START_RSPN,
+ kSSL_ERROR_EVENT_TIMER_ARTIFACT_RSPN,
+ kSSL_ERROR_EVENT_TIMER_END
+ } ESSLErrorEventTimers;
+
+ // Logging Protocol Function Prototypes
+ EFrameworkunifiedStatus OnStartLogging(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnLogStartResponse(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnLogStartResponseTimeout(HANDLE f_hApp);
+ EFrameworkunifiedStatus RequestNextArtifact(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnArtifactResponse(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnArtifactResponseTimeout(HANDLE f_hApp);
+
+ // Protocol functions sent to self.
+ EFrameworkunifiedStatus OnArtifactRequest(HANDLE f_hApp);
+
+ // Error Event Artifact Request Function Prototypes
+ EFrameworkunifiedStatus SendLogArtifactResponseToSelf(
+ HANDLE f_hApp, EArtifactId f_artifactId,
+ std::string f_artifactFilePathAndName);
+
+ EFrameworkunifiedStatus OnObtainLoggerserviceLogRequest(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnObtainTransmitLogRequest(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnObtainPerformanceLogRequest(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnObtainScreenShotRequest(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnObtainScreenShotResponse(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnObtainKernelLogInfoRequest(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnObtainDRInitialLogRequest(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnObtainDRLocationLogRequest(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnStorageResponseOk(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnStorageResponseWriteFailed(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnStorageResponseNotFound(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnStorageResponseNoWritten(HANDLE f_hApp);
+ EFrameworkunifiedStatus CheckPathForArtifact(HANDLE f_hApp, TLoggingArtifact f_artifact);
+ EFrameworkunifiedStatus OnClearAllLogRequest(HANDLE f_hApp);
+ EFrameworkunifiedStatus OnNaviLogRequest(HANDLE f_hApp);
+
+ // verify function for external storage
+ EFrameworkunifiedStatus VerifyExtStorage(TLoggerErrorEvent event);
+ bool IsNeedVerify(EErrorEventType type);
+
+ HANDLE m_hApp;
+ bool m_bIsPrevEventCompleted;
+ CErrorEventCfg m_errorEventCfg;
+ TLoggerErrorEvent m_errorEventNtfData;
+ Timer m_errorEventTimers[kSSL_ERROR_EVENT_TIMER_END];
+ std::vector<TLoggingArtifact> m_artifactRequestVec;
+ TArtifactResponseVec m_artifactResponseVec;
+ std::vector<FrameworkunifiedProtocolCallbackHandler> m_requesterCallbacksVec;
+ std::string m_archiveDestination;
+ CLoggerUtil m_loggerUtil;
+ CLoggerPopups m_loggerPopups;
+ CLoggerCfg* m_pLoggerCfg;
+ CLoggerErrorEventStorage m_loggerStorage;
+ CLoggerErrorEventCANEvtReply m_loggerCanEvent;
+ static const UI_32 m_loggingStartRspnToSec = 1;
+ static const UI_32 m_screenShotRspnToSec = 2;
+ CReaderWriterControl* m_pReaderWriterControl;
+
+ std::string m_ServiceName;
+ uint32_t m_time;
+ UI_32 m_currentEventTriggerNumber;
+ HANDLE m_diagsessionhandle;
+
+ HANDLE m_thrdEvntLogWriter;
+
+ public:
+ int m_sfd;
+};
+
+EFrameworkunifiedStatus SSLogger_SendtoSM(HANDLE f_hApp, TLoggingArtifact f_artifact);
+EFrameworkunifiedStatus SSLogger_SendtoSelf(HANDLE f_hApp, TLoggingArtifact f_artifact);
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_H_
+
diff --git a/logger_service/server/include/ss_logger_error_event_archive.h b/logger_service/server/include/ss_logger_error_event_archive.h
new file mode 100644
index 00000000..feaba965
--- /dev/null
+++ b/logger_service/server/include/ss_logger_error_event_archive.h
@@ -0,0 +1,77 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief This file supports error event logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_ARCHIVE_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_ARCHIVE_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_if.h>
+
+#include <libtar_listhash.h>
+#include <libtar.h>
+
+#include <system_service/ss_system_types.h>
+#include <string>
+#include <vector>
+
+class CErrorEventArchive {
+ public:
+ CErrorEventArchive();
+ ~CErrorEventArchive();
+
+ EFrameworkunifiedStatus openArchive(std::string f_pathAndName);
+
+ EFrameworkunifiedStatus addToArchive(std::vector<std::string> f_filePathAndNameList);
+
+ EFrameworkunifiedStatus addToArchive(std::string f_filePathAndName,
+ std::string f_destinationName, UI_8 f_depth =
+ CErrorEventArchive::MAX_DIRECTORY_DEPTH);
+
+ EFrameworkunifiedStatus closeArchive(void);
+
+ static SI_32 gzOpenArchive(PCHAR f_pcPathname, SI_32 f_siOflags,
+ SI_32 f_siMode);
+
+ static SI_32 gzCloseArchive();
+
+ static ssize_t gzWriteArchive(int fd, const void* buf, size_t count);
+
+ static ssize_t gzReadArchive(int fd, void* buf, size_t count);
+
+ static const UI_8 MAX_DIRECTORY_DEPTH = 4;
+
+ private:
+ EFrameworkunifiedStatus addFileToArchive(std::string f_filename,
+ std::string f_destinationName);
+
+ EFrameworkunifiedStatus addDirectoryToArchive(std::string f_path,
+ std::string f_destinationName, UI_8 f_depth =
+ CErrorEventArchive::MAX_DIRECTORY_DEPTH);
+
+ tartype_t m_gztype;
+ TAR *m_pTarInfo;
+ std::string m_pathAndName;
+ std::string m_tmpName;
+
+ static const UI_32 TARMODE = 0644;
+};
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_ARCHIVE_H_
diff --git a/logger_service/server/include/ss_logger_error_event_can_evt_reply.h b/logger_service/server/include/ss_logger_error_event_can_evt_reply.h
new file mode 100644
index 00000000..7ebb6ec4
--- /dev/null
+++ b/logger_service/server/include/ss_logger_error_event_can_evt_reply.h
@@ -0,0 +1,48 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief This file supports notifying CAN abou HK and CAN error events
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_CAN_EVT_REPLY_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_CAN_EVT_REPLY_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <system_service/ss_logger_service_protocol.h>
+
+#include "ss_logger_cfg.h"
+#include "ss_logger_error_event_cfg.h"
+#include "ss_logger_common.h"
+class CLoggerErrorEventCANEvtReply {
+ public:
+ CLoggerErrorEventCANEvtReply();
+ virtual ~CLoggerErrorEventCANEvtReply();
+ EFrameworkunifiedStatus Initialize(CLoggerCfg* f_pLoggerCfg);
+
+ BOOL IsEventNeeded(TLoggerErrorEvent f_event);
+ EFrameworkunifiedStatus PublishStartEvent(HANDLE f_hApp, TLoggerErrorEvent f_event);
+ EFrameworkunifiedStatus PublishEndEvent(HANDLE f_hApp, TLoggerErrorEvent f_event,
+ UI_32 f_triggerNumber, uint32_t f_time);
+
+ EFrameworkunifiedStatus PublishErrorEvent(HANDLE f_hApp, TLoggerErrorEvent f_event,
+ BOOL f_isValid, UI_32 f_triggerNumber,
+ uint32_t f_time);
+ private:
+};
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_CAN_EVT_REPLY_H_
diff --git a/logger_service/server/include/ss_logger_error_event_cfg.h b/logger_service/server/include/ss_logger_error_event_cfg.h
new file mode 100644
index 00000000..b9b13094
--- /dev/null
+++ b/logger_service/server/include/ss_logger_error_event_cfg.h
@@ -0,0 +1,132 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief This file supports error event logging configuration.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_CFG_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_CFG_H_
+#include <system_service/ss_system_manager_if.h>
+#include <vector>
+#include <map>
+#include <string>
+
+typedef UI_32 ARTIFACT_BIT_MASK;
+typedef UI_32 EVENT_BIT_MASK;
+
+#define NBR_ARTIFACT_BITS (sizeof(ARTIFACT_BIT_MASK) * 8)
+
+enum EVENT_BIT {
+ EVENT_BIT_NONE = 0x00000000,
+ EVENT_BIT_POPUP = 1 << (UI_32) 1,
+ EVENT_BIT_CAN_NOTIFICATION = 1 << (UI_32) 2,
+ EVENT_BIT_DIAG = 1 << (UI_32) 3,
+};
+
+struct TLoggingErrorEventInformation {
+ ARTIFACT_BIT_MASK ArtifactBitMask;
+ EVENT_BIT_MASK EventBitMask;
+};
+struct TLoggingArtifactCfg {
+ EErrorEventType ErrorType;
+ TLoggingErrorEventInformation Information;
+};
+struct TLoggerErrorEvent {
+ TLoggerErrorEvent()
+ : EventType(eErrorEventTypeMaxValue),
+ ModuleName(""),
+ isNeedReboot(FALSE),
+ EventBitMask(EVENT_BIT_NONE) { // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ }
+ TLoggerErrorEvent(SMErrorEventNtfData l_SMErrorEvent) { // NOLINT (runtime/explicit)
+ EventType = l_SMErrorEvent.EventType;
+ ModuleName = l_SMErrorEvent.ModuleName;
+ isNeedReboot = l_SMErrorEvent.isNeedReboot;
+ EventBitMask = EVENT_BIT_NONE;
+ }
+ EErrorEventType EventType;
+ std::string ModuleName;
+ BOOL isNeedReboot;
+ EVENT_BIT_MASK EventBitMask;
+};
+struct TLoggingArtifact;
+
+typedef EFrameworkunifiedStatus (*TLoggingCbFunction)(HANDLE, TLoggingArtifact);
+
+enum ECallbackType {
+ eCbTypePath = 0,
+ eCbTypeFunction,
+ eCbTypeInvalid
+};
+
+struct TLoggingArtifactCallback {
+ ECallbackType Type;
+ std::string Path;
+ TLoggingCbFunction Function;
+};
+
+struct TLoggingArtifactInformation {
+ std::string OwnerServiceName;
+ UI_32 RequestTimeoutMs;
+ TLoggingArtifactCallback Cb;
+ BOOL Remove;
+};
+struct TLoggingArtifact {
+ EArtifactId ArtifactId;
+ TLoggingArtifactInformation Information;
+};
+
+struct TLoggingArtifactResponse {
+ EArtifactId ArtifactId;
+ std::string Filepath;
+ BOOL Remove;
+};
+
+//////////////////////////////////////////////////////////////////////////////////////////
+///// External function definition for Logger callbacks
+//////////////////////////////////////////////////////////////////////////////////////////
+extern EFrameworkunifiedStatus SSLogger_SendtoSM(HANDLE f_hApp, TLoggingArtifact f_artifact);
+extern EFrameworkunifiedStatus SSLogger_SendtoSelf(HANDLE f_hApp,
+ TLoggingArtifact f_artifact);
+
+typedef std::map<EErrorEventType, TLoggingErrorEventInformation> TArtifactBitMaskMap;
+typedef std::map<EArtifactId, TLoggingArtifactInformation> TArtifactMap;
+typedef std::vector<TLoggingArtifactResponse> TArtifactResponseVec;
+
+class CErrorEventCfg {
+ public:
+ CErrorEventCfg(void);
+
+ ~CErrorEventCfg(void);
+
+ EFrameworkunifiedStatus Initialize(void);
+
+ void GetArtifactRequestVec(
+ EErrorEventType f_eventType,
+ std::vector<TLoggingArtifact> &f_refArtifactRequestVec); // NOLINT (runtime/references)
+ EVENT_BIT_MASK GetEventsForErrorEvent(EErrorEventType f_eventType);
+ private:
+ UI_32 ValidateConfiguration(void);
+ TArtifactBitMaskMap m_errorEventTypeToArtifactBitMaskMap;
+ TArtifactMap m_errorArtifactMap;
+
+ static TLoggingArtifactCfg m_loggerErrorEventCfgTbl[eErrorEventTypeMaxValue];
+ static TLoggingArtifact m_loggerErrorArtifactCfgTbl[eArtifactIdMaxValue];
+};
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_CFG_H_
diff --git a/logger_service/server/include/ss_logger_error_event_storage.h b/logger_service/server/include/ss_logger_error_event_storage.h
new file mode 100644
index 00000000..e5620e81
--- /dev/null
+++ b/logger_service/server/include/ss_logger_error_event_storage.h
@@ -0,0 +1,82 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief This file supports error event logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_STORAGE_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_STORAGE_H_
+
+#include <sys/types.h>
+#include <pthread.h>
+#include <mqueue.h>
+#include <time.h>
+#include <native_service/frameworkunified_types.h>
+#include <ss_logger_error_event_cfg.h>
+//#include <vehicle_service/Clock_API.h>
+#include <string>
+#include "ss_logger_cfg.h"
+
+enum ELoggerStorageThreadCommands {
+ eLoggerStorageThreadCmdOK = 0xAFFE,
+ eLoggerStorageThreadCmdWriteFailed,
+ eLoggerStorageThreadCmdNotFound,
+ eLoggerStorageThreadCmdNoWritten
+};
+
+class CLoggerErrorEventStorage {
+ public:
+ CLoggerErrorEventStorage();
+ virtual ~CLoggerErrorEventStorage();
+
+ EFrameworkunifiedStatus Initialize(HANDLE f_hApp, std::string f_ParentName,
+ CLoggerCfg *f_pLoggerCfg);
+
+ EFrameworkunifiedStatus Start(std::string f_target, TArtifactResponseVec f_responseVector,
+ uint32_t f_time);
+
+ void ThreadFunction(void);
+ void Cleanup(void);
+
+ private:
+ static void* ThreadFunctionWrapper(void* param);
+ static void CleanupWrapper(void* param);
+
+ EFrameworkunifiedStatus PackageAndPlaceArtifacts(std::string f_archiveDestination,
+ TArtifactResponseVec &f_responseVector, // NOLINT (runtime/references)
+ uint32_t l_logTime);
+
+ SI_32 CopyFiles(std::string f_archiveDestination,
+ TArtifactResponseVec &f_responseVector, BOOL isDeleteFiles); // NOLINT (runtime/references)
+
+ EFrameworkunifiedStatus RemoveDeprecatedArtifacts(TArtifactResponseVec &f_responseVector); // NOLINT (runtime/references)
+ HANDLE m_parentMcQueue;
+ pthread_t m_thread;
+ pthread_mutex_t m_mutex;
+ mqd_t m_sendQueue;
+ mqd_t m_receiveQueue;
+ std::string m_destination;
+ TArtifactResponseVec m_responseVec;
+ struct mq_attr m_mqattr;
+ SI_32 m_mutexInit;
+ CLoggerCfg *m_pLoggerCfg;
+ SLoggerStorageInfo m_loggerStorageInfo;
+ uint32_t m_logTime;
+};
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_STORAGE_H_
diff --git a/logger_service/server/include/ss_logger_fs_directory.h b/logger_service/server/include/ss_logger_fs_directory.h
new file mode 100644
index 00000000..9006f5fa
--- /dev/null
+++ b/logger_service/server/include/ss_logger_fs_directory.h
@@ -0,0 +1,108 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief This file contains declaration of class CFSDirectory.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_FS_DIRECTORY_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_FS_DIRECTORY_H_
+#include <native_service/frameworkunified_types.h>
+#include<string>
+
+// Class to provide file system directory operations like create,delete etc.
+class CFSDirectory {
+ public:
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// CFSDirectory
+ /// Constructor of CFSDirectory class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ CFSDirectory();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ /// ~CFSDirectory
+ /// Destructor of CFSDirectory class
+ ///
+ /// \param
+ ///
+ /// \return
+ ///
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ ~CFSDirectory();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// This method is used to check if the directory exists.
+ ///
+ /// \param [in] f_cDirPath
+ /// std::string - Path of the directory to delete.
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ static BOOL DoesDirectoryExist(std::string &f_cDirPath); // NOLINT (runtime/references)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// This method is used to create a directory.
+ ///
+ /// \param [in] f_cDirPath
+ /// std::string - Path of the directory to delete.
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ static EFrameworkunifiedStatus CreateDirectory(std::string &f_cDirPath); // NOLINT (runtime/references)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// This method is used to verify directory.
+ ///
+ /// \param [in] f_cPath
+ /// std::string - Path of the directory to delete.
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ static BOOL IsDirectory(std::string &f_cPath); // NOLINT (runtime/references)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// This method is used to delete directory.
+ ///
+ /// \param [in] f_cPath
+ /// std::string - Path of the directory to delete.
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ static BOOL RemoveDirectory(std::string &f_cPath); // NOLINT (runtime/references)
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ /// This method is used to delete file in direcotry.
+ ///
+ /// \param [in] f_cPath
+ /// std::string - Path of the directory to delete.
+ ///
+ /// \return status
+ /// EFrameworkunifiedStatus - success or error
+ ////////////////////////////////////////////////////////////////////////////////////////////
+ static BOOL RemoveSubDirectory(std::string &f_cPath); // NOLINT (runtime/references)
+};
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_FS_DIRECTORY_H_
diff --git a/logger_service/server/include/ss_logger_popups.h b/logger_service/server/include/ss_logger_popups.h
new file mode 100644
index 00000000..d45459df
--- /dev/null
+++ b/logger_service/server/include/ss_logger_popups.h
@@ -0,0 +1,51 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief This file supports error event logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_POPUPS_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_POPUPS_H_
+#include <native_service/frameworkunified_types.h>
+#include <system_service/ss_logger_service_protocol.h>
+#include <string>
+#include <vector>
+
+#include "ss_logger_cfg.h"
+#include "ss_logger_error_event_cfg.h"
+class CLoggerPopups {
+ public:
+ CLoggerPopups();
+ virtual ~CLoggerPopups();
+ EFrameworkunifiedStatus Initialize(CLoggerCfg* f_pLoggerCfg);
+ BOOL IsPopupNeeded(TLoggerErrorEvent f_event);
+ BOOL CanShowStartPopup(std::vector<TLoggingArtifact>* f_remainingArtifact);
+ EFrameworkunifiedStatus ShowStartPopup(HANDLE f_hApp, TLoggerErrorEvent f_event,
+ std::vector<TLoggingArtifact>* f_remainingArtifact,
+ std::string f_dest);
+ EFrameworkunifiedStatus ShowEndPopup(HANDLE f_hApp, TLoggerErrorEvent f_event,
+ std::string f_dest);
+ EFrameworkunifiedStatus ShowErrorPopup(HANDLE f_hApp, TLoggerErrorEvent f_event,
+ UI_16 f_errCode);
+ std::string getDeviceName(std::string f_dest);
+ private:
+ CLoggerCfg *m_pLoggerCfg;
+ BOOL m_startShown;
+};
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_POPUPS_H_
diff --git a/logger_service/server/include/ss_logger_reader_writer_control.h b/logger_service/server/include/ss_logger_reader_writer_control.h
new file mode 100644
index 00000000..4587ac7b
--- /dev/null
+++ b/logger_service/server/include/ss_logger_reader_writer_control.h
@@ -0,0 +1,49 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * ss_logger_reader_writer_control.h
+ */
+
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_READER_WRITER_CONTROL_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_READER_WRITER_CONTROL_H_
+
+#include <native_service/frameworkunified_types.h>
+#include <string>
+#include "readerWriter/reader_writer.h"
+#include "ss_logger_cfg.h"
+
+enum EReaderWriterType {
+ eReaderWriterLogDebug,
+ eReaderWriterLogTransmit,
+ eReaderWriterLogPerformance,
+ eReaderWriterLogInvalid
+};
+class CReaderWriterControl {
+ public:
+ CReaderWriterControl();
+ virtual ~CReaderWriterControl();
+ EFrameworkunifiedStatus Initialize(CLoggerCfg* f_pLoggerCfg);
+ EFrameworkunifiedStatus UpdateLoggingParams(void* param);
+ EFrameworkunifiedStatus FlushCache(EReaderWriterType f_type);
+ private:
+ CLoggerCfg * m_pLoggerCfg;
+ ReaderWriter::CReaderWriter m_debugReaderWriter;
+ ReaderWriter::CReaderWriter m_transmitReaderWriter;
+ ReaderWriter::CReaderWriter m_performanceReaderWriter;
+};
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_READER_WRITER_CONTROL_H_
diff --git a/logger_service/server/include/ss_logger_scrshot.h b/logger_service/server/include/ss_logger_scrshot.h
new file mode 100644
index 00000000..a9e1b311
--- /dev/null
+++ b/logger_service/server/include/ss_logger_scrshot.h
@@ -0,0 +1,30 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_SCRSHOT_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_SCRSHOT_H_
+
+#define JPEG_PATH_CH0 "/nv/log/work/screenShot/screen_shot_Ch0.jpeg"
+#define JPEG_PATH_CH1 "/nv/log/work/screenShot/screen_shot_Ch1.jpeg"
+#define SCRSHOT_EXE_PATH "/usr/agl/bin/SS_ScrShot"
+#define SCREEN_SHOT_PATH "/nv/log/work/screenShot"
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_SCRSHOT_H_
diff --git a/logger_service/server/include/ss_logger_service_callbacks.h b/logger_service/server/include/ss_logger_service_callbacks.h
new file mode 100644
index 00000000..c466ee11
--- /dev/null
+++ b/logger_service/server/include/ss_logger_service_callbacks.h
@@ -0,0 +1,96 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief This file contains the callback for Notifications and Protocol
+/// commands.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_SERVICE_CALLBACKS_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_SERVICE_CALLBACKS_H_
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <native_service/frameworkunified_framework_types.h>
+#include <system_service/ss_error_event_common.h>
+#include "ss_logger_error_event.h"
+#include "ss_logger_reader_writer_control.h"
+#include "ss_logger_cfg.h"
+
+class CLoggerServiceCallbacks {
+ private:
+ static const UI_32 kNUMBER_PROTOCOL_HANDLERS = 17u;
+ FrameworkunifiedProtocolCallbackHandler m_protocolHandlers[kNUMBER_PROTOCOL_HANDLERS];
+ CLoggerCfg *m_pLoggerCfg;
+ CErrorEvent *m_pErrorEvent;
+
+ public:
+ CLoggerServiceCallbacks();
+ ~CLoggerServiceCallbacks();
+
+ EFrameworkunifiedStatus Initialize(HANDLE f_hApp, CLoggerCfg *f_pLoggerCfg,
+ CErrorEvent *f_pErrorEvent);
+
+ EFrameworkunifiedStatus LoggerServerOnOpenSession(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServerOnCloseSession(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_SetMileageData(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_SetLoggerParams(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_UDPLogging(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_SetCurrentDateTime(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_UpdateCommonInfo(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_Handle_CWORD56_Events(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_LogResetEvents(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_OnCopyEmergencyLog(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_OnCANTrigger(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus LoggerServer_OnDTCTrigger(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus LoggerServer_On_SHTDWN_Complete(HANDLE f_hApp);
+
+ EFrameworkunifiedStatus LoggerServer_OnSetVIN(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_OnCopyEvntLog(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_OnClearEvntLog(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_OnReadNumberOfEvents(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_OnReadStatCounter(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_OnResetStatCounter(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_OnSetDiagID(HANDLE hApp);
+
+ EFrameworkunifiedStatus LoggerServer_UploadEventLog(HANDLE hApp);
+
+ HANDLE RetrieveRegisteredClientHandle(HANDLE hApp, PCSTR pRequester);
+};
+
+EFrameworkunifiedStatus LoggerService_OnStop(HANDLE hApp);
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_SERVICE_CALLBACKS_H_
+
diff --git a/logger_service/server/include/ss_logger_types.h b/logger_service/server/include/ss_logger_types.h
new file mode 100644
index 00000000..dba34e99
--- /dev/null
+++ b/logger_service/server/include/ss_logger_types.h
@@ -0,0 +1,52 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief This file supports shared internal logger module data types.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_TYPES_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_TYPES_H_
+
+#include <native_service/frameworkunified_sm_eventdata.h>
+
+typedef enum _ENPS_Archivetype {
+ ARCHTYPE_COMPRESSION = 0, // Compression
+ ARCHTYPE_DECOMPRESSION = 1 // DeCompression
+} ENPS_Archivetype;
+
+typedef CHAR CopyInfoStr[MAX_PATH_LENGTH]; ///< Information passed via the framework
+
+typedef enum _LOGGERSERVICE_COMPRESSION_TYPE {
+ eLoggerserviceNone = 0, // No Compression before file persistence
+ eLoggerserviceDefaultCompression, // Compress file before persistence using default compression method
+ eLoggerserviceCompressUsingLibz // Compress file before persistence using libz
+} LOGGERSERVICE_COMPRESSION_TYPE;
+
+typedef struct _NPS_CopyInfoMsg {
+ CopyInfoStr m_cSourcePath; // Source path
+ CopyInfoStr m_cDestinationPath; // Destination path
+ ENPS_Archivetype m_eArchiveType; // Compression or DeCompression
+ LOGGERSERVICE_COMPRESSION_TYPE m_eCompressionType; // Check for Compression of the file
+} NSP_CopyInfoCmd;
+
+typedef struct _NPS_CopyStatus {
+ BOOL m_bPersistenceChk; // Persistence Success or Failure
+ LOGGERSERVICE_COMPRESSION_TYPE m_eCompressionType; // Check for Compression of the file
+} NSP_CopyStatusResponse, NSP_CopyCancel;
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_TYPES_H_
diff --git a/logger_service/server/include/ss_logger_util.h b/logger_service/server/include/ss_logger_util.h
new file mode 100644
index 00000000..a5d83c53
--- /dev/null
+++ b/logger_service/server/include/ss_logger_util.h
@@ -0,0 +1,127 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief Provide support for SS Logger module utility functions.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_UTIL_H_
+#define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_UTIL_H_
+
+///////////////////////////////////////////////////////////////////////////////
+// INCLUDES
+///////////////////////////////////////////////////////////////////////////////
+
+#include <time.h>
+#include <native_service/frameworkunified_types.h>
+#include <system_service/ss_templates.h>
+#include <system_service/ss_system_manager_if.h>
+#include <string>
+#include <vector>
+#include "ss_logger_error_event_cfg.h"
+#include "loggerservicedebug_loggerservicelog.h"
+#include "ss_logger_cfg.h"
+///////////////////////////////////////////////////////////////////////////////
+// DEFINE
+///////////////////////////////////////////////////////////////////////////////
+// If you changed BUF_MAX_SIZE, To contact the secure team.
+// Because There is impact for decrypt tool.
+#define BUF_MAX_SIZE (1024*8)
+#define USB_PATH_SIZE 64
+#ifdef RELEASE_BUILD
+#define DEV_ENC_EXTENSION ".enc1"
+#define REL_ENC_EXTENSION ".enc2"
+#define ALIGNMENT_SIZE 4
+#endif // RELEASE_BUILD
+#define LOGGER_TMP_FN "__LOGGER.tmp"
+
+///////////////////////////////////////////////////////////////////////////////
+// CONFIGURATION CLASS DEFINITION
+///////////////////////////////////////////////////////////////////////////////
+typedef enum _ELoggerserviceLogType {
+ eLoggerservicelogTypeNormal,
+ eLoggerservicelogTypeAbnormal,
+ eLoggerservicelogTypeGrpRelaunch,
+ eLoggerservicelogTypeOther,
+} ELOGGERSERVICELOGTYPE;
+
+class CLoggerUtil {
+ public:
+ CLoggerUtil(void);
+
+ ~CLoggerUtil(void);
+
+ EFrameworkunifiedStatus Initialize(CLoggerCfg *f_pLoggerCfg);
+
+ EFrameworkunifiedStatus checkDestinationAvailable(TLoggerErrorEvent &f_eventNtfData); // NOLINT (runtime/references)
+ std::string getDestination(TLoggerErrorEvent &f_eventNtfData); // NOLINT (runtime/references)
+ EFrameworkunifiedStatus getFilePathAndName(HANDLE f_hApp,
+ TLoggerErrorEvent &f_eventNtfData, // NOLINT (runtime/references)
+ uint32_t f_time, std::string &f_pathAndName); // NOLINT (runtime/references)
+ void SetMilage(UI_32 f_milage);
+
+ EFrameworkunifiedStatus getEmmcNaviLogParams(uint32_t f_time,
+ EPWR_SHUTDOWN_TRIGGER_TYPE errorType,
+ std::string &f_pathAndName, UI_32 &f_logMax); // NOLINT (runtime/references)
+
+ EFrameworkunifiedStatus deleteOldLog(std::string log_path,
+ std::vector<std::string> &l_vector, // NOLINT (runtime/references)
+ std::string &f_archive_destination, UI_32 max_num); // NOLINT (runtime/references)
+ EFrameworkunifiedStatus deleteOldEmmcLog(std::string &f_archive_destination, // NOLINT (runtime/references)
+ EErrorEventType type);
+ static EFrameworkunifiedStatus forceDeleteOldLog(std::string f_archive_destination,
+ size_t f_req_size);
+ static size_t deleteRequestLogs(std::string f_emmcpath, ELOGGERSERVICELOGTYPE f_reqtype,
+ size_t f_reqsize, ELOGGERSERVICELOGTYPE f_deltype);
+ static EFrameworkunifiedStatus CopyFile(std::string f_source, std::string f_destination);
+ static EFrameworkunifiedStatus CopyUntyped(std::string f_source,
+ std::string f_destination);
+ static EFrameworkunifiedStatus CopyDirectory(std::string f_source,
+ std::string f_destination);
+
+ static EFrameworkunifiedStatus MoveFile(std::string f_source, std::string f_destination);
+ static EFrameworkunifiedStatus MoveUntyped(std::string f_source,
+ std::string f_destination);
+ static EFrameworkunifiedStatus MoveDirectory(std::string f_source,
+ std::string f_destination);
+
+ static ELOGGERSERVICELOGTYPE QueryLoggerservicelogType(std::string f_logname);
+ static void SyncDir(std::string f_dir_path);
+#ifdef RELEASE_BUILD
+ static EFrameworkunifiedStatus PathCheckAndCopyFile(std::string f_source,
+ std::string f_destination);
+#endif // RELEASE_BUILD
+ void SetUsbMountPath(std::string usbpath);
+
+ private:
+ std::string GetUserInvokedFilename(HANDLE f_hApp, uint32_t f_time);
+ std::string GetEmmcFilename(uint32_t f_time);
+ std::string GetEmmcErrorFilename(uint32_t f_time);
+ std::string GetEmmcNaviLogFilename(uint32_t f_time);
+ std::string GetTimeString(uint32_t f_time);
+
+ EFrameworkunifiedStatus getNaviLogFilePathAndName(std::string &f_prefix, uint32_t f_time, // NOLINT (runtime/references)
+ std::string &f_pathAndName); // NOLINT (runtime/references)
+
+ CLoggerCfg *m_pCfg;
+ UI_32 m_Milage;
+ UI_32 m_bootCount;
+ static char m_usbpath[USB_PATH_SIZE];
+};
+
+#endif // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_UTIL_H_
+
diff --git a/logger_service/server/lib/Makefile b/logger_service/server/lib/Makefile
new file mode 100644
index 00000000..113a7a4f
--- /dev/null
+++ b/logger_service/server/lib/Makefile
@@ -0,0 +1,62 @@
+#
+# @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+######### installed program #############
+
+
+######### installed library(*.a) #############
+INST_LIBS = libSS_LoggerStoreLogs
+
+######### installed shared library(*.so) #############
+
+
+######### install headers(*.h) #############
+
+
+######### compiled sources #############
+libSS_LoggerStoreLogs_SRCS += ss_logger_store_logs.cpp
+
+######### add source path #############
+
+
+######### add include path #############
+CPPFLAGS += -I./
+CPPFLAGS += -I../include
+
+CPPFLAGS += -Wl,--no-undefined
+CPPFLAGS += -Werror=implicit-function-declaration
+CPPFLAGS += -Werror=format-security
+
+CPPFLAGS += -Wconversion
+CPPFLAGS += -Wint-to-pointer-cast
+CPPFLAGS += -Wpointer-arith
+CPPFLAGS += -Wformat
+
+######### add compile option #############
+CPPFLAGS += -DLINUX
+CPPFLAGS += -DFRAMEWORKUNIFIEDLOGOPTIONS=0x08 -DFRAMEWORKUNIFIEDLOGAPPZONES=31,30
+CPPFLAGS += -fno-exceptions
+
+######### linked library #############
+
+
+######### linked library (dynamic) #############
+
+
+######### add library path #############
+LDFLAGS += -g -shared
+LDFLAGS += -Wl,--no-as-needed
+include ../../../system_service.mk
diff --git a/logger_service/server/lib/ss_logger_store_logs.cpp b/logger_service/server/lib/ss_logger_store_logs.cpp
new file mode 100644
index 00000000..d54ca9c2
--- /dev/null
+++ b/logger_service/server/lib/ss_logger_store_logs.cpp
@@ -0,0 +1,2270 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SystemServices_Logger
+/// \brief This file supports the logger service interface for SystemManager.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "system_service/ss_logger_store_logs.h"
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <libtar_listhash.h>
+#include <libtar.h>
+#include <zlib.h>
+#include <sys/klog.h>
+
+#include <stdlib.h>
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_types.h>
+#include <native_service/frameworkunified_framework_types.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <system_service/ss_system_types.h>
+#include <native_service/ns_ringbuffer.h>
+#include <native_service/ns_logger_if.h>
+#include <native_service/ns_config_parser_if.h>
+#include <native_service/cl_lockid.h>
+//#include <vehicle_service/Clock_API.h>
+#include <vector>
+#include <sstream>
+#include <iomanip>
+#include <string>
+#include <algorithm>
+#include "ss_logger_store_logs_loggerservicelog.h"
+
+#define LOGGERSERVICELOG_CONFIG_PATH "/usr/agl/share/systemmanager/scfg/ss_logger.cfg"
+#define LOGGER_TMP_FN "__LOGGER.tmp"
+#define LOGGERSERVICELOG_TMP_OUTPUT_PATH "/tmp"
+#define PSTORE_DIR_PATH "/dev/pstore"
+#define KERNEL_BOOT_LOG_FN "kernelboot.log"
+#define KERNEL_LOG_FN "kernel.log"
+#define CONNECTIVITY_DIR_NAME "connectivity"
+#define COMMUNICATION_DIR_NAME "communication"
+#define RADIO_DIR_NAME "radio"
+#define GRAPHICS_FN_LOG_FN "graphics.log"
+#define SYSLOG_DIR_NAME "syslog"
+#define WINSYS_LOG_FN "winsys.log"
+#define APPFW_DIR_NAME "appfw"
+#define TOMOYO_DIR_PATH "/nv/ptdata/sec"
+#define TOMOYO_DIR_NAME "tomoyo"
+#define ACCOFFON_DIR_NAME "accoffon"
+
+#define PATHNAME_SEPARATOR '/'
+#define PATHNAME_SEPARATOR_STR "/"
+#define SS_STORE_FILENAME_SYSILG_TERM "_SYS_ILG_RESET.tar.gz"
+#define SS_STORE_FILENAME__CWORD52__TERM "__CWORD52_.log"
+#define LOGARCHIVE_FILENAME_STORE_ARCHIVE "/tmp/ss_logger_ilgfilenum"
+#define TMPFILE_MODE 0640
+#define SSLOGGER_PATHNAME (255 + 1)
+#define FILENUMBER_UPPER_LIMIT_OVER 100000u
+#define FILENUMBER_LOWER_LIMIT 1u
+#define FILENUMBER_DIGIT_NUM 5
+#define INVALID_FILENUMBER (FILENUMBER_UPPER_LIMIT_OVER)
+
+
+/* Read all messages remaining in the ring buffer. (allowed for non-root) */
+#define SYSLOG_ACTION_READ_ALL 3
+/* Return size of the log buffer */
+#define SYSLOG_ACTION_SIZE_BUFFER 10
+
+#define ENABLE_DEBUG_LOG 0
+#if ENABLE_DEBUG_LOG
+#define DEB_LOGGERSERVICELOG(zone,funcname,print_fmt, ...) if(zone!=ZONE_FUNC) \
+fprintf(stderr,"%d/%s/%d:="print_fmt"\n", zone, funcname, __LINE__,##__VA_ARGS__)
+#else
+#define DEB_LOGGERSERVICELOG(zone,funcname,print_fmt, ...)
+#endif
+
+typedef struct {
+ std::string output_path;
+ SI_32 output_max;
+ SI_32 output_errmax;
+} CfgInfo;
+
+typedef struct {
+ std::string file_path;
+ std::string dest_name;
+ BOOL tmp_file_delete;
+} LogInfo;
+
+typedef struct {
+ std::string path;
+ int index;
+} LoggerservicelogInfo;
+
+
+static const char* sys_illegal_log[] = {
+ "frameworkunified_sys.log",
+ };
+
+
+typedef enum {
+ SS_STORELOGS_KERNEL_LOG = 0,
+ SS_STORELOGS_KERNEL_BOOT_LOG
+} SS_STORELOGS_KERNEL_LOG_TYPE;
+
+typedef void (*GetLogFileFunc)(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list); // NOLINT (runtime/references)
+
+static const UI_8 MAX_DIRECTORY_DEPTH = 4;
+static const UI_32 TARMODE = 0644;
+
+static EFrameworkunifiedStatus addToArchive(TAR* f_pTarInfo, std::string f_filePathAndName,
+ std::string f_destinationName, UI_8 f_depth =
+ MAX_DIRECTORY_DEPTH);
+static EFrameworkunifiedStatus addDirectoryToArchive(TAR* f_pTarInfo, std::string f_path,
+ std::string f_destinationName,
+ UI_8 f_depth = MAX_DIRECTORY_DEPTH);
+static SI_32 gzOpenArchive(PCHAR f_pcPathname, SI_32 f_siOflags,
+ SI_32 f_siMode);
+static SI_32 gzCloseArchive();
+static ssize_t gzWriteArchive(int fd, const void* buf, size_t count);
+static ssize_t gzReadArchive(int fd, void* buf, size_t count);
+static EFrameworkunifiedStatus addFileToArchive(TAR* f_pTarInfo, std::string f_filename,
+ std::string f_destinationName);
+static EFrameworkunifiedStatus addAllFileToArchive (TAR* f_pTarInfo, std::string collectDir);
+static EFrameworkunifiedStatus copyFile(std::string f_source, std::string f_destination);
+static EFrameworkunifiedStatus copyDirectory (std::string f_source, std::string f_destination);
+static EFrameworkunifiedStatus copyUntyped (std::string f_source, std::string f_destination);
+static EFrameworkunifiedStatus copyFileToAccOffOnDir(std::vector<LogInfo>& list, SS_STORELOGS_OPE_TYPE type);
+static void getLoggerservicelogFile(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list, // NOLINT (runtime/references)
+ std::vector<LoggerservicelogInfo> &loggerservicelogList); // NOLINT (runtime/references)
+static void getKernellogFile(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list); // NOLINT (runtime/references)
+static void getLastKernelLog(std::vector<LogInfo>& list); // NOLINT (runtime/references)
+static void getKernelLog(std::vector<LogInfo>& list); // NOLINT (runtime/references)
+static void getKernelBootLog(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list); // NOLINT (runtime/references)
+static void getConnectivitylogFile(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list); // NOLINT (runtime/references)
+static void getRadiologFile(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list); // NOLINT (runtime/references)
+static void getCommunicationlogFile(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list); // NOLINT (runtime/references)
+static void getGraphicslogFile(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list); // NOLINT (runtime/references)
+static void getSyslogFile(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list); // NOLINT (runtime/references)
+static void getWinSyslogFile(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list); // NOLINT (runtime/references)
+static void getAppFwlogFile(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list); // NOLINT (runtime/references)
+static void getTomoyologFile(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list); // NOLINT (runtime/references)
+
+//static std::string getFileName(std::string &path, uint32_t f_time, // NOLINT (runtime/references)
+// SS_STORELOGS_OPE_TYPE type);
+static std::string getFileName(std::string &path, uint32_t f_time, // NOLINT (runtime/references)
+ SS_STORELOGS_OPE_TYPE type, UI_32 l_counter);
+
+static void getEmmcCounter(std::string &path, UI_32& f_counter); // NOLINT (runtime/references)
+static void getConfigInfo(CfgInfo& f_cfginfo); // NOLINT (runtime/references)
+static EFrameworkunifiedStatus deleteOldEmmcLog(CfgInfo& f_cfginfo, // NOLINT (runtime/references)
+ std::string& f_archive_destination, // NOLINT (runtime/references)
+ SS_STORELOGS_OPE_TYPE type);
+static EFrameworkunifiedStatus storeLogs(SS_STORELOGS_OPE_TYPE type);
+static EFrameworkunifiedStatus deleteOldLog(std::string log_path,
+ std::vector<std::string>& l_vector, // NOLINT (runtime/references)
+ std::string& f_archive_destination, // NOLINT (runtime/references)
+ UI_32 max_num);
+static size_t deleteRequestLogs(std::string f_emmcpath, ELOGGERSERVICELOGTYPE f_reqtype,
+ size_t f_reqsize, ELOGGERSERVICELOGTYPE f_deltype);
+static EFrameworkunifiedStatus forceDeleteOldLog(std::string f_archive_destination,
+ size_t f_req_size);
+static ELOGGERSERVICELOGTYPE QueryLoggerservicelogType(std::string f_logname);
+static void SyncDir(std::string f_dir_path);
+static BOOL RemoveSubDirectory(std::string &f_cPath); // NOLINT (runtime/references)
+static void CreateSaveFinFlag(SS_STORELOGS_OPE_TYPE type);
+static void ClearLoggerservicelogBuffer(std::vector<LoggerservicelogInfo> &loggerservicelogList); // NOLINT (runtime/references)
+static void copyLoggerservicelogFile(std::string distPath);
+static void deleteTmpAccOffOn(std::string accOffOnDir);
+static void deleteAccOffOnDir(std::string deletePath);
+static void deleteAccOffOnUntyped(std::string deletePath);
+
+static EFrameworkunifiedStatus getFileNumber(const std::string &filename,UI_32 &number);
+static bool compareFileNumber(UI_32 filename1_number,const std::string &filename2);
+static EFrameworkunifiedStatus removeFiles(const std::string &log_path, std::vector<std::string> &l_vector,
+ size_t begin_pos, size_t end_pos);
+static EFrameworkunifiedStatus removeSameNumFiles(std::vector<std::string>::iterator &itr, const std::string &log_path,
+ std::vector<std::string> &l_vector);
+static EFrameworkunifiedStatus deleteOldLogAbnrm(const std::string& log_path, std::vector<std::string>& l_vector,
+ const std::string& f_archive_destination, SI_32 max_num, UI_32 abnrm_total);
+static EFrameworkunifiedStatus storeTempArchive(const std::string &real_name);
+static EFrameworkunifiedStatus getFileNumberFromTempArchive(UI_32 &filenumber);
+
+
+static std::string m_pathAndName; // NOLINT (runtime/string)
+static std::string m_tmpName; // NOLINT (runtime/string)
+
+const GetLogFileFunc GetLogFuncTbl[] = { getKernellogFile,
+ getConnectivitylogFile, getRadiologFile, getCommunicationlogFile,
+ getGraphicslogFile, getSyslogFile, getWinSyslogFile, getAppFwlogFile,
+ getTomoyologFile
+ };
+// GZF save variables
+static gzFile g_gztype;
+
+// ->Bus-Error avoidance
+static tartype_t l_gztype;
+
+static EFrameworkunifiedStatus openArchive(TAR** f_pTarInfo, std::string f_pathAndName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+// ->Bus-Error avoidance (because of local variables, content becomes indeterminate when functions exit)
+// tartype_t l_gztype;
+
+ *f_pTarInfo = NULL;
+ g_gztype = NULL;
+ l_gztype.openfunc = (openfunc_t) &gzOpenArchive;
+ l_gztype.closefunc = (closefunc_t) &gzCloseArchive;
+ l_gztype.readfunc = (readfunc_t) &gzReadArchive;
+ l_gztype.writefunc = (writefunc_t) &gzWriteArchive;
+
+ m_pathAndName = f_pathAndName;
+
+ /* check if directory exists */
+ size_t l_found = f_pathAndName.find_last_of('/');
+ std::string l_path = f_pathAndName.substr(0, l_found);
+
+ if (0 != access(l_path.c_str(), F_OK)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Directory does not exist. Creating...");
+ return eFrameworkunifiedStatusFail;
+ }
+
+ /* create archive in tmp */
+ m_tmpName = "/tmp/log.tar.gz";
+
+ int l_tarRetVal = tar_open(f_pTarInfo, const_cast<char*>(m_tmpName.c_str()), &l_gztype,
+ O_WRONLY | O_CREAT, TARMODE, TAR_GNU);
+
+ if ((l_tarRetVal != 0) || (*f_pTarInfo == NULL) || g_gztype == NULL) { // LCOV_EXCL_BR_LINE 6: tar_open must return ok // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 6: tar_open must return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Could not open TAR-Archive!");
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusAccessError;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eFrameworkunifiedStatus);
+}
+
+static EFrameworkunifiedStatus addToArchive(TAR* f_pTarInfo, std::string f_filePathAndName,
+ std::string f_destinationName, UI_8 f_depth) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusFileLoadError;
+ struct stat l_stat;
+ int l_statRetVal;
+
+ if (0 != access(f_filePathAndName.c_str(), F_OK)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. The specified file path and name does not exist: %s",
+ f_filePathAndName.c_str());
+ } else if (0 != (l_statRetVal = stat(f_filePathAndName.c_str(), &l_stat))) { // LCOV_EXCL_BR_LINE 5: stat's error case // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 5: stat's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. stat() for file or directory returned error: %s -> %d",
+ f_filePathAndName.c_str(), l_statRetVal);
+ // LCOV_EXCL_STOP
+ } else if (0 != S_ISDIR(l_stat.st_mode)) {
+ if (0 < f_depth) { // LCOV_EXCL_BR_LINE 6: f_depth must be greater than 0
+ l_eFrameworkunifiedStatus = addDirectoryToArchive(f_pTarInfo, f_filePathAndName,
+ f_destinationName, f_depth);
+ } else {
+ // LCOV_EXCL_START 6: f_depth must be greater than 0
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ "Maximum recursive depth reached! File %s not added to archive.",
+ f_filePathAndName.c_str());
+ // LCOV_EXCL_STOP
+ }
+ } else if (0 != S_ISREG(l_stat.st_mode)) {
+ char path[PATH_MAX];
+ if (realpath(f_filePathAndName.c_str(), path) != NULL) {
+ f_filePathAndName = path;
+ l_eFrameworkunifiedStatus = addFileToArchive(f_pTarInfo, f_filePathAndName,
+ f_destinationName);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ "Archive not opened or could not access file: \"%s\"",
+ f_filePathAndName.c_str());
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. specified file may be a symbolic link or other non 'regular' type. File: %s, mode: 0x%04X.",
+ f_filePathAndName.c_str(), l_stat.st_mode);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eFrameworkunifiedStatus);
+}
+
+
+static EFrameworkunifiedStatus getFileNumberFromTempArchive(UI_32 &filenumber)
+{
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ char buf[FILENUMBER_DIGIT_NUM + 1];
+ int fd;
+ int result;
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ fd = open(LOGARCHIVE_FILENAME_STORE_ARCHIVE, O_RDONLY);
+ if (fd == -1) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR,__FUNCTION__," Error. open(). path = %s ,errno = %d", LOGARCHIVE_FILENAME_STORE_ARCHIVE, errno);
+ return eFrameworkunifiedStatusAccessError;
+ }
+
+ result = read(fd, buf, FILENUMBER_DIGIT_NUM);
+ if (result != FILENUMBER_DIGIT_NUM) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR,__FUNCTION__," Error. read(). path = %s ,result = %d, errno = %d",
+ LOGARCHIVE_FILENAME_STORE_ARCHIVE, result, errno);
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusAccessError;
+ } else {
+ char *endptr;
+ int error_number;
+ int temp_value;
+ buf[FILENUMBER_DIGIT_NUM] = '\x0';
+ errno = EOK;
+ temp_value = strtol(buf, &endptr, 10);
+ error_number = errno;
+ if ((error_number != EOK) || (*endptr != '\x0')) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR,__FUNCTION__," Error. Failed to comvert string. source = %s ,errno = %d", buf, errno);
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ } else {
+ filenumber = temp_value;
+ }
+ }
+ result = close(fd);
+ if (result != 0) { // LCOV_EXCL_BR_LINE 6: close() must return ok
+ // LCOV_EXCL_START 6: close() must return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR,__FUNCTION__," Error. close(). path = %s ,errno = %d", LOGARCHIVE_FILENAME_STORE_ARCHIVE, errno);
+ // LCOV_EXCL_STOP
+ }
+ result = remove(LOGARCHIVE_FILENAME_STORE_ARCHIVE);
+ if (result != 0) { // LCOV_EXCL_BR_LINE 6: remove() must return ok
+ // LCOV_EXCL_START 6: remove() must return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR,__FUNCTION__," Error. remove(). path = %s ,errno = %d", LOGARCHIVE_FILENAME_STORE_ARCHIVE, errno);
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eFrameworkunifiedStatus;
+}
+
+static EFrameworkunifiedStatus storeTempArchive(const std::string &real_name)
+{
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ std::string filename;
+ size_t pos;
+ int fd;
+ int result;
+ const char *p_real_filename;
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ fd = open(LOGARCHIVE_FILENAME_STORE_ARCHIVE, O_CREAT | O_WRONLY, TMPFILE_MODE);
+ if (fd == -1) { // LCOV_EXCL_BR_LINE 5: open's error case
+ // LCOV_EXCL_START 5: open's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR,__FUNCTION__," Error. open(). path = %s ,errno = %d", LOGARCHIVE_FILENAME_STORE_ARCHIVE, errno);
+ return eFrameworkunifiedStatusAccessError;
+ // LCOV_EXCL_STOP
+ }
+
+ pos = real_name.find_last_of(PATHNAME_SEPARATOR);
+ if (pos == std::string::npos) { // LCOV_EXCL_BR_LINE 6: there must be '/' in string real_name
+ // LCOV_EXCL_START 6: there must be '/' in string real_name
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ p_real_filename = real_name.c_str();
+ // LCOV_EXCL_STOP
+ } else {
+ p_real_filename = &real_name[pos + 1];
+ }
+
+ result = write(fd, p_real_filename, FILENUMBER_DIGIT_NUM);
+ if (result != FILENUMBER_DIGIT_NUM) { // LCOV_EXCL_BR_LINE 5: write's error case
+ // LCOV_EXCL_START 5: write's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR,__FUNCTION__," Error. write(). path = %s ,result = %d, errno = %d",
+ LOGARCHIVE_FILENAME_STORE_ARCHIVE, result, errno);
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusAccessError;
+ // LCOV_EXCL_STOP
+ }
+
+ result = close(fd);
+ if (result != 0) { // LCOV_EXCL_BR_LINE 5: close's error case
+ // LCOV_EXCL_START 5: close's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR,__FUNCTION__," Error. close(). path = %s ,errno = %d", LOGARCHIVE_FILENAME_STORE_ARCHIVE, errno);
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusAccessError;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eFrameworkunifiedStatus;
+}
+
+
+
+//static EFrameworkunifiedStatus closeArchive(TAR* f_pTarInfo) {
+static EFrameworkunifiedStatus closeArchive(TAR* f_pTarInfo, SS_STORELOGS_OPE_TYPE type) {
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if (0 != tar_append_eof(f_pTarInfo)) { // LCOV_EXCL_BR_LINE 5: tar_append_eof's error case
+ // LCOV_EXCL_START 5: tar_append_eof's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "tar_append_eof()");
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+ if (0 != tar_close(f_pTarInfo)) { // LCOV_EXCL_BR_LINE 5: tar_close's error case
+ // LCOV_EXCL_START 5: tar_close's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Could not close archive");
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+
+ if (eFrameworkunifiedStatusOK == l_eFrameworkunifiedStatus) { // LCOV_EXCL_BR_LINE 6: l_eFrameworkunifiedStatus must be eFrameworkunifiedStatusOK
+ l_eFrameworkunifiedStatus = copyFile(m_tmpName, m_pathAndName);
+ if (eFrameworkunifiedStatusOK == l_eFrameworkunifiedStatus) {
+
+ if (type == SS_STORELOGS_ILLEGAL) {
+ l_eFrameworkunifiedStatus = storeTempArchive(m_pathAndName);
+ if (eFrameworkunifiedStatusOK != l_eFrameworkunifiedStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error. Failed to store temporary file.");
+ }
+ }
+
+ l_eFrameworkunifiedStatus =
+ (0 == remove(m_tmpName.c_str())) ? eFrameworkunifiedStatusOK : eFrameworkunifiedStatusFault;
+ if (eFrameworkunifiedStatusOK != l_eFrameworkunifiedStatus) { // LCOV_EXCL_BR_LINE 5: remove's error case
+ // LCOV_EXCL_START 5: remove's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_WARN,
+ __FUNCTION__,
+ " Warning. Failed to remove temporary archive. Will overwrite on next event");
+ // LCOV_EXCL_STOP
+ }
+ } else if (eFrameworkunifiedStatusErrNoEAGAIN == l_eFrameworkunifiedStatus) { // LCOV_EXCL_BR_LINE 4: no space error case
+ // LCOV_EXCL_START 4: no space error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // disk space full
+ struct stat st_buf;
+ size_t req_size;
+ if (stat(m_tmpName.c_str(), &st_buf) != -1) {
+ req_size = st_buf.st_size;
+ if (eFrameworkunifiedStatusOK == forceDeleteOldLog(m_pathAndName, req_size)) {
+ l_eFrameworkunifiedStatus = copyFile(m_tmpName, m_pathAndName);
+ if (eFrameworkunifiedStatusOK != l_eFrameworkunifiedStatus) {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ "Try Again but Error. Failed to copy to destination.%s, size=%d",
+ m_pathAndName.c_str(), req_size);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error. force delete failed.%s, size=%d",
+ m_pathAndName.c_str(), req_size);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " emmc full: dest=%s, size=%d",
+ m_pathAndName.c_str(), req_size);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Warning. Failed to get tmp log file stat. dest=%s",
+ m_pathAndName.c_str());
+ }
+ // LCOV_EXCL_STOP
+ } else {
+ /* should we copy lost archive to emmc?? */
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Failed to copy to destination. %s", m_pathAndName.c_str());
+ }
+ remove(m_tmpName.c_str());
+ m_tmpName = "";
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eFrameworkunifiedStatus);
+}
+
+static EFrameworkunifiedStatus addFileToArchive(TAR* f_pTarInfo, std::string f_filename,
+ std::string f_destinationName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK; /* check if Tar is open and if file can be read */
+
+ if ((NULL != f_pTarInfo) && (0 == access(f_filename.c_str(), R_OK))
+ && (0 != f_destinationName.length())) {
+ int l_tarRetVal = tar_append_file(f_pTarInfo, const_cast<char*>(f_filename.c_str()),
+ const_cast<char*>(f_destinationName.c_str()));
+ if (0 != l_tarRetVal) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Could not add file \'%s\' to tar archive.", f_filename.c_str());
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusAccessError;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Archive not opened or could not access file: \"%s\"",
+ f_filename.c_str());
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eFrameworkunifiedStatus);
+}
+
+static EFrameworkunifiedStatus addAllFileToArchive (TAR* f_pTarInfo, std::string collectDir)
+{
+ struct dirent l_pDirent;
+ struct dirent* next;
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ DEB_LOGGERSERVICELOG(ZONE_FUNC, __FUNCTION__, "+");
+ DIR * l_pDir = opendir(collectDir.c_str());
+ if (l_pDir == NULL) {
+ DEB_LOGGERSERVICELOG(ZONE_ERR, __FUNCTION__, "Could not open directory: %s", collectDir.c_str());
+ } else {
+ while (0 == readdir_r(l_pDir,&l_pDirent,&next) && next != NULL) {
+ if ( ( 0 != strcmp( l_pDirent.d_name, "." ) ) &&
+ ( 0 != strcmp( l_pDirent.d_name, ".." )) &&
+ ( 0 != strcmp( l_pDirent.d_name, "lost+found" )) &&
+ ( '.' != l_pDirent.d_name[0] ) ) {
+ std::string l_fileSource = collectDir;
+ l_fileSource.append("/");
+ l_fileSource.append(l_pDirent.d_name);
+ std::string l_fileDestination = l_pDirent.d_name;
+ l_eStatus = addToArchive(f_pTarInfo,l_fileSource,l_fileDestination);
+ if (l_eStatus != eFrameworkunifiedStatusOK) {
+ break;
+ }
+ }
+ }
+ closedir (l_pDir);
+ }
+ DEB_LOGGERSERVICELOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+static EFrameworkunifiedStatus addDirectoryToArchive(TAR* f_pTarInfo, std::string f_path,
+ std::string f_destinationName,
+ UI_8 f_depth) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ DIR *l_pDir = opendir(f_path.c_str());
+ if (l_pDir != NULL) {
+ struct dirent* l_pDirent;
+ while ((l_pDirent = readdir(l_pDir)) != NULL) {
+ if ((0 != strcmp(l_pDirent->d_name, ".")) && /* Ignore special . directory. */
+ (0 != strcmp(l_pDirent->d_name, "..")) && /* Ignore special .. directory. */
+ ('.' != l_pDirent->d_name[0])) { /* Ignore hidden files */
+ std::string l_extension = "/";
+ std::string l_fileName = f_path;
+ std::string l_destName = f_destinationName;
+ l_extension.append(l_pDirent->d_name);
+ l_fileName.append(l_extension);
+ l_destName.append(l_extension);
+ l_eFrameworkunifiedStatus = addToArchive(f_pTarInfo, l_fileName, l_destName,
+ static_cast<UI_8>(f_depth - 1));
+ }
+ }
+ closedir(l_pDir);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eFrameworkunifiedStatus);
+}
+
+static SI_32 gzOpenArchive(PCHAR f_pcPathname, SI_32 f_siOflags,
+ SI_32 f_siMode) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ SI_32 l_siFileDescriptor = -1;
+
+ if (f_pcPathname) {
+ PCHAR l_pcGzoflags;
+
+ switch (f_siOflags & O_ACCMODE) { // LCOV_EXCL_BR_LINE 200: only O_WRONLY be set
+ case O_WRONLY:
+ l_pcGzoflags = (PCHAR) "wb";
+ break;
+ // LCOV_EXCL_START 200: only O_WRONLY be set
+ case O_RDONLY:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_pcGzoflags = (PCHAR) "rb";
+ break;
+ // LCOV_EXCL_STOP
+ case O_RDWR:
+ default:
+ return -1;
+ }
+ if (-1 == (l_siFileDescriptor = open(f_pcPathname, f_siOflags, f_siMode))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return -1;
+ }
+
+ if ((f_siOflags & O_CREAT) && fchmod(l_siFileDescriptor, f_siMode)) {
+ close(l_siFileDescriptor);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return -1;
+ }
+
+ g_gztype = gzdopen(l_siFileDescriptor, l_pcGzoflags);
+ if (!g_gztype) {
+ close(l_siFileDescriptor);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return -1;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Source Path empty.");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (SI_32) l_siFileDescriptor;
+}
+
+static SI_32 gzCloseArchive() {
+ return gzclose(g_gztype);
+}
+
+static ssize_t gzWriteArchive(int fd, const void* buf, size_t count) {
+ return gzwrite(g_gztype, const_cast<void*>(buf), (unsigned int) count);
+}
+
+static ssize_t gzReadArchive(int fd, void* buf, size_t count) {
+ return gzread(g_gztype, buf, (unsigned int) count);
+}
+
+static EFrameworkunifiedStatus copyFile(std::string f_source, std::string f_destination) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ ssize_t l_nrd;
+ ssize_t l_nwr;
+ char l_buf[1024];
+
+ int l_if = open(f_source.c_str(), O_RDONLY | O_CLOEXEC);
+ if (-1 == l_if) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error. Failed to open file: %s for reading.", f_source.c_str());
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ std::string l_tmpDest;
+ size_t l_pos = f_destination.find_last_of('/');
+
+ if (std::string::npos != l_pos) { // LCOV_EXCL_BR_LINE 6: there must be '/' in string f_destination
+ l_tmpDest = f_destination.substr(0, l_pos);
+ l_tmpDest.append("/");
+ l_tmpDest.append(LOGGER_TMP_FN);
+ if (unlink(l_tmpDest.c_str()) != 0) {
+ // always delete tmpLog, and create new tmpLog.
+ }
+ } else {
+ // LCOV_EXCL_START 6: there must be '/' in string f_destination
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_tmpDest = f_destination;
+ // LCOV_EXCL_STOP
+ }
+
+ int l_of = open(l_tmpDest.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC,
+ 0640);
+ if (-1 == l_of) { // LCOV_EXCL_BR_LINE 5: open's error case
+ // LCOV_EXCL_START 5: open's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "dest open fail:%s,errno:%d,msg:%s",
+ l_tmpDest.c_str(), errno, strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ } else {
+ do {
+ l_nrd = read(l_if, l_buf, sizeof(l_buf));
+ if (l_nrd == -1) { // LCOV_EXCL_BR_LINE 5: read's error case
+ // LCOV_EXCL_START 5: read's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "read fail:%s,errno:%d,msg:%s",
+ f_source.c_str(), errno, strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusAccessError;
+ break;
+ // LCOV_EXCL_STOP
+ }
+ l_nwr = write(l_of, l_buf, l_nrd);
+ if (l_nwr == -1) { // LCOV_EXCL_BR_LINE 5: write's error case
+ // LCOV_EXCL_START 5: write's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (ENOSPC == errno) { // LCOV_EXCL_BR_LINE 4: no space error case
+ // LCOV_EXCL_START 4: no space error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "write fail(ENOSPC):%s,errno:%d,msg:%s", l_tmpDest.c_str(),
+ errno, strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusErrNoEAGAIN;
+ // LCOV_EXCL_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "write fail:%s,errno:%d,msg%s",
+ l_tmpDest.c_str(), errno, strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusAccessError;
+ }
+ break;
+ // LCOV_EXCL_STOP
+ }
+ } while (l_nrd > 0);
+ fsync(l_of);
+ close(l_of);
+ }
+ close(l_if);
+
+ if (rename(l_tmpDest.c_str(), f_destination.c_str()) != 0) { // LCOV_EXCL_BR_LINE 5: rename's error case
+ // LCOV_EXCL_START 5: rename's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "rename %s to %s fail,errno:%d,msg:%s",
+ l_tmpDest.c_str(), f_destination.c_str(), errno, strerror(errno));
+ // LCOV_EXCL_STOP
+ }
+
+ if (std::string::npos != l_pos) { // LCOV_EXCL_BR_LINE 6: there must be '/' in string f_destination
+ std::string l_destPath = f_destination.substr(0, l_pos);
+ SyncDir(l_destPath);
+ } else {
+ // LCOV_EXCL_START 6: there must be '/' in string f_destination
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "dest invalid:%s", f_destination.c_str());
+ // LCOV_EXCL_STOP
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+static EFrameworkunifiedStatus copyDirectory (std::string f_source, std::string f_destination)
+{
+ DEB_LOGGERSERVICELOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ DIR * l_pDir = opendir(f_source.c_str());
+ if (l_pDir == NULL) {
+ DEB_LOGGERSERVICELOG(ZONE_ERR, __FUNCTION__, "Could not open directory: %s", f_source.c_str());
+ } else {
+ if (mkdir(f_destination.c_str(),0775) == -1) {
+ if (errno == EEXIST) {
+ DEB_LOGGERSERVICELOG(ZONE_FUNC, __FUNCTION__, "Directory: %s already exists.", f_destination.c_str());
+ } else {
+ DEB_LOGGERSERVICELOG(ZONE_ERR, __FUNCTION__, "Could not create directory: %s. Errno: %s", f_destination.c_str(),strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ SyncDir(f_destination);
+ size_t l_pos = f_destination.find_last_of('/');
+ if (l_pos != std::string::npos) {
+ std::string l_destPath = f_destination.substr(0, l_pos);
+ SyncDir(l_destPath);
+ }
+ }
+
+ struct dirent l_pDirent;
+ struct dirent* next;
+ while (0 == readdir_r(l_pDir,&l_pDirent,&next) && next != NULL) {
+ if ( ( 0 != strcmp( l_pDirent.d_name, "." ) ) &&
+ ( 0 != strcmp( l_pDirent.d_name, ".." )) &&
+ ( 0 != strcmp( l_pDirent.d_name, "lost+found" )) &&
+ ( '.' != l_pDirent.d_name[0] ) ) {
+ std::string l_fileSource = f_source;
+ std::string l_fileDestination = f_destination;
+ l_fileSource.append("/");
+ l_fileSource.append(l_pDirent.d_name);
+ l_fileDestination.append("/");
+ l_fileDestination.append(l_pDirent.d_name);
+ l_eStatus = copyUntyped(l_fileSource,l_fileDestination);
+ }
+ }
+ closedir (l_pDir);
+ }
+ DEB_LOGGERSERVICELOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+static EFrameworkunifiedStatus copyUntyped (std::string f_source, std::string f_destination)
+{
+ DEB_LOGGERSERVICELOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ struct stat l_stat;
+ SI_8 l_statRetVal;
+ if (0 != access(f_source.c_str(), F_OK)) {
+ DEB_LOGGERSERVICELOG(ZONE_ERR,__FUNCTION__," Error. The specified file path and name does not exist: %s", f_source.c_str());
+ } else if (0 != (l_statRetVal = lstat(f_source.c_str(), &l_stat))) {
+ DEB_LOGGERSERVICELOG(ZONE_ERR,__FUNCTION__," Error. stat() for file or directory returned error: %s -> %d", f_source.c_str(), l_statRetVal);
+ } else if (0 != S_ISDIR(l_stat.st_mode)) {
+ l_eStatus = copyDirectory(f_source, f_destination);
+ } else if (0 != S_ISLNK(l_stat.st_mode)) {
+ l_eStatus = copyDirectory(f_source, f_destination);
+ } else if (0 != S_ISREG(l_stat.st_mode)) {
+ l_eStatus = copyFile(f_source, f_destination);
+ } else {
+ DEB_LOGGERSERVICELOG(ZONE_ERR,__FUNCTION__," Error. specified file may be a symbolic link or other non 'regular' type. File: %s, mode: 0x%04X.",f_source.c_str(),l_stat.st_mode);
+ }
+ DEB_LOGGERSERVICELOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+static EFrameworkunifiedStatus copyFileToAccOffOnDir(std::vector<LogInfo>& list, SS_STORELOGS_OPE_TYPE type)
+{
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+ std::string f_destination = LOGGERSERVICELOG_TMP_OUTPUT_PATH;
+ f_destination.append("/");
+ f_destination.append(ACCOFFON_DIR_NAME);
+ DIR * l_pDir = opendir(LOGGERSERVICELOG_TMP_OUTPUT_PATH);
+ if (l_pDir == NULL) {
+ DEB_LOGGERSERVICELOG(ZONE_ERR, __FUNCTION__, "Could not open directory: %s", LOGGERSERVICELOG_TMP_OUTPUT_PATH);
+ l_eStatus = eFrameworkunifiedStatusFail;
+ return l_eStatus;
+ } else {
+ closedir (l_pDir);
+ if (mkdir(f_destination.c_str(), 0775) == -1) {
+ DEB_LOGGERSERVICELOG(ZONE_ERR, __FUNCTION__, "Could not create directory: %s. Errno: %s", f_destination.c_str(),strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusFail;
+ return l_eStatus;
+ }
+ } if (list.size() != 0) {
+ for (UI_32 j = 0; j < list.size(); j++) {
+ std::string dest_name = f_destination;
+ dest_name.append("/");
+ dest_name.append(list.at(j).dest_name);
+ l_eFrameworkunifiedStatus = copyUntyped(list.at(j).file_path, dest_name);
+ if (l_eFrameworkunifiedStatus != eFrameworkunifiedStatusOK) {
+ DEB_LOGGERSERVICELOG(ZONE_WARN, __FUNCTION__, " Error. File %s failed to archive.", list.at(j).file_path.c_str());
+ l_eStatus = l_eFrameworkunifiedStatus;
+ }
+ }
+ copyLoggerservicelogFile(f_destination);
+ }
+ return l_eStatus;
+}
+
+ELOGGERSERVICELOGTYPE QueryLoggerservicelogType(std::string f_logname) {
+// if (f_logname.find("_ILG_RESET.tar.gz") != std::string::npos
+ if (f_logname.find(SS_STORE_FILENAME_SYSILG_TERM) != std::string::npos) {
+ return eLoggerservicelogTypeSysAbnormal;
+ } else if (f_logname.find(SS_STORE_FILENAME__CWORD52__TERM) != std::string::npos) {
+ return eLoggerservicelogType_CWORD52_;
+ } else if (f_logname.find("_ILG_RESET.tar.gz") != std::string::npos
+
+ || f_logname.find("_ERR.tar.gz") != std::string::npos) {
+ return eLoggerservicelogTypeAbnormal;
+ } else if (f_logname.find("_GRP_RELAUNCH.tar.gz") != std::string::npos) {
+ return eLoggerservicelogTypeGrpRelaunch;
+ } else if (f_logname.find(".tar.gz") != std::string::npos) {
+ return eLoggerservicelogTypeNormal;
+ } else {
+ return eLoggerservicelogTypeOther;
+ }
+}
+
+void SyncDir(std::string f_dir_path) {
+ int fd = open(f_dir_path.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC);
+#define OPE_ERR_MSG "%s %s failed. errno:%d,msg:%s"
+ if (fd == -1) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, OPE_ERR_MSG, f_dir_path.c_str(), "open",
+ errno, strerror(errno));
+ } else {
+ if (fsync(fd) == -1) { // LCOV_EXCL_BR_LINE 5: fsync's error case
+ // LCOV_EXCL_START 5: fsync's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, OPE_ERR_MSG, f_dir_path.c_str(), "fsync",
+ errno, strerror(errno));
+ // LCOV_EXCL_STOP
+ }
+ if (close(fd) == -1) { // LCOV_EXCL_BR_LINE 5: close's error case
+ // LCOV_EXCL_START 5: close's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, OPE_ERR_MSG, f_dir_path.c_str(), "close",
+ errno, strerror(errno));
+ // LCOV_EXCL_STOP
+ }
+ }
+#undef OPE_ERR_MSG
+}
+
+// LCOV_EXCL_START 4: no space error case
+size_t deleteRequestLogs(std::string f_emmcpath, ELOGGERSERVICELOGTYPE f_reqtype,
+ size_t f_reqsize, ELOGGERSERVICELOGTYPE f_deltype) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ DIR* l_dirp = NULL;
+ std::vector<std::string> vect;
+ std::vector<std::string>::iterator it;
+ UI_32 l_count = 0;
+ size_t l_totalsize = 0;
+
+ ELOGGERSERVICELOGTYPE filetype;
+
+
+ // create saved file list on eMMC
+ l_dirp = opendir(f_emmcpath.c_str());
+ if (l_dirp != NULL) {
+ struct dirent l_dirent;
+ struct dirent* next;
+ while (0 == readdir_r(l_dirp, &l_dirent, &next) && next != NULL) {
+ std::string l_filename = l_dirent.d_name;
+
+// if (QueryLoggerservicelogType(l_filename) == f_deltype) {
+// vect.push_back(l_filename);
+// }
+ if ((l_filename == ".") && (l_filename == "..")) {
+ continue;
+ }
+ filetype = QueryLoggerservicelogType(l_filename);
+ if (f_deltype == eLoggerservicelogTypeAbnormal) {
+ if ((filetype == eLoggerservicelogTypeAbnormal) || (filetype == eLoggerservicelogTypeSysAbnormal) ||
+ (filetype == eLoggerservicelogType_CWORD52_)) {
+ vect.push_back(l_filename);
+ }
+ } else if (filetype == f_deltype) {
+ vect.push_back(l_filename);
+ }
+
+ }
+ closedir(l_dirp);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " open failed eMMC path: %s",
+ f_emmcpath.c_str());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return 0;
+ }
+
+ // get num of delete logs
+ std::sort(vect.begin(), vect.end());
+ for (it = vect.begin(); it != vect.end(); it++) {
+ l_count++;
+
+ std::string l_filename = *it;
+ struct stat st_buf;
+ std::string l_tmpstr = f_emmcpath;
+ l_tmpstr.append(l_filename.c_str());
+ if (stat(l_tmpstr.c_str(), &st_buf) != -1) {
+ l_totalsize += st_buf.st_size;
+ }
+
+ if (l_totalsize > f_reqsize) {
+ break;
+ }
+ }
+
+ // start delete logs
+ if ((l_totalsize > f_reqsize) || (f_reqtype == eLoggerservicelogTypeAbnormal)
+ || (f_reqtype == eLoggerservicelogTypeGrpRelaunch)) {
+ for (it = vect.begin(); it != vect.end() && l_count > 0; it++) {
+ l_count--;
+
+ std::string l_filename = *it;
+ std::string l_tmpstr = f_emmcpath;
+ l_tmpstr.append(l_filename.c_str());
+ if (unlink(l_tmpstr.c_str()) != 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " unlink failed %s:%d,msg:%s",
+ l_tmpstr.c_str(), errno, strerror(errno));
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " del-file=%s total=%d", l_tmpstr.c_str(),
+ l_totalsize);
+ }
+
+ if (f_reqtype == eLoggerservicelogTypeAbnormal) {
+ removeSameNumFiles(it, f_emmcpath, vect);
+ }
+
+ SyncDir(f_emmcpath);
+ } else {
+ l_totalsize = 0;
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_INFO,
+ __FUNCTION__,
+ " nothing to delete logs req-type=%d del-logtype=%d total=%d, log_count=%d",
+ f_reqtype, f_deltype, l_totalsize, l_count);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_totalsize;
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 4: no space error case
+EFrameworkunifiedStatus forceDeleteOldLog(std::string f_archive_destination,
+ size_t f_req_size) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ std::string l_emmc_path;
+ size_t l_delsize = 0;
+ ELOGGERSERVICELOGTYPE l_logtype = eLoggerservicelogTypeOther;
+
+ size_t l_pos = f_archive_destination.find_last_of('/');
+ if (std::string::npos != l_pos) {
+ l_emmc_path = f_archive_destination.substr(0, l_pos);
+ l_emmc_path.append("/");
+ l_logtype = QueryLoggerservicelogType(
+ f_archive_destination.substr(l_pos + 1,
+ f_archive_destination.size() - l_pos + 1));
+
+ if ((l_logtype == eLoggerservicelogTypeSysAbnormal) || (l_logtype == eLoggerservicelogType_CWORD52_)) {
+ l_logtype = eLoggerservicelogTypeAbnormal;
+ }
+
+ }
+
+ if (l_logtype == eLoggerservicelogTypeOther) {
+ // not found
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Invalid Parameter. dest=%s",
+ f_archive_destination.c_str());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusFail;
+ }
+
+ // remove dirty-file if exist
+ if (unlink(f_archive_destination.c_str()) != 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " unlink failed %s:%d.",
+ f_archive_destination.c_str(), errno);
+ }
+
+ // delete normal log
+ l_delsize = deleteRequestLogs(l_emmc_path, l_logtype, f_req_size,
+ eLoggerservicelogTypeNormal);
+ if (l_delsize >= f_req_size) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " delete normal logs success: req-size=%d, del-size=%d", f_req_size,
+ l_delsize);
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else if (l_logtype == eLoggerservicelogTypeAbnormal) {
+ // delete abnormal log if request type is abnormal
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " continue delete abnormal logs: req-size=%d, del-size=%d",
+ f_req_size, l_delsize);
+ size_t l_tmpsize = f_req_size;
+ l_tmpsize -= l_delsize;
+ l_delsize = deleteRequestLogs(l_emmc_path, l_logtype, l_tmpsize,
+ eLoggerservicelogTypeAbnormal);
+ if (l_delsize >= l_tmpsize) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " delete abnormal logs success: req-size=%d, del-size=%d",
+ f_req_size, l_delsize);
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " abnormal log delete not complete. req-size=%d, del-size=%d",
+ f_req_size, l_delsize);
+ }
+ } else if (l_logtype == eLoggerservicelogTypeGrpRelaunch) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " continue delete group relaunch logs: req-size=%d, del-size=%d",
+ f_req_size, l_delsize);
+ size_t l_tmpsize = f_req_size;
+ l_tmpsize -= l_delsize;
+ l_delsize = deleteRequestLogs(l_emmc_path, l_logtype, l_tmpsize,
+ eLoggerservicelogTypeGrpRelaunch);
+ if (l_delsize >= l_tmpsize) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " delete group relaunch logs success: req-size=%d, del-size=%d",
+ f_req_size, l_delsize);
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR, __FUNCTION__,
+ " group relaunch log delete not complete. req-size=%d, del-size=%d",
+ f_req_size, l_delsize);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " normal log del not complete. req-size=%d, del-size=%d", f_req_size,
+ l_delsize);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function SS_LoggerStoreDebugLogs
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus SS_LoggerStoreLogs(SS_STORELOGS_OPE_TYPE type) {
+ if (type < SS_STORELOGS_MAX) {
+ return storeLogs(type);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error. Bad enum number %d", type);
+ return eFrameworkunifiedStatusFail;
+ }
+}
+
+
+EFrameworkunifiedStatus SS_LoggerStoreLogs_deleteOldLogAbnrm(const std::string& log_path,
+ std::vector<std::string>& l_vector,
+ const std::string& f_archive_destination,
+ SI_32 max_num,
+ UI_32 abnrm_total) {
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus;
+ l_eFrameworkunifiedStatus = deleteOldLogAbnrm(log_path, l_vector, f_archive_destination, max_num, abnrm_total);
+ return l_eFrameworkunifiedStatus;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// IsDirectory
+/// Method to check if the entity is a directory.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+static BOOL IsDirectory(std::string &f_cPath) { // NOLINT (runtime/references)
+ BOOL l_bReturn = FALSE;
+ struct stat st_buf;
+
+ if (-1 == stat(f_cPath.c_str(), &st_buf)) { // LCOV_EXCL_BR_LINE 5: stat's error case // NOLINT (runtime/references) // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 5: stat's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: stat failed for path/file %s, errno %d", f_cPath.c_str(),
+ errno);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ // LCOV_EXCL_STOP
+ } else if (S_ISDIR(st_buf.st_mode)) {
+ l_bReturn = TRUE; // return true if f_cPath is a directory
+ }
+ return l_bReturn;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// RemoveDirectory
+/// Method to remove a directory.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+static BOOL RemoveDirectory(std::string &f_cPath) { // NOLINT (runtime/references)
+ BOOL l_bReturn = FALSE;
+
+ if (RemoveSubDirectory(f_cPath)) { // LCOV_EXCL_BR_LINE 6: RemoveSubDirectory always return true
+ // delete the parent directory
+ if (0 == rmdir(f_cPath.c_str())) { // LCOV_EXCL_BR_LINE 5: rmdir's error case
+ l_bReturn = TRUE;
+ }
+ }
+ return l_bReturn;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// RemoveSubDirectory
+/// Method to remove a sub directory.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+static BOOL RemoveSubDirectory(std::string &f_cPath) { // NOLINT (runtime/references)
+ BOOL l_bReturn = TRUE;
+
+ if (!f_cPath.empty()) { // LCOV_EXCL_BR_LINE 6: f_cPath can't be empty
+ std::string l_cFilePath = "";
+ struct dirent l_Dirent;
+ struct dirent* next;
+ DIR *l_pDir = NULL;
+
+ l_pDir = opendir(f_cPath.c_str());
+ if (NULL != l_pDir) { // LCOV_EXCL_BR_LINE 5: opendir's error case
+ if ('/' != f_cPath[f_cPath.length() - 1]) { // LCOV_EXCL_BR_LINE 6: there must be no '/'
+ f_cPath.append("/");
+ }
+
+ while (0 == readdir_r(l_pDir, &l_Dirent, &next) && next != NULL) {
+ if (0 != std::strcmp(l_Dirent.d_name, ".")
+ && 0 != std::strcmp(l_Dirent.d_name, "..")
+ && 0 != std::strcmp(l_Dirent.d_name, "lost+found")) {
+ l_cFilePath.assign(f_cPath);
+ l_cFilePath.append(l_Dirent.d_name); // concatenate the strings to get the complete f_cPath
+ if (TRUE == IsDirectory(l_cFilePath)) {
+ l_bReturn = RemoveDirectory(l_cFilePath);
+ } else {
+ // it's a file, we can use unlink
+ if (unlink(l_cFilePath.c_str()) == -1) { // LCOV_EXCL_BR_LINE 5: unlink's error case
+ // LCOV_EXCL_START 5: unlink's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_bReturn = FALSE;
+ // LCOV_EXCL_STOP
+ }
+ }
+ }
+ }
+ closedir(l_pDir); // close the directory
+ SyncDir(f_cPath);
+ } else {
+ // LCOV_EXCL_START 5: opendir's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "l_pDir is NULL");
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 6: f_cPath can't be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Pathname empty.");
+ l_bReturn = FALSE;
+ // LCOV_EXCL_STOP
+ }
+ return l_bReturn;
+}
+
+static void CreateSaveFinFlag(SS_STORELOGS_OPE_TYPE type) {
+ if (type == SS_STORELOGS_INTERFACEUNIFIEDLOG) {
+ int fd;
+ fd = open(SS_LOGGER_SAVE_INTERFACEUNIFIEDLOG_FLAG,
+ O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0640);
+ if (fd == -1) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error. Create %s. errno %d msg :%s",
+ SS_LOGGER_SAVE_INTERFACEUNIFIEDLOG_FLAG, errno, strerror(errno));
+ } else {
+ fsync(fd);
+ close(fd);
+ std::string l_flagPath = SS_LOGGER_SAVE_INTERFACEUNIFIEDLOG_FLAG;
+ size_t l_pos = l_flagPath.find_last_of('/');
+ if (std::string::npos != l_pos) { // LCOV_EXCL_BR_LINE 6: there must be '/' in l_flagPath
+ std::string l_dirPath = l_flagPath.substr(0, l_pos);
+ SyncDir(l_dirPath);
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "create saveflag finish.");
+ fprintf(stderr, "%s:Completed\n", __FUNCTION__);
+ }
+ }
+ }
+}
+
+static void deleteAccOffOnUntyped(std::string deletePath)
+{
+ struct stat l_stat;
+ SI_8 l_statRetVal;
+ if (0 != access(deletePath.c_str(), F_OK)) {
+ DEB_LOGGERSERVICELOG(ZONE_WARN, __FUNCTION__, "access error (%s)", deletePath.c_str());
+ } else if (0 != (l_statRetVal = lstat(deletePath.c_str(), &l_stat))) {
+ DEB_LOGGERSERVICELOG(ZONE_WARN, __FUNCTION__, "get stat error (%s)", deletePath.c_str());
+ } else if (0 != S_ISDIR(l_stat.st_mode)) {
+ deleteAccOffOnDir(deletePath);
+ } else if (0 != S_ISREG(l_stat.st_mode)) {
+ unlink(deletePath.c_str());
+ }
+}
+
+static void deleteAccOffOnDir(std::string deletePath)
+{
+ DIR * l_pDir = opendir(deletePath.c_str());
+ if (l_pDir != NULL) {
+ struct dirent l_pDirent;
+ struct dirent* next;
+ while (0 == readdir_r(l_pDir,&l_pDirent,&next) && next != NULL) {
+ if ( ( 0 != strcmp( l_pDirent.d_name, "." ) ) &&
+ ( 0 != strcmp( l_pDirent.d_name, ".." )) &&
+ ( 0 != strcmp( l_pDirent.d_name, "lost+found" )) &&
+ ( '.' != l_pDirent.d_name[0] ) ) {
+ std::string l_deletePath = deletePath;
+ l_deletePath.append("/");
+ l_deletePath.append(l_pDirent.d_name);
+ deleteAccOffOnUntyped(l_deletePath);
+ }
+ }
+ closedir (l_pDir);
+ }
+ RemoveDirectory(deletePath);
+}
+
+static EFrameworkunifiedStatus storeLogs(SS_STORELOGS_OPE_TYPE type) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ std::string file_name;
+ std::vector<LogInfo> list;
+ std::vector<LoggerservicelogInfo> loggerservicelogList;
+ TAR* tar_info = NULL;
+ uint32_t time_info;
+ uint8_t status;
+ CfgInfo cfginfo;
+
+ UI_32 l_counter = INVALID_FILENUMBER;
+
+
+ // load ss_logger configuration file.
+ getConfigInfo(cfginfo);
+
+
+ if (type == SS_STORELOGS_SYS_ILLEGAL) {
+ if (getFileNumberFromTempArchive(l_counter) != eFrameworkunifiedStatusOK) {
+ // ------------------------------------ //
+ // no made ILG_RESET.tar.gz //
+ // when is abnormal logging count over. //
+ // ------------------------------------ //
+ return eFrameworkunifiedStatusOK;
+ }
+ }
+
+
+// Clock_getSystemTimeY2K38(&time_info, &status);
+
+// file_name = getFileName(cfginfo.output_path, time_info, type);
+//
+// // prepare log files for collectting
+// for (UI_32 i = 0; i < _countof(GetLogFuncTbl); i++) {
+// GetLogFuncTbl[i](type, list);
+// }
+ file_name = getFileName(cfginfo.output_path, time_info, type, l_counter);
+
+ if (type != SS_STORELOGS_SYS_ILLEGAL) {
+ // prepare log files for collectting
+ for (UI_32 i = 0; i < _countof(GetLogFuncTbl); i++) {
+ GetLogFuncTbl[i](type, list);
+ }
+ }
+
+ if (type == SS_STORELOGS_ACCOFFON) {
+ copyFileToAccOffOnDir(list, type);
+ DEB_LOGGERSERVICELOG(ZONE_FUNC, __FUNCTION__, "- : FrameworkunifiedStatus = %d", l_eFrameworkunifiedStatus);
+ return l_eFrameworkunifiedStatus;
+ } else if (type != SS_STORELOGS_ACCOFFON_PRESS) {
+ // loggerservicelogList used with clear buffer
+ getLoggerservicelogFile(type, list, loggerservicelogList);
+ }
+
+ // ---------------------------------------------------------------- //
+ // Warning!!! Logs by using FRAMEWORKUNIFIEDLOG macro, are not saved from here!! //
+ // You can saved logs by FRAMEWORKUNIFIEDLOG after finished to clear buffer. //
+ // ---------------------------------------------------------------- //
+
+ if (list.size() != 0) {
+ // delete old archive before create new one.
+ deleteOldEmmcLog(cfginfo, file_name, type);
+
+ l_eFrameworkunifiedStatus = openArchive(&tar_info, file_name);
+ if (l_eFrameworkunifiedStatus == eFrameworkunifiedStatusOK) {
+ if (type == SS_STORELOGS_ACCOFFON_PRESS) {
+ std::string collectPath;
+ collectPath = LOGGERSERVICELOG_TMP_OUTPUT_PATH;
+ collectPath.append("/");
+ collectPath.append(ACCOFFON_DIR_NAME);
+ if (0 != access(collectPath.c_str(), F_OK)) {
+ DEB_LOGGERSERVICELOG(ZONE_ERR,__FUNCTION__," Error. The specified file path and name does not exist: %s", collectPath.c_str());
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusFail;
+ return l_eFrameworkunifiedStatus;
+ } else {
+ l_eFrameworkunifiedStatus = addAllFileToArchive(tar_info,collectPath);
+ }
+ } else {
+ for (UI_32 j = 0; j < list.size(); j++) {
+ l_eFrameworkunifiedStatus = addToArchive(tar_info, list.at(j).file_path, list.at(j).dest_name);
+ if(l_eFrameworkunifiedStatus != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, " Error. File %s failed to archive.", list.at(j).file_path.c_str());
+ }
+ }
+ }
+
+// l_eFrameworkunifiedStatus = closeArchive(tar_info);
+ l_eFrameworkunifiedStatus = closeArchive(tar_info, type);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "finish archiving logs(%d)", type);
+
+ // when finish archiving, clear frameworkunifiedlog buffer.
+ if (type == SS_STORELOGS_ACCOFFON_PRESS) {
+ deleteTmpAccOffOn((std::string)ACCOFFON_DIR_NAME);
+ DEB_LOGGERSERVICELOG(ZONE_FUNC, __FUNCTION__, "- : FrameworkunifiedStatus = %d", l_eFrameworkunifiedStatus);
+ return (l_eFrameworkunifiedStatus);
+ } else {
+ ClearLoggerservicelogBuffer(loggerservicelogList);
+ }
+
+ // create flag of archiving completed
+ CreateSaveFinFlag(type);
+
+ // -------------------------------------------- //
+ // You can save logs by FRAMEWORKUNIFIEDLOG macro from here. //
+ // -------------------------------------------- //
+ }
+
+ // remove temporary or unnecessary files.
+ for (UI_32 k = 0; k < list.size(); k++) {
+ if (list.at(k).tmp_file_delete == TRUE) {
+ struct stat l_stat;
+ if (0 != stat(list.at(k).file_path.c_str(), &l_stat)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Error. stat(%s) errno. %d",
+ list.at(k).file_path.c_str(), errno);
+ } else if (S_ISDIR(l_stat.st_mode)) {
+ RemoveDirectory(list.at(k).file_path);
+ } else {
+ if (0 != unlink(list.at(k).file_path.c_str())) { // LCOV_EXCL_BR_LINE 5: unlink's error case
+ // LCOV_EXCL_START 5: unlink's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, " Error. unlink(%s) errno. %d",
+ list.at(k).file_path.c_str(), errno);
+ // LCOV_EXCL_STOP
+ }
+ }
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "- : FrameworkunifiedStatus = %d", l_eFrameworkunifiedStatus);
+ return (l_eFrameworkunifiedStatus);
+}
+
+static void getConnectivitylogFile(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list) { // NOLINT (runtime/references)
+
+ LogInfo log_info;
+
+ log_info.file_path = FRAMEWORKUNIFIEDLOG_RAMDISC_PATH;
+ log_info.file_path.append("/");
+ log_info.file_path.append(CONNECTIVITY_DIR_NAME);
+ log_info.dest_name = CONNECTIVITY_DIR_NAME;
+ log_info.tmp_file_delete = FALSE;
+ list.push_back(log_info);
+}
+
+static void getRadiologFile(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list) { // NOLINT (runtime/references)
+
+ LogInfo log_info;
+
+ log_info.file_path = FRAMEWORKUNIFIEDLOG_RAMDISC_PATH;
+ log_info.file_path.append("/");
+ log_info.file_path.append(RADIO_DIR_NAME);
+ log_info.dest_name = RADIO_DIR_NAME;
+ log_info.tmp_file_delete = FALSE;
+ list.push_back(log_info);
+}
+
+static void getCommunicationlogFile(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list) { // NOLINT (runtime/references)
+
+ LogInfo log_info;
+
+ log_info.file_path = FRAMEWORKUNIFIEDLOG_RAMDISC_PATH;
+ log_info.file_path.append("/");
+ log_info.file_path.append(COMMUNICATION_DIR_NAME);
+ log_info.dest_name = COMMUNICATION_DIR_NAME;
+ log_info.tmp_file_delete = FALSE;
+ list.push_back(log_info);
+}
+
+static void getGraphicslogFile(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list) { // NOLINT (runtime/references)
+ LogInfo log_info;
+
+ log_info.file_path = FRAMEWORKUNIFIEDLOG_RAMDISC_PATH;
+ log_info.file_path.append("/");
+ log_info.file_path.append(GRAPHICS_FN_LOG_FN);
+ log_info.dest_name = GRAPHICS_FN_LOG_FN;
+ log_info.tmp_file_delete = FALSE;
+ list.push_back(log_info);
+}
+
+static void getSyslogFile(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list) { // NOLINT (runtime/references)
+ LogInfo log_info;
+
+ log_info.file_path = FRAMEWORKUNIFIEDLOG_RAMDISC_PATH;
+ log_info.file_path.append("/");
+ log_info.file_path.append(SYSLOG_DIR_NAME);
+ log_info.dest_name = SYSLOG_DIR_NAME;
+ log_info.tmp_file_delete = FALSE;
+ list.push_back(log_info);
+}
+
+static void getWinSyslogFile(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list) { // NOLINT (runtime/references)
+
+ LogInfo log_info;
+
+ log_info.file_path = FRAMEWORKUNIFIEDLOG_RAMDISC_PATH;
+ log_info.file_path.append("/");
+ log_info.file_path.append(WINSYS_LOG_FN);
+ log_info.dest_name = WINSYS_LOG_FN;
+ log_info.tmp_file_delete = FALSE;
+ list.push_back(log_info);
+}
+
+static void getAppFwlogFile(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list) { // NOLINT (runtime/references)
+
+ LogInfo log_info;
+
+ log_info.file_path = FRAMEWORKUNIFIEDLOG_RAMDISC_PATH;
+ log_info.file_path.append("/");
+ log_info.file_path.append(APPFW_DIR_NAME);
+ log_info.dest_name = APPFW_DIR_NAME;
+ log_info.tmp_file_delete = FALSE;
+ list.push_back(log_info);
+}
+
+static void getTomoyologFile(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list) { // NOLINT (runtime/references)
+
+ LogInfo log_info;
+
+ log_info.file_path = TOMOYO_DIR_PATH;
+ log_info.file_path.append("/");
+ log_info.file_path.append(TOMOYO_DIR_NAME);
+ log_info.dest_name = TOMOYO_DIR_NAME;
+ log_info.tmp_file_delete = TRUE;
+ list.push_back(log_info);
+}
+
+static void getLoggerservicelogFile(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list, // NOLINT (runtime/references)
+ std::vector<LoggerservicelogInfo>& loggerservicelogList) { // NOLINT (runtime/references)
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_32 l_DumpSize = 0;
+ std::string src_file_path;
+ std::string dst_file_path;
+ PCSTR file_name;
+ UI_32 file_num;
+ LogInfo log_info;
+ LoggerservicelogInfo loggerservicelog_info;
+
+ file_num = NSLogGetFrameworkunifiedlogFileTotalNum();
+ for (UI_32 cont = 0; cont < file_num; cont++) {
+ file_name = NSLogGetFrameworkunifiedlogFileName(cont);
+ if (file_name == NULL) {
+ break;
+ }
+ src_file_path = FRAMEWORKUNIFIEDLOG_RAMDISC_PATH;
+ src_file_path.append("/");
+ src_file_path.append(file_name);
+ dst_file_path = LOGGERSERVICELOG_TMP_OUTPUT_PATH;
+ dst_file_path.append("/");
+ dst_file_path.append(file_name);
+
+ int index;
+ index = NSLogGetFrameworkunifiedlogIndex(src_file_path.c_str());
+ CNSRingBuffer* l_pLoggerservicelog = new (std::nothrow) CNSRingBuffer(
+ src_file_path, 0, index + LOCK_NSLOG_ACCES_IF_1);
+ if (l_pLoggerservicelog == NULL) { // LCOV_EXCL_BR_LINE 5: new's error case
+ // LCOV_EXCL_START 5: new's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FRAMEWORKUNIFIEDLOG RingBuffer handle is NULL %s",
+ src_file_path.c_str());
+ continue;
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pLoggerservicelog->Open())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FRAMEWORKUNIFIEDLOG RingBuffer Open failed %s %d",
+ src_file_path.c_str(), l_eStatus);
+ } else {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pLoggerservicelog->DumpToFile(dst_file_path.c_str(),
+ &l_DumpSize))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FRAMEWORKUNIFIEDLOG RingBuffer DumpToFile failed %s %d",
+ src_file_path.c_str(), l_eStatus);
+ } else {
+ log_info.file_path = dst_file_path;
+ log_info.dest_name = file_name;
+ log_info.tmp_file_delete = TRUE;
+ list.push_back(log_info);
+ // save frameworkunifiedlog-info for using clear frameworkunifiedlog buffer
+ loggerservicelog_info.path = src_file_path;
+ loggerservicelog_info.index = index;
+ loggerservicelogList.push_back(loggerservicelog_info);
+ }
+ (void) l_pLoggerservicelog->Close();
+ }
+ delete l_pLoggerservicelog;
+ }
+}
+
+static void copyLoggerservicelogFile(std::string distPath)
+{
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_32 l_DumpSize = 0;
+ std::string src_file_path;
+ std::string dst_file_path;
+ PCSTR file_name;
+ UI_32 file_num;
+
+ file_num = NSLogGetFrameworkunifiedlogFileTotalNum();
+
+ for (UI_32 cont = 0; cont < file_num; cont++) {
+ file_name = NSLogGetFrameworkunifiedlogFileName(cont);
+
+ if (file_name == NULL) {
+ break;
+ }
+
+ src_file_path = FRAMEWORKUNIFIEDLOG_RAMDISC_PATH;
+ src_file_path.append("/");
+ src_file_path.append(file_name);
+
+ dst_file_path = distPath;
+ dst_file_path.append("/");
+ dst_file_path.append(file_name);
+
+ int index;
+ index = NSLogGetFrameworkunifiedlogIndex(src_file_path.c_str());
+ CNSRingBuffer* l_pLoggerservicelog = new (std::nothrow)CNSRingBuffer(src_file_path,0,index+LOCK_NSLOG_ACCES_IF_1);
+ if (l_pLoggerservicelog == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FRAMEWORKUNIFIEDLOG RingBuffer handle is NULL %s", src_file_path.c_str());
+ continue;
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pLoggerservicelog->Open())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,"Error: FRAMEWORKUNIFIEDLOG RingBuffer Open failed %s %d", src_file_path.c_str(), l_eStatus);
+ } else {
+ if (eFrameworkunifiedStatusOK != (l_eStatus = l_pLoggerservicelog->DumpToFile(dst_file_path.c_str(), &l_DumpSize))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,"Error: FRAMEWORKUNIFIEDLOG RingBuffer DumpToFile failed %s %d", src_file_path.c_str(), l_eStatus);
+ }
+ (void)l_pLoggerservicelog->Close();
+ }
+ delete l_pLoggerservicelog;
+ }
+}
+
+static void deleteTmpAccOffOn(std::string accOffOnDir)
+{
+ std::string l_tmpAccOffOnPath = LOGGERSERVICELOG_TMP_OUTPUT_PATH;
+ l_tmpAccOffOnPath.append("/");
+ l_tmpAccOffOnPath.append(accOffOnDir.c_str());
+ DIR * l_pDir = opendir(l_tmpAccOffOnPath.c_str());
+ if (l_pDir != NULL) {
+ struct dirent l_pDirent;
+ struct dirent* next;
+ while (0 == readdir_r(l_pDir,&l_pDirent,&next) && next != NULL) {
+ if ( ( 0 != strcmp( l_pDirent.d_name, "." ) ) &&
+ ( 0 != strcmp( l_pDirent.d_name, ".." )) &&
+ ( 0 != strcmp( l_pDirent.d_name, "lost+found" )) &&
+ ( '.' != l_pDirent.d_name[0] ) ) {
+ std::string l_deletePath = l_tmpAccOffOnPath;
+ l_deletePath.append("/");
+ l_deletePath.append(l_pDirent.d_name);
+ deleteAccOffOnUntyped(l_deletePath);
+ }
+ }
+ closedir (l_pDir);
+ }
+ RemoveDirectory(l_tmpAccOffOnPath);
+}
+
+static void ClearLoggerservicelogBuffer(std::vector<LoggerservicelogInfo> &loggerservicelogList) { // NOLINT (runtime/references)
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ std::vector<LoggerservicelogInfo>::iterator ite = loggerservicelogList.begin();
+
+ if (ite == loggerservicelogList.end()) {
+ // target not found...
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "nothing to clear");
+ } else {
+ for (ite = loggerservicelogList.begin(); ite != loggerservicelogList.end(); ite++) {
+ CNSRingBuffer* l_pLoggerservicelog = new (std::nothrow) CNSRingBuffer(
+ ite->path.c_str(), 0, ite->index + LOCK_NSLOG_ACCES_IF_1);
+ if (l_pLoggerservicelog == NULL) { // LCOV_EXCL_BR_LINE 5: new's error case
+ // LCOV_EXCL_START 5: new's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FRAMEWORKUNIFIEDLOG RingBuffer handle is NULL %s", ite->path.c_str());
+ continue;
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pLoggerservicelog->Open())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FRAMEWORKUNIFIEDLOG RingBuffer Open failed %s %d", ite->path.c_str(),
+ l_eStatus);
+ } else {
+ if (eFrameworkunifiedStatusOK != (l_eStatus = l_pLoggerservicelog->ClearBuf())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FRAMEWORKUNIFIEDLOG RingBuffer ClearBuf failed %s %d",
+ ite->path.c_str(), l_eStatus);
+ }
+ (void) l_pLoggerservicelog->Close();
+ }
+ delete l_pLoggerservicelog;
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Completed");
+ fprintf(stderr, "%s:Completed\n", __FUNCTION__);
+}
+
+static void createKernelLog(SS_STORELOGS_KERNEL_LOG_TYPE type) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ int len;
+ int fd;
+ char* buf;
+ ssize_t wr_len;
+
+ len = klogctl(SYSLOG_ACTION_SIZE_BUFFER, NULL, 0);
+ if (len < 0) { // LCOV_EXCL_BR_LINE 5: klogctl's error case
+ // LCOV_EXCL_START 5: klogctl's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error. Failed to get syslog buffer size: %d, %s", errno,
+ strerror(errno));
+ // LCOV_EXCL_STOP
+ } else {
+ buf = reinterpret_cast<char*>(malloc(len));
+ if (buf != NULL) { // LCOV_EXCL_BR_LINE 5: malloc's error case
+ len = klogctl(SYSLOG_ACTION_READ_ALL, buf, len);
+ if ((len < 0) || (len == 0)) { // LCOV_EXCL_BR_LINE 5: klogctl's error case
+ // LCOV_EXCL_START 5: klogctl's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error. Failed to read syslog buffer: %d, %s", errno,
+ strerror(errno));
+ // LCOV_EXCL_STOP
+ } else {
+ std::string file_put_path = "";
+
+ switch (type) {
+ case SS_STORELOGS_KERNEL_LOG:
+ file_put_path = LOGGERSERVICELOG_TMP_OUTPUT_PATH;
+ file_put_path.append("/");
+ file_put_path.append(KERNEL_LOG_FN);
+ fd = open(file_put_path.c_str(),
+ O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644);
+ break;
+ case SS_STORELOGS_KERNEL_BOOT_LOG:
+ file_put_path = FRAMEWORKUNIFIEDLOG_RAMDISC_PATH;
+ file_put_path.append("/");
+ file_put_path.append(KERNEL_BOOT_LOG_FN);
+ fd = open(file_put_path.c_str(),
+ O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644);
+ break;
+ default:
+ fd = -1;
+ break;
+ }
+
+ if (fd == -1) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error. Failed to open file: %s: %d, %s",
+ file_put_path.c_str(), errno, strerror(errno));
+ } else {
+ wr_len = write(fd, buf, len);
+ if (wr_len == -1) { // LCOV_EXCL_BR_LINE 5: write's error case
+ // LCOV_EXCL_START 5: write's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. File write failed. errno: %d, %s", errno,
+ strerror(errno));
+ // LCOV_EXCL_STOP
+ }
+ fsync(fd);
+ close(fd);
+ }
+ }
+ free(buf);
+ } else {
+ // LCOV_EXCL_START 5: malloc's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Memory allocation Failed %s",
+ strerror(errno));
+ // LCOV_EXCL_STOP
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+static void getKernellogFile(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list) { // NOLINT (runtime/references)
+ getLastKernelLog(list);
+
+ getKernelLog(list);
+
+ if (type != SS_STORELOGS_ACCOFFON) {
+ getKernelBootLog(type, list);
+ }
+}
+
+static void getLastKernelLog(std::vector<LogInfo>& list) { // NOLINT (runtime/references)
+ LogInfo log_info;
+
+ log_info.file_path = PSTORE_DIR_PATH;
+ log_info.dest_name = "kernellog";
+ log_info.tmp_file_delete = FALSE;
+ list.push_back(log_info);
+}
+
+static void getKernelLog(std::vector<LogInfo>& list) { // NOLINT (runtime/references)
+ createKernelLog(SS_STORELOGS_KERNEL_LOG);
+
+ LogInfo log_info;
+
+ std::string klog_path = LOGGERSERVICELOG_TMP_OUTPUT_PATH;
+ klog_path.append("/");
+ klog_path.append(KERNEL_LOG_FN);
+
+ if (0 == access(klog_path.c_str(), F_OK)) {
+ log_info.file_path = klog_path;
+ log_info.dest_name = KERNEL_LOG_FN;
+ log_info.tmp_file_delete = TRUE;
+ list.push_back(log_info);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Info: %s not found.", klog_path.c_str());
+ }
+}
+
+static void getKernelBootLog(SS_STORELOGS_OPE_TYPE type,
+ std::vector<LogInfo>& list) { // NOLINT (runtime/references)
+ createKernelLog(SS_STORELOGS_KERNEL_BOOT_LOG);
+
+ LogInfo log_info;
+
+ std::string klog_path = FRAMEWORKUNIFIEDLOG_RAMDISC_PATH;
+ klog_path.append("/");
+ klog_path.append(KERNEL_BOOT_LOG_FN);
+
+ if (0 == access(klog_path.c_str(), F_OK)) {
+ std::string klog_out_path = LOGGERSERVICELOG_TMP_OUTPUT_PATH;
+ klog_out_path.append("/");
+ klog_out_path.append(KERNEL_BOOT_LOG_FN);
+
+ if (eFrameworkunifiedStatusOK == copyFile(klog_path.c_str(), klog_out_path.c_str())) { // LCOV_EXCL_BR_LINE 6: copyFile must return ok // NOLINT[whitespace/line_length]
+ log_info.file_path = klog_out_path;
+ log_info.dest_name = KERNEL_BOOT_LOG_FN;
+ log_info.tmp_file_delete = TRUE;
+ list.push_back(log_info);
+ } else {
+ // LCOV_EXCL_START 6: copyFile must return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Info: copyFile src:%s dest:%s failed.",
+ klog_path.c_str(), klog_out_path.c_str());
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Info: %s not found.", klog_path.c_str());
+ }
+}
+
+
+//static std::string getFileName(std::string &path, uint32_t f_time, // NOLINT (runtime/references)
+// SS_STORELOGS_OPE_TYPE type) {
+static std::string getFileName(std::string &path, uint32_t f_time,
+ SS_STORELOGS_OPE_TYPE type, UI_32 l_counter) {
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ std::stringstream l_nameStream;
+
+// UI_32 l_counter = 0;
+ std::string l_time_str = "00000000_000000";
+ std::string l_ret;
+ char buffer[20];
+ struct tm l_time_tmp;
+
+
+// getEmmcCounter(path, l_counter);
+ if (l_counter == INVALID_FILENUMBER) {
+ l_counter = 0;
+ getEmmcCounter(path, l_counter);
+ }
+
+
+// CLOCK_RETURN clock_ret = Clock_getLocalTimeY2K38(&f_time, &l_time_tmp);
+// if (clock_ret == CLOCK_OK) {
+// if (0 != strftime(buffer, sizeof(buffer), "%Y%m%d_%H%M%S", &l_time_tmp)) {
+// l_time_str = buffer;
+// }
+// }
+
+// l_nameStream << std::setw(5) << std::setfill('0') << std::right << std::dec
+// << l_counter << '_';
+ l_nameStream << std::setw(FILENUMBER_DIGIT_NUM) << std::setfill('0') << std::right << std::dec
+ << l_counter << '_';
+
+
+ switch (type) {
+ case SS_STORELOGS_ILLEGAL:
+ l_nameStream << std::setw(15) << l_time_str << "_ILG_RESET.tar.gz";
+ break;
+ case SS_STORELOGS_INTERFACEUNIFIEDLOG:
+ l_nameStream << std::setw(15) << l_time_str << "_ACCOFF.tar.gz";
+ break;
+ case SS_STORELOGS_ACCOFFON:
+ case SS_STORELOGS_ACCOFFON_PRESS:
+ l_nameStream << std::setw(15) << l_time_str << "_ACCOFFON.tar.gz";
+ break;
+
+ case SS_STORELOGS_SYS_ILLEGAL:
+ l_nameStream << std::setw(15) << l_time_str << SS_STORE_FILENAME_SYSILG_TERM;
+ break;
+
+ default:
+ //Set the file name as usual for cases other than the anomaly log specification.
+ l_nameStream << std::setw(15) << l_time_str << ".tar.gz";
+ break;
+ }
+
+ l_ret = path;
+ l_ret.append("/");
+ l_ret.append(l_nameStream.str());
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_ret);
+}
+
+static void getEmmcCounter(std::string &path, UI_32& f_counter) { // NOLINT (runtime/references)
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ std::string l_checkFileName;
+ std::vector<UI_32> l_vector;
+ DIR *l_dirp;
+ struct dirent *l_direntp;
+ size_t l_pos;
+ UI_32 l_count;
+ UI_32 l_maxCount = 0;
+
+ l_dirp = opendir(path.c_str());
+ if (l_dirp != NULL) {
+ for (;;) {
+ l_direntp = readdir(l_dirp);
+ if (l_direntp == NULL) {
+ break;
+ }
+ l_checkFileName = l_direntp->d_name;
+ l_pos = l_checkFileName.find(".tar.gz");
+ if (std::string::npos != l_pos) {
+ l_pos = l_checkFileName.find("_");
+ if (std::string::npos != l_pos) {
+ std::string l_numberString = l_checkFileName.substr(0, l_pos);
+ l_count = static_cast<UI_32>(strtoul(l_numberString.c_str(), NULL, 10));
+ l_vector.push_back(l_count);
+ l_maxCount = std::max(l_count, l_maxCount);
+ }
+ }
+ }
+ closedir(l_dirp);
+ }
+ l_maxCount++;
+
+// if (l_maxCount >= 100000u) {
+// l_maxCount = 1;
+ if (l_maxCount >= FILENUMBER_UPPER_LIMIT_OVER) {
+ l_maxCount = FILENUMBER_LOWER_LIMIT;
+
+ for (;;) {
+ std::vector<UI_32>::iterator find_itr = std::find(l_vector.begin(),
+ l_vector.end(),
+ l_maxCount);
+ if (find_itr == l_vector.end()) {
+ break;
+ }
+ l_maxCount++;
+ }
+ }
+ f_counter = l_maxCount;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+static void getConfigInfo(CfgInfo& f_cfginfo) { // NOLINT (runtime/references)
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ f_cfginfo.output_path = "";
+ f_cfginfo.output_max = 0;
+
+ CNSConfigReader *l_pReaderCfg = new CNSConfigReader();
+
+ if (NULL == l_pReaderCfg) { // LCOV_EXCL_BR_LINE 5: new's error case
+ // LCOV_EXCL_START 5: new's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Unable to allocate CNSConfigReader object.");
+ // LCOV_EXCL_STOP
+ } else {
+ if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->Parse(LOGGERSERVICELOG_CONFIG_PATH))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. l_pReaderCfg->Parse(%s) returned: 0x%X",
+ LOGGERSERVICELOG_CONFIG_PATH, l_eStatus);
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetString("LOGGING.EmmcOutputPath",
+ f_cfginfo.output_path))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. l_pReaderCfg->GetString(LOGGING.EmmcOutputPath)");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetInt("LOGGING.EmmcOutputMax",
+ f_cfginfo.output_max))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. l_pReaderCfg->GetInt(LOGGING.EmmcOutputMax)");
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pReaderCfg->GetInt("LOGGING.EmmcOutputErrMax",
+ f_cfginfo.output_errmax))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. l_pReaderCfg->GetInt(LOGGING.EmmcOutputErrMax)");
+ }
+ delete l_pReaderCfg;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+static EFrameworkunifiedStatus deleteOldLog(std::string log_path,
+ std::vector<std::string>& l_vector, // NOLINT (runtime/references)
+ std::string& f_archive_destination, // NOLINT (runtime/references)
+ UI_32 max_num) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ size_t l_pos = f_archive_destination.find_last_of('/');
+
+ if (std::string::npos != l_pos) { // LCOV_EXCL_BR_LINE 6: '/' must exist in f_archive_destination
+ std::sort(l_vector.begin(), l_vector.end());
+ std::vector<std::string>::iterator itr = l_vector.begin();
+ for (UI_32 i = static_cast<UI_32>(l_vector.size()); (max_num - 1) < i; i--, itr++) {
+ if (itr == l_vector.end()) { // LCOV_EXCL_BR_LINE 6: itr can't be l_vector.end()
+ // LCOV_EXCL_START 6: itr can't be l_vector.end()
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ break;
+ // LCOV_EXCL_STOP
+ }
+ std::string l_FilePath = log_path;
+ std::string l_FileName = *itr;
+ l_FilePath.append("/");
+ l_FilePath.append(l_FileName.c_str());
+ if (0 != unlink(l_FilePath.c_str())) {
+ l_eStatus = eFrameworkunifiedStatusAccessError;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. delete old log file %s:%d.",
+ l_FilePath.c_str(), errno);
+ }
+ }
+ SyncDir(log_path);
+ } else {
+ // LCOV_EXCL_START 6: '/' must exist in f_archive_destination
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. delete target not found. %s",
+ f_archive_destination.c_str());
+ // LCOV_EXCL_STOP
+ }
+ return l_eStatus;
+}
+
+
+static EFrameworkunifiedStatus getFileNumber(const std::string &filename,UI_32 &number) {
+ char buf[16];
+ size_t pos;
+ size_t offset;
+ size_t length;
+ UI_32 temp_value;
+
+ offset = filename.find_last_of(PATHNAME_SEPARATOR) + 1;
+ pos = filename.find_first_of('_', offset);
+ length = pos-offset;
+ if (std::string::npos == pos) {
+ return eFrameworkunifiedStatusInvldParam;
+ } else if (sizeof(buf) <= length) {
+ return eFrameworkunifiedStatusInvldParam;
+ }
+
+ char *endptr;
+ int error_number;
+
+ memcpy(buf, filename.c_str() + offset, length);
+ buf[length] = '\x0';
+
+ errno = EOK;
+ temp_value = strtol(buf, &endptr, 10);
+ error_number = errno;
+ if ((error_number != EOK) || (*endptr != '\x0')) {
+ return eFrameworkunifiedStatusInvldParam;
+ }
+ number = temp_value;
+ return eFrameworkunifiedStatusOK;
+}
+
+static bool compareFileNumber(UI_32 filename1_number, const std::string &filename2) {
+ EFrameworkunifiedStatus l_eStatus;
+ bool result;
+ UI_32 filename2_number;
+
+ l_eStatus = getFileNumber(filename2, filename2_number);
+ if (l_eStatus != eFrameworkunifiedStatusOK) {
+ return false;
+ }
+ result = (filename1_number == filename2_number);
+ return result;
+}
+
+static EFrameworkunifiedStatus removeFiles(const std::string &log_path, std::vector<std::string> &l_vector,
+ size_t begin_pos, size_t end_pos) {
+ std::string l_FilePath;
+ size_t i;
+ int result;
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ EFrameworkunifiedStatus l_ePartStatus = eFrameworkunifiedStatusOK;
+ l_FilePath.reserve(SSLOGGER_PATHNAME);
+ for (i = begin_pos; i < end_pos; i++) {
+ l_FilePath = log_path + PATHNAME_SEPARATOR_STR + l_vector[i];
+ result = unlink(l_FilePath.c_str());
+ if (0 != result) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. unlink() filename = %s ,errno = %d.", l_FilePath.c_str(), errno);
+ l_ePartStatus = eFrameworkunifiedStatusAccessError;
+ if (l_ePartStatus != eFrameworkunifiedStatusOK) {
+ l_eStatus = l_ePartStatus;
+ }
+ }
+ }
+ return l_eStatus;
+}
+
+static EFrameworkunifiedStatus removeSameNumFiles(std::vector<std::string>::iterator &itr, const std::string &log_path,
+ std::vector<std::string> &l_vector) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ if (l_vector.begin() == itr) { // LCOV_EXCL_BR_LINE 4: itr is l_vector.begin() only when no space error case
+ // LCOV_EXCL_START 4: itr is l_vector.begin() only when no space error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+ // LCOV_EXCL_STOP
+ }
+ std::string &removed_filename = *(itr - 1);
+ UI_32 removed_filenumber;
+ if (getFileNumber(removed_filename, removed_filenumber) != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 6: double check, must return ok // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 6: double check, must return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, " Warning. Type mismatch filename. = %s", removed_filename.c_str());
+ return eFrameworkunifiedStatusOK;
+ // LCOV_EXCL_STOP
+ }
+
+ std::string l_FilePath;
+ EFrameworkunifiedStatus l_ePartStatus = eFrameworkunifiedStatusOK;
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ int result;
+ for (;itr < l_vector.end(); itr++) {
+ const std::string &exist_filename = (*itr);
+ if (compareFileNumber(removed_filenumber, exist_filename) == true) {
+ l_FilePath = log_path + PATHNAME_SEPARATOR_STR + exist_filename;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Remove file = %s.", l_FilePath.c_str());
+ result = unlink(l_FilePath.c_str());
+ if (0 != result) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. unlink() filename = %s , errno = %d.", l_FilePath.c_str(), errno);
+ l_ePartStatus = eFrameworkunifiedStatusAccessError;
+ if (l_ePartStatus != eFrameworkunifiedStatusOK) {
+ l_eStatus = l_ePartStatus;
+ }
+ }
+ } else {
+ break;
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+static EFrameworkunifiedStatus deleteOldLogAbnrm(const std::string& log_path, std::vector<std::string>& l_vector,
+ const std::string& f_archive_destination, SI_32 max_num, UI_32 abnrm_total) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ size_t l_pos = f_archive_destination.find_last_of(PATHNAME_SEPARATOR);
+ if (std::string::npos == l_pos) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. delete target not found. %s", f_archive_destination.c_str());
+ return eFrameworkunifiedStatusFail;
+ }
+ if (l_vector.size() == 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. empty array.");
+ return eFrameworkunifiedStatusFail;
+ }
+ //FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " max_num = %d , vect_abnrm.size() = %d", max_num, vect_abnrm.size());
+
+ size_t i;
+ EFrameworkunifiedStatus l_ePartStatus = eFrameworkunifiedStatusOK;
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ size_t end_pos = l_vector.size();
+ SI_32 abnrm_count = 0;
+ UI_32 exist_filenumber;
+ ELOGGERSERVICELOGTYPE filetype;
+
+ max_num = abnrm_total - max_num + 1;
+ std::sort(l_vector.begin(), l_vector.end());
+ for (i = 0; i < end_pos; i++) {
+ const std::string &exist_filename = l_vector[i];
+ if (getFileNumber(exist_filename, exist_filenumber) != eFrameworkunifiedStatusOK) {
+ continue;
+ }
+ filetype = QueryLoggerservicelogType(exist_filename);
+ if (filetype == eLoggerservicelogTypeAbnormal) {
+ abnrm_count++;
+ if (max_num <= abnrm_count) {
+ end_pos = i + 1;
+ break;
+ }
+ }
+ }
+ l_ePartStatus = removeFiles(log_path, l_vector, 0, end_pos);
+ if (l_ePartStatus != eFrameworkunifiedStatusOK) {
+ l_eStatus = l_ePartStatus;
+ }
+ if (end_pos < l_vector.size()) {
+ std::vector<std::string>::iterator itr = l_vector.begin() + end_pos;
+ l_ePartStatus = removeSameNumFiles(itr, log_path, l_vector);
+ if (l_ePartStatus != eFrameworkunifiedStatusOK) {
+ l_eStatus = l_ePartStatus;
+ }
+ }
+ SyncDir(log_path);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+
+static EFrameworkunifiedStatus deleteOldEmmcLog(CfgInfo& f_cfginfo, // NOLINT (runtime/references)
+ std::string& f_archive_destination, // NOLINT (runtime/references)
+ SS_STORELOGS_OPE_TYPE type) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ DIR *l_dirp = NULL;
+ struct dirent *l_direntp = NULL;
+ std::vector<std::string> vect_abnrm;
+ std::vector<std::string> vect_nrm;
+ std::vector<std::string> vect_rlnc;
+ std::string l_emmc_path = f_cfginfo.output_path;
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ UI_32 abnrm_count = 0;
+
+ if (SS_STORELOGS_SYS_ILLEGAL == type) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+ }
+
+
+ l_dirp = opendir(l_emmc_path.c_str());
+ if (l_dirp != NULL) {
+ while ((l_direntp = readdir(l_dirp)) != NULL) {
+ std::string l_findFileName = l_direntp->d_name;
+
+// if ((std::string::npos != l_findFileName.find("_ILG_RESET.tar.gz"))
+// || (std::string::npos != l_findFileName.find("_ERR.tar.gz"))) {
+ if ((l_findFileName == ".") || (l_findFileName == "..")) {
+ continue;
+ } else if (std::string::npos != l_findFileName.find(SS_STORE_FILENAME_SYSILG_TERM)) {
+ vect_abnrm.push_back(l_findFileName);
+ } else if (std::string::npos != l_findFileName.find(SS_STORE_FILENAME__CWORD52__TERM)) {
+ vect_abnrm.push_back(l_findFileName);
+ } else if((std::string::npos != l_findFileName.find("_ILG_RESET.tar.gz")) ||
+ (std::string::npos != l_findFileName.find("_ERR.tar.gz"))) {
+
+ vect_abnrm.push_back(l_findFileName);
+
+ abnrm_count++;
+
+ } else if (std::string::npos
+ != l_findFileName.find("_GRP_RELAUNCH.tar.gz")) {
+ vect_rlnc.push_back(l_findFileName);
+ } else if (std::string::npos != l_findFileName.find(".tar.gz")) {
+ vect_nrm.push_back(l_findFileName);
+ }
+ }
+ closedir(l_dirp);
+ }
+
+ if (SS_STORELOGS_ILLEGAL == type) {
+ if ((UI_32) f_cfginfo.output_errmax <= vect_abnrm.size()) {
+ l_eStatus = deleteOldLog(l_emmc_path, vect_abnrm, f_archive_destination,
+ (UI_32) f_cfginfo.output_errmax);
+ }
+ } else {
+ if ((UI_32) f_cfginfo.output_max <= vect_nrm.size()) {
+ l_eStatus = deleteOldLog(l_emmc_path, vect_nrm, f_archive_destination,
+ (UI_32) f_cfginfo.output_max);
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
diff --git a/logger_service/server/lib/ss_logger_store_logs_loggerservicelog.h b/logger_service/server/lib/ss_logger_store_logs_loggerservicelog.h
new file mode 100644
index 00000000..1d2880bd
--- /dev/null
+++ b/logger_service/server/lib/ss_logger_store_logs_loggerservicelog.h
@@ -0,0 +1,96 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SystemServices_Logger
+/// \brief This file supports AGL application logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LOGGER_SERVICE_SERVER_LIB_SS_LOGGER_STORE_LOGS_LOGGERSERVICELOG_H_
+#define LOGGER_SERVICE_SERVER_LIB_SS_LOGGER_STORE_LOGS_LOGGERSERVICELOG_H_
+
+#include <native_service/ns_logger_if.h>
+
+#define ZONE_INIT ZONEMASK(10)
+#define ZONE_FUNC ZONEMASK(11)
+#define ZONE_MEM ZONEMASK(12)
+#define ZONE_13 ZONEMASK(13)
+#define ZONE_14 ZONEMASK(14)
+#define ZONE_15 ZONEMASK(15)
+#define ZONE_16 ZONEMASK(16)
+#define ZONE_17 ZONEMASK(17)
+#define ZONE_18 ZONEMASK(18)
+#define ZONE_19 ZONEMASK(19)
+#define ZONE_20 ZONEMASK(20)
+#define ZONE_21 ZONEMASK(21)
+#define ZONE_22 ZONEMASK(22)
+#define ZONE_23 ZONEMASK(23)
+#define ZONE_24 ZONEMASK(24)
+#define ZONE_25 ZONEMASK(25)
+#define ZONE_26 ZONEMASK(26)
+#define ZONE_27 ZONEMASK(27)
+#define ZONE_28 ZONEMASK(28)
+#define ZONE_INFO ZONEMASK(29)
+
+#define ZONE_TEXT_10 "Init"
+#define ZONE_TEXT_11 "Function"
+#define ZONE_TEXT_12 "Memory"
+#define ZONE_TEXT_13 ""
+#define ZONE_TEXT_14 ""
+#define ZONE_TEXT_15 ""
+#define ZONE_TEXT_16 ""
+#define ZONE_TEXT_17 ""
+#define ZONE_TEXT_18 ""
+#define ZONE_TEXT_19 ""
+#define ZONE_TEXT_20 ""
+#define ZONE_TEXT_21 ""
+#define ZONE_TEXT_22 ""
+#define ZONE_TEXT_23 ""
+#define ZONE_TEXT_24 ""
+#define ZONE_TEXT_25 ""
+#define ZONE_TEXT_26 ""
+#define ZONE_TEXT_27 ""
+#define ZONE_TEXT_28 ""
+#define ZONE_TEXT_29 "Info"
+// These ARE RESERVED AND SHOULDN'T BE TOUCHED
+// USE THEM WHEN REALLY NEEDED!!!!!
+#define ZONE_TEXT_30 "Warning"
+#define ZONE_TEXT_31 "Error"
+#define ZONE_WARN ZONEMASK(30)
+#define ZONE_ERR ZONEMASK(31)
+
+#ifndef FRAMEWORKUNIFIEDLOGOPTIONS
+#define FRAMEWORKUNIFIEDLOGOPTIONS (LMSGQ) // LPRINT , LMSGQ, LSLOGGER
+#endif
+
+#ifndef FRAMEWORKUNIFIEDLOGAPPZONES
+#define FRAMEWORKUNIFIEDLOGAPPZONES ZONE_ERR, ZONE_WARN, ZONE_FUNC
+#endif /* FRAMEWORKUNIFIEDLOGAPPZONES */
+
+extern const CHAR AppName[];
+
+typedef enum _ELoggerserviceLogType {
+ eLoggerservicelogTypeNormal,
+ eLoggerservicelogTypeAbnormal,
+
+ eLoggerservicelogTypeSysAbnormal,
+ eLoggerservicelogType_CWORD52_,
+
+ eLoggerservicelogTypeGrpRelaunch,
+ eLoggerservicelogTypeOther,
+} ELOGGERSERVICELOGTYPE;
+
+#endif // LOGGER_SERVICE_SERVER_LIB_SS_LOGGER_STORE_LOGS_LOGGERSERVICELOG_H_
diff --git a/logger_service/server/realtimeUsbLog/Makefile b/logger_service/server/realtimeUsbLog/Makefile
new file mode 100644
index 00000000..2cd5901d
--- /dev/null
+++ b/logger_service/server/realtimeUsbLog/Makefile
@@ -0,0 +1,22 @@
+#
+# @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+
+SUBDIRS += work
+
+
+
+include ../../../system_service.mk
diff --git a/logger_service/server/realtimeUsbLog/realtimeUsbLog.conf_bin b/logger_service/server/realtimeUsbLog/realtimeUsbLog.conf_bin
new file mode 100644
index 00000000..440d361f
--- /dev/null
+++ b/logger_service/server/realtimeUsbLog/realtimeUsbLog.conf_bin
@@ -0,0 +1,4 @@
+/usr/agl/bin|${OSW_reldbg}
+debug|dbg
+release|rel
+product|rel
diff --git a/logger_service/server/realtimeUsbLog/src/Makefile b/logger_service/server/realtimeUsbLog/src/Makefile
new file mode 100644
index 00000000..bdeae32b
--- /dev/null
+++ b/logger_service/server/realtimeUsbLog/src/Makefile
@@ -0,0 +1,77 @@
+#
+# @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+######### installed program #############
+INST_PROGS = realtimeUsbLog
+
+######### installed library(*.a) #############
+
+
+######### installed shared library(*.so) #############
+
+
+######### install headers(*.h) #############
+
+
+######### compiled sources #############
+realtimeUsbLog_SRCS += ss_logger_realtime_usb.cpp
+realtimeUsbLog_SRCS += loggerservice_main.cpp
+######### add source path #############
+VPATH += ../src
+
+######### add include path #############
+CPPFLAGS += -I./
+
+#CPPFLAGS += -I../inc
+#CPPFLAGS += -I../../inc
+CPPFLAGS += -I../../include
+CPPFLAGS += -I../../../../system_manager/server/include
+CPPFLAGS += -I../../../../system_manager/server/include/processlauncher
+
+
+######### add compile option #############
+CPPFLAGS += -DLINUX
+CXXFLAGS += -std=c++11
+CPPFLAGS += -DFRAMEWORKUNIFIEDLOGOPTIONS=0x08 -DFRAMEWORKUNIFIEDLOGAPPZONES=31,30
+######### linked library #############
+
+
+######### linked library (dynamic) #############
+#LDLIBS += -Wl,-Bdynamic -lxxx
+LDLIBS += -Wl,-Bdynamic -lcommon
+#LDLIBS += -Wl,-Bdynamic -lextension
+LDLIBS += -Wl,-Bdynamic -lNS_FrameworkUnified
+LDLIBS += -Wl,-Bdynamic -lSS_SystemIfUnified
+LDLIBS += -Wl,-Bdynamic -lstdc++
+LDLIBS += -Wl,-Bdynamic -lPosixBasedOS001legacy
+
+LDLIBS += -Wl,-Bdynamic -lsssmcfg
+#LDLIBS += -Wl,-Bdynamic -lMounter
+LDLIBS += -Wl,-Bdynamic -lresm
+LDLIBS += -Wl,-Bdynamic -lssver
+LDLIBS += -Wl,-Bdynamic -lSS_RomAccessIf
+#LDLIBS += -Wl,-Bdynamic -lDiagCodeAPI
+LDLIBS += -Wl,-Bdynamic -lvp
+LDLIBS += -Wl,-Bdynamic -ltar -lz
+LDLIBS += -Wl,-Bdynamic -lrt
+LDLIBS += -Wl,-Bdynamic -lvp
+
+######### add library path #############
+
+LDFLAGS += -g -Wl,--gc-sections
+
+LINK_CXX=Y
+include ../../../../system_service.mk
diff --git a/logger_service/server/realtimeUsbLog/src/loggerservice_main.cpp b/logger_service/server/realtimeUsbLog/src/loggerservice_main.cpp
new file mode 100644
index 00000000..b9ca02c9
--- /dev/null
+++ b/logger_service/server/realtimeUsbLog/src/loggerservice_main.cpp
@@ -0,0 +1,103 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SystemManager
+/// \brief Application entry point.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <errno.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <system_service/ss_system_if.h>
+#include <native_service/frameworkunified_dispatcher.h>
+#include <system_service/ss_string_maps.h>
+#include <system_service/ss_version.h>
+#include <native_service/ns_version_if.h>
+#include <system_service/ss_system_types.h>
+#include <system_service/ss_logger_store_logs.h>
+#include <fstream>
+#include <cstdlib>
+
+BOOL g_isExec = FALSE;
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedOnInitialization
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ eStatus = StartRtUsbLogThread(hApp);
+ return eStatus;
+}
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedOnDestroy
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnDestroy(HANDLE hApp) {
+ return eFrameworkunifiedStatusOK;
+}
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedOnDummy
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnDummy(HANDLE hApp) {
+ return eFrameworkunifiedStatusOK;
+}
+
+//////////////////////////////////////////
+// Function : main
+//////////////////////////////////////////
+int main(int argc, char *argv[]) {
+ HANDLE hApp;
+ int nsFd;
+ char clientName[16] = "realtimeUsbLog";
+ FrameworkunifiedDefaultCallbackHandler cbFuncs;
+
+ cbFuncs.onInitilization = FrameworkunifiedOnInitialization;
+ cbFuncs.onDestroy = FrameworkunifiedOnDestroy;
+
+ cbFuncs.onStart = FrameworkunifiedOnDummy;
+ cbFuncs.onStop = FrameworkunifiedOnDummy;
+ cbFuncs.onDebugDump = FrameworkunifiedOnDummy;
+ cbFuncs.createStateMachine = FrameworkunifiedOnDummy;
+ cbFuncs.ssFrameworkInterface = FrameworkunifiedOnDummy;
+
+ FrameworkunifiedCreateDispatcherWithoutLoop(clientName, hApp, argc, argv, &cbFuncs, FALSE);
+
+ FrameworkunifiedGetDispatcherFD(hApp, &nsFd);
+
+ g_isExec = TRUE;
+ while (g_isExec) {
+ fd_set fds;
+ int maxFd = 0;
+
+ FD_ZERO(&fds);
+
+ FD_SET(nsFd, &fds);
+ maxFd = nsFd;
+
+ select(maxFd + 1, &fds, NULL, NULL, NULL);
+
+ if (FD_ISSET(nsFd, &fds)) {
+ FrameworkunifiedDispatchProcessWithoutLoop(hApp);
+ }
+ }
+
+ FrameworkunifiedDestroyDispatcherWithoutLoop(hApp);
+ return 0;
+}
diff --git a/logger_service/server/realtimeUsbLog/src/ss_logger_realtime_usb.cpp b/logger_service/server/realtimeUsbLog/src/ss_logger_realtime_usb.cpp
new file mode 100644
index 00000000..9499a555
--- /dev/null
+++ b/logger_service/server/realtimeUsbLog/src/ss_logger_realtime_usb.cpp
@@ -0,0 +1,722 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_InterfaceunifiedLogCapture
+/// \brief This file contains the standard set functions called by the NS
+// dispatcher on application initialization, cleanup and wakeup.
+///
+///////////////////////////////////////////////////////////////////////////////
+// System Headers
+#include <fcntl.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/param.h>
+#include <sys/time.h>
+#include <mqueue.h>
+#include <errno.h>
+#include <string.h>
+#include <dirent.h>
+#include <time.h>
+#include <loggerservicedebug_loggerservicelog.h>
+#include <native_service/frameworkunified_multithreading.h>
+#include <system_service/ss_system_manager_if.h>
+#include <system_service/ss_system_manager_notifications.h>
+#include <native_service/frameworkunified_timer.h>
+#include <system_service/ss_devicedetection_service_notifications.h>
+#include <system_service/ss_devicedetection_service.h>
+#include <system_service/ss_devicedetection_service_protocol.h>
+#include <system_service/ss_devicedetection_service_ifc.h>
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_service_protocol.h>
+#include <native_service/frameworkunified_types.h>
+#include <queue>
+#include <string>
+
+// System definition
+#ifndef TN_LOGGERRTIME
+#define TN_LOGGERRTIME "LoggerRtime"
+#define PR_LOGGERRTIME_S PR_TSS_S
+#define PR_LOGGERRTIME PR_TSS
+#endif // TN_LOGGERRTIME
+// Queue resource
+#define USB_REALTIME_MSGMAX 256
+#define USB_REALTIME_SIZMAX 4096
+#define USB_REALTIME_QNAME "/PlRtLogger"
+// Folder path
+#define USB_RT_FOLDERPATH_ "/REALTIME_"
+
+// older path
+#define USB_RT_TMP_PATH "/tmp"
+// File name
+#define USB_RT_LOGNAME_TMP "usbrt_tmp.log"
+#define ENC_BUF_MAX_SIZE (1024*8)
+
+#ifdef RELEASE_BUILD
+// encrypt values
+#define DEV_ENC_EXTENSION ".enc1"
+#define REL_ENC_EXTENSION ".enc2"
+#define ALIGNMENT_SIZE 4
+#endif // RELEASE_BUILD
+
+// File path
+#define USB_RT_LOGNAME_ "loggerservice_usb__realtime"
+// Max size of each log file
+#define USB_RT_FILE_SIZE (1024*1024)
+// Num of logs to write in std::queue at one time
+#define QUELOG_WRITE_BLOCK_NUM 300
+// Max of logs to save in std::queue
+#define QUELOG_SAVE_MAX 12000
+#define QUELOG_DELNUM (QUELOG_WRITE_BLOCK_NUM*2) // num of deletion at one time
+// TIMER ID
+#define USB_RT_TIMER_EV 0x89
+#define USB_RT_TIMER_SYNC 1 // kind
+#define USB_RT_TIMER_CYCLE 10000 // cycle of timeout(msec)
+
+static HANDLE g_rt_tid = NULL;
+static int g_wfd = -1;
+static mqd_t g_qid = (mqd_t) - 1;
+static int g_num_of_file = 1;
+static char g_mnt_path[MAXPATHLEN];
+static char g_fld_path[MAXPATHLEN];
+static char g_log_path[MAXPATHLEN];
+static char *g_log_name;
+static bool g_need_sync = false;
+static size_t g_filesize = 0;
+
+//static queue<string> g_saveq;
+static std::queue<std::string> g_saveq;
+
+static DeviceDetectionServiceIf g_devDetect;
+static bool g_usb_available = false;
+
+static char g_log_tmp_path[MAXPATHLEN];
+
+EFrameworkunifiedStatus rtUsbLogThread(HANDLE hApp);
+EFrameworkunifiedStatus rtUsbLogTShutdown(HANDLE hApp);
+EFrameworkunifiedStatus OnPowerOnOffNotification(HANDLE hApp);
+
+EFrameworkunifiedStatus StartTimer(HANDLE hApp, const UI_32 timeout);
+EFrameworkunifiedStatus CancelTimer(void);
+
+// DeviceDetection Related funcs
+EFrameworkunifiedStatus OnDeviceDetectionAvailability(HANDLE hApp);
+EFrameworkunifiedStatus OnDeviceDetectionOpenSessionACK(HANDLE hApp);
+EFrameworkunifiedStatus onDeviceDetectionCloseSessionACK(HANDLE hApp);
+EFrameworkunifiedStatus onUsbDetectCallback(HANDLE hApp);
+
+EFrameworkunifiedStatus EncryptAndCopyFile(void);
+
+EFrameworkunifiedStatus StartRtUsbLogThread(HANDLE hApp) {
+ FrameworkunifiedChildThreadAttr attr;
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (g_rt_tid != NULL) {
+ return eFrameworkunifiedStatusOK;
+ }
+
+ // Create Realtime USB Logging Thread and start
+ memset(&attr, 0, sizeof(FrameworkunifiedChildThreadAttr));
+ // One time while to break on Error
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedCreateChildThreadAttrSetSched(&attr,
+ eFrameworkunifiedSchedPolicyTSS,
+ PR_LOGGERRTIME))) {
+ return l_eStatus;
+ }
+ g_rt_tid = FrameworkunifiedCreateChildThreadWithAttribute(hApp, TN_LOGGERRTIME,
+ rtUsbLogThread,
+ rtUsbLogTShutdown, &attr);
+ if (g_rt_tid == NULL) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ l_eStatus = FrameworkunifiedStartChildThread(hApp, g_rt_tid, 0, (PVOID) NULL);
+ }
+
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus StopRtUsbLogThread(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ // Close fd to sync
+ if (g_wfd != -1) {
+ if (0 != close(g_wfd)) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ EncryptAndCopyFile();
+ }
+ // Close message queue
+ if (g_qid != (mqd_t) - 1) {
+ if (0 != mq_close(g_qid)) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ }
+ // Terminate Thread
+ if (eFrameworkunifiedStatusOK != FrameworkunifiedStopChildThread(hApp, g_rt_tid, 0, NULL)) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ if (eFrameworkunifiedStatusOK != FrameworkunifiedDestroyChildThread(hApp, g_rt_tid)) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus OnPowerOnOffNotification(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ T_SS_SM_UserModeOnOffNotification_StructType onoff_mode;
+
+ l_eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID) &onoff_mode,
+ sizeof(onoff_mode));
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ fprintf(stderr, "%s: Failed to fetch OnOff Mode\n", __FUNCTION__);
+ return l_eStatus;
+ }
+ if (!onoff_mode.isUserModeOn) { // ACC-OFF
+ // Close fd to sync
+ if (g_wfd >= 0) {
+ syncfs(g_wfd);
+ if (0 != close(g_wfd)) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ EncryptAndCopyFile();
+ g_wfd = -2; // ACC-OFF detected
+ }
+ }
+ return l_eStatus;
+}
+
+static int getStartFileNum(void) {
+ int start = 0;
+ int num;
+ DIR *dirp;
+ struct dirent entry;
+ struct dirent *next;
+
+ if ((dirp = opendir(g_fld_path)) == NULL) {
+ fprintf(stderr, "%s: Failed in opendir, errno=%d\n", __FUNCTION__, errno);
+ return -1;
+ }
+ for (;;) {
+ if (readdir_r(dirp, &entry, &next) != 0) {
+ fprintf(stderr, "%s: Failed in readdir_r, errno=%d\n", __FUNCTION__,
+ errno);
+ closedir(dirp);
+ return -1;
+ }
+ if (next == NULL) { // NO more
+ break;
+ }
+ if (strncmp(entry.d_name, g_log_name, strlen(g_log_name)) != 0) {
+ continue;
+ }
+ num = atoi(entry.d_name + strlen(g_log_name));
+ if (num > start) {
+ start = num;
+ }
+ }
+ closedir(dirp);
+ start++;
+
+ return start;
+}
+
+EFrameworkunifiedStatus WriteAndSwitchLogFile(const char* data, ssize_t size) {
+ ssize_t wrotelen;
+ char logpath[MAXPATHLEN];
+
+ wrotelen = write(g_wfd, data, size);
+ if (wrotelen != size) {
+ close(g_wfd);
+ g_wfd = -1;
+ g_filesize = 0;
+ EncryptAndCopyFile();
+ fprintf(stderr, "%s: Failed to write, size=%d, wrotelen=%d, errno=%d\n",
+
+// __FUNCTION__, static_cast<int32_t>size, static_cast<int32_t>wrotelen, errno);
+ __FUNCTION__, static_cast<int32_t>(size), static_cast<int32_t>(wrotelen), errno);
+
+ return eFrameworkunifiedStatusFail;
+ } else {
+ g_filesize += wrotelen;
+ g_need_sync = true;
+ if (static_cast<int>(g_filesize) >= USB_RT_FILE_SIZE) {
+ g_filesize = 0;
+ close(g_wfd);
+ EncryptAndCopyFile();
+ g_num_of_file++;
+
+
+// snprintf(logpath, "%s/%s", g_log_tmp_path, USB_RT_LOGNAME_TMP);
+ snprintf(logpath, MAXPATHLEN, "%s/%s", g_log_tmp_path, USB_RT_LOGNAME_TMP);
+
+ if ((g_wfd = open(logpath, O_RDWR | O_CREAT | O_TRUNC | O_CLOEXEC, 0644))
+ == -1) {
+ fprintf(stderr, "%s: Failed to open file %s, errno=%d\n", __FUNCTION__,
+ logpath, errno);
+ return eFrameworkunifiedStatusFail;
+ }
+ }
+ }
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus OnMessageQueueReceived(HANDLE hApp) {
+ ssize_t len, len2;
+ char msg[USB_REALTIME_SIZMAX], msg2[USB_REALTIME_SIZMAX];
+ char logpath[MAXPATHLEN];
+ unsigned int prior;
+ struct stat stbuf;
+
+// string work_str;
+ std::string work_str;
+
+ bool pushed = false;
+ const struct timespec tspec = { 0, 0 };
+
+ // write loop
+ while (1) {
+ pushed = false;
+ if (g_qid == (mqd_t) - 1) { // Already ACC-OFFed
+ return eFrameworkunifiedStatusOK;
+ }
+ len = mq_timedreceive(g_qid, msg, sizeof(msg), &prior, &tspec);
+ if (len == (ssize_t) - 1) { // NO more data
+ if (errno != ETIMEDOUT) {
+ fprintf(stderr, "%s: Unexpected error %d\n", __FUNCTION__, errno);
+ }
+ break;
+ }
+ // Remove overflowed log
+ if (g_saveq.size() > QUELOG_SAVE_MAX) {
+ int delnum = g_saveq.size() - QUELOG_SAVE_MAX + QUELOG_DELNUM;
+ for (int i = 0; i < delnum; i++) {
+ g_saveq.pop();
+ }
+ }
+ // check if file is opened
+ if (g_wfd == -1) {
+ /*
+ * Make folder and open log file
+ */
+ // save dequeued log
+
+// g_saveq.push(string((const char*) msg, len));
+ g_saveq.push(std::string((const char*) msg, len));
+
+ pushed = true; // request pushed or NON-log message -> NO NEED to write this data to log file
+ // Check USB mounted
+ if (!g_usb_available) {
+ // No mount event is received
+ continue;
+ }
+ // Check USB mounted
+ if (stat(g_mnt_path, &stbuf) != 0) {
+ // No mount path found
+ continue;
+ }
+ // Check and make subfolder
+ int mkdres = mkdir(g_fld_path, 0666);
+ if (mkdres == 0) {
+ g_num_of_file = 1;
+ } else if (mkdres == -1 && errno == EEXIST) {
+ // Decide file number to start(Check current log files)
+ g_num_of_file = getStartFileNum();
+ if (g_num_of_file <= 0) {
+ fprintf(stderr, "%s: Failed in getStartFileNum\n", __FUNCTION__);
+ continue;
+ }
+ } else {
+ fprintf(stderr, "%s: Failed to mkdir %s, errno=%d\n", __FUNCTION__,
+ g_fld_path, errno);
+ continue;
+ }
+
+ // Open File
+ g_filesize = 0;
+
+
+// snprintf(logpath, "%s/%s", g_log_tmp_path, USB_RT_LOGNAME_TMP);
+ snprintf(logpath, MAXPATHLEN, "%s/%s", g_log_tmp_path, USB_RT_LOGNAME_TMP);
+
+ if ((g_wfd = open(logpath, O_RDWR | O_CREAT | O_TRUNC | O_CLOEXEC, 0644))
+ == -1) {
+ fprintf(stderr, "%s: Failed to open file %s, errno=%d\n", __FUNCTION__,
+ logpath, errno);
+ continue;
+ }
+ } else if (g_wfd == -2) {
+ // Already ACC-OFF, Just throw the logs away
+ continue;
+ }
+ // Write out saved log if any
+ int written_once = QUELOG_WRITE_BLOCK_NUM; // num of written at once
+ while (1) {
+ if (g_saveq.empty()) {
+ break;
+ }
+ if (written_once >= QUELOG_WRITE_BLOCK_NUM) {
+ written_once = 0;
+ while (1) {
+ // read request queue
+ len2 = mq_timedreceive(g_qid, msg2, sizeof(msg2), &prior, &tspec);
+ if (len2 == (ssize_t) - 1) { // NO MORE data
+ if (errno != ETIMEDOUT) {
+ fprintf(stderr, "%s: Unexpected error %d\n", __FUNCTION__, errno);
+ }
+ break;
+ }
+
+// g_saveq.push(string((const char*) msg2, len2));
+ g_saveq.push(std::string((const char*) msg2, len2));
+
+ }
+ }
+ work_str = g_saveq.front();
+ if (eFrameworkunifiedStatusOK
+ != WriteAndSwitchLogFile(work_str.data(), work_str.length())) {
+ fprintf(stderr, "%s: Failed in write Saved data, errno=%d\n",
+ __FUNCTION__, errno);
+ break;
+ } else {
+ written_once++;
+ g_saveq.pop();
+ }
+ }
+ if (pushed || g_wfd == -1) {
+ continue;
+ }
+ // write data
+ if (eFrameworkunifiedStatusOK != WriteAndSwitchLogFile(msg, len)) {
+ fprintf(stderr, "%s: Failed in write Saved data-2, errno=%d\n",
+ __FUNCTION__, errno);
+ }
+ }
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus OnSyncTimeout(HANDLE hApp) {
+ if (g_need_sync) {
+ if (g_wfd != -1 && g_wfd != -2) {
+ char logpath[MAXPATHLEN];
+ fsync(g_wfd);
+ close(g_wfd);
+ g_wfd = -1;
+ EncryptAndCopyFile();
+
+// snprintf(logpath, "%s/%s", g_log_tmp_path, USB_RT_LOGNAME_TMP);
+ snprintf(logpath, MAXPATHLEN, "%s/%s", g_log_tmp_path, USB_RT_LOGNAME_TMP);
+
+ if ((g_wfd = open(logpath, O_RDWR | O_CREAT | O_APPEND | O_CLOEXEC, 0644))
+ == -1) {
+ fprintf(stderr, "%s: Failed to open file %s, errno=%d (%s)\n",
+ __FUNCTION__, logpath, errno, strerror(errno));
+ // because in order to continue to obtain logs.
+ return eFrameworkunifiedStatusOK;
+ }
+ g_need_sync = false;
+ }
+ }
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus rtUsbLogThread(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ struct mq_attr qattr;
+ const struct timespec idle_time = { 1, 0 }; // 1sec
+ HANDLE timer_handle = NULL;
+
+ // Subscribe Boot Mode Notifcation to SysMgr
+ l_eStatus = FrameworkunifiedSubscribeNotificationWithCallback(hApp,
+ NTFY_SSSystemMgrPowerOnOff,
+ OnPowerOnOffNotification);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ fprintf(stderr, "%s: Subscribe PowerOnOff failed, status=%d\n",
+ __FUNCTION__, l_eStatus);
+ }
+ // Subscribe Device Detection Availability
+ while (1) {
+ if (g_devDetect.Initialize(hApp)) {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = g_devDetect.NotifyOnDeviceDetectionAvailability(
+ OnDeviceDetectionAvailability))) {
+ fprintf(stderr,
+ "%s: DevDetec AvailabilityCallback registration failed\n",
+ __FUNCTION__);
+ }
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = g_devDetect.NotifyOnOpenSessionAck(
+ OnDeviceDetectionOpenSessionACK))) {
+ fprintf(stderr, "%s: DevDetec OpenSession ACK registration failed\n",
+ __FUNCTION__);
+ }
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = g_devDetect.NotifyOnCloseSessionAck(
+ onDeviceDetectionCloseSessionACK))) {
+ fprintf(stderr, "%s: DevDetec CloseSession ACK registration failed\n",
+ __FUNCTION__);
+ }
+ break;
+ } else {
+ fprintf(stderr, "%s: Device Detection Object Initialization failed\n",
+ __FUNCTION__);
+ nanosleep(&idle_time, NULL);
+ }
+ }
+
+ // open message queue
+ while (1) {
+ qattr.mq_flags = 0;
+ qattr.mq_maxmsg = USB_REALTIME_MSGMAX;
+ qattr.mq_msgsize = USB_REALTIME_SIZMAX;
+ qattr.mq_curmsgs = 0;
+ if ((g_qid = mq_open(USB_REALTIME_QNAME, O_RDWR | O_CREAT, 0666, &qattr))
+ >= (mqd_t) 0) {
+ break;
+ }
+ fprintf(stderr, "%s: Failed in mq_open, errno=%d\n", __FUNCTION__, errno);
+ nanosleep(&idle_time, NULL);
+ }
+
+ // Attach callback func to message queue fd
+ l_eStatus = FrameworkunifiedAttachCallbackToDispatcherWithFd(hApp, static_cast<int>(g_qid),
+ OnMessageQueueReceived);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ fprintf(
+ stderr,
+ "%s: Error in FrameworkunifiedAttachCallbackToDispatcherWithFd with mq_fd, status=%d\n",
+ __FUNCTION__, l_eStatus);
+ return l_eStatus;
+ }
+ // Start Cyclic Timer
+ timer_handle = FrameworkunifiedAttachTimerCallback(hApp, USB_RT_TIMER_CYCLE,
+ USB_RT_TIMER_CYCLE,
+ OnSyncTimeout);
+ if (timer_handle == NULL) {
+ fprintf(stderr, "%s: Error in FrameworkunifiedAttachTimerCallback\n", __FUNCTION__);
+ return eFrameworkunifiedStatusFail;
+ }
+
+ // Enter dispatcher ==> Just return
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus rtUsbLogTShutdown(HANDLE hApp) {
+ return eFrameworkunifiedStatusOK;
+}
+
+EFrameworkunifiedStatus OnDeviceDetectionAvailability(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (FrameworkunifiedIsServiceAvailable(hApp)) {
+ if (eFrameworkunifiedStatusOK != (eStatus = g_devDetect.OpenSessionRequest())) {
+ fprintf(stderr, "%s: Open session request failed\n", __FUNCTION__);
+ }
+ } else {
+ if (eFrameworkunifiedStatusOK != (eStatus = g_devDetect.CloseSessionRequest())) {
+ fprintf(stderr, "%s: Close session request failed\n", __FUNCTION__);
+ }
+ }
+ return eStatus;
+}
+
+EFrameworkunifiedStatus OnDeviceDetectionOpenSessionACK(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (eFrameworkunifiedStatusOK == (eStatus = g_devDetect.DecodeOpenSessionResponse())) {
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = g_devDetect.RegisterForDeviceDetectionEvent(
+ SS_DEV_DETECT_ANY_USB_EV, onUsbDetectCallback))) {
+ fprintf(stderr, "%s: Registration for SS_DEV_DETECT_ANY_USB_EV failed\n",
+ __FUNCTION__);
+ }
+ } else {
+ fprintf(stderr, "%s: Decode open session response failed\n", __FUNCTION__);
+ }
+ return eStatus;
+}
+
+EFrameworkunifiedStatus onDeviceDetectionCloseSessionACK(HANDLE hApp) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ CloseSessionAck tCloseSessionAck;
+
+ if (hApp) {
+ if (eFrameworkunifiedStatusOK
+ == (eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &tCloseSessionAck,
+ sizeof(tCloseSessionAck)))) {
+ if (eFrameworkunifiedStatusOK != tCloseSessionAck.eStatus) {
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+ }
+ }
+ return eStatus;
+}
+
+EFrameworkunifiedStatus onUsbDetectCallback(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ SS_MediaDetectInfo l_tMediaDetectInfo;
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &l_tMediaDetectInfo,
+ sizeof(l_tMediaDetectInfo)))) {
+ fprintf(stderr, "%s: FrameworkunifiedGetMsgDataOfSize Failed Status:0x%x\n",
+ __FUNCTION__, l_eStatus);
+ } else {
+ if (l_tMediaDetectInfo.dev_type != eUSB) { // NOT mass storage device
+ return l_eStatus;
+ }
+ if (l_tMediaDetectInfo.bIsDeviceAvailable) {
+ if (g_usb_available) { // Already mounted
+ return l_eStatus;
+ }
+ // set USB device available
+ g_usb_available = true;
+ // Organize paths to access
+ strncpy(g_mnt_path, l_tMediaDetectInfo.deviceMountpath,
+ sizeof(g_mnt_path));
+
+ snprintf(g_fld_path, MAXPATHLEN, "%s%s", g_mnt_path, USB_RT_FOLDERPATH_);
+ snprintf(g_log_path, MAXPATHLEN, "%s/%s", g_fld_path, USB_RT_LOGNAME_);
+ g_log_name = const_cast<char*>(USB_RT_LOGNAME_);
+
+
+
+// snprintf(g_log_tmp_path, "%s", USB_RT_TMP_PATH);
+ snprintf(g_log_tmp_path, MAXPATHLEN, "%s", USB_RT_TMP_PATH);
+
+
+ } else {
+ // unset USB device available
+ if (strcmp(l_tMediaDetectInfo.deviceMountpath, g_mnt_path) == 0) {
+ g_usb_available = false;
+ g_mnt_path[0] = 0;
+ if (g_wfd != -1 && g_wfd != -2) {
+ close(g_wfd);
+ g_wfd = -1;
+ EncryptAndCopyFile();
+ }
+ }
+ }
+ }
+
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus EncryptAndCopyFile(void) {
+ char usblogpath[MAXPATHLEN];
+ char logpath[MAXPATHLEN];
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ int rfd, wfd;
+ int ret;
+ struct stat istat_buf;
+
+
+// snprintf(usblogpath, "%s%05d.log", g_log_path, g_num_of_file);
+
+// snprintf(logpath, "%s/%s", g_log_tmp_path, USB_RT_LOGNAME_TMP);
+ snprintf(usblogpath, MAXPATHLEN, "%s%05d.log", g_log_path, g_num_of_file);
+
+ snprintf(logpath, MAXPATHLEN, "%s/%s", g_log_tmp_path, USB_RT_LOGNAME_TMP);
+
+
+ rfd = open(logpath, O_RDWR | O_CLOEXEC);
+ if (rfd == -1) {
+ fprintf(stderr, "%s: Error. Failed to open file: %s for reading.\n",
+ __FUNCTION__, logpath);
+ return eFrameworkunifiedStatusFail;
+ }
+
+ ret = fstat(rfd, &istat_buf);
+ if (ret < 0) {
+ fprintf(stderr, "%s: Error. stat(%s). errno: %d, %s \n", __FUNCTION__,
+ logpath, errno, strerror(errno));
+ close(rfd);
+ return eFrameworkunifiedStatusFail;
+ } else {
+ BYTE *pData;
+ int total_len;
+ int read_len;
+ off_t total_size = istat_buf.st_size;
+
+ wfd = open(usblogpath, O_RDWR | O_APPEND | O_TRUNC | O_CREAT | O_CLOEXEC,
+ 0644);
+ if (wfd == -1) {
+ fprintf(stderr, "%s: Error. Failed to open file: %s for reading.\n",
+ __FUNCTION__, usblogpath);
+ close(rfd);
+ return eFrameworkunifiedStatusFail;
+ }
+
+ pData = reinterpret_cast<BYTE*>(malloc(ENC_BUF_MAX_SIZE));
+ if (pData == NULL) {
+ fprintf(stderr, "%s: Error. Failed to malloc %d byte for dst \n",
+ __FUNCTION__, ENC_BUF_MAX_SIZE);
+ close(rfd);
+ close(wfd);
+ return eFrameworkunifiedStatusFail;
+ }
+
+ total_len = static_cast<int>(total_size);
+ do {
+ read_len = read(rfd, pData, ENC_BUF_MAX_SIZE);
+ if (read_len == -1) {
+ fprintf(stderr, "%s: Error. File read failed. errno: %d, %s \n",
+ __FUNCTION__, errno, strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusFail;
+ break;
+ }
+ ret = write(wfd, pData, read_len);
+ if (ret == -1) {
+ fprintf(stderr, "%s: Error. length(%d) no space to write: %d, %s \n",
+ __FUNCTION__, ret, errno, strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusFail;
+ break;
+ }
+ total_len -= read_len;
+ } while (total_len > 0);
+
+ fsync(wfd);
+ free(pData);
+ close(wfd);
+ close(rfd);
+
+ if (l_eStatus == eFrameworkunifiedStatusFail) {
+ return l_eStatus;
+ }
+ {
+ // Synchronization security
+ struct stat ostat_buf;
+ while (1) {
+ ret = stat(usblogpath, &ostat_buf);
+ if (ret < 0) {
+ fprintf(stderr, "%s: Error. stat(%s). errno: %d, %s", __FUNCTION__,
+ usblogpath, errno, strerror(errno));
+ break;
+ }
+ if (ostat_buf.st_size >= total_size) {
+ break;
+ }
+ usleep(1000); // interval
+ }
+ }
+ }
+ return l_eStatus;
+}
diff --git a/logger_service/server/realtimeUsbLog/work/Makefile b/logger_service/server/realtimeUsbLog/work/Makefile
new file mode 100644
index 00000000..61a53ddf
--- /dev/null
+++ b/logger_service/server/realtimeUsbLog/work/Makefile
@@ -0,0 +1,23 @@
+#
+# @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#ADD_EXT:=rel
+
+
+LDLIBS += -Wl,-Bdynamic -lcrypto
+CPPFLAGS += -DRELEASE_BUILD
+
+include ../src/Makefile
diff --git a/logger_service/server/realtimeUsbLog/work_debug/Makefile b/logger_service/server/realtimeUsbLog/work_debug/Makefile
new file mode 100644
index 00000000..5654d9df
--- /dev/null
+++ b/logger_service/server/realtimeUsbLog/work_debug/Makefile
@@ -0,0 +1,19 @@
+#
+# @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+ADD_EXT:=dbg
+
+include ../src/Makefile
diff --git a/logger_service/server/screenShot/Makefile b/logger_service/server/screenShot/Makefile
new file mode 100644
index 00000000..8f801231
--- /dev/null
+++ b/logger_service/server/screenShot/Makefile
@@ -0,0 +1,53 @@
+#
+# @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+######### installed program #############
+INST_PROGS = SS_ScrShot
+
+######### installed library(*.a) #############
+
+
+######### installed shared library(*.so) #############
+
+
+######### install headers(*.h) #############
+
+
+######### compiled sources #############
+SS_ScrShot_SRCS = ss_logger_scrshot.cpp
+
+######### add source path #############
+
+
+######### add compile option #############
+CPPFLAGS += -DLINUX
+CPPFLAGS += -fno-exceptions
+
+######### linked library #############
+
+
+######### linked library (dynamic) #############
+LDLIBS += -Wl,-Bdynamic -ldu
+LDLIBS += -Wl,-Bdynamic -ljpeg
+#LDLIBS += -Wl,-Bdynamic -lextension
+LDLIBS += -Wl,-Bdynamic -lvp
+LDLIBS += -Wl,-Bdynamic -ldrm
+
+######### add library path #############
+LDFLAGS += -Wl,--gc-sections
+
+LINK_CXX=Y
+include ../../../system_service.mk
diff --git a/logger_service/server/screenShot/ss_logger_scrshot.cpp b/logger_service/server/screenShot/ss_logger_scrshot.cpp
new file mode 100644
index 00000000..d45b212e
--- /dev/null
+++ b/logger_service/server/screenShot/ss_logger_scrshot.cpp
@@ -0,0 +1,89 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief
+///
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <jpeglib.h>
+#include <du.h>
+
+#define MAX_IMAGE_WIDTH 1280
+#define MAX_IMAGE_HEIGHT 480
+#define COLOR_COMPONENT 4
+
+int SS_Logger_SaveScreenShot(const char* filename, int type) {
+ FILE *outfile;
+ struct SCRSHOT_capture_arg stSCR;
+ struct jpeg_compress_struct cinfo;
+ struct jpeg_error_mgr jerr;
+ unsigned char *work_buf;
+
+ stSCR.du = type; // 0:E2 1:M2
+ stSCR.fmt = SCRSHOT_FMT_ARGB8888;
+ stSCR.buff = malloc(MAX_IMAGE_WIDTH * MAX_IMAGE_HEIGHT * COLOR_COMPONENT);
+ stSCR.buff_len = MAX_IMAGE_WIDTH * MAX_IMAGE_HEIGHT * COLOR_COMPONENT;
+ stSCR.ev_handler = NULL; // sync mode
+
+ if (stSCR.buff == NULL) {
+ exit(1);
+ }
+
+ if (SCRSHOT_RET_SUCCESS != SCRSHOT_capture(&stSCR)) {
+ exit(1);
+ }
+
+ cinfo.err = jpeg_std_error(&jerr);
+ jpeg_create_compress(&cinfo);
+
+ if ((outfile = fopen(filename, "wb")) == NULL) {
+ exit(1);
+ }
+ jpeg_stdio_dest(&cinfo, outfile);
+ cinfo.image_width = stSCR.width;
+ cinfo.image_height = stSCR.height;
+ cinfo.input_components = COLOR_COMPONENT;
+ cinfo.in_color_space = JCS_EXT_BGRA;
+ jpeg_set_defaults(&cinfo);
+ jpeg_start_compress(&cinfo, TRUE);
+
+ work_buf = (unsigned char*) stSCR.buff;
+ for (unsigned int i = 0; i < stSCR.height; i++) {
+ jpeg_write_scanlines(&cinfo, (JSAMPARRAY) & (work_buf), 1);
+ work_buf += stSCR.width * COLOR_COMPONENT;
+ }
+
+ jpeg_finish_compress(&cinfo);
+ jpeg_destroy_compress(&cinfo);
+ free(stSCR.buff);
+ fclose(outfile);
+ exit(0);
+}
+
+int main(int argc, char *argv[]) {
+ if (argc < 3) {
+ exit(1);
+ }
+ int chType = atoi(argv[2]);
+ SS_Logger_SaveScreenShot(argv[1], chType);
+
+ return 0;
+}
diff --git a/logger_service/server/src/cached_file_writer.cpp b/logger_service/server/src/cached_file_writer.cpp
new file mode 100644
index 00000000..e7d392e5
--- /dev/null
+++ b/logger_service/server/src/cached_file_writer.cpp
@@ -0,0 +1,79 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "readerWriter/writer/cached_file_writer.h"
+#include <native_service/frameworkunified_types.h>
+
+namespace ReaderWriter {
+
+CCachedFileWriter::CCachedFileWriter() {
+ std::memset(this->m_buffer, 0, CACHED_BLOCK_SIZE);
+ m_index = 0u;
+}
+
+CCachedFileWriter::~CCachedFileWriter() {
+}
+
+EFrameworkunifiedStatus CCachedFileWriter::Write(UI_8* f_data, UI_32 f_length,
+ SI_32& f_bytesWritten) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ // length check
+ if (f_data != NULL) { // LCOV_EXCL_BR_LINE 200: f_data can not be null
+ if ((this->m_index + f_length) > CACHED_BLOCK_SIZE) { // LCOV_EXCL_BR_LINE 200: data size can not over 4*1024
+ l_eStatus = this->FlushCache();
+ }
+ if (f_length > CACHED_BLOCK_SIZE) { // LCOV_EXCL_BR_LINE 200: data size can not over 4*1024
+ // LCOV_EXCL_START 200: data size can not over 4*1024
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Possible memory corruption.");
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. Length(%d) bigger than cache. Will dump memory to core and ignore data. ",
+ f_length);
+ // LCOV_EXCL_STOP
+ } else {
+ (void) std::memcpy(&this->m_buffer[this->m_index], f_data, f_length);
+ this->m_index += f_length;
+ f_bytesWritten = f_length;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CCachedFileWriter::FlushCache(void) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ SI_32 l_written = 0;
+ SI_32 l_writtenTotal = 0;
+ while (((l_writtenTotal >= 0) && ((UI_32) l_writtenTotal < this->m_index))
+ && (eFrameworkunifiedStatusOK == l_eStatus)) {
+ l_eStatus = this->WriteData(&this->m_buffer[l_writtenTotal],
+ this->m_index - l_writtenTotal, l_written);
+ l_writtenTotal += l_written;
+ l_written = 0;
+ }
+ this->m_index = 0;
+ return l_eStatus;
+}
+} // namespace ReaderWriter
diff --git a/logger_service/server/src/file_writer.cpp b/logger_service/server/src/file_writer.cpp
new file mode 100644
index 00000000..7d7fb8b2
--- /dev/null
+++ b/logger_service/server/src/file_writer.cpp
@@ -0,0 +1,122 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "readerWriter/writer/file_writer.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string>
+
+namespace ReaderWriter {
+CFileWriter::CFileWriter()
+ : m_FileHandle(-1),
+ m_fileposn(-1),
+ m_maxFileSize(0) {
+}
+
+CFileWriter::~CFileWriter() {
+ if (this->m_FileHandle != -1) { // LCOV_EXCL_BR_LINE 200: it aways open, so m_FileHandle can not be -1
+ this->Close();
+ this->m_FileHandle = -1;
+ }
+}
+
+EFrameworkunifiedStatus CFileWriter::Initialize(CLoggerCfg* f_pLoggerCfg,
+ std::string f_Name1, UI_32 f_size1,
+ std::string f_Name2, UI_32 f_size2) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ this->m_pLoggerCfg = f_pLoggerCfg;
+ this->m_maxFileSize = f_size1;
+ if ((f_Name1.length() != 0) && (this->m_FileHandle == -1)) { // LCOV_EXCL_BR_LINE 6:Due to the initial status
+ m_filename = f_Name1;
+ l_eStatus = this->Open();
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %d", l_eStatus);
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CFileWriter::Open(void) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ if (this->m_FileHandle != -1) { // LCOV_EXCL_BR_LINE 6:Due to the initial status
+ // File already opened, no action required.
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else if (m_filename.length() != 0) { // LCOV_EXCL_BR_LINE 6:Because the applicable variable cannot be changed from the external API
+ this->m_FileHandle = open(m_filename.c_str(),
+ O_WRONLY | O_CREAT | O_TRUNC,
+ 0644);
+ if (-1 != this->m_FileHandle) { // LCOV_EXCL_BR_LINE 5:The open cannot pass because it cannot be mock
+ l_eStatus = eFrameworkunifiedStatusOK;
+ m_fileposn = lseek(m_FileHandle, 0L, SEEK_CUR);
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %d", l_eStatus);
+ return (l_eStatus);
+}
+
+BOOL CFileWriter::IsOpen(void) {
+ return (-1 == m_FileHandle) ? FALSE : TRUE;
+}
+
+EFrameworkunifiedStatus CFileWriter::Write(UI_8* f_data, UI_32 f_length,
+ SI_32& f_bytesWritten) {
+ return (this->WriteData(f_data, f_length, f_bytesWritten));
+}
+
+EFrameworkunifiedStatus CFileWriter::WriteData(UI_8* f_data, UI_32 f_length,
+ SI_32& f_bytesWritten) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ f_bytesWritten = 0;
+ if (-1 == m_FileHandle) { // LCOV_EXCL_BR_LINE 200: m_FileHandle can not be null
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ while ((eFrameworkunifiedStatusOK == l_eStatus)
+ && ((f_bytesWritten >= 0) && ((UI_32) f_bytesWritten < f_length))) {
+ SI_32 l_bytesWritten = -1;
+ m_fileposn = lseek(m_FileHandle, 0L, SEEK_CUR);
+ if ((m_fileposn + (UI_32) f_length) >= this->m_maxFileSize) {
+ SI_32 l_deltaLength = static_cast<SI_32>(this->m_maxFileSize - m_fileposn);
+ l_bytesWritten = static_cast<SI_32>(write(m_FileHandle, &f_data[f_bytesWritten],
+ l_deltaLength));
+ f_bytesWritten += l_bytesWritten;
+ if ((l_bytesWritten >= 0) && (l_deltaLength == l_bytesWritten)) {
+ m_fileposn = lseek(m_FileHandle, 0L, SEEK_SET);
+ }
+ } else {
+ l_bytesWritten = static_cast<SI_32>(write(m_FileHandle, &f_data[f_bytesWritten],
+ f_length - f_bytesWritten));
+ f_bytesWritten += l_bytesWritten;
+ }
+ l_eStatus = (l_bytesWritten > -1) ? eFrameworkunifiedStatusOK : eFrameworkunifiedStatusFail;
+ }
+
+ return (l_eStatus);
+}
+
+void CFileWriter::Close() { // LCOV_EXCL_START 6:Because the condition cannot be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (this->m_FileHandle != -1) {
+ (void) close(this->m_FileHandle);
+ this->m_FileHandle = -1;
+ }
+}
+// LCOV_EXCL_STOP
+} // namespace ReaderWriter
diff --git a/logger_service/server/src/loggerservice_application.cpp b/logger_service/server/src/loggerservice_application.cpp
new file mode 100644
index 00000000..d67ee088
--- /dev/null
+++ b/logger_service/server/src/loggerservice_application.cpp
@@ -0,0 +1,1161 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_InterfaceunifiedLogCapture
+/// \brief This file contains the standard set functions called by the NS
+// dispatcher on application initialization, cleanup and wakeup.
+///
+///////////////////////////////////////////////////////////////////////////////
+// System Headers
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_service_protocol.h>
+#include <native_service/frameworkunified_types.h>
+#include <native_service/cl_process.h>
+
+#include <native_service/nslogutil_cmd_if.h>
+#include <native_service/ns_np_service.h>
+#include <native_service/ns_np_service_protocol.h>
+
+#include <loggerservicedebug_loggerservicelog.h>
+#include <loggerservicedebug_thread_if.h>
+#include <loggerservicedebug_writer_Evntworker.h>
+
+#include <native_service/frameworkunified_timer.h>
+#include <ss_logger_device_detection.h>
+
+#include <ss_logger_cfg.h>
+#include <system_service/ss_logger_service_notifications.h>
+#include <system_service/ss_logger_service.h>
+#include <ss_logger_service_callbacks.h>
+
+#include <system_service/ss_sm_client_if.h>
+
+#include <system_service/ss_sm_rom_access.h>
+#include <system_service/ss_system_manager_if.h>
+#include <system_service/ss_system_manager_protocol.h>
+#include <system_service/ss_system_manager_notifications.h>
+
+#include <system_service/ss_devicedetection_service_notifications.h>
+#include <system_service/ss_devicedetection_service_ifc.h>
+#include <system_service/ss_services.h>
+#include <ss_logger_error_event.h>
+#include <ss_logger_reader_writer_control.h>
+#include <ss_logger_common.h>
+//#include <stub/pfdrec_thread_ifc.h>
+#include <system_service/ss_templates.h>
+#include <system_service/ss_logger_store_logs.h>
+#include <queue>
+#include <string>
+
+// const definitions
+#define TMPFS_PATH "/tmp"
+
+#define SYS_ILLEGAL_LOG_DELAY_TIME ( 20 * 1000 )
+const CHAR LOGGERSERVICELOGGER_SETPARAMS[] = TMPFS_PATH "/loggerservicelogger_setparams.log";
+const CHAR Counter_LOG_PATH_FN[] = TMPFS_PATH "/loggerservice_counter.log";
+const CHAR Mileage_LOG_PATH_FN[] = TMPFS_PATH "/loggerservice_mileage.log";
+
+const CHAR g_strLogQueWriterWorkerName[] = "pdg.LogQueWriter";
+const CHAR g_strTransmitQueWriterWorkerName[] = "pdg.TransmitQueWriter";
+const CHAR g_strUdpQueWriterWorkerName[] = "pdg.UdpQueWriter";
+const CHAR g_strEvntLogQueWorkerName[] = "pdg.EvntLogQue";
+
+// handles to writer threads
+static HANDLE g_thrdLogWriter = NULL; // Var. that holds the child handle to the Log Writer thread
+static HANDLE g_thrdTxWriter = NULL; // Var. that holds the child handle to the Tx Writer thread
+
+/// Event_logger
+HANDLE g_thrdEvntLogWriter = NULL; // Var. that holds the child handle to the EVNTLOGGER Writer thread
+static TEvntWriterInfo Evntlog_wi = { };
+TUploadEventLogResp g_stUploadEventLogResp;
+
+// global variable to store the service status
+ELOGGERSERVICESTATUS g_eLoggerServiceStatus = eLSInit;
+
+// class to usb and reader threads
+LoggerserviceDebugChildThread g_loggerservicedebug_threads;
+
+/// Device Detection Class Instance
+DeviceDetectionServiceIf g_devDetect_t;
+
+CLoggerCfg g_loggerCfg;
+CErrorEvent g_errorEventHandler;
+CLoggerServiceCallbacks g_serviceCallbacks;
+CLoggerDeviceDetection g_deviceDetection;
+CReaderWriterControl g_ReaderWriterControl;
+//CPFDRECThread g_PFDRECThread;
+TimerCtrl* g_pLRotateTimer = NULL;
+uint32_t g_iLRotateCmd;
+
+/// Decide the function NormalStartupProcess execution
+static bool g_normal_startup_status = false;
+
+/// Callbacks for messages that will be received and processed by this module
+static EFrameworkunifiedStatus OnUsbEject(HANDLE hApp);
+
+static EFrameworkunifiedStatus OnUsbStoreLogs(HANDLE hApp);
+
+static EFrameworkunifiedStatus SMSessionAckCb(HANDLE hApp);
+
+/// Positive Response Call backs from child thread for statistical counter read
+static EFrameworkunifiedStatus cbStatisticalCounterSuccessResp(HANDLE hApp);
+
+/// Error Response Call backs from child thread for statistical counter read
+static EFrameworkunifiedStatus cbStatisticalCounterErrorResp(HANDLE hApp);
+
+/// Response Call backs from child thread for clear event logs
+static EFrameworkunifiedStatus cbClearEventLogsResponse(HANDLE hApp);
+
+/// Response Call backs from child thread for copying event logs to USB
+static EFrameworkunifiedStatus cbCopyEventLogsUSBResponse(HANDLE hApp);
+
+/// Response Call backs from child thread for Reading number of events logged
+static EFrameworkunifiedStatus cbReadNumbOfEventsResponse(HANDLE hApp);
+
+/// Response Call backs from child thread for Upload eventlog
+static EFrameworkunifiedStatus cbUploadEventLogResponse(HANDLE hApp);
+
+/// Notificatin from SystemManager when All Services wakeup completed
+static EFrameworkunifiedStatus cbServiceWakeupStatus(HANDLE hApp);
+
+
+/// generate SYS_ILG_LOG
+static EFrameworkunifiedStatus SysIllegalLogTimer_OnInterval(HANDLE hApp);
+
+
+/// Call back tables for response from event logger child thread
+FrameworkunifiedProtocolCallbackHandler evtLogChildThread_handler[] = { { // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ eThrdCmdStatisticalCounterSuccessResp, cbStatisticalCounterSuccessResp }, {
+ eThrdCmdStatisticalCounterErrorResp, cbStatisticalCounterErrorResp }, {
+ eThrdCmdCopyEventLogUSBResponse, cbCopyEventLogsUSBResponse }, {
+ eThrdCmdClearEventLogResponse, cbClearEventLogsResponse }, {
+ eThrdCmdNumberOfEventsLoggedResponse, cbReadNumbOfEventsResponse }, {
+ eThrdCmdUploadEventLogResponse, cbUploadEventLogResponse } };
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedOnInitialization
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnInitialization(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ // 1. Register Srv Availability Notification
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedRegisterServiceAvailabilityNotification(hApp, NTFY_SS_LoggerService_Availability))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to set service availability notification:0x%x ", l_eStatus);
+ // LCOV_EXCL_STOP
+ }
+
+ // 2. Publish Service not available
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedPublishServiceAvailability(hApp, FALSE))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to set service availability notification:%d ", l_eStatus);
+ // LCOV_EXCL_STOP
+ }
+
+ l_eStatus = g_loggerCfg.Initialize(hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "g_loggerCfg.Initialize()"); // LCOV_EXCL_BR_LINE 15: macro
+
+ std::string l_cfgFilePathAndName =
+ "/usr/agl/share/systemmanager/scfg/ss_logger.cfg";
+ if (eFrameworkunifiedStatusOK != (l_eStatus = g_loggerCfg.Load(l_cfgFilePathAndName))) { // LCOV_EXCL_BR_LINE 200:To ensure success
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR, __FUNCTION__,
+ " Error. Failed to load SS_Logger configuration from %s with error: %d",
+ l_cfgFilePathAndName.c_str(), l_eStatus);
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = g_loggerCfg.Validate())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Configuration validation failed with error: %d.",
+ l_eStatus);
+ }
+
+ g_loggerCfg.Print(); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+
+ l_eStatus = g_deviceDetection.Initialize(hApp, &g_loggerCfg); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ LOG_STATUS_IF_ERRORED(l_eStatus, "g_deviceDetection.Initialize"); // LCOV_EXCL_BR_LINE 15: macro
+
+ l_eStatus = g_ReaderWriterControl.Initialize(&g_loggerCfg); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ LOG_STATUS_IF_ERRORED(l_eStatus, "g_ReaderWriterControl.Initialize()"); // LCOV_EXCL_BR_LINE 15: macro
+
+ if (NULL == (g_thrdEvntLogWriter = FrameworkunifiedCreateChildThreadWithPriority( hApp, g_strEvntLogQueWorkerName, EvntWriterWorkerOnStart, EvntWriterWorkerOnStop, frameworkunified::framework::CFrameworkunifiedThreadPriorities::GetPriority(std::string(g_strEvntLogQueWorkerName))))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ "FrameworkunifiedCreateChildThreadWithPriority Failed Status:0x%x for thread create of %s",
+ l_eStatus, g_strEvntLogQueWorkerName);
+ return (l_eStatus);
+ // LCOV_EXCL_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG( // LCOV_EXCL_BR_LINE 15: macro
+ ZONE_INFO,
+ __FUNCTION__,
+ "FrameworkunifiedCreateChildThreadWithPriority Success Status: for thread create of %s",
+ g_strEvntLogQueWorkerName); // LCOV_EXCL_BR_LINE 15: macro
+ }
+
+ l_eStatus = g_errorEventHandler.Initialize(hApp, &g_loggerCfg, // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ &g_ReaderWriterControl,
+ g_thrdEvntLogWriter,
+ g_strEvntLogQueWorkerName); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 200:To ensure success
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. g_errorEventHandler.Initialize() returned: %d.", l_eStatus);
+ // LCOV_EXCL_STOP
+ }
+ l_eStatus = g_serviceCallbacks.Initialize(hApp, &g_loggerCfg,
+ &g_errorEventHandler); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ LOG_STATUS_IF_ERRORED(l_eStatus, "g_serviceCallbacks.Initialize()"); // LCOV_EXCL_BR_LINE 15: macro
+
+ // Callback to Event log child Thread
+ l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(
+ hApp, g_strEvntLogQueWorkerName, evtLogChildThread_handler,
+ _countof(evtLogChildThread_handler)); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, // LCOV_EXCL_BR_LINE 15: macro
+ "Status of callback for child thread attach:%X", l_eStatus); // LCOV_EXCL_BR_LINE 15: macro
+
+ // setup call backs for my children
+ FrameworkunifiedAttachCallbackToDispatcher(hApp, AppName, eThrdCmdUsbEject, OnUsbEject); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ FrameworkunifiedAttachCallbackToDispatcher(hApp, AppName, eThrdCmdUsbStoreLogs,
+ OnUsbStoreLogs);
+
+ // Publications
+ FrameworkunifiedNotificationsList publish_notifs[] = {
+ // Notifications name,length, state
+ { NTFY_LOGGER_SETCONTROLMASK, sizeof(CHANGELOGPARAMS), eFrameworkunifiedStateVar } };
+
+ // Indicate to Notification Service what I will be Publishing!
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedNPRegisterNotifications(hApp, publish_notifs, _countof(publish_notifs)))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "FrameworkunifiedNPRegisterNotifications Failed Status:0x%x ", l_eStatus);
+ return (l_eStatus);
+ // LCOV_EXCL_STOP
+ }
+
+ /// Start the Writer threads
+ strncpy(Evntlog_wi.mileage_filename, Mileage_LOG_PATH_FN,
+ Evntlog_wi.FN_LEN - 1);
+ Evntlog_wi.mileage_filename[Evntlog_wi.FN_LEN - 1] = '\0';
+ strncpy(Evntlog_wi.base_cnt_filename, Counter_LOG_PATH_FN,
+ Evntlog_wi.FN_LEN - 1);
+ Evntlog_wi.base_cnt_filename[Evntlog_wi.FN_LEN - 1] = '\0';
+ Evntlog_wi.max_filelen = g_loggerCfg.m_logMaxFileSize;
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedStartChildThread(hApp, g_thrdEvntLogWriter, sizeof(Evntlog_wi), &Evntlog_wi))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
+ "Fail to Start Writer Worker thread. Status:0x%x", l_eStatus);
+ // LCOV_EXCL_STOP
+ }
+
+ l_eStatus = RegisterSMSessionAckCallback(SMSessionAckCb); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ LOG_STATUS_IF_ERRORED(l_eStatus, "RegisterSMSessionAckCallback()"); // LCOV_EXCL_BR_LINE 15: macro
+
+// l_eStatus = g_PFDRECThread.Initialize(hApp); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+// LOG_STATUS_IF_ERRORED(l_eStatus, "g_PFDRECThread.Initialize()"); // LCOV_EXCL_BR_LINE 15: macro
+
+ // Publish Service available this can also be published from FrameworkunifiedOnStart callback
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedPublishServiceAvailability(hApp, TRUE))) { // LCOV_EXCL_BR_LINE 4:NSFW
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to set service availability notification:0x%x ", l_eStatus);
+ // LCOV_EXCL_STOP
+ }
+
+l_eStatus = FrameworkunifiedSubscribeNotificationWithCallback(hApp, NTFY_SSServiceWakeupStatus, cbServiceWakeupStatus); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedSubscribeNotificationWithCallback()"); // LCOV_EXCL_BR_LINE 15: macro
+
+ // Set Service status to init
+ g_eLoggerServiceStatus = eLSInit;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+// lotate interval
+#define LOGROTATE_INTERVAL_TIME 60
+// Get syslog file size
+static off_t syslog_fsize(void) {
+ struct stat stat_buf;
+
+ if (stat("/ramd/log/frameworkunifiedlog/syslog/syslog.log", &stat_buf) < 0)
+ return 0;
+
+ return stat_buf.st_size;
+}
+
+// Send SIGHUP to syslogd for restart syslogd.
+static EFrameworkunifiedStatus SendSigHupToSyslogd(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ int fd = open("/var/run/syslogd.pid", O_RDONLY);
+
+ if (fd != -1) { // LCOV_EXCL_BR_LINE 200:Depends on the actual syslogd
+ // LCOV_EXCL_START 200:Depends on the actual syslogd
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ char buf[32];
+ ssize_t rsize;
+ long int pid; // NOLINT (runtime/int)
+ char *endptr;
+ rsize = read(fd, buf, sizeof(buf) - 1);
+ if (rsize != -1) {
+ buf[rsize] = 0;
+ pid = strtol(buf, &endptr, 10);
+ if (kill(static_cast<pid_t>(pid), SIGHUP) == -1) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "Error SIGHUP syslogd(pid:%ld) %s: log rotation", pid,
+ strerror(errno));
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "read:no:%d,msg:%s", errno,
+ strerror(errno));
+ }
+ close(fd);
+ // LCOV_EXCL_STOP
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "open:no:%d,msg:%s", errno,
+ strerror(errno));
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+// Rotate LogFile
+static EFrameworkunifiedStatus OnRotationLog(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ pid_t pid;
+ off_t old_logfsize, new_logfsize;
+ CL_ProcessAttr_t clAttr;
+ char *args[] = { const_cast<char*>("/usr/sbin/logrotate"),
+ const_cast<char*>("--state=/ramd/log/frameworkunifiedlog/syslog/logrotate.status"),
+ const_cast<char*>("/usr/agl/share/logrotate/logrotate.conf"), NULL };
+
+ old_logfsize = syslog_fsize();
+
+ if (CL_ProcessCreateAttrInit(&clAttr) != 0) { // LCOV_EXCL_BR_LINE 200:Because the clAttr is never NULL, it will always succeed
+ // LCOV_EXCL_START 200:Because the clAttr is never NULL, it will always succeed
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "CL_ProcessCreateAttrInit");
+ return eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+ if (CL_ProcessCreateAttrSetGroup(&clAttr, 1) != 0) { // LCOV_EXCL_BR_LINE 200:To ensure success
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "CL_ProcessCreateAttrSetGroup");
+ return eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+
+ pid = CL_ProcessCreate(args[0], args, NULL, &clAttr);
+ if (pid == -1) { // LCOV_EXCL_BR_LINE 200:To ensure success
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "CL_ProcessCreate");
+ return eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+
+ fd_set fds;
+ struct timeval tv;
+ int selection;
+ do {
+ tv.tv_sec = 3;
+ tv.tv_usec = 0;
+ FD_ZERO(&fds);
+ FD_SET(g_errorEventHandler.m_sfd, &fds);
+ selection = select(g_errorEventHandler.m_sfd + 1, &fds, NULL, NULL, &tv);
+ } while ((selection < 0) && (errno == EINTR)); // LCOV_EXCL_BR_LINE 5:c function error
+
+ if (selection < 0) { // LCOV_EXCL_BR_LINE 5:c function error
+ // LCOV_EXCL_START 5:c function error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Select:selection:%d,no:%d,msg:%s",
+ selection, errno, strerror(errno));
+ // LCOV_EXCL_STOP
+ } else {
+ if (FD_ISSET(g_errorEventHandler.m_sfd, &fds)) { // LCOV_EXCL_BR_LINE 5:c function error
+ int ret = 0;
+ do {
+ CL_ProcessCleanupInfo_t cinfo;
+
+ ret = CL_ProcessCleanup(g_errorEventHandler.m_sfd, &cinfo);
+
+ if ((ret != -1) && (cinfo.code == CLD_EXITED)) {
+ if (cinfo.status != 0) { // LCOV_EXCL_BR_LINE 5:c function error(waitid in CL_ProcessCleanup)
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "CL_ProcessCleanup:status:%d",
+ cinfo.status);
+ }
+ } else if (ret == -1) { // LCOV_EXCL_BR_LINE 5:c function error
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "CL_ProcessCleanup:no:%d,msg:%s",
+ errno, strerror(errno));
+ }
+ } while (ret == 1); // // LCOV_EXCL_BR_LINE 4: CL_ProcessCleanup will not return 1
+ } else {
+ // LCOV_EXCL_START 5:c function error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FD_ISSET");
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ new_logfsize = syslog_fsize();
+ if (new_logfsize < old_logfsize) {
+ // in case of logfile rotated, send SIGHUP to syslogd for restart.
+ l_eStatus = SendSigHupToSyslogd();
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+// timer fd max
+#define LOGROTATE_TIMER_SET_MAX 1
+
+// Start logrotate
+static EFrameworkunifiedStatus StartLogrotate(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ // cleanup
+ if (unlink("/ramd/log/frameworkunifiedlog/syslog/logrotate.status") == -1) {
+ // nop
+ }
+
+ if (g_pLRotateTimer == NULL) { // LCOV_EXCL_BR_LINE 200: As it is always NULL at startup
+ g_pLRotateTimer = new TimerCtrl(LOGROTATE_TIMER_SET_MAX);
+ if (g_pLRotateTimer == NULL) { // LCOV_EXCL_BR_LINE 5: new error
+ // LCOV_EXCL_START 5: new error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 5: new error
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "TimerCreate failed.");
+ // LCOV_EXCL_STOP
+ } else {
+ // Start Rotate Timer
+ g_pLRotateTimer->Initialize(hApp);
+ g_iLRotateCmd = g_pLRotateTimer->CreateTimer(OnRotationLog);
+ g_pLRotateTimer->StartTimer(g_iLRotateCmd, LOGROTATE_INTERVAL_TIME, 0,
+ LOGROTATE_INTERVAL_TIME, 0);
+ }
+ } else {
+ // LCOV_EXCL_START 200: As it is always NULL at startup
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Timer already exists.");
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+// Stop logrotate
+static EFrameworkunifiedStatus StopLogrotate(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (g_pLRotateTimer != NULL) { // LCOV_EXCL_BR_LINE 6: dead code
+ // Stop Rotate Timer
+ g_pLRotateTimer->DeleteTimer(g_iLRotateCmd);
+ delete g_pLRotateTimer;
+ g_pLRotateTimer = NULL;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+static void *accOffOnCollect(void* param) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ SS_LoggerStoreLogs(SS_STORELOGS_ACCOFFON_PRESS);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return NULL;
+}
+
+// Normal startup process
+static EFrameworkunifiedStatus NormalStartupProcess(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (false == g_normal_startup_status) {
+ LBM_RAM_t p_info;
+ l_eStatus = GetBootLoaderInfoRequestToSystemManager(&p_info);
+ if (l_eStatus != eFrameworkunifiedStatusOK) {
+ AGL_ASSERT_NOT_TESTED();
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, " Error. GetBootLoaderInfo = %d", l_eStatus);
+ } else if (p_info.syscomSts == SUBCPU_STS_COMNG) {
+ AGL_ASSERT_NOT_TESTED();
+ HANDLE timer;
+ timer = FrameworkunifiedAttachTimerCallback(hApp, SYS_ILLEGAL_LOG_DELAY_TIME, 0, SysIllegalLogTimer_OnInterval);
+ if (timer == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, " Failed to register timer.");
+ }
+ }
+
+ if (0 == access("/tmp/accoffon", F_OK)) {
+ pthread_t threadAccOffOn;
+ pthread_create( &threadAccOffOn, NULL, accOffOnCollect, NULL);
+ }
+
+ if (g_eLoggerServiceStatus == eLSStop) {
+ AGL_ASSERT_NOT_TESTED();
+ // Publish Service available this can also be published from FrameworkunifiedOnStart callback
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedPublishServiceAvailability(hApp, TRUE))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to set service availability notification:0x%x ",
+ l_eStatus);
+ }
+
+ /// Start the Writer threads
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedStartChildThread(hApp, g_thrdEvntLogWriter,
+ sizeof(Evntlog_wi), &Evntlog_wi))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
+ "Fail to Start Writer Worker thread. Status:0x%x", l_eStatus);
+ }
+ }
+ // Set Service status to init
+ g_eLoggerServiceStatus = eLSStart;
+
+ // Start logrotate
+ StartLogrotate(hApp);
+
+ // Set normal_startup_status flag (true)
+ g_normal_startup_status = true;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE hApp)
+ * @brief Used to .
+ *
+ * @param hApp Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+EFrameworkunifiedStatus FrameworkunifiedOnPreStart(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ EFrameworkunifiedStatus l_eStatus = NormalStartupProcess(hApp);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE hApp)
+ * @brief Used to .
+ *
+ * @param hApp Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStart(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ EFrameworkunifiedStatus l_eStatus = NormalStartupProcess(hApp);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE hApp)
+ * @brief Used to .
+ *
+ * @param hApp Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ EFrameworkunifiedStatus l_eStatus = NormalStartupProcess(hApp);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+static EFrameworkunifiedStatus SysIllegalLogTimer_OnInterval(HANDLE hApp) { // LCOV_EXCL_START 200: There is no SUBCP_STS_COMNG case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ l_eStatus = SS_LoggerStoreLogs(SS_STORELOGS_SYS_ILLEGAL);
+ if (l_eStatus != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, " Failed SS_LoggerStoreLogs()");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE hApp)
+ * @brief Used to .
+ *
+ * @param hApp Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion.
+ */
+EFrameworkunifiedStatus FrameworkunifiedOnPreStop(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE hApp)
+ * @brief Used to .
+ *
+ * @param hApp Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion.
+ */
+EFrameworkunifiedStatus FrameworkunifiedOnBackgroundStop(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE hApp)
+ * @brief Used to .
+ *
+ * @param hApp Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ /*Get stop factor form hApp*/
+ T_SS_SM_STOP_DataStructType errorType;
+
+ // LCOV_EXCL_BR_START 4: NSFW error
+ if (eFrameworkunifiedStatusOK
+ != FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID) &errorType, sizeof(errorType),
+ eSMRRelease)) {
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 4: NSFW error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
+ " FrameworkunifiedGetMsgDataOfSize failed with error");
+ // LCOV_EXCL_STOP
+ } else {
+ EFrameworkunifiedStatus loggerserviceRet = SS_LoggerStoreLogs(SS_STORELOGS_INTERFACEUNIFIEDLOG);
+ LOG_STATUS_IF_ERRORED(loggerserviceRet, "Fail to save Loggerservice Log");
+
+ EFrameworkunifiedStatus naviLog_status = g_errorEventHandler.SaveNaviLog(
+ errorType.shutdownTrigger);
+ LOG_STATUS_IF_ERRORED(naviLog_status, "Fail to save Navi Log");
+ }
+ StopLoggingFunction(hApp);
+
+ if (g_eLoggerServiceStatus == eLSStart) { // LCOV_EXCL_BR_LINE 200: g_eLoggerServiceStatus must be eLSStart on ACC-OFF
+ LoggerService_OnStop(hApp);
+ }
+
+ // Set normal_startup_status flag (false)
+ g_normal_startup_status = false;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+/**
+ * EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE hApp)
+ * @brief Used to .
+ *
+ * @param hApp Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE hApp) { // LCOV_EXCL_START 8:dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP
+
+/**
+ * EFrameworkunifiedStatus LoggerService_OnStop(HANDLE hApp)
+ * @brief Logger Stop is called on Shutdown complete cmd
+ *
+ * @param hApp Handle to the SS_Power Framework Obj.
+ *
+ * @return method status of completion or failure.
+ */
+EFrameworkunifiedStatus LoggerService_OnStop(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // Set Service status to init
+ g_eLoggerServiceStatus = eLSStop;
+
+ /// Start the Writer threads
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedStopChildThread(hApp, g_thrdEvntLogWriter, sizeof(Evntlog_wi), &Evntlog_wi))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
+ "Fail to Start Writer Worker thread. Status:0x%x", l_eStatus);
+ // LCOV_EXCL_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__,
+ "Successful in Sending Stop to ChildThread");
+ }
+
+ // Publish Service available this can also be published from FrameworkunifiedOnStart callback
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedPublishServiceAvailability(hApp, FALSE))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to set service availability notification:0x%x ", l_eStatus);
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus SMSessionAckCb(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ HANDLE l_hSession;
+
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(hApp); // LCOV_EXCL_BR_LINE 15: macro
+
+ l_hSession = FrameworkunifiedGetOpenSessionHandle(hApp);
+
+ if (NULL == l_hSession) { // LCOV_EXCL_BR_LINE 4:NSFW
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR, __FUNCTION__,
+ " Error. FrameworkunifiedGetSessionHandle() returned a NULL session handle. "
+ "Error events originating from System Manager will not be detected.");
+ // LCOV_EXCL_STOP
+ } else {
+ l_eStatus = FrameworkunifiedSetSessionHandle(hApp, FrameworkunifiedGetMsgSrc(hApp), l_hSession);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedSetSessionHandle()"); // LCOV_EXCL_BR_LINE 15: macro
+
+ l_eStatus = g_errorEventHandler.RegisterSessionErrorEvent(l_hSession);
+ LOG_STATUS_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: macro
+ "g_errorEventHandler.RegisterSessionErrorEvent()");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus FrameworkunifiedOnWakeup(HANDLE hApp) { // LCOV_EXCL_START 8:dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedOnShutdown
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnShutdown(HANDLE hApp) { // LCOV_EXCL_START 8:dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedOnEShutdown
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnEShutdown(HANDLE hApp) { // LCOV_EXCL_START 8:dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+//////////////////////////////////////////
+// Function : FrameworkunifiedOnDebugDump
+//////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnDebugDump(HANDLE hApp) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////
+/// HACK! mb20100701
+/// \todo Add behavior to this function
+////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus FrameworkunifiedOnDestroy(HANDLE hApp) { // LCOV_EXCL_START 14:For process termination processing
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusNotImplemented;
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus OnUsbEject(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+
+ if (g_loggerservicedebug_threads.Running(
+ LoggerserviceDebugChildThread::kLoggerserviceDebugCaptureLogScript)) {
+ g_loggerservicedebug_threads.Stop(LoggerserviceDebugChildThread::kLoggerserviceDebugCaptureLogScript);
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_INFO,
+ __FUNCTION__,
+ "Stopped Thread: %s",
+ g_loggerservicedebug_threads.Name(
+ LoggerserviceDebugChildThread::kLoggerserviceDebugCaptureLogScript));
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus OnUsbStoreLogs(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ TThrdCaptureLogsEvt evt = { };
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &evt, sizeof(evt)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedGetMsgDataOfSize Failed Status:0x%x ",
+ l_eStatus);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return l_eStatus;
+ }
+
+ l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdLogWriter, eThrdCmdWriterStop, 0, NULL);
+ l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdTxWriter, eThrdCmdWriterStop, 0, NULL);
+
+ l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdLogWriter, eThrdCmdWriteFilesToUsb,
+ sizeof(evt), &evt);
+ l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdTxWriter, eThrdCmdWriteFilesToUsb,
+ sizeof(evt), &evt);
+
+ l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdLogWriter, eThrdCmdWriterResume, 0,
+ NULL);
+ l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdTxWriter, eThrdCmdWriterResume, 0, NULL);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :cbStatisticalCounterPosResponse
+///////////////////////////////////////////////////////////////////////
+// LCOV_EXCL_START 8:dead code
+EFrameworkunifiedStatus cbStatisticalCounterSuccessResp(HANDLE hApp) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ TStatisticalCntCmdSuccessResp l_stCmdSuccessResp;
+ SS_loggerserviceprotocol l_eResponseCmd;
+ HANDLE l_hSession = NULL;
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<TStatisticalCntCmdSuccessResp>(hApp,
+ l_stCmdSuccessResp))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ if (NULL
+ != (l_hSession = FrameworkunifiedGetSessionHandle(
+ hApp, l_stCmdSuccessResp.stSessiondata.strSrcName.c_str(),
+ l_stCmdSuccessResp.stSessiondata.session_id))) {
+ l_eResponseCmd = SS_LOGGER_READ_STATL_COUNTER_SUCCESS_RESP;
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(l_hSession, l_eResponseCmd,
+ sizeof(SStatisticalCounter),
+ &l_stCmdSuccessResp.stBuffer))) {
+ LOG_ERROR("FrameworkunifiedSendMsg()");
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ LOG_ERROR("FrameworkunifiedGetSessionHandle()");
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :cbStatisticalCounterErrResponse
+///////////////////////////////////////////////////////////////////////
+// LCOV_EXCL_START 8:dead code
+EFrameworkunifiedStatus cbStatisticalCounterErrorResp(HANDLE hApp) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ TSessionData l_stSessiondata;
+ SS_loggerserviceprotocol l_eResponseCmd;
+ HANDLE l_hSession = NULL;
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<TSessionData>(hApp, l_stSessiondata))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ if (NULL
+ != (l_hSession = FrameworkunifiedGetSessionHandle(hApp,
+ l_stSessiondata.strSrcName.c_str(),
+ l_stSessiondata.session_id))) {
+ l_eResponseCmd = SS_LOGGER_READ_STATL_COUNTER_ERROR_RESP;
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(l_hSession, l_eResponseCmd, 0x00, NULL))) {
+ LOG_ERROR("FrameworkunifiedSendMsg()");
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ LOG_ERROR("FrameworkunifiedGetSessionHandle()");
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :cbClearEventLogsResponse
+///////////////////////////////////////////////////////////////////////
+// LCOV_EXCL_START 8:dead code
+EFrameworkunifiedStatus cbClearEventLogsResponse(HANDLE hApp) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ TClearEvntLogCmdResponse l_stCmdResponse;
+ HANDLE l_hSession = NULL;
+ SS_loggerserviceprotocol l_eResponseCmd;
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<TClearEvntLogCmdResponse>(hApp, l_stCmdResponse))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ if (NULL
+ != (l_hSession = FrameworkunifiedGetSessionHandle(
+ hApp, l_stCmdResponse.stSessiondata.strSrcName.c_str(),
+ l_stCmdResponse.stSessiondata.session_id))) {
+ if (l_stCmdResponse.u8Response == (UI_8) CLEAR_EVENT_LOG_SUCCESS) {
+ l_eResponseCmd = SS_LOGGERCLEAREVENT_SUCCESS_RESP;
+ } else {
+ l_eResponseCmd = SS_LOGGERCLEAREVENT_ERROR_RESP;
+ }
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(l_hSession, l_eResponseCmd, 0x00, NULL))) {
+ LOG_ERROR("FrameworkunifiedSendMsg()");
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ LOG_ERROR("FrameworkunifiedGetSessionHandle()");
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :cbCopyEventLogsUSBResponse
+///////////////////////////////////////////////////////////////////////
+// LCOV_EXCL_START 8:dead code
+EFrameworkunifiedStatus cbCopyEventLogsUSBResponse(HANDLE hApp) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ TWriteFilesToUsbCmdResponse l_stCmdResponse;
+ HANDLE l_hSession = NULL;
+ SS_loggerserviceprotocol l_eResponseCmd;
+ EEvtLoggerErrorCode l_eResponseCode;
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<TWriteFilesToUsbCmdResponse>(hApp,
+ l_stCmdResponse))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ if (NULL
+ != (l_hSession = FrameworkunifiedGetSessionHandle(
+ hApp, l_stCmdResponse.stSessiondata.strSrcName.c_str(),
+ l_stCmdResponse.stSessiondata.session_id))) {
+ if (l_stCmdResponse.u8Response == (UI_8) COPY_EVT_USB_SUCCESS) {
+ l_eResponseCmd = SS_LOGGERCOPYEVENTUSB_SUCCESS_RESP;
+ l_eResponseCode = NO_ERROR_INFO;
+ } else {
+ l_eResponseCmd = SS_LOGGERCOPYEVENTUSB_ERROR_RESP;
+ l_eResponseCode = (EEvtLoggerErrorCode) l_stCmdResponse.u8Response;
+ }
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(l_hSession, l_eResponseCmd,
+ sizeof(EEvtLoggerErrorCode),
+ &l_eResponseCode))) {
+ LOG_ERROR("FrameworkunifiedSendMsg()");
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ LOG_ERROR("FrameworkunifiedGetSessionHandle()");
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 8:dead code
+EFrameworkunifiedStatus cbReadNumbOfEventsResponse(HANDLE hApp) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_16 l_NumOfEvents = 0;
+ TEvntsLogged l_stNumberOfEvtsLogged;
+ HANDLE l_hsession = NULL;
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<TEvntsLogged>(hApp, l_stNumberOfEvtsLogged))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ l_NumOfEvents = l_stNumberOfEvtsLogged.u16numberofeventslogged;
+ if (NULL
+ != (l_hsession = FrameworkunifiedGetSessionHandle(
+ hApp, l_stNumberOfEvtsLogged.stSessiondata.strSrcName.c_str(),
+ l_stNumberOfEvtsLogged.stSessiondata.session_id))) {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(l_hsession,
+ SS_LOGGER_ENG_READ_NUMOFEVENTS_RESP,
+ sizeof(UI_16), &l_NumOfEvents))) {
+ LOG_ERROR("FrameworkunifiedSendMsg()");
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetSessionHandle()");
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 8:dead code
+EFrameworkunifiedStatus cbUploadEventLogResponse(HANDLE hApp) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ HANDLE l_hsession = NULL;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "UploadEventLog Response Msg Len = %d",
+ FrameworkunifiedGetMsgLength(hApp));
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<TUploadEventLogResp>(hApp, g_stUploadEventLogResp))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ if (NULL
+ != (l_hsession = FrameworkunifiedGetSessionHandle(
+ hApp, g_stUploadEventLogResp.stSessiondata.strSrcName.c_str(),
+ g_stUploadEventLogResp.stSessiondata.session_id))) {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendMsg(l_hsession, SS_LOGGER_UPLOAD_EVENTLOG_RESP,
+ sizeof(STEventLogPersistBuffer),
+ &g_stUploadEventLogResp.stEventLogBuffer))) {
+ LOG_ERROR("FrameworkunifiedSendMsg()");
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetSessionHandle()");
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus cbServiceWakeupStatus(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ l_eStatus = g_errorEventHandler.CreateKernelLog(hApp,
+ SS_LOGGER_KBOOTLOG_CREATE);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "CreateKernelLog(SS_LOGGER_KBOOTLOG_CREATE)");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+void StopLoggingFunction(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ // PFDRECThread Stop
+// EFrameworkunifiedStatus l_eStatus = g_PFDRECThread.Finalize(hApp);
+// LOG_STATUS_IF_ERRORED(l_eStatus, "g_PFDRECThread.Finalize()");
+
+ // Stop logrotate
+ StopLogrotate(hApp);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
diff --git a/logger_service/server/src/loggerservice_main.cpp b/logger_service/server/src/loggerservice_main.cpp
new file mode 100644
index 00000000..334d73de
--- /dev/null
+++ b/logger_service/server/src/loggerservice_main.cpp
@@ -0,0 +1,59 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_InterfaceunifiedLogCapture
+/// \brief Application entry point.
+///
+///////////////////////////////////////////////////////////////////////////////
+// System Headers
+#include <pthread.h>
+#include <native_service/frameworkunified_dispatcher.h>
+#include <native_service/frameworkunified_application.h>
+#include <system_service/ss_system_if.h>
+#include <loggerservicedebug_loggerservicelog.h>
+#include <system_service/ss_version.h>
+#include <native_service/ns_version_if.h>
+#include <system_service/ss_services.h>
+#include <cstdlib>
+#include <iostream>
+
+CFrameworkunifiedVersion g_FrameworkunifiedVersion(MAJORNO, MINORNO, REVISION);
+
+FRAMEWORKUNIFIEDLOGPARAM g_FrameworkunifiedLogParams = { FRAMEWORKUNIFIEDLOGOPTIONS, {
+ZONE_TEXT_10, ZONE_TEXT_11, ZONE_TEXT_12,
+ZONE_TEXT_13, ZONE_TEXT_14, ZONE_TEXT_15,
+ZONE_TEXT_16, ZONE_TEXT_17, ZONE_TEXT_18,
+ZONE_TEXT_19, ZONE_TEXT_20, ZONE_TEXT_21,
+ZONE_TEXT_22, ZONE_TEXT_23, ZONE_TEXT_24,
+ZONE_TEXT_25, ZONE_TEXT_26, ZONE_TEXT_27,
+ZONE_TEXT_28, ZONE_TEXT_29, ZONE_TEXT_30,
+ZONE_TEXT_31 }, FRAMEWORKUNIFIEDLOGZONES };
+
+const CHAR AppName[] = SERVICE_LOGGER;
+
+//////////////////////////////////////////
+// Function : main
+//////////////////////////////////////////
+int main(int argc, char *argv[]) {
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ FrameworkunifiedDefaultCallbackHandler cbFuncs; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ FRAMEWORKUNIFIED_MAKE_DEFAULT_CALLBACK(cbFuncs); // LCOV_EXCL_BR_LINE 15: macro
+ FRAMEWORKUNIFIED_SET_ZONES(); // LCOV_EXCL_BR_LINE 15: macro
+
+ eStatus = FrameworkunifiedDispatcherWithArguments(AppName, argc, argv, &cbFuncs); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ return eStatus;
+} // LCOV_EXCL_BR_LINE 10:the last line
diff --git a/logger_service/server/src/loggerservicedebug_child_thread.cpp b/logger_service/server/src/loggerservicedebug_child_thread.cpp
new file mode 100644
index 00000000..beb4ea3f
--- /dev/null
+++ b/logger_service/server/src/loggerservicedebug_child_thread.cpp
@@ -0,0 +1,134 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_InterfaceunifiedLogCapture
+/// \brief Class that threads for usb, and readers use to AGL and get
+/// information from the parent.
+///
+///////////////////////////////////////////////////////////////////////////////
+// System Headers
+#include <loggerservicedebug_thread_if.h>
+#include <new>
+
+const CHAR g_strLogQueReaderWorkerName[] = "pdg.LogQueR";
+const CHAR g_strTransmitQueReaderWorkerName[] = "pdg.TransQueR";
+const CHAR g_strPerformanceQueReaderWorkerName[] = "pdg.PerformQueR";
+const CHAR g_strUsbEjectWorkerName[] = "pdg.UsbEject";
+const CHAR g_strUsbLogCaptureWorkerName[] = "pdg.UsbLogCapt";
+const CHAR g_strCaptureLogScriptExeName[] = "pdg.CaptLogScri";
+
+LoggerserviceDebugChildThread::LoggerserviceDebugChildThread() {
+ names[LoggerserviceDebugChildThread::kLoggerserviceDebugLogQueReader] =
+ g_strLogQueReaderWorkerName;
+ names[LoggerserviceDebugChildThread::kLoggerserviceDebugTransmitQueReader] =
+ g_strTransmitQueReaderWorkerName;
+ names[LoggerserviceDebugChildThread::kLoggerserviceDebugCaptureLogScript] =
+ g_strCaptureLogScriptExeName;
+ names[LoggerserviceDebugChildThread::kLoggerservicePerformanceLogQueReader] =
+ g_strPerformanceQueReaderWorkerName;
+
+ threads[LoggerserviceDebugChildThread::kLoggerserviceDebugLogQueReader] = NULL;
+ threads[LoggerserviceDebugChildThread::kLoggerserviceDebugTransmitQueReader] = NULL;
+ threads[LoggerserviceDebugChildThread::kLoggerserviceDebugCaptureLogScript] = NULL;
+ threads[LoggerserviceDebugChildThread::kLoggerservicePerformanceLogQueReader] = NULL;
+} // LCOV_EXCL_BR_LINE 10:the last line
+
+LoggerserviceDebugChildThread::~LoggerserviceDebugChildThread() { // LCOV_EXCL_START 14:global instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+BOOL LoggerserviceDebugChildThread::Start(ELoggerserviceDebugThreads id, const char* parentsName,
+ const char * sendDataToQue,
+ void* (*routine)(void*),
+ const char * sendToUdpQue) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ BOOL rtn = FALSE;
+ if (id < LoggerserviceDebugChildThread::kLoggerserviceDebugMax && id > -1) {
+ if (threads[id] == NULL) {
+ if ( NULL
+ != (threads[id] = new (std::nothrow) CChild(parentsName,
+ sendDataToQue,
+ names[id].c_str(),
+ routine, sendToUdpQue))) {
+ rtn = TRUE;
+ }
+ } else {
+ rtn = TRUE;
+ }
+ }
+
+ return rtn;
+}
+// LCOV_EXCL_STOP
+
+void LoggerserviceDebugChildThread::Stop(ELoggerserviceDebugThreads id) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (id < LoggerserviceDebugChildThread::kLoggerserviceDebugMax && id > -1) {
+ if (threads[id] != NULL) {
+ delete threads[id];
+ threads[id] = NULL;
+ }
+ }
+}
+// LCOV_EXCL_STOP
+
+BOOL LoggerserviceDebugChildThread::Running(ELoggerserviceDebugThreads id) const { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ BOOL rtn = FALSE;
+ if (id < LoggerserviceDebugChildThread::kLoggerserviceDebugMax && id > -1) {
+ if (threads[id] != NULL) {
+ rtn = TRUE;
+ }
+ }
+
+ return rtn;
+}
+// LCOV_EXCL_STOP
+
+void LoggerserviceDebugChildThread::StopAll() { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ for (int id = kLoggerserviceDebugLogQueReader; id < kLoggerserviceDebugMax; id++) {
+ if (threads[id] != NULL) {
+ threads[id]->Join();
+ delete threads[id];
+ threads[id] = NULL;
+ }
+ }
+}
+// LCOV_EXCL_STOP
+
+const char * LoggerserviceDebugChildThread::Name(ELoggerserviceDebugThreads id) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (id < LoggerserviceDebugChildThread::kLoggerserviceDebugMax && id > -1) {
+ return names[id].c_str();
+ }
+
+ return NULL;
+}
+// LCOV_EXCL_STOP
+
+void LoggerserviceDebugChildThread::LiftWaitBarrier(ELoggerserviceDebugThreads id) { // LCOV_EXCL_START 7:debug code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (id < LoggerserviceDebugChildThread::kLoggerserviceDebugMax && id > -1) {
+ if (threads[id] != NULL) {
+ threads[id]->IsValidWaitBarrier();
+ }
+ }
+}
+// LCOV_EXCL_STOP
+
diff --git a/logger_service/server/src/loggerservicedebug_writer_Evntworker.cpp b/logger_service/server/src/loggerservicedebug_writer_Evntworker.cpp
new file mode 100644
index 00000000..5c2ecb0a
--- /dev/null
+++ b/logger_service/server/src/loggerservicedebug_writer_Evntworker.cpp
@@ -0,0 +1,1362 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_LogTraceSender
+/// \brief frameworkunifieddebug writer thread class, handles writing a log file
+/// all really done by my_writer class.
+///
+///////////////////////////////////////////////////////////////////////////////
+// System Headers
+#include "loggerservicedebug_writer_Evntworker.h"
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <time.h>
+#include <sys/timeb.h>
+#include <boost/bind.hpp>
+#include <errno.h>
+#include <native_service/ns_np_service_protocol.h>
+#include <native_service/frameworkunified_application.h>
+#include <native_service/frameworkunified_framework_types.h>
+#include <native_service/frameworkunified_timer.h>
+#include <loggerservicedebug_thread_if.h>
+#include <loggerservicedebug_loggerservicelog.h>
+#include <system_service/ss_logger_service_notifications.h>
+#include <system_service/ss_devicedetection_service_ifc.h>
+#include <system_service/ss_logger_service_protocol.h>
+#include <system_service/ss_logger_service.h>
+#include <system_service/ss_templates.h>
+//#include <vehicle_service/Clock_API.h>
+#include <new>
+#include <utility>
+#include <string>
+
+/// Macros definition for the constants
+#define SIZE_0 (size_t)0
+#define SIZE_1 (size_t)1
+#define COUNTER_SIZE 6 ///< Counter ID 2 bytes and Counter Value is 4 bytes
+#define SINGLE_EVENT_INFO_SIZE 10 ///< Event log size
+#define INITIAL_CNT_VALUE 0x00000001 ///< Init count value for counter logging
+#define MAX_CNT_VALUE 0xFFFFFFFF ///< Max count calue for counter logging
+#define MAX_USB_DEVICE 2 ///< Max USB devices
+
+// Temp path for event logs that used for copying to USB
+const CHAR TMP_DEBUG_EVNTLOG_PATH_FN[] = "/tmp/loggerservice_Evntdebug.dat";
+
+// Structure to hold the USB device information
+TThrdEvtLogStore gSUSBDevInfo[MAX_USB_DEVICE] = { };
+
+// Structure to hold the SD card device information
+TThrdEvtLogStore gSSDCardevInfo = { };
+
+// Object for device detection class
+DeviceDetectionServiceIf m_device_detector_obj;
+
+// Map container for startup phase counter
+CounterInformation CEvntWriterWorker::counter;
+
+// Deque container for event logging
+DEQUE_Event_Type CEvntWriterWorker::deque_event_info;
+
+static CEvntWriterWorker * pObj = new (std::nothrow) CEvntWriterWorker(); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+static TEvntWriterInfo wi = { };
+
+// Event Common Info global structure
+extern UEvtLoggerCommonInfo g_uEvtLoggerCommonInfo;
+extern UI_16 g_u16DiagId;
+static EFrameworkunifiedStatus ReadEventLogQueue(HANDLE hThread);
+// created global variables as they are used in non member function
+HANDLE g_hReceive = NULL;
+HANDLE g_hEvtLogTimer = NULL;
+
+CEvntWriterWorker::CEvntWriterWorker()
+ : m_u32MileageData(0),
+ m_u32NumberEventsLogged(0) {
+ memset(m_stVINnumber.VINstr, 0, m_stVINnumber.VIN_LEN);
+}
+
+CEvntWriterWorker::~CEvntWriterWorker() { // LCOV_EXCL_START 14:global instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CEvntWriterWorker::Initialize(HANDLE hThread) {
+ return eFrameworkunifiedStatusOK;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :EventLogRegisterCbHandlers
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::EventLogRegisterCbHandlers(HANDLE hThread) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ FrameworkunifiedProtocolCallbackHandler aParentHandlers[] = { {
+ eThrdCmdWriteEvntFilesToUsb, boost::bind(
+ &CEvntWriterWorker::OnCmdWriteEventFilesToUsb, this, _1) }, {
+ eThrdCmdClearEvntLogs, boost::bind(
+ &CEvntWriterWorker::OnCmdClearEventLogs, this, _1) }, {
+ eThrdCmdStatisticalCounter, boost::bind(
+ &CEvntWriterWorker::OnCmdReadStatisticalCounter, this, _1) }, {
+ eThrdCmdResetStatisticalCntrs, boost::bind(
+ &CEvntWriterWorker::OnCmdResetStatisticalCounter, this, _1) }, {
+ eThrdCmdSetVINnumber, boost::bind(&CEvntWriterWorker::OnCmdSetVIN, this,
+ _1) }, { eThrdCmdImmPersistEvtLog,
+ boost::bind(&CEvntWriterWorker::immediate_persist_event_log, this, _1) },
+ { eThrdCmdMileageData, boost::bind(&CEvntWriterWorker::EvtThd_SetMileage,
+ this, _1) }, {
+ eThrdCmdGetNumberOfEventsLogged, boost::bind(
+ &CEvntWriterWorker::OnCmdReadNumberOfEventsLogged, this, _1) }, {
+ eThrdCmdUploadEventLog, boost::bind(
+ &CEvntWriterWorker::OnCmdUploadEventLog, this, _1) } };
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedAttachParentCallbacksToDispatcher(
+ hThread, aParentHandlers, _countof(aParentHandlers)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: parent call backs attach failed , err code: %d", l_eStatus);
+ }
+
+ // TO DO replace the queue name with macro EVENTLOG_MSGQ_NAME, after NS delivers it.
+ if (NULL != (g_hReceive = McOpenReceiverNotBlocked("/EvntLogQue"))) {
+ if (NULL
+ == (g_hEvtLogTimer = FrameworkunifiedAttachTimerCallback(hThread, 100, 1000,
+ ReadEventLogQueue))) {
+ LOG_ERROR("FrameworkunifiedAttachTimerCallback()");
+ }
+ } else {
+ LOG_ERROR("McOpenReceiverNotBlocked");
+ }
+
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus ReadEventLogQueue(HANDLE hThread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ CHAR source[MAX_QUEUE_NAME_SIZE];
+ UI_32 l_cmd = 0;
+ UI_8 pbuf[MAX_QUEUE_MSG_SIZE];
+
+ if (NULL != g_hReceive) { // LCOV_EXCL_BR_LINE 6: g_hReceive is always null
+ // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ while (1) {
+ if (eFrameworkunifiedStatusOK != (l_eStatus = McReceive(g_hReceive, source, &l_cmd,
+ MAX_QUEUE_MSG_SIZE,
+ pbuf))) {
+ break;
+ } else {
+ switch (l_cmd) {
+ case SS_MSG_EVTLOG:
+ if (pObj) {
+ if (eFrameworkunifiedStatusOK != (l_eStatus = pObj->OnCmdEventLog(pbuf))) {
+ LOG_ERROR("OnCmdEventLog()");
+ }
+ } else {
+ LOG_ERROR("pObj NULL");
+ }
+ break;
+
+ case SS_MSG_LOGGERCNT:
+ if (pObj) {
+ if (eFrameworkunifiedStatusOK != (l_eStatus = pObj->OnCmdIncrcount(pbuf))) {
+ LOG_ERROR("OnCmdIncrcount()");
+ }
+ } else {
+ LOG_ERROR("pObj NULL");
+ }
+ break;
+
+ case SS_MSG_LOGGER_CNT_EVTLOG:
+ if (pObj) {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = pObj->OnCmdIncrwriteevent(pbuf))) {
+ LOG_ERROR("OnCmdIncrwriteevent()");
+ }
+ } else {
+ LOG_ERROR("pObj NULL");
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+ // LCOV_EXCL_STOP
+ } else {
+ LOG_ERROR("Receive Handle NULL"); // LCOV_EXCL_BR_LINE 15:macro
+ }
+
+ if (eFrameworkunifiedStatusErrNoEAGAIN == l_eStatus) { // LCOV_EXCL_BR_LINE 6: l_eStatus is always eFrameworkunifiedStatusOK
+ l_eStatus = eFrameworkunifiedStatusOK; // LCOV_EXCL_LINE 6: l_eStatus is always eFrameworkunifiedStatusOK
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+///////////////////////////////////////////////////////////////////////
+/// Function :EvntWriterWorkerOnStart
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus EvntWriterWorkerOnStart(HANDLE hThread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusFail;
+
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedGetMsgDataOfSize(hThread, (PVOID) &wi, sizeof(wi), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: Unable to read handle from FrameWork Thread.%d", eStatus);
+ // LCOV_EXCL_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "Successfully read handle from FrameWork Thread.\n"); // LCOV_EXCL_BR_LINE 15:macro
+ }
+
+ // Device Detection Obj initialization
+ if (m_device_detector_obj.Initialize(hThread)) { // LCOV_EXCL_BR_LINE 200:To ensure success
+ memset(&gSUSBDevInfo, 0, sizeof(gSUSBDevInfo));
+ memset(&gSSDCardevInfo, 0, sizeof(gSSDCardevInfo));
+
+ if (eFrameworkunifiedStatusOK != (eStatus = m_device_detector_obj.NotifyOnDeviceDetectionAvailability( DD_USBServiceAvailabilityCallBack))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: ServiceAvailabilityCallback registration failed");
+ }
+
+ if (eFrameworkunifiedStatusOK != (eStatus = m_device_detector_obj.NotifyOnOpenSessionAck( DD_USBOpenSessionAckCallBack))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: OpenSessionAckCallback registration failed");
+ }
+
+ if (eFrameworkunifiedStatusOK != (eStatus = m_device_detector_obj.NotifyOnCloseSessionAck( DD_USBCloseSessionAckCallBack))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: CloseSessionCallback registration failed");
+ }
+ } else {
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: Device Detection Object Initialization failed!");
+ // LCOV_EXCL_STOP
+ }
+
+ if (pObj) { // LCOV_EXCL_BR_LINE 200:As it is always TRUE
+ FrameworkunifiedSetThreadSpecificData(hThread, pObj);
+ if (eFrameworkunifiedStatusOK != (eStatus = pObj->Initialize(hThread))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: CEvntWriterWorker Initialize Failed");
+ }
+ } else {
+ // LCOV_EXCL_START 200:As it is always TRUE
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "pObj is NULL");
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :EvntWriterWorkerOnStop
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus EvntWriterWorkerOnStop(HANDLE hThread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+
+ if (pObj) { // LCOV_EXCL_BR_LINE 200:As it is always TRUE
+ if (NULL != g_hEvtLogTimer) { // LCOV_EXCL_BR_LINE 200:As it is always NULL
+ // LCOV_EXCL_START 200:As it is always NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ CALL_AND_LOG_STATUS(FrameworkunifiedDetachTimerCallback(hThread, g_hEvtLogTimer));
+ g_hEvtLogTimer = NULL;
+ // LCOV_EXCL_STOP
+ }
+
+ /// To Read all msgs of EventLog queue on shutdown
+ CALL_AND_LOG_STATUS(ReadEventLogQueue(hThread)); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ /// Close ReadEventLog Queue receive handle
+ if (NULL != g_hReceive) { // LCOV_EXCL_BR_LINE 200:As it is always NULL
+ // LCOV_EXCL_START 200:As it is always NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ CALL_AND_LOG_STATUS(McClose(g_hReceive));
+ g_hReceive = NULL;
+ // LCOV_EXCL_STOP
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdIncrcount_phase
+///////////////////////////////////////////////////////////////////////
+VOID CEvntWriterWorker::OnCmdIncrcount_phase(st_LogCount *cnt) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+
+ if (NULL != cnt) {
+ EStatCounterGroupID group;
+ UI_16 counterID = ((*cnt).cnt_id);
+ group = static_cast<EStatCounterGroupID>((counterID >> 8) & 0x00FF);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__,
+ "Increment counter(%04X) for group(%02X) by one", counterID, group);
+ counterIncrementByValue(group, counterID, 0x01u);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "Function call without parameter");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdIncrcount
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::OnCmdIncrcount(UI_8 *pbuf) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ st_LogCount cnt;
+
+ if (eFrameworkunifiedStatusOK
+ == (eStatus = McGetDataOfSize(pbuf, (PVOID) &cnt, sizeof(cnt)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__,
+ "call increment function cnt.phase=%x,cnt.ID=%x", cnt.phase,
+ cnt.cnt_id);
+ OnCmdIncrcount_phase(&cnt);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "Not recieved data from q");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdIncrwriteevent
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::OnCmdIncrwriteevent(UI_8* pbuf) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ st_LogEvent EC;
+ st_LogEvent_ss ev = { };
+ st_LogCount C;
+
+ if (eFrameworkunifiedStatusOK
+ == (eStatus = McGetDataOfSize(pbuf, (PVOID) &EC, sizeof(EC)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "Successful increment");
+ ev.event_id = EC.event_id;
+ ev.data[0] = EC.data[0];
+ ev.data[1] = EC.data[1];
+ ev.data[2] = EC.data[2];
+ ev.data[3] = EC.data[3];
+ OnCmdWriteEventLogs(&ev);
+ C.phase = (SystemPhase) (EC.phase);
+ C.cnt_id = EC.cnt_ID;
+ OnCmdIncrcount_phase(&C);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "Not recieved data from q");
+ }
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdWriteEventLogs
+///////////////////////////////////////////////////////////////////////
+VOID CEvntWriterWorker::OnCmdWriteEventLogs(st_LogEvent_ss *ev) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+// FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ UI_32 u32deque_size = 0;
+ u32deque_size = static_cast<UI_32>(deque_event_info.size());
+ u32deque_size = u32deque_size * SINGLE_EVENT_INFO_SIZE; // Existing Event Info size
+ u32deque_size += SINGLE_EVENT_INFO_SIZE;
+ // FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__,"Deque size before write:%X ",u32deque_size);
+
+ if (u32deque_size > MAX_EVENTLOG_SIZE) {
+// FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__,"Deque size will be exceeded after new event:%X ",u32deque_size);
+// FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__,"Removed the oldest event and add latest event in the the end");
+ deque_event_info.pop_front();
+ u32deque_size = static_cast<UI_32>(deque_event_info.size());
+// FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__,"Deque size after pop:%X ",(u32deque_size*SINGLE_EVENT_INFO_SIZE));
+ }
+ deque_event_info.push_back(*ev);
+// FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__,"Deque size after write:%X ",
+// (deque_event_info.size()*SINGLE_EVENT_INFO_SIZE));
+// FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+}
+// LCOV_EXCL_STOP
+
+UI_32 LS_ConvertEndian(UI_32 * pvar) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ UI_32 retVal = (UI_32) 0;
+ UI_32 var = *pvar;
+ retVal = (((var & 0xFF000000) >> 24) | ((var & 0x00FF0000) >> 8)
+ | ((var & 0x0000FF00) << 8) | ((var & 0x000000FF) << 24));
+ return (retVal);
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdEventLog
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::OnCmdEventLog(UI_8* pbuf) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+// FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+ st_LogEvent_ss ev = { };
+ st_LogEvent_full ev_full = { };
+ UI_32 l_mileage;
+ if (eFrameworkunifiedStatusOK
+ == (eStatus = McGetDataOfSize(pbuf, &ev_full, sizeof(ev_full)))) {
+ if (0 != ev_full.grp_ID) {
+ if (0x01 == ev_full.grp_ID) {
+ // copied to local var as m_u32MileageData value is persisted
+ l_mileage = m_u32MileageData;
+ ev.ts = LS_ConvertEndian(&l_mileage);
+ } else {
+ ev.ts = ev_full.ts;
+ }
+ ev.grp_ID = ev_full.grp_ID;
+ ev.event_id = ev_full.event_id;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "TS %u, GRPID %d, EVTID %d", ev.ts,
+ ev.grp_ID, ev.event_id);
+ // FRAMEWORKUNIFIEDLOG_EVT(Zone,EventId,4,data0,data1,data2,data3)
+ // Data in tool should be represented in Little Endian format means data3(MSB)..data0(LSB)
+ // In the COMMON_DATA, 1st element of structure u_stEvtLoggerCommonInfo is stored in the CommonData[0],
+ // ie BodayCAN_Stat,
+ // in the data array, byte0=>MSB, byte3=>LSB in the tool
+ if (ev_full.typeofdata == COMMON_DATA) {
+ for (UI_8 j = 0; j < 3; j++) {
+ ev.data[j] = g_uEvtLoggerCommonInfo.CommonData[j];
+ }
+ // byte0 param
+ ev.data[3] = ev_full.data[0];
+ } else {
+ // in array data[0] => MSB in tool, data[3] => LSB in the tool
+ for (UI_8 i = 4, j = 0; i > 0 && j < 4; i--, j++) {
+ ev.data[i - 1] = ev_full.data[j];
+ }
+ }
+ OnCmdWriteEventLogs(&ev);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: Invalid event");
+ }
+ }
+// FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdStop
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::OnCmdStop(HANDLE hThread) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CEvntWriterWorker::OnCmdStart(HANDLE hThread) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :read_count_from_file
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::readCountFromFile(PCSTR filename) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ UI_32 counter_ID = 0;
+ UI_32 counter_val = 0;
+ FILE* fp;
+ if (filename != NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Open counter file:%s", filename);
+ if (NULL != (fp = ::fopen(filename, "r"))) {
+ while (!feof(fp)) {
+ EStatCounterGroupID group;
+ UI_8 groupID;
+ UI_8 count = static_cast<UI_8>(::fscanf(fp, "%04X%08X", &counter_ID, &counter_val));
+ groupID = (counter_ID >> 8) & 0xFF;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Read: 0x%04X 0x%08X", counter_ID,
+ counter_val);
+ if ((count == 2u)
+ && (groupID >= static_cast<UI_8>(STARTUP_SHUTDOWN_COUNTER_GROUP))
+ && (groupID <= static_cast<UI_8>(APP_USAGE_COUNTER_GROUP))) {
+ // Check if group is valid before casting it o EStatCounterGroup
+ group = static_cast<EStatCounterGroupID>(groupID);
+ counterIncrementByValue(group, static_cast<UI_16>(counter_ID), counter_val);
+ }
+ }
+ ::fclose(fp);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Normal File failed to open");
+ eStatus = eFrameworkunifiedStatusFileLoadError;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Filename is NULL-pointer");
+ eStatus = eFrameworkunifiedStatusAccessError;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 8: dead code
+EFrameworkunifiedStatus CEvntWriterWorker::writeGroupToFile(FILE *fp,
+ EStatCounterGroupID group) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ if (fp != NULL) {
+ CounterInformation::iterator countInfIt = counter.find(group);
+ if (countInfIt != counter.end()) {
+ Counter count = countInfIt->second;
+ if (!count.empty()) {
+ Counter::iterator countIt;
+ for (countIt = count.begin(); countIt != count.end(); ++countIt) {
+ ::fprintf(fp, "%04X%08X\n", countIt->first, countIt->second);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Written %d entries for Group 0x%02X",
+ (UI_8)count.size(), (UI_8)group);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Group 0x%02X is empty", (UI_8)group);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Group not found in map");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Parameter fp is NULL-pointer");
+ eStatus = eFrameworkunifiedStatusAccessError;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :writeCountToFile
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::writeCountToFile(PCSTR filename) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FILE *fp;
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ CounterInformation::iterator countInfIt;
+ if (0 == strcmp(filename, Counter_LOG_PATH_FN)) {
+ if (NULL != (fp = ::fopen(filename, "w"))) {
+ for (countInfIt = counter.begin(); countInfIt != counter.end();
+ ++countInfIt) {
+ (void) writeGroupToFile(fp, countInfIt->first);
+ }
+ ::fclose(fp);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: Not valid file");
+ eStatus = eFrameworkunifiedStatusErrNoEBADF;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :read_events_from_buffer
+///////////////////////////////////////////////////////////////////////
+// LCOV_EXCL_START 8: dead code
+VOID CEvntWriterWorker::read_events_from_buffer(
+ STEventLogPersistBuffer* f_pstEvtLogBuf) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ deque_event_info.clear();
+ for (int i = 0; i < (f_pstEvtLogBuf->Current_Log_Size); i++) {
+ if (i < f_pstEvtLogBuf->EVT_BUFMAXSIZE) {
+ deque_event_info.push_back(f_pstEvtLogBuf->EvtLog_Buffer[i]);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: EventLog buffer size greater than EVT_BUFMAXSIZE");
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Size of DEQUE event is :%d",
+ static_cast<int>(deque_event_info.size()));
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :write_events_to_buffer
+///////////////////////////////////////////////////////////////////////
+// LCOV_EXCL_START 8: dead code
+VOID CEvntWriterWorker::write_events_to_buffer(
+ STEventLogPersistBuffer* f_pstEvtLogBuf) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+// FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ st_LogEvent_ss l_event_info;
+ DEQUE_Event_Type::iterator deque_it;
+ deque_it = deque_event_info.begin();
+ int i = 0;
+
+ memset(f_pstEvtLogBuf, 0x00, sizeof(STEventLogPersistBuffer));
+ while (deque_it != deque_event_info.end()) {
+ if (0x00 != deque_it->grp_ID) {
+ l_event_info.ts = deque_it->ts;
+ l_event_info.grp_ID = deque_it->grp_ID;
+ l_event_info.event_id = deque_it->event_id;
+ memcpy(l_event_info.data, deque_it->data, sizeof(l_event_info.data));
+// FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__,"Event record is:%X ",++EventRecordCnt);
+ if (i < f_pstEvtLogBuf->EVT_BUFMAXSIZE) {
+ memcpy(&f_pstEvtLogBuf->EvtLog_Buffer[i], &l_event_info,
+ sizeof(l_event_info));
+ }
+ }
+ deque_it++;
+ i++;
+ }
+ f_pstEvtLogBuf->Current_Log_Size = static_cast<UI_16>(deque_event_info.size());
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Size of DEQUE event is :%d",
+ static_cast<int>(deque_event_info.size()));
+// FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :write_event_to_file
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::write_event_to_file(const CHAR* filename) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ UI_32 u32File_Size;
+ st_LogEvent_ss Sevent_Info;
+ DEQUE_Event_Type::iterator deque_it;
+ FILE *fp;
+
+ if (NULL != (fp = ::fopen(filename, "wb"))) {
+ deque_it = deque_event_info.begin();
+ while (deque_it != deque_event_info.end()) {
+ Sevent_Info.ts = deque_it->ts;
+ Sevent_Info.grp_ID = deque_it->grp_ID;
+ Sevent_Info.event_id = deque_it->event_id;
+ memcpy(Sevent_Info.data, deque_it->data, sizeof(Sevent_Info.data));
+
+ if (0x00 != deque_it->grp_ID) {
+ if (SIZE_1
+ != (u32File_Size = static_cast<UI_32>(::fwrite(&Sevent_Info, sizeof(Sevent_Info), 1,
+ fp)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: Writing in to file is failed");
+ eStatus = eFrameworkunifiedStatusFail;
+ break;
+ }
+ }
+ deque_it++;
+ }
+ ::fclose(fp);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: File failed to open");
+ eStatus = eFrameworkunifiedStatusFileLoadError;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdClearEventLogs
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::OnCmdClearEventLogs(HANDLE hThread) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ TSessionData l_stSessionData;
+ TClearEvntLogCmdResponse l_stCmdResponse;
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<TSessionData>(hThread,
+ l_stCmdResponse.stSessiondata))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ deque_event_info.clear();
+ if (eFrameworkunifiedStatusOK != (l_eStatus = immediate_persist_event_log(hThread))) {
+ l_stCmdResponse.u8Response = (UI_8) CLEAR_EVENT_LOG_FAILED;
+ } else {
+ l_stCmdResponse.u8Response = (UI_8) CLEAR_EVENT_LOG_SUCCESS;
+ }
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendParent(hThread, eThrdCmdClearEventLogResponse,
+ sizeof(TClearEvntLogCmdResponse),
+ &l_stCmdResponse))) {
+ LOG_ERROR("FrameworkunifiedSendParent()");
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP 8
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdSetVIN
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::OnCmdSetVIN(HANDLE hThread) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ STVIN_NUMBER l_stVIN_Number;
+
+ if (eFrameworkunifiedStatusOK
+ == (l_eStatus = FrameworkunifiedGetMsgDataOfSize(hThread, &l_stVIN_Number,
+ sizeof(l_stVIN_Number), eSMRRelease))) {
+ memcpy(&m_stVINnumber, &l_stVIN_Number, sizeof(STVIN_NUMBER));
+ }
+
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdGetVIN
+///////////////////////////////////////////////////////////////////////
+VOID CEvntWriterWorker::OnCmdGetVIN(STVIN_NUMBER& f_stVIN_Number) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ memcpy(&f_stVIN_Number, &m_stVINnumber, sizeof(STVIN_NUMBER));
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdWriteEventFilesToUsb
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::OnCmdWriteEventFilesToUsb(HANDLE hThread) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ TWriteFilesToUsbCmdData l_stCmdData;
+ TWriteFilesToUsbCmdResponse l_stCmdResponse;
+
+ TThrdEvtLogStore evt = { };
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<TWriteFilesToUsbCmdData>(hThread, l_stCmdData))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ if ((USB0 == l_stCmdData.eDevId) || (USB1 == l_stCmdData.eDevId)) {
+ memcpy(&evt, &gSUSBDevInfo[l_stCmdData.eDevId], sizeof(TThrdEvtLogStore));
+ } else if (SD == l_stCmdData.eDevId) {
+ memcpy(&evt, &gSSDCardevInfo, sizeof(TThrdEvtLogStore));
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldID;
+ LOG_ERROR("Invalid DeviceId()");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "USB dev info:Available %d, Location %s, Parse %s ",
+ evt.IsDeviceAvailable, evt.parse_fn, evt.location);
+ l_stCmdResponse.u8Response = copy_event_files_to_usb(&evt);
+ l_stCmdResponse.stSessiondata.strSrcName = l_stCmdData.stSessiondata.strSrcName;
+ l_stCmdResponse.stSessiondata.session_id = l_stCmdData.stSessiondata.session_id;
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendParent(hThread, eThrdCmdCopyEventLogUSBResponse,
+ sizeof(TWriteFilesToUsbCmdResponse),
+ &l_stCmdResponse))) {
+ LOG_ERROR("FrameworkunifiedSendParent()");
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdReadStatisticalCounter
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::OnCmdReadStatisticalCounter(HANDLE hThread) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ SStatisticalCounter buffer = { 0 };
+ TStatisticalCntCmdSuccessResp l_stCmdSuccessResp;
+
+ if (hThread != NULL) {
+ TStatisticalCountersCmd l_stCmdData;
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<TStatisticalCountersCmd>(hThread, l_stCmdData))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadStatisticalCounter(l_stCmdData.eGroupId, buffer))) {
+ LOG_ERROR("ReadStatisticalCounter()");
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendParent(hThread,
+ eThrdCmdStatisticalCounterErrorResp,
+ sizeof(TSessionData),
+ &l_stCmdData.stSessiondata))) {
+ LOG_ERROR("FrameworkunifiedSendParent()");
+ }
+ } else {
+ (VOID) memcpy(&l_stCmdSuccessResp.stBuffer, &buffer,
+ sizeof(SStatisticalCounter));
+ (VOID) memcpy(&l_stCmdSuccessResp.stSessiondata,
+ &l_stCmdData.stSessiondata, sizeof(TSessionData));
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendParent(hThread,
+ eThrdCmdStatisticalCounterSuccessResp,
+ sizeof(TStatisticalCntCmdSuccessResp),
+ &l_stCmdSuccessResp))) {
+ LOG_ERROR("FrameworkunifiedSendParent()");
+ }
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :ReadStatisticalCounter
+///////////////////////////////////////////////////////////////////////
+// LCOV_EXCL_START 8: dead code
+EFrameworkunifiedStatus CEvntWriterWorker::ReadStatisticalCounter(
+ EStatCounterGroupID eCounterGroup, SStatisticalCounter& buffer) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ UI_32 size = 0u;
+
+ CounterInformation::iterator countInfIt = counter.find(eCounterGroup);
+ if (counter.end() != countInfIt) {
+ Counter count = countInfIt->second;
+ Counter::iterator countIt;
+ if (((UI_16) count.size()) <= 40) {
+ for (countIt = count.begin(); countIt != count.end(); ++countIt) {
+ UI_16 counterID = countIt->first;
+ UI_32 counterVal = countIt->second;
+ u16copy(&buffer.StatisticalCountBuffer[size], counterID);
+ size += static_cast<UI_16>( sizeof(counterID));
+
+ counterVal = countIt->second;
+ u32copy(&buffer.StatisticalCountBuffer[size], counterVal);
+ size += static_cast<UI_16>( sizeof(counterVal));
+ }
+ } else {
+ eStatus = eFrameworkunifiedStatusInvldBuf;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: Too many counter elements %02d > 42 ", static_cast<int>(count.size()));
+ }
+ } else {
+ /*OK, here: empty buffer will be returned*/
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdResetStatisticalCounter
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::OnCmdResetStatisticalCounter(HANDLE hThread) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ TStatisticalCountersCmd l_stCmdData;
+
+ if (hThread != NULL) {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<TStatisticalCountersCmd>(hThread, l_stCmdData))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ResetStatisticalCounter(l_stCmdData.eGroupId))) {
+ LOG_ERROR("ResetStatisticalCounter()");
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+///////////////////////////////////////////////////////////////////////
+/// Function :ResetStatisticalCounter
+///////////////////////////////////////////////////////////////////////
+// LCOV_EXCL_START 8: dead code
+EFrameworkunifiedStatus CEvntWriterWorker::ResetStatisticalCounter(
+ EStatCounterGroupID eCounterGroup) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ CounterInformation::iterator countInfIt;
+ countInfIt = counter.find(eCounterGroup);
+ if (counter.end() != countInfIt) {
+ countInfIt->second.clear();
+ counter.erase(countInfIt->first);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Erased group: 0x%02X from map",
+ (UI_8)eCounterGroup);
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldID;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :_GetCurrentTimeString
+///////////////////////////////////////////////////////////////////////
+PSTR _GetCurrentTimeString(PCHAR TempFileName, PSTR f_pstrVIN) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ uint32_t rawtime;
+ uint8_t status;
+ struct tm local_time;
+ CHAR tbuf[30];
+ UI_8 l_len = 0;
+ std::string l_strVIN = f_pstrVIN;
+
+ // Time string is based on current date and time. Time string format is <year-mon-dayThhmm>.
+// Clock_getSystemTimeY2K38(&rawtime, &status);
+// Clock_getLocalTimeY2K38(&rawtime, &local_time);
+ if (0
+ != (l_len = static_cast<UI_8>(strftime(tbuf, sizeof(tbuf), "%Y-%m-%dT%H%M",
+ &local_time)))) {
+ sprintf(TempFileName, "%s_%s_%04X.dat", l_strVIN.c_str(), tbuf, // NOLINT (runtime/printf)
+ g_u16DiagId);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "EventLog File Name :%s, tbuf_len = %d",
+ TempFileName, l_len);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return TempFileName;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :copy_event_files_to_usb
+///////////////////////////////////////////////////////////////////////
+UI_8 CEvntWriterWorker::copy_event_files_to_usb(TThrdEvtLogStore *pStUSBIndo) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ CHAR buffer[10];
+ CHAR TempFileName[MAX_SYS_INFO_SIZE];
+ STVIN_NUMBER l_stVIN_Number;
+ std::string _filename("");
+ UI_8 u8Result = COPY_EVT_USB_SUCCESS;
+
+ // Initializing all Char arrays.
+ memset(buffer, 0, 10);
+ memset(TempFileName, 0, MAX_SYS_INFO_SIZE);
+
+ if (pStUSBIndo->IsDeviceAvailable == TRUE) {
+ _filename = pStUSBIndo->location;
+ OnCmdGetVIN(l_stVIN_Number);
+ _filename += _GetCurrentTimeString(TempFileName, l_stVIN_Number.VINstr);
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = write_event_to_file(_filename.c_str()))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: Write to file failed:%d",
+ l_eStatus);
+ u8Result = (UI_8) USB_DEVICE_WRITE_ERROR;
+ }
+
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: Device not available, so event logs can not be copied");
+ u8Result = (UI_8) USB_DEVICE_NOT_AVAILABLE;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+ return u8Result;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :DD_USBSrvDetectionCallBack
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus DD_USBSrvDetectionCallBack(HANDLE hApp) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
+
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ SS_MediaDetectInfo tMediaDetectInfo = { };
+ std::string FilePathStr;
+ UI_8 u8Pos = 0;
+
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &tMediaDetectInfo,
+ sizeof(tMediaDetectInfo)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
+ "MediaDetectCallBack FrameworkunifiedGetMsgDataOfSize Failed Status:0x%x ",
+ eStatus);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Device = %d", tMediaDetectInfo.dev_type);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Availability = %d",
+ tMediaDetectInfo.bIsDeviceAvailable);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " device path = %s",
+ tMediaDetectInfo.deviceMountpath);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " File path = %s",
+ tMediaDetectInfo.filepathName);
+
+ FilePathStr.append(tMediaDetectInfo.deviceMountpath);
+
+ if (tMediaDetectInfo.dev_type == eUSB) {
+ if (tMediaDetectInfo.bIsDeviceAvailable == TRUE) {
+ u8Pos = static_cast<UI_8>(FilePathStr.find_last_of("/\\"));
+
+ if (FilePathStr.compare(u8Pos + 1, 12, "usb-00-d0-p0") == 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "USB1 Detected ");
+ gSUSBDevInfo[0].IsDeviceAvailable = TRUE;
+ snprintf(gSUSBDevInfo[0].parse_fn, gSUSBDevInfo[0].FN_LEN, "%s/",
+ FilePathStr.c_str());
+ snprintf(gSUSBDevInfo[0].location, gSUSBDevInfo[0].FN_LEN, "%s/",
+ FilePathStr.c_str());
+ } else if (FilePathStr.compare(u8Pos + 1, 12, "usb-01-d0-p0") == 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "USB2 Detected ");
+ gSUSBDevInfo[1].IsDeviceAvailable = TRUE;
+ snprintf(gSUSBDevInfo[1].parse_fn, gSUSBDevInfo[1].FN_LEN, "%s/",
+ FilePathStr.c_str());
+ snprintf(gSUSBDevInfo[1].location, gSUSBDevInfo[1].FN_LEN, "%s/",
+ FilePathStr.c_str());
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "USB Detected :%s", FilePathStr.c_str());
+ }
+ } else {
+ u8Pos = static_cast<UI_8>(FilePathStr.find_last_of("/\\"));
+
+ if (FilePathStr.compare(u8Pos + 1, 12, "usb-00-d0-p0") == 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "USB1 Ejected ");
+ gSUSBDevInfo[0].IsDeviceAvailable = FALSE;
+ } else if (FilePathStr.compare(u8Pos + 1, 12, "usb-01-d0-p0") == 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "USB2 Ejected ");
+ gSUSBDevInfo[1].IsDeviceAvailable = FALSE;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "USB Ejected :%s", FilePathStr.c_str());
+ }
+ }
+
+ } else if (tMediaDetectInfo.dev_type == eSD) {
+ if (tMediaDetectInfo.bIsDeviceAvailable == TRUE) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "SD card Detected ");
+ gSSDCardevInfo.IsDeviceAvailable = TRUE;
+ snprintf(gSSDCardevInfo.parse_fn, gSSDCardevInfo.FN_LEN, "%s/",
+ FilePathStr.c_str());
+ snprintf(gSSDCardevInfo.location, gSSDCardevInfo.FN_LEN, "%s/",
+ FilePathStr.c_str());
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "SD card Ejected ");
+ gSSDCardevInfo.IsDeviceAvailable = FALSE;
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
+
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+//////////////////////////////////////////
+// Function : DD_USBServiceAvailabilityCallBack
+//////////////////////////////////////////
+EFrameworkunifiedStatus DD_USBServiceAvailabilityCallBack(HANDLE hThread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (FrameworkunifiedIsServiceAvailable(hThread)) {
+ if (eFrameworkunifiedStatusOK // LCOV_EXCL_BR_LINE:200 Because the IF of DetectionService is guaranteed to be successful
+ != (eStatus = m_device_detector_obj.OpenSessionRequest())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Open session request failed");
+ }
+ } else {
+ if (eFrameworkunifiedStatusOK // LCOV_EXCL_BR_LINE:200 Because the IF of DetectionService is guaranteed to be successful
+ != (eStatus = m_device_detector_obj.CloseSessionRequest())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Close session request failed");
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+//////////////////////////////////////////
+// Function : DD_USBOpenSessionAckCallBack
+//////////////////////////////////////////
+EFrameworkunifiedStatus DD_USBOpenSessionAckCallBack(HANDLE hThread) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (eFrameworkunifiedStatusOK == (eStatus = // LCOV_EXCL_BR_LINE:200 Because the IF of DetectionService is guaranteed to be successful
+ m_device_detector_obj.DecodeOpenSessionResponse())) {
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = m_device_detector_obj.RegisterForDeviceDetectionEvent( // LCOV_EXCL_BR_LINE:200 Because the IF of DetectionService is guaranteed to be successful // NOLINT[whitespace/line_length]
+ SS_DEV_DETECT_ANY_USB_EV, DD_USBSrvDetectionCallBack))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Registration for SS_DEV_DETECT_ANY_USB_EV failed");
+ }
+
+ if (eFrameworkunifiedStatusOK
+ != (eStatus = m_device_detector_obj.RegisterForDeviceDetectionEvent( // LCOV_EXCL_BR_LINE:200 Because the IF of DetectionService is guaranteed to be successful // NOLINT[whitespace/line_length]
+ SS_DEV_DETECT_ANY_SD_EV, DD_USBSrvDetectionCallBack))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Registration for SS_DEV_DETECT_ANY_SD_EV failed");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Decode open session response failed");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+//////////////////////////////////////////
+// Function : DD_USBCloseSessionAckCallBack
+//////////////////////////////////////////
+EFrameworkunifiedStatus DD_USBCloseSessionAckCallBack(HANDLE hApp) { // LCOV_EXCL_START 200: CloseSessionRequest can not be called // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ CloseSessionAck tCloseSessionAck = { };
+
+ if (hApp) {
+ if (eFrameworkunifiedStatusOK
+ == (eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &tCloseSessionAck,
+ sizeof(tCloseSessionAck)))) {
+ if (eFrameworkunifiedStatusOK == tCloseSessionAck.eStatus) {
+ UI_32 l_uiSessionId = tCloseSessionAck.sessionId;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "session %d closed successfully",
+ l_uiSessionId);
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 8: dead code
+EFrameworkunifiedStatus CEvntWriterWorker::counterIncrementByValue(EStatCounterGroupID group,
+ UI_16 id, UI_32 value) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus result = eFrameworkunifiedStatusFail;
+ CounterInformation::iterator count_inf_it;
+ count_inf_it = counter.find(group);
+ if (counter.end() == count_inf_it) {
+ Counter newCounter;
+ newCounter.insert(std::pair<UI_16, UI_32>(id, value));
+ counter.insert(std::pair<EStatCounterGroupID, Counter>(group, newCounter));
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__,
+ "Added new Counter for group %d, id: 0x%04X, value: 0x%08X",
+ (UI_8)group, id, value);
+ } else {
+ Counter::iterator count_it;
+ count_it = count_inf_it->second.find(id);
+ if (count_inf_it->second.end() == count_it) {
+ count_inf_it->second.insert(std::pair<UI_16, UI_32>(id, value));
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__,
+ "Added new Entry for group %d, id: 0x%04X, value: 0x%08X",
+ (UI_8)group, id, value);
+ } else {
+ if (count_it->second != MAX_CNT_VALUE) {
+ count_it->second += value;
+ }
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_FUNC,
+ __FUNCTION__,
+ "Modified Entry for group %d, id: 0x%04X, by value: 0x%08X, new value: 0x%08X",
+ (UI_8)group, id, value, count_it->second);
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return result;
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CEvntWriterWorker::immediate_persist_event_log(HANDLE hThread) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ STEventLogPersistBuffer* l_evtlogbuf;
+ l_evtlogbuf = new (std::nothrow) STEventLogPersistBuffer;
+
+ if (NULL != l_evtlogbuf) {
+ if (pObj) {
+ pObj->write_events_to_buffer(l_evtlogbuf);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: CEvntWriterWorker Object handle is NULL");
+ }
+ delete l_evtlogbuf;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: New failed to allocate memory, err: %s", strerror(errno));
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CEvntWriterWorker::EvtThd_SetMileage(HANDLE hThread) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_32 l_u32mileage;
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedGetMsgDataOfSize(hThread, &l_u32mileage,
+ sizeof(l_u32mileage)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedGetMsgDataOfSize Failed Status:%d ",
+ l_eStatus);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+ }
+ m_u32MileageData = l_u32mileage;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :write_mileage_to_file
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::write_mileage_to_file(const CHAR* filename) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ UI_32 u32File_Size;
+ SI_32 fd = -1;
+
+ if (-1 != (fd = ::open(filename, O_WRONLY | O_CREAT | O_TRUNC,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP))) {
+ if (SIZE_0
+ >= (u32File_Size = static_cast<UI_32>(::write(fd, &m_u32MileageData, sizeof(UI_32))))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: Writing in to file is failed");
+ eStatus = eFrameworkunifiedStatusFail;
+ }
+ ::close(fd);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: File failed to open");
+ eStatus = eFrameworkunifiedStatusFileLoadError;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :read_mileage_from_file
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::read_mileage_from_file(const CHAR* filename) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+// UI_32 u32File_Size;
+ SI_32 fd = -1;
+
+ if (NULL != filename) {
+ if (-1 != (fd = ::open(filename, O_RDONLY, S_IRUSR))) {
+ if (-1 == ::read(fd, &m_u32MileageData, sizeof(UI_32))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: Reading file failed, %s",
+ strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "m_u32MileageData = %d",
+ m_u32MileageData);
+ }
+ ::close(fd);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: File failed to open");
+ l_eStatus = eFrameworkunifiedStatusFileLoadError;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: Filename is NULL");
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdReadNumberOfEventsLogged
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::OnCmdReadNumberOfEventsLogged(HANDLE hThread) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ TEvntsLogged l_stEventsLogged;
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<TSessionData>(hThread,
+ l_stEventsLogged.stSessiondata))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ l_stEventsLogged.u16numberofeventslogged = (UI_16) deque_event_info.size();
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Number of Events Read: %d",
+ l_stEventsLogged.u16numberofeventslogged);
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendParent(hThread,
+ eThrdCmdNumberOfEventsLoggedResponse,
+ sizeof(TEvntsLogged), &l_stEventsLogged))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Error: FrameworkunifiedSendMsg failed %d", l_eStatus);
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdUploadEventLog
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::OnCmdUploadEventLog(HANDLE hThread) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<TSessionData>(
+ hThread, m_stUploadEventLogResp.stSessiondata))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ if (pObj) {
+ pObj->write_events_to_buffer(&m_stUploadEventLogResp.stEventLogBuffer);
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendParent(hThread, eThrdCmdUploadEventLogResponse,
+ sizeof(TUploadEventLogResp),
+ &m_stUploadEventLogResp))) {
+ LOG_ERROR("FrameworkunifiedSendParent()");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: CEvntWriterWorker Object handle is NULL");
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+///////////////////////////////////////////////////////////////////////
+/// Function :OnCmdCopyEvntLogToTmp
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CEvntWriterWorker::OnCmdCopyEvntLogToTmp(HANDLE hThread) { // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return eFrameworkunifiedStatusOK;
+}
+// LCOV_EXCL_STOP
diff --git a/logger_service/server/src/mem_reader.cpp b/logger_service/server/src/mem_reader.cpp
new file mode 100644
index 00000000..6d25d764
--- /dev/null
+++ b/logger_service/server/src/mem_reader.cpp
@@ -0,0 +1,125 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief This file supports reading from a shared mem area.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "readerWriter/reader/mem_reader.h"
+#include <string>
+
+namespace ReaderWriter {
+
+CMemReader::CMemReader()
+ : m_pSharedBuf(NULL),
+ m_sharedBufSize(0) {
+}
+
+CMemReader::~CMemReader() {
+ this->Close();
+}
+
+EFrameworkunifiedStatus CMemReader::Initialize(CLoggerCfg* f_pLoggerCfg, std::string f_name,
+ UI_32 f_maxSize) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldParam;
+ m_sharedBufSize = f_maxSize;
+ m_pSharedBuf = new (std::nothrow) CNSSharedMemReader(f_name, TRUE); // LCOV_EXCL_BR_LINE 5:Cannot pass because it cannot be new
+ if (NULL != m_pSharedBuf) { // LCOV_EXCL_BR_LINE 5:Cannot pass because it cannot be new
+ l_eStatus = this->Open();
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %d", l_eStatus);
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CMemReader::Open(void) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldParam;
+ if (NULL != m_pSharedBuf) { // LCOV_EXCL_BR_LINE 5: new will aways sucess, so m_pSharedBuf will noe be null
+ if (!m_pSharedBuf->IsOpen()) {
+ // maps the shared memory buffer
+ l_eStatus = m_pSharedBuf->Open();
+ } else {
+ // Already opened no action required
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return l_eStatus;
+}
+
+BOOL CMemReader::IsOpen(void) {
+ return this->m_pSharedBuf->IsOpen();
+}
+
+EFrameworkunifiedStatus CMemReader::Read(UI_8* f_data, UI_32 f_length, SI_32& f_bytesRead) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (this->m_pSharedBuf != NULL) {
+ if (TRUE != this->m_pSharedBuf->IsOpen()) {
+ l_eStatus = m_pSharedBuf->Open();
+ }
+ if (l_eStatus == eFrameworkunifiedStatusOK) {
+ f_bytesRead = m_pSharedBuf->Read(reinterpret_cast<char *>(f_data), f_length);
+ if (NS_SHM_ERROR != f_bytesRead) {
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ }
+
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CMemReader::ReadToFile(std::string f_fileName, UI_32& f_Written) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+
+ if ((NULL != m_pSharedBuf) && // LCOV_EXCL_BR_LINE 5: new will aways sucess, so m_pSharedBuf will noe be null
+ (f_fileName.length() != 0)) {
+ l_eStatus = m_pSharedBuf->DumpToFile(f_fileName.c_str(), &f_Written);
+ }
+
+ return l_eStatus;
+}
+
+void CMemReader::Close(void) {
+ if (NULL != m_pSharedBuf) { // LCOV_EXCL_BR_LINE 6: m_pSharedBuf can not be null
+ // un-map the shared memory object
+ (void) m_pSharedBuf->Close();
+
+ delete m_pSharedBuf;
+ m_pSharedBuf = NULL;
+ }
+}
+
+EFrameworkunifiedStatus CMemReader::ResetPosition(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusNullPointer;
+ if (NULL != m_pSharedBuf) { // LCOV_EXCL_BR_LINE 6:Because m_pSharedBuf is always NULL
+ // un-map the shared memory object
+ l_eStatus = m_pSharedBuf->SetReadPtrToWritePtr();
+ LOG_STATUS_IF_ERRORED(l_eStatus, "m_pSharedBuf->SetReadPtrToWritePtr();"); // LCOV_EXCL_BR_LINE 15:Macro
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %d", l_eStatus);
+ return (l_eStatus);
+}
+} // namespace ReaderWriter
diff --git a/logger_service/server/src/mod_version.c b/logger_service/server/src/mod_version.c
new file mode 100644
index 00000000..a484d10b
--- /dev/null
+++ b/logger_service/server/src/mod_version.c
@@ -0,0 +1,49 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_LogTraceSender
+/// \brief This file supports logging module version identification.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <native_service/frameworkunified_types.h>
+
+#define MOD_VERSION_LENGTH 12
+
+static CHAR s_ModVersion[MOD_VERSION_LENGTH + 1] = "0.0.0";
+
+SI_8 GetModuleVersion (CHAR* pRetBuf, UI_8 nBufLen)
+{ // LCOV_EXCL_START 8: dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ UI_8 CopyLen = 0;
+ SI_8 RetVal = -1;
+
+ if (NULL != pRetBuf)
+ {
+ CopyLen = MIN_VAL(nBufLen, MOD_VERSION_LENGTH);
+ strncpy(pRetBuf, s_ModVersion, CopyLen);
+ pRetBuf[CopyLen] = '\0';
+ RetVal = 0;
+ }
+ return RetVal;
+}
+// LCOV_EXCL_STOP 8: dead code
+
diff --git a/logger_service/server/src/queue_reader.cpp b/logger_service/server/src/queue_reader.cpp
new file mode 100644
index 00000000..1c831544
--- /dev/null
+++ b/logger_service/server/src/queue_reader.cpp
@@ -0,0 +1,101 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "readerWriter/reader/queue_reader.h"
+#include <string>
+
+namespace ReaderWriter {
+CQueueReader::CQueueReader()
+ : m_handle(-1),
+ m_queName("") { // LCOV_EXCL_BR_LINE 11:except,C++ STL
+}
+
+CQueueReader::~CQueueReader() {
+ if (this->IsOpen()) {
+ this->Close();
+ }
+}
+
+EFrameworkunifiedStatus CQueueReader::Initialize(CLoggerCfg* f_pLoggerCfg,
+ std::string f_name, UI_32 f_maxSize) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldParam;
+ if (f_pLoggerCfg != NULL) { // LCOV_EXCL_BR_LINE 6:Because the applicable variable cannot be changed from the external API
+ this->m_pLoggerCfg = f_pLoggerCfg;
+ // Check for invalid name
+ if (f_name.length() != 0) { // LCOV_EXCL_BR_LINE 6:it can not be 0
+ m_queName = f_name;
+ l_eStatus = this->Open();
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %d", l_eStatus);
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CQueueReader::Open(void) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldParam;
+
+ if (-1 != m_handle) { // LCOV_EXCL_BR_LINE 6:Because m_handle is always -1
+ // Queue already opened, no action required.
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else if (m_queName.length() != 0) { // LCOV_EXCL_BR_LINE 6:Because m_queName is not always an empty string
+ const UI_32 MAX_MESSAGES_STORED_IN_QUEUE = 512;
+ struct mq_attr mqattr;
+ mqattr.mq_flags = 0;
+ mqattr.mq_maxmsg = MAX_MESSAGES_STORED_IN_QUEUE;
+ mqattr.mq_msgsize = MAX_QUEUE_MSG_SIZE;
+
+ this->m_handle = mq_open(m_queName.c_str(), O_RDONLY | O_CREAT, 0666,
+ &mqattr);
+ if (-1 != m_handle) { // LCOV_EXCL_BR_LINE 5:mq_open cannot be passed because it cannot be turned mock
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %d", l_eStatus);
+ return (l_eStatus);
+}
+
+BOOL CQueueReader::IsOpen(void) {
+ return (-1 != m_handle) ? TRUE : FALSE; // LCOV_EXCL_BR_LINE 6:Because the condition cannot be set
+}
+
+EFrameworkunifiedStatus CQueueReader::Read(UI_8* f_data, UI_32 f_length,
+ SI_32& f_bytesRead) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+
+ if (this->m_handle != -1) { // LCOV_EXCL_BR_LINE 6:Because the condition cannot be set
+ if (f_length <= MAX_QUEUE_MSG_SIZE) { // LCOV_EXCL_BR_LINE 6:Because the applicable variable cannot be changed from the external API
+ f_bytesRead = static_cast<SI_32>(mq_receive(this->m_handle, reinterpret_cast<char *>(f_data),
+ (size_t) MAX_QUEUE_MSG_SIZE, NULL));
+
+ if ((0 <= f_bytesRead) && ((UI_32) f_bytesRead <= f_length)) { // LCOV_EXCL_BR_LINE 6:Because the condition cannot be set
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ }
+ }
+ return (l_eStatus);
+}
+
+void CQueueReader::Close(void) {
+ if (this->m_handle != -1) { // LCOV_EXCL_BR_LINE 200: m_handle is aways not -1
+ (void) mq_close(this->m_handle);
+ }
+}
+} // namespace ReaderWriter
diff --git a/logger_service/server/src/reader.cpp b/logger_service/server/src/reader.cpp
new file mode 100644
index 00000000..4ceaf47b
--- /dev/null
+++ b/logger_service/server/src/reader.cpp
@@ -0,0 +1,86 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "readerWriter/reader/reader.h"
+#include <string>
+#include <new>
+#include <iostream>
+#include "readerWriter/reader/queue_reader.h"
+#include "readerWriter/reader/mem_reader.h"
+#include "ss_logger_cfg.h"
+namespace ReaderWriter {
+CReader::CReader()
+ : m_pLoggerCfg(NULL) {
+}
+
+CReader::~CReader() {
+}
+
+CReader* CReader::OpenReader(CLoggerCfg* f_pLoggerCfg, EReaderType f_type,
+ std::string f_name, UI_32 f_maxSize) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ CReader* l_ret = NULL;
+ if (f_pLoggerCfg != NULL) { // LCOV_EXCL_BR_LINE 200:As it is not always NULL
+ if (f_name.length() != 0) { // LCOV_EXCL_BR_LINE 200:Because it is not always an empty string
+ switch (f_type) { // LCOV_EXCL_BR_LINE 200:As it must be eReaderWriterTypeQueue or eReaderWriterTypeMem
+ case eReaderWriterTypeFile:
+ break;
+
+ case eReaderWriterTypeQueue:
+ l_ret = new (std::nothrow) CQueueReader(); // LCOV_EXCL_BR_LINE 5:Cannot pass because it cannot be new
+ break;
+
+ case eReaderWriterTypeMem:
+ l_ret = new (std::nothrow) CMemReader(); // LCOV_EXCL_BR_LINE 5:Cannot pass because it cannot be new
+ break;
+
+ default:
+ break;
+ }
+ }
+ if (NULL != l_ret) { // LCOV_EXCL_BR_LINE 200:As it is not always NULL
+ if (eFrameworkunifiedStatusOK != l_ret->Initialize(f_pLoggerCfg, f_name, f_maxSize)) {
+ delete (l_ret);
+ l_ret = NULL;
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_ret;
+}
+
+
+EFrameworkunifiedStatus CReader::ReadToFile(std::string f_fileName, UI_32& f_Written) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusNotImplemented;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus CReader::ResetPosition(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusNotImplemented;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+} // namespace ReaderWriter
diff --git a/logger_service/server/src/reader_writer.cpp b/logger_service/server/src/reader_writer.cpp
new file mode 100644
index 00000000..df1cd9c3
--- /dev/null
+++ b/logger_service/server/src/reader_writer.cpp
@@ -0,0 +1,282 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "readerWriter/reader_writer.h"
+#include <errno.h>
+#include <loggerservicedebug_loggerservicelog.h>
+#include <system_service/ss_templates.h>
+#include <native_service/frameworkunified_thread_priority.h>
+#include <string>
+
+namespace ReaderWriter {
+
+CReaderWriter::CReaderWriter()
+ : m_pLoggerCfg(NULL),
+ m_reader(NULL),
+ m_writer(NULL),
+ m_running(FALSE),
+ m_thread(-1),
+ m_readerName(""),
+ m_paused(FALSE) {
+
+ pthread_cond_init(&m_condVariable, NULL);
+}
+
+CReaderWriter::~CReaderWriter() { // LCOV_EXCL_START 14:global instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (NULL != this->m_reader) {
+ delete (this->m_reader);
+ this->m_reader = NULL;
+ }
+
+ if (NULL != this->m_writer) {
+ delete (this->m_writer);
+ this->m_writer = NULL;
+ }
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CReaderWriter::Initialize(CLoggerCfg* f_pLoggerCfg,
+ EReaderType f_readerType,
+ std::string f_readerName,
+ UI_32 f_readerMaxSize,
+ EWriterType f_writerType,
+ std::string f_writer1Name,
+ UI_32 f_writer1MaxSize,
+ std::string f_writer2Name,
+ UI_32 f_writer2MaxSize) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ if (NULL == (this->m_pLoggerCfg = f_pLoggerCfg)) { // LCOV_EXCL_BR_LINE 6:Because the applicable variable cannot be changed from the external API
+ // FRAMEWORKUNIFIEDLOG not needed... If this starts we won't be able to print loggerservicelogs anyways.
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ } else {
+ this->m_reader = CReader::OpenReader(f_pLoggerCfg, f_readerType, // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ f_readerName, f_readerMaxSize);
+ this->m_writer = CWriter::OpenWriter(f_pLoggerCfg, f_writerType, // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ f_writer1Name, f_writer1MaxSize,
+ f_writer2Name, f_writer2MaxSize);
+
+ if ((NULL == this->m_reader) || (NULL == this->m_writer)) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+
+ this->Cleanup(this);
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %d", l_eStatus);
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CReaderWriter::Start(std::string f_readerName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusNullPointer;
+ if (this->m_running == FALSE) { // LCOV_EXCL_BR_LINE 6:Because m_running is always FALSE
+ this->m_readerName = f_readerName;
+ BOOL l_barInit =
+ // LCOV_EXCL_BR_START 5:pthread cannot be passed because it cannot be turned mock
+ (EOK == pthread_barrier_init(&m_barrier, NULL, 2)) ? TRUE : FALSE;
+ if (l_barInit) {
+ // LCOV_EXCL_BR_STOP
+ pthread_attr_t attr;
+ struct sched_param params;
+ pthread_attr_init(&attr);
+ pthread_attr_getschedparam(&attr, &params);
+ SI_32 prio = frameworkunified::framework::CFrameworkunifiedThreadPriorities::GetPriority(
+ f_readerName);
+ if (-1 != prio) { // LCOV_EXCL_BR_LINE 6:Because prio is always -1
+ // LCOV_EXCL_START 6:Because the prio is not always -1
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ params.sched_priority = prio;
+ pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
+ pthread_attr_setschedparam(&attr, &params);
+ // LCOV_EXCL_STOP
+ }
+
+ if (EOK == pthread_create(&m_thread, &attr, &CReaderWriter::ThreadFunctionWrapper, this)) { // LCOV_EXCL_BR_LINE 5:pthread cannot be passed because it cannot be turned mock // NOLINT[whitespace/line_length]
+ this->m_running = TRUE;
+ l_eStatus = eFrameworkunifiedStatusOK;
+ pthread_barrier_wait(&this->m_barrier); /* Wait for thread to take off*/
+ }
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %d", l_eStatus);
+ return (l_eStatus);
+}
+
+void* CReaderWriter::ThreadFunctionWrapper(void* param) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ CReaderWriter* l_pObj = reinterpret_cast<CReaderWriter *>(param);
+
+ l_pObj->ThreadFunction(l_pObj);
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. ThreadFunction has exited");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return NULL;
+}
+
+void CReaderWriter::ThreadFunction(CReaderWriter* l_pObj) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ int l_oldState;
+
+ pthread_setname_np(pthread_self(), this->m_readerName.c_str());
+ pthread_cleanup_push(&CReaderWriter::CleanupWrapper, this);
+ pthread_mutex_init(&m_writeMutex, NULL);
+ pthread_mutex_init(&m_pauseMutex, NULL);
+ int l_wait = pthread_barrier_wait(&m_barrier);
+
+ if ((eFrameworkunifiedStatusOK == l_eStatus)
+ // LCOV_EXCL_BR_START 5:pthread cannot be passed because it cannot be turned mock
+ && (((PTHREAD_BARRIER_SERIAL_THREAD == l_wait) || (0 == l_wait)))) {
+ // LCOV_EXCL_BR_STOP
+ UI_8 data[MAX_QUEUE_MSG_SIZE + 1];
+ while (TRUE) {
+ if (TRUE == this->m_paused) {
+ if (EOK == pthread_mutex_lock(&this->m_pauseMutex)) { // LCOV_EXCL_BR_LINE 5:pthread cannot be passed because it cannot be turned mock
+ (void)pthread_cond_wait(&m_condVariable, &m_pauseMutex); // LCOV_EXCL_BR_LINE 5:pthread cannot be passed because it cannot be turned mock
+ (void) pthread_mutex_unlock(&this->m_pauseMutex); // LCOV_EXCL_BR_LINE 5:pthread cannot be passed because it cannot be turned mock
+ }
+ }
+ if (!this->m_reader->IsOpen() || !this->m_writer->IsOpen()) { // LCOV_EXCL_BR_LINE 6:As it is not always open
+ (void)this->m_reader->Open(); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ (void)this->m_writer->Open(); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ }
+
+ if (!this->m_reader->IsOpen() || !this->m_writer->IsOpen()) {
+
+// ->Reduced frequency of accesses to IsOpen()
+ usleep(1000*1000); // LCOV_EXCL_BR_LINE 5:C function
+ } else {
+ while ((eFrameworkunifiedStatusOK == l_eStatus) && (FALSE == this->m_paused)) {
+ SI_32 l_bytesRead = -1;
+ SI_32 l_bytesWritten = -1;
+ l_eStatus = this->m_reader->Read(data,
+ MAX_QUEUE_MSG_SIZE,
+ l_bytesRead); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ pthread_setcancelstate(PTHREAD_CANCEL_DISABLE,
+ &l_oldState);
+ if (EOK == pthread_mutex_lock(&this->m_writeMutex)) { // LCOV_EXCL_BR_LINE 5: c code error case
+ l_eStatus = this->m_writer->Write(data,
+ (UI_32) l_bytesRead,
+ l_bytesWritten);
+ (void) pthread_mutex_unlock(&this->m_writeMutex);
+ }
+ pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,
+ &l_oldState);
+ }
+ }
+ l_eStatus = eFrameworkunifiedStatusOK; // Reset l_eStatus
+ }
+ }
+ }
+
+ pthread_cleanup_pop(1);
+}
+
+
+void CReaderWriter::CleanupWrapper(void* param) {
+ CReaderWriter* l_pObj = reinterpret_cast<CReaderWriter *>(param);
+
+ l_pObj->Cleanup(l_pObj);
+}
+
+void CReaderWriter::Cleanup(CReaderWriter* l_pObj) {
+
+// (void) pthread_mutex_unlock(&this->m_pauseMutex);
+// (void) pthread_mutex_unlock(&this->m_writeMutex);
+
+
+ if (this->m_reader != NULL) { // LCOV_EXCL_BR_LINE 5: new will aways sucess, so m_reader can not be null
+ delete (this->m_reader);
+ this->m_reader = NULL;
+ }
+ if (this->m_writer != NULL) { // LCOV_EXCL_BR_LINE 5: new will aways sucess, so m_writer can not be null
+ delete (this->m_writer);
+ this->m_writer = NULL;
+ }
+ this->m_running = FALSE;
+}
+
+EFrameworkunifiedStatus CReaderWriter::FlushCache(std::string f_filename) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ if (TRUE == this->m_pLoggerCfg->IsLoggingEnabled()) { // LCOV_EXCL_BR_LINE 6: it can not be false
+ if (EOK == pthread_mutex_lock(&this->m_writeMutex)) { // LCOV_EXCL_BR_LINE 5:pthread cannot be passed because it cannot be turned mock
+ if (this->m_writer != NULL) { // LCOV_EXCL_BR_LINE 5: new will aways sucess, so m_writer can not be null
+ l_eStatus = this->m_writer->FlushCache();
+ LOG_STATUS_IF_ERRORED(l_eStatus, "this->m_writer->FlushCache()")
+ }
+ (void) pthread_mutex_unlock(&this->m_writeMutex);
+ }
+
+ UI_32 l_written;
+ if (NULL != this->m_reader) { // LCOV_EXCL_BR_LINE 6:Because it depends on the startup process
+ l_eStatus = this->m_reader->ReadToFile(f_filename, l_written);
+ /*Don't output error, if function not implemented*/
+ l_eStatus =
+ (l_eStatus == eFrameworkunifiedStatusNotImplemented) ? eFrameworkunifiedStatusOK : l_eStatus;
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "this->m_reader->ReadToFile(f_filename, l_written)");
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CReaderWriter::UpdateLoggingParameters(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ if (EOK == pthread_mutex_lock(&this->m_writeMutex)) { // LCOV_EXCL_BR_LINE 5:pthread cannot be passed because it cannot be turned mock
+ if (this->m_writer != NULL) {
+ l_eStatus = this->m_writer->UpdateLoggingParameters();
+ }
+ (void) pthread_mutex_unlock(&this->m_writeMutex);
+ }
+ BOOL l_enabled = this->m_pLoggerCfg->IsLoggingEnabled();
+ if ((this->m_paused == FALSE) && (FALSE == l_enabled)) {
+ this->Pause();
+ } else if ((this->m_paused == TRUE) && (TRUE == l_enabled)) {
+ this->Resume();
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "- : %d", l_eStatus);
+ return (l_eStatus);
+}
+
+void CReaderWriter::Pause(void) {
+ (void) pthread_mutex_lock(&this->m_pauseMutex);
+ this->m_paused = TRUE;
+
+ (void) pthread_mutex_unlock(&this->m_pauseMutex);
+}
+
+void CReaderWriter::Resume(void) {
+ (void) pthread_mutex_lock(&this->m_pauseMutex);
+ if (this->m_reader != NULL) { // LCOV_EXCL_BR_LINE 5: new will aways sucess, so m_reader can not be null
+ (void) this->m_reader->ResetPosition();
+ }
+ pthread_cond_signal(&m_condVariable);
+ this->m_paused = FALSE;
+ (void) pthread_mutex_unlock(&this->m_pauseMutex);
+}
+} // namespace ReaderWriter
diff --git a/logger_service/server/src/ss_logger_cfg.cpp b/logger_service/server/src/ss_logger_cfg.cpp
new file mode 100644
index 00000000..6891792e
--- /dev/null
+++ b/logger_service/server/src/ss_logger_cfg.cpp
@@ -0,0 +1,707 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief Provide support for CPU high load monitor configuration.
+///
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// INCLUDES
+///////////////////////////////////////////////////////////////////////////////
+#include "ss_logger_cfg.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <dirent.h>
+#include <boost/bind.hpp>
+#include <native_service/nslogutil_cmd_if.h>
+#include <native_service/ns_np_service_protocol.h>
+#include <system_service/ss_logger_service_notifications.h>
+#include <iostream>
+#include <iomanip>
+#include <sstream>
+#include <string>
+#include <algorithm>
+#include <vector>
+
+const static UI_32 cMAX_EMMC_COUNTER_VALUE = 100000u; // NOLINT (build/storage_class)
+///////////////////////////////////////////////////////////////////////////////
+// CLASS METHODS
+///////////////////////////////////////////////////////////////////////////////
+
+CLoggerCfg::CLoggerCfg()
+noexcept :
+ m_logMaxFileSize(0),
+ m_performanceLogMaxFileSize(0),
+ m_emmcOutputMax(0),
+ m_emmcOutputErrMax(0),
+ m_emmcOutputGrpRelaunchMax(0),
+ m_emmcOutputNaviLogMax(0),
+ m_emmcOutputNaviLogNmlMax(0),
+ m_emmcOutputNaviLogErrMax(0),
+ m_emmcOutputPath(""),
+ m_emmcOutputNaviLogPath(""),
+ m_usb0MountPath(""),
+ m_usb1MountPath(""),
+ m_sdMountPath(""),
+ m_eDevType(eDevUSB1),
+ m_UserInvokedLoggingNumber(1u),
+ m_EmmcCounter(0u),
+ m_eLoggerUDPLoggingStatus(eDeactivate),
+ m_eLoggerStatus(SS_LOGGER_DEFAULT_VALUE) {
+ m_udpEnvFlag = FALSE;
+ std::memset(m_logMask, 0, sizeof(m_logMask));
+ }
+
+CLoggerCfg::~CLoggerCfg(void) { // LCOV_EXCL_START 14:global instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CLoggerCfg::Initialize(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ char* l_udp_env = getenv("UDPLOGS_ON");
+ m_udpEnvFlag = (
+ l_udp_env == NULL ?
+ FALSE : (strcmp("TRUE", l_udp_env) == 0 ? TRUE : FALSE));
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+EFrameworkunifiedStatus CLoggerCfg::SetandPersistLoggingParams(HANDLE f_hApp,
+ STLoggerSetAllParams f_Params,
+ BOOL f_InitCall) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ BOOL l_paramChanged = f_InitCall;
+ BOOL l_updateLoggerState = f_InitCall;
+
+ if ((TRUE == l_paramChanged) // LCOV_EXCL_BR_LINE 200:l_paramChanged is never TRUE
+ ||
+ (m_eLoggerStatus != f_Params.Logger_State)
+ || // LCOV_EXCL_BR_LINE 200:Because m_UserInvokedLoggingNumber != f_Params.Log_FolderCnt is never false
+ (m_UserInvokedLoggingNumber != f_Params.Log_FolderCnt)
+ || (m_eLoggerUDPLoggingStatus != f_Params.Logger_UDPState)
+ || (m_eDevType != f_Params.Device_Type)) {
+ l_paramChanged = TRUE;
+ } else {
+ l_paramChanged = FALSE;
+ }
+
+ l_updateLoggerState =
+ ((l_updateLoggerState == TRUE)
+ || (m_eLoggerStatus != f_Params.Logger_State)) ? TRUE : FALSE;
+
+ // After startup Logging will be set to default value
+ if (TRUE == f_InitCall) { // LCOV_EXCL_BR_LINE 200:f_InitCall is never TRUE
+ // LCOV_EXCL_START 200:f_InitCall is never TRUE
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ m_eLoggerStatus = SS_LOGGER_DEFAULT_VALUE;
+ // LCOV_EXCL_STOP
+ } else {
+ m_eLoggerStatus = f_Params.Logger_State;
+ }
+ m_eLoggerUDPLoggingStatus = f_Params.Logger_UDPState;
+ m_UserInvokedLoggingNumber = f_Params.Log_FolderCnt;
+ m_eDevType = f_Params.Device_Type;
+
+ if (TRUE == l_paramChanged) {
+ l_eStatus = PersistLoggingParam(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15: macro
+ "PersistLoggingParam()");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerCfg::SetLoggingParams(HANDLE f_hApp,
+ STLoggerSetParams f_stLoggerSetParams)
+ noexcept {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ STLoggerSetAllParams l_Params;
+
+ l_Params.Logger_UDPState = m_eLoggerUDPLoggingStatus;
+ l_Params.Log_FolderCnt = m_UserInvokedLoggingNumber;
+ l_Params.Logger_State = f_stLoggerSetParams.Logger_State;
+ l_Params.Device_Type = f_stLoggerSetParams.Device_Type;
+
+ l_eStatus = SetandPersistLoggingParams(f_hApp, l_Params, FALSE);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "SetandPersistLoggingParams()"); // LCOV_EXCL_BR_LINE 15: macro
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerCfg::SetUDPLogging(HANDLE f_hApp,
+ ELOGGER_STAT f_eUDPLoggingStatus) noexcept {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ STLoggerSetAllParams l_Params;
+
+ l_Params.Logger_UDPState = f_eUDPLoggingStatus;
+ l_Params.Log_FolderCnt = m_UserInvokedLoggingNumber;
+ l_Params.Logger_State = m_eLoggerStatus;
+ l_Params.Device_Type = m_eDevType;
+
+ l_eStatus = SetandPersistLoggingParams(f_hApp, l_Params, FALSE);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "SetandPersistLoggingParams()"); // LCOV_EXCL_BR_LINE 15: macro
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerCfg::PersistLoggingParam(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_INFO, __FUNCTION__,
+ "LoggerState = %d, Device_Type = %d,UDPLogging = %d, TriggerNumber = %d",
+ m_eLoggerStatus, m_eDevType, m_eLoggerUDPLoggingStatus,
+ m_UserInvokedLoggingNumber); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+
+ this->UpdateLoggingStatus();
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusOK;
+}
+
+void CLoggerCfg::RemoveCarriageReturn(std::string &f_str) {
+ if (f_str.empty()) { // LCOV_EXCL_BR_LINE 8: Because there is no empty string case
+ return;
+ }
+
+ if ('\r' == f_str.at(f_str.size() - 1)) {
+ f_str.erase(f_str.size() - 1, 1);
+ }
+}
+EFrameworkunifiedStatus CLoggerCfg::Load(const std::string &f_filePathAndName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusDbRecNotFound;
+
+ if ("" == f_filePathAndName) { // LCOV_EXCL_BR_LINE 200: Because there is no empty string case
+ // LCOV_EXCL_START 200: Because there is no empty string case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Invalid configuration file name detected.");
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ // LCOV_EXCL_STOP
+ } else {
+ // FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Reading Configuration Data from %s", f_filePathAndName.c_str());
+
+ CNSConfigReader *l_pReaderCfg = new CNSConfigReader(); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ if (NULL == l_pReaderCfg) { // LCOV_EXCL_BR_LINE 5:new error
+ // LCOV_EXCL_START 5:new error
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Unable to allocate CNSConfigReader object.");
+ l_eStatus = eFrameworkunifiedStatusFileLoadError;
+ // LCOV_EXCL_STOP
+ } else {
+ if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->Parse(f_filePathAndName))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. l_pReaderCfg->Parse(%s) returned: 0x%X",
+ f_filePathAndName.c_str(), l_eStatus);
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetInt("LOGGING.LogMaxFileSize", m_logMaxFileSize))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus, "l_pReaderCfg->GetInt(LOGGING.LogMaxFileSize)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetInt("LOGGING.PerformanceLogSize", m_performanceLogMaxFileSize))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus, "l_pReaderCfg->GetInt(LOGGING.LogMaxFileSize)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetString("LOGGING.EmmcOutputPath", m_emmcOutputPath))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus, "l_pReaderCfg->GetString(LOGGING.EmmcOutputPath)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetString("LOGGING.EmmcOutputNaviLogPath", m_emmcOutputNaviLogPath))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus,
+ "l_pReaderCfg->GetString(LOGGING.EmmcOutputNaviLogPath)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetString("LOGGING.Usb0MountPath", m_usb0MountPath))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus, "l_pReaderCfg->GetString(LOGGING.Usb0MountPath)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetString("LOGGING.Usb1MountPath", m_usb1MountPath))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus, "l_pReaderCfg->GetString(LOGGING.Usb1MountPath)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetString("LOGGING.SdMountPath", m_sdMountPath))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus, "l_pReaderCfg->GetString(LOGGING.SdMountPath)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetInt("LOGGING.EmmcOutputMax", m_emmcOutputMax))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus, "l_pReaderCfg->GetString(LOGGING.EmmcOutputMax)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetInt("LOGGING.EmmcOutputErrMax", m_emmcOutputErrMax))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus,
+ "l_pReaderCfg->GetString(LOGGING.EmmcOutputErrMax)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetInt("LOGGING.EmmcOutputGrpRelaunchMax", m_emmcOutputGrpRelaunchMax))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus,
+ "l_pReaderCfg->GetString(LOGGING.EmmcOutputGrpRelaunchMax)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetInt("LOGGING.EmmcOutputNaviLogMax", m_emmcOutputNaviLogMax))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus,
+ "l_pReaderCfg->GetString(LOGGING.EmmcOutputNaviLogMax)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetInt("LOGGING.EmmcOutputNaviLogNmlMax", m_emmcOutputNaviLogNmlMax))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus,
+ "l_pReaderCfg->GetString(LOGGING.EmmcOutputNaviLogNmlMax)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetInt("LOGGING.EmmcOutputNaviLogErrMax", m_emmcOutputNaviLogErrMax))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus,
+ "l_pReaderCfg->GetString(LOGGING.EmmcOutputNaviLogErrMax)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetString("STORAGE.ThreadName", m_loggerStorageInfo.Name))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus, "l_pReaderCfg->GetString(STORAGE.ThreadName)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetInt("STORAGE.Priority", m_loggerStorageInfo.Priority))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus, "l_pReaderCfg->GetInt(STORAGE.Priority)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetInt("STORAGE.Timeout", m_loggerStorageInfo.Timeout))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus, "l_pReaderCfg->GetInt(STORAGE.Timeout)");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetInt("STORAGE.TimeoutAfter", m_loggerStorageInfo.TimeoutAfter))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_STATUS(l_eStatus, "l_pReaderCfg->GetInt(STORAGE.TimeoutAfter)");
+ // LCOV_EXCL_STOP
+ } else {
+ RemoveCarriageReturn(m_emmcOutputPath);
+ RemoveCarriageReturn(m_emmcOutputNaviLogPath);
+ RemoveCarriageReturn(m_usb0MountPath);
+ RemoveCarriageReturn(m_usb1MountPath);
+ RemoveCarriageReturn(m_sdMountPath);
+ RemoveCarriageReturn(m_loggerStorageInfo.Name);
+
+ for (UI_32 i = 0; i < ZONE_MASK_ARRAY_ELTS; i++) {
+ SI_32 l_logMaskTemp;
+ std::stringstream l_cfgParamName;
+
+ l_cfgParamName << "SETLOGMASK.MASK" << i;
+ if (eFrameworkunifiedStatusOK != (l_eStatus = l_pReaderCfg->GetInt(l_cfgParamName.str(), l_logMaskTemp))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. l_pReaderCfg->GetInt(%s) failed with error: %d.",
+ l_cfgParamName.str().c_str(), l_eStatus);
+
+ break;
+ // LCOV_EXCL_STOP
+ } else {
+ m_logMask[i] = (UI_32) l_logMaskTemp;
+ }
+ }
+
+ m_EELStorageRelPath = "/EEL_export";
+ m_EELActivateRelPath = "/EEL_activate";
+ m_LoggerserviceEmmcLogsRelPath = "/LOGGERSERVICE_EMMC_LOGS";
+
+ if (eFrameworkunifiedStatusOK == l_eStatus) { // LCOV_EXCL_BR_LINE 200:To ensure success
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Info. Configuration successfully loaded."); // LCOV_EXCL_BR_LINE 15: macro
+ }
+ }
+
+ delete l_pReaderCfg; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerCfg::Validate(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldParam;
+
+ if (m_logMaxFileSize == 0) { // LCOV_EXCL_BR_LINE 200:Because the size is never 0
+ // LCOV_EXCL_START 200:Because the size is never 0
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. Invalid configuration detected. LogMaxFileSize: %d Must be > 0.",
+ m_logMaxFileSize);
+ // LCOV_EXCL_STOP
+ } else if (m_emmcOutputPath == "") {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. Invalid configuration detected."
+ " EmmcOutputPath: %s Must be a valid path containing a trailing backslash.",
+ m_emmcOutputPath.c_str());
+ } else if (m_emmcOutputNaviLogPath == "") { // LCOV_EXCL_BR_LINE 200:Because it is not always an empty string
+ // LCOV_EXCL_START 200:Because it is not always an empty string
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. Invalid configuration detected."
+ " EmmcOutputNaviLogPath: %s Must be a valid path containing a trailing backslash.",
+ m_emmcOutputNaviLogPath.c_str());
+ // LCOV_EXCL_STOP
+ } else if (m_usb0MountPath == "") { // LCOV_EXCL_BR_LINE 200:Because it is not always an empty string
+ // LCOV_EXCL_START 200:Because it is not always an empty string
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. Invalid configuration detected."
+ " Usb0MountPath: %s Must be a valid path containing a trailing backslash.",
+ m_usb0MountPath.c_str());
+ // LCOV_EXCL_STOP
+ } else if (m_usb1MountPath == "") { // LCOV_EXCL_BR_LINE 200:Because it is not always an empty string
+ // LCOV_EXCL_START 200:Because it is not always an empty string
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. Invalid configuration detected."
+ " Usb1MountPath: %s Must be a valid path containing a trailing backslash.",
+ m_usb1MountPath.c_str());
+ // LCOV_EXCL_STOP
+ } else if (m_sdMountPath == "") { // LCOV_EXCL_BR_LINE 200:Because it is not always an empty string
+ // LCOV_EXCL_START 200:Because it is not always an empty string
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. Invalid configuration detected. SdMountPath: %s Must be a valid path containing a trailing backslash.",
+ m_sdMountPath.c_str());
+ // LCOV_EXCL_STOP
+ } else {
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+void CLoggerCfg::Print(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+std::string CLoggerCfg::getEmmcOutputPath(void) {
+ return (m_emmcOutputPath);
+}
+
+std::string CLoggerCfg::getEmmcOutputNaviLogPath(void) {
+ return (m_emmcOutputNaviLogPath);
+}
+
+std::string CLoggerCfg::getUsb0MountPath(void) {
+ return (m_usb0MountPath);
+}
+void CLoggerCfg::setUsb0MountPath(std::string& f_deviceMountpath) {
+ m_usb0MountPath = f_deviceMountpath;
+}
+
+EFrameworkunifiedStatus CLoggerCfg::GetUserInvokedDestination(std::string& f_dest) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ f_dest = "";
+ switch (m_eDevType) {
+ case eDevUSB1:
+ f_dest = m_usb0MountPath;
+ break;
+
+ case eDevUSB2:
+ f_dest = m_usb1MountPath;
+ break;
+
+ case eDevSD:
+ f_dest = m_sdMountPath;
+ break;
+
+ case eTotalDevicesTypes:
+ case eInvalid_DevType:
+ default:
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Unknown device type: %d",
+ m_eDevType);
+ l_eStatus = eFrameworkunifiedStatusFail;
+ break;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerCfg::GetEmmcDestination(std::string& f_dest) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ f_dest = m_emmcOutputPath;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerCfg::GetEmmcNaviLogDestination(std::string& f_dest) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ f_dest = m_emmcOutputNaviLogPath;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+UI_32 CLoggerCfg::GetUserInvokedCounter(void) {
+ return m_UserInvokedLoggingNumber;
+}
+
+EFrameworkunifiedStatus CLoggerCfg::GetIncrementAndPersistUserInvokedCounter(
+ HANDLE f_hApp, UI_32 &f_counter) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ f_counter = m_UserInvokedLoggingNumber;
+ m_UserInvokedLoggingNumber++;
+ l_eStatus = PersistLoggingParam(f_hApp);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerCfg::GetAndIncrementEmmcCounter(UI_32 &f_counter) noexcept {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ std::string l_checkFileName;
+ std::vector<UI_32> l_vector;
+ DIR *l_dirp;
+ struct dirent l_dirent;
+ struct dirent* next = NULL;
+ size_t l_pos;
+ UI_32 l_count;
+ UI_32 l_maxCount;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ if (m_EmmcCounter == 0u) {
+ l_maxCount = 0;
+ l_dirp = opendir(m_emmcOutputPath.c_str());
+ if (l_dirp != NULL) { // LCOV_EXCL_BR_LINE 5: m_emmcOutputPath is not null, opendir is C code, always ok
+ for (;;) {
+ int l_ret = readdir_r(l_dirp, &l_dirent, &next);
+ if (((l_ret == 0) && (next == NULL))
+ || (l_ret > 0)) {
+ break;
+ }
+ l_checkFileName = l_dirent.d_name;
+ l_pos = l_checkFileName.find(".tar.gz");
+ if (std::string::npos != l_pos) {
+ l_pos = l_checkFileName.find("_");
+ if (std::string::npos != l_pos) { // LCOV_EXCL_BR_LINE 200: tar.gz file is aways has "_"
+ std::string l_numberString = l_checkFileName.substr(0, l_pos);
+ l_count = static_cast<UI_32>(strtoul(l_numberString.c_str(), NULL, 10));
+ l_vector.push_back(l_count);
+ l_maxCount = std::max(l_count, l_maxCount);
+ }
+ }
+ }
+ closedir(l_dirp);
+ } else {
+ // LCOV_EXCL_START 5: m_emmcOutputPath is not null, opendir is C code, always ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ f_counter = 1;
+ return eFrameworkunifiedStatusOK;
+ // LCOV_EXCL_STOP
+ }
+
+ // reach at max number
+ if (l_maxCount >= LOGGERSERVICELOG_EMMC_COUNTER_MAX) {
+ RefreshEmmcCounter(m_EmmcCounter);
+ } else {
+ m_EmmcCounter = l_maxCount + 1;
+ }
+ } else if (m_EmmcCounter >= LOGGERSERVICELOG_EMMC_COUNTER_MAX) {
+ // reach at max number
+ RefreshEmmcCounter(m_EmmcCounter);
+ } else {
+ m_EmmcCounter++;
+ }
+
+ f_counter = m_EmmcCounter;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerCfg::RefreshEmmcCounter(UI_32& f_counter) noexcept {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ std::string l_checkFileName;
+ std::vector<std::string> l_vector;
+ DIR *l_dirp;
+ struct dirent l_dirent;
+ struct dirent* next = NULL;
+ size_t l_pos;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ // get filename saved frameworkunifiedlog on eMMC Device
+ l_dirp = opendir(m_emmcOutputPath.c_str());
+ if (l_dirp != NULL) { // LCOV_EXCL_BR_LINE 5: m_emmcOutputPath is not null, opendir is C code, always ok
+ for (;;) {
+ int l_ret = readdir_r(l_dirp, &l_dirent, &next);
+ if (((l_ret == 0) && (next == NULL)) || (l_ret > 0)) {
+ break;
+ }
+ l_checkFileName = l_dirent.d_name;
+ l_pos = l_checkFileName.find(".tar.gz");
+ if (std::string::npos != l_pos) {
+ l_pos = l_checkFileName.find("_");
+ if (std::string::npos != l_pos) {
+ l_vector.push_back(l_checkFileName);
+ }
+ }
+ }
+ closedir(l_dirp);
+ } else {
+ // LCOV_EXCL_START 5: m_emmcOutputPath is not null, opendir is C code, always ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // ignore opendir failure. this means saved frameworkunifiedlog is nothing on eMMC Device
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "open dir error path=%s errno=%s.",
+ m_emmcOutputPath.c_str(), strerror(errno));
+ f_counter = 1;
+ return eFrameworkunifiedStatusOK;
+ // LCOV_EXCL_STOP
+ }
+
+ // sort at log count
+ std::sort(l_vector.begin(), l_vector.end());
+
+ std::vector<std::string>::iterator it;
+ std::string l_orgFilePath;
+ std::string l_renameFilePath;
+ UI_32 l_wpt = 0;
+ UI_32 l_count;
+
+ it = l_vector.begin();
+ while (it != l_vector.end()) {
+ std::stringstream l_nameStream;
+ // get log counter parts
+ l_wpt++;
+ l_checkFileName = *it;
+ l_pos = l_checkFileName.find("_");
+ std::string l_numberString = l_checkFileName.substr(0, l_pos);
+ l_count = static_cast<UI_32>(strtoul(l_numberString.c_str(), NULL, 10));
+
+ // rename file if necessary
+ if (l_count != l_wpt) {
+ l_renameFilePath = l_orgFilePath = m_emmcOutputPath.c_str();
+ l_renameFilePath.append("/");
+ l_orgFilePath.append("/");
+ l_orgFilePath.append(l_checkFileName);
+
+ l_nameStream << std::setw(5) << std::setfill('0') << std::right
+ << std::dec << l_wpt;
+ l_checkFileName.replace(0, l_pos, l_nameStream.str());
+
+ l_renameFilePath.append(l_checkFileName);
+
+ if (rename(l_orgFilePath.c_str(), l_renameFilePath.c_str()) != 0) { // LCOV_EXCL_BR_LINE 5: rename is C code
+ // LCOV_EXCL_START 5: rename is C code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // rename failed but continue reamin log rename because new log need to be saved.
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "log file[%s]->[%s] rename failed: err=%s.",
+ l_orgFilePath.c_str(), l_renameFilePath.c_str(), strerror(errno));
+ // LCOV_EXCL_STOP
+ }
+ }
+ it++;
+ }
+
+ f_counter = l_wpt + 1;
+
+ // set return value as next log counter
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+BOOL CLoggerCfg::IsUDPLoggingEnabled(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ BOOL l_ret =
+ ((this->m_eLoggerUDPLoggingStatus == eActivate)
+ || (this->m_udpEnvFlag == TRUE)) ? TRUE : FALSE;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "- : %s", (TRUE == l_ret)?"TRUE":"FALSE");
+ return (l_ret);
+}
+
+void CLoggerCfg::AddLoggingParamCB(CbFuncPtr f_fp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ if (f_fp != NULL) { // LCOV_EXCL_BR_LINE 6: it aways not be null
+ this->m_LoggingCallBack.push_back(f_fp);
+ (void) f_fp(NULL);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+void CLoggerCfg::UpdateLoggingStatus(void) noexcept {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ std::vector<CbFuncPtr>::iterator l_iter;
+ for (l_iter = m_LoggingCallBack.begin(); l_iter != m_LoggingCallBack.end(); l_iter++) { // LCOV_EXCL_BR_LINE 11:Unexpected branch // NOLINT[whitespace/line_length]
+ (void) (*l_iter)(NULL);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+EFrameworkunifiedStatus CLoggerCfg::GetLoggerStorageInfo(SLoggerStorageInfo &f_info) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ f_info = m_loggerStorageInfo;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+BOOL CLoggerCfg::IsLoggingEnabled(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ return (this->m_eLoggerStatus == eActivate) ? TRUE : FALSE;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
diff --git a/logger_service/server/src/ss_logger_device_detection.cpp b/logger_service/server/src/ss_logger_device_detection.cpp
new file mode 100644
index 00000000..8fbc5547
--- /dev/null
+++ b/logger_service/server/src/ss_logger_device_detection.cpp
@@ -0,0 +1,209 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_NS_InterfaceunifiedLogCapture
+/// \brief This file supports USB logging threads.
+///
+///////////////////////////////////////////////////////////////////////////////
+
+// System Headers
+#include <errno.h>
+#include <stdio.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#ifdef AGL_STUB
+#else
+#include <sys/usbdi.h>
+#endif
+#include <limits.h>
+#include <string.h>
+#include <native_service/ns_message_center_if.h>
+#include <ss_logger_fs_directory.h>
+#include <boost/bind.hpp>
+
+// Pasa Logs
+#include <loggerservicedebug_loggerservicelog.h>
+#include <ss_logger_device_detection.h>
+#include <loggerservicedebug_thread_if.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <system_service/ss_logger_service.h>
+#include <system_service/ss_devicedetection_service_notifications.h>
+#include <system_service/ss_devicedetection_service_ifc.h>
+#include <system_service/ss_sm_client_if.h>
+#include <string>
+#include "ss_logger_common.h"
+
+//
+const SI_32 INVALID_FD = -1;
+
+// Max command line length
+const UI_32 MAX_SYS_CMD_LN_LENGTH = 120;
+
+CLoggerDeviceDetection::CLoggerDeviceDetection() :
+ m_pLoggerCfg(NULL),
+ m_loggerUtil(NULL) {
+}
+
+CLoggerDeviceDetection::~CLoggerDeviceDetection() { // LCOV_EXCL_START 14:global instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CLoggerDeviceDetection::Initialize(HANDLE f_hApp, CLoggerCfg * f_pLoggerCfg) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ m_pLoggerCfg = f_pLoggerCfg;
+ // Device Detection Obj initialization
+ if (m_devDetect.Initialize(f_hApp)) { // LCOV_EXCL_BR_LINE 200:To ensure success
+ if (eFrameworkunifiedStatusOK != (l_eStatus = m_devDetect.NotifyOnDeviceDetectionAvailability(
+ boost::bind(&CLoggerDeviceDetection::DD_ServiceAvailabilityCallBack, this, _1) ))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "ServiceAvailabilityCallback registration failed");
+ }
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = m_devDetect.NotifyOnOpenSessionAck(
+ boost::bind(&CLoggerDeviceDetection::DD_OpenSessionAckCallBack, this, _1) ))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "OpenSessionAckCallback registration failed");
+ }
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = m_devDetect.NotifyOnCloseSessionAck(
+ boost::bind(&CLoggerDeviceDetection::DD_CloseSessionAckCallBack, this, _1) ))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "CloseSessionCallback registration failed");
+ }
+ } else {
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Device Detection Object Initialization failed!");
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+//////////////////////////////////////////
+// Function : ServiceAvailabilityCallBack
+//////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerDeviceDetection::DD_ServiceAvailabilityCallBack(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (FrameworkunifiedIsServiceAvailable(hApp)) {
+ if (eFrameworkunifiedStatusOK != (eStatus = m_devDetect.OpenSessionRequest())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Open session request failed");
+ }
+ } else {
+ if (eFrameworkunifiedStatusOK != (eStatus = m_devDetect.CloseSessionRequest())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Close session request failed");
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+//////////////////////////////////////////
+// Function : OpenSessionAckCallBack
+//////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerDeviceDetection::DD_OpenSessionAckCallBack(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (eFrameworkunifiedStatusOK == (eStatus = m_devDetect.DecodeOpenSessionResponse())) {
+ if (eFrameworkunifiedStatusOK != (eStatus = m_devDetect.RegisterForDeviceDetectionEvent(SS_DEV_DETECT_ANY_USB_EV,
+ boost::bind(&CLoggerDeviceDetection::DD_MediaDetectCallBack, this, _1)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Registration for SS_DEV_DETECT_ANY_USB_EV failed");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Decode open session response failed");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+//////////////////////////////////////////
+// Function : OpenSessionAckCallBack
+//////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerDeviceDetection::DD_CloseSessionAckCallBack(HANDLE hApp) { // LCOV_EXCL_START 200: can not called from devicedetection_service // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ CloseSessionAck tCloseSessionAck;
+
+ if (hApp) {
+ if (eFrameworkunifiedStatusOK == (eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &tCloseSessionAck, sizeof (tCloseSessionAck)))) {
+ if (eFrameworkunifiedStatusOK == tCloseSessionAck.eStatus) {
+ UI_32 l_uiSessionId = tCloseSessionAck.sessionId;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "session %d closed successfully", l_uiSessionId);
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CLoggerDeviceDetection::DD_CloseSessionWithDevDetectionSrv(HANDLE hApp) { // LCOV_EXCL_START 200: can not called from devicedetection_service // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ if (eFrameworkunifiedStatusOK == (eStatus = m_devDetect.
+ NotifyOnCloseSessionAck(boost::bind(&CLoggerDeviceDetection::DD_CloseSessionAckCallBack, this, _1)))) {
+ if (eFrameworkunifiedStatusOK != (eStatus = m_devDetect.CloseSessionRequest())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to send CloseSessionRequest");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Failed to register closeSessionAckCallback");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CLoggerDeviceDetection::DD_MediaDetectCallBack(HANDLE hApp) { // LCOV_EXCL_START 200: can not called from devicedetection_service // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ std::string l_devstr;
+ std::string l_filePathStr;
+ SS_MediaDetectInfo l_tMediaDetectInfo;
+
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &l_tMediaDetectInfo, sizeof (l_tMediaDetectInfo)))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "FrameworkunifiedGetMsgDataOfSize Failed Status:0x%x ", l_eStatus);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Device = %d", l_tMediaDetectInfo.dev_type);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Availability = %d", l_tMediaDetectInfo.bIsDeviceAvailable);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " device path = %s", l_tMediaDetectInfo.deviceMountpath);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " File path = %s", l_tMediaDetectInfo.filepathName);
+
+ if (l_tMediaDetectInfo.dev_type == eUSB) {
+ if (l_tMediaDetectInfo.bIsDeviceAvailable == TRUE && m_pLoggerCfg != NULL) {
+ std::string l_usbMountPath;
+ l_usbMountPath = l_tMediaDetectInfo.deviceMountpath;
+ m_pLoggerCfg->setUsb0MountPath(l_usbMountPath);
+ m_loggerUtil->SetUsbMountPath(l_usbMountPath);
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
diff --git a/logger_service/server/src/ss_logger_error_event.cpp b/logger_service/server/src/ss_logger_error_event.cpp
new file mode 100644
index 00000000..935e284a
--- /dev/null
+++ b/logger_service/server/src/ss_logger_error_event.cpp
@@ -0,0 +1,1047 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief This file supports error event logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "ss_logger_error_event.h"
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <boost/bind.hpp>
+#include <unistd.h>
+#include <sys/wait.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <system_service/ss_sm_client_if.h>
+#include <system_service/ss_client_names.h>
+#include <system_service/ss_logger_service_protocol.h>
+#include <system_service/ss_logger_service.h>
+#include <system_service/ss_services.h>
+#include <system_service/ss_templates.h>
+//#include <stub/el_mem.h>
+#include <native_service/cl_process.h>
+//#include <vehicle_service/Clock_API.h>
+#include <string>
+#include "loggerservicedebug_loggerservicelog.h"
+#include "loggerservicedebug_thread_if.h"
+#include "ss_logger_service_callbacks.h"
+#include "ss_logger_error_event_archive.h"
+#include "ss_logger_common.h"
+#include "ss_logger_types.h"
+#include "ss_logger_fs_directory.h"
+
+CErrorEvent::CErrorEvent()
+ : m_hApp(NULL),
+ m_bIsPrevEventCompleted(true),
+ m_errorEventNtfData(),
+ m_pLoggerCfg(NULL),
+ m_pReaderWriterControl(NULL),
+ m_ServiceName(""),
+ m_time(0),
+ m_currentEventTriggerNumber(0),
+ m_diagsessionhandle(NULL),
+ m_thrdEvntLogWriter(NULL),
+ m_sfd(-1) { // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+} // LCOV_EXCL_BR_LINE 11:Unexpected branch
+
+CErrorEvent::~CErrorEvent() { // LCOV_EXCL_START 14:globle instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CErrorEvent::Initialize(HANDLE f_hApp, CLoggerCfg *f_pLoggerCfg,
+ CReaderWriterControl *f_pReaderWriterControl,
+ HANDLE f_thrdEvntLogWriter,
+ std::string f_strEvntLogQueWorkerName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ Timer *l_pTimer;
+
+ m_sfd = CL_ProcessInit();
+ if (m_sfd == -1) { // LCOV_EXCL_BR_LINE 8:Because the process initialization is guaranteed to be successful
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. m_sfd CL_ProcessInit() failed \n."); // LCOV_EXCL_LINE 8:Because the process initialization is guaranteed to be successful
+ }
+
+ SS_LoggerServerEvents l_errorEventStateEvents[] = {
+ SS_LOGGER_SCREENCAPTURE_EVT };
+
+ FrameworkunifiedProtocolCallbackHandler l_smCallbacks[] = {
+ // Logging Protocol Callbacks
+ { SS_SM_EVENT_ERROR_TO_SSL, boost::bind(&CErrorEvent::OnStartLogging,
+ this, _1) }, {
+ SS_SM_ERROR_EVENT_LOGGING_START_RSPN, boost::bind(
+ &CErrorEvent::OnLogStartResponse, this, _1) }, {
+ SS_SM_ERROR_EVENT_ARTIFACT_RSPN, boost::bind(
+ &CErrorEvent::OnArtifactResponse, this, _1) } }; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+
+ FrameworkunifiedProtocolCallbackHandler l_selfCallbacks[] = {
+ // Logging Protocol Callbacks
+ { SS_LOGGER_ERROR_EVENT_ARTIFACT_REQ, boost::bind(
+ &CErrorEvent::OnArtifactRequest, this, _1) }, {
+ SS_SM_ERROR_EVENT_ARTIFACT_RSPN, boost::bind(
+ &CErrorEvent::OnArtifactResponse, this, _1) } }; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+
+ FrameworkunifiedProtocolCallbackHandler l_requesterCallbacks[] = { {
+ SS_LOGGER_SCREENCAPTURE_EVT_ACK, boost::bind(
+ &CErrorEvent::OnObtainScreenShotResponse, this, _1) } }; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+
+ FrameworkunifiedProtocolCallbackHandler l_storageThreadCallbacks[] = { {
+ eLoggerStorageThreadCmdOK, boost::bind(&CErrorEvent::OnStorageResponseOk,
+ this, _1) }, {
+ eLoggerStorageThreadCmdWriteFailed, boost::bind(
+ &CErrorEvent::OnStorageResponseWriteFailed, this, _1) }, {
+ eLoggerStorageThreadCmdNotFound, boost::bind(
+ &CErrorEvent::OnStorageResponseNotFound, this, _1) }, {
+ eLoggerStorageThreadCmdNoWritten, boost::bind(
+ &CErrorEvent::OnStorageResponseNoWritten, this, _1) } }; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ for (UI_32 i = 0; i < _countof(l_requesterCallbacks); i++) {
+ m_requesterCallbacksVec.push_back(l_requesterCallbacks[i]); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ }
+
+ if (NULL == f_hApp) { // LCOV_EXCL_BR_LINE 6:As it is not always NULL
+ // LCOV_EXCL_START 6:As it is not always NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR, __FUNCTION__,
+ " Error. Argument f_hApp passed NULL pointer. Initialization failed.");
+ // LCOV_EXCL_STOP
+ } else if (NULL == (m_thrdEvntLogWriter = f_thrdEvntLogWriter)) { // LCOV_EXCL_BR_LINE 6:As it is not always NULL
+ // LCOV_EXCL_START 6:As it is not always NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR, __FUNCTION__,
+ " Error. Argument f_hApp passed NULL pointer. Initialization failed.");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = m_errorEventCfg.Initialize())) { // LCOV_EXCL_BR_LINE 200:To ensure success
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. m_errorEventCfg.Initialize() returned: %d.", l_eStatus);
+ // LCOV_EXCL_STOP
+ } 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]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. FrameworkunifiedAttachCallbacksToDispatcher(SERVICE_SYSMANAGER) returned: %d.",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ } 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]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. FrameworkunifiedAttachCallbacksToDispatcher(SERVICE_SYSMANAGER) returned: %d.",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ } 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]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. FrameworkunifiedDefineStateEvents(SS_LOGGER_SCREENCAPTURE_EVT) returned: %d",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ } else if (NULL == f_pLoggerCfg) { // LCOV_EXCL_BR_LINE 200:As it is not always NULL
+ // LCOV_EXCL_START 200:As it is not always NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. f_pLoggerCfg passed NULL pointer.");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = m_loggerPopups.Initialize(f_pLoggerCfg))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. m_loggerPopups.Initialize(f_pLoggerCfg) returned: %d.",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ } else if (NULL == f_pReaderWriterControl) { // LCOV_EXCL_BR_LINE 200:As it is not always NULL
+ // LCOV_EXCL_START 200:As it is not always NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Argument f_pReaderWriterControl passed NULL pointer.");
+ // LCOV_EXCL_STOP
+ } 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]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. m_loggerPopups.Initialize(f_pLoggerCfg) returned: %d.",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ } 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]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. FrameworkunifiedAttachCallbacksToDispatcher(ERROR_EVENT_STORAGE_QUEUE_NAME) returned: %d.",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = m_loggerCanEvent.Initialize(f_pLoggerCfg))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. m_loggerCanEvent.Initialize() returned: %d.", l_eStatus);
+ // LCOV_EXCL_STOP
+ } else {
+ m_hApp = f_hApp;
+ m_pLoggerCfg = f_pLoggerCfg;
+ m_pReaderWriterControl = f_pReaderWriterControl;
+ l_eStatus = m_loggerUtil.Initialize(m_pLoggerCfg); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ LOG_STATUS_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 5:macro
+ "CLoggerUtil::m_loggerUtil.Initialize(m_pLoggerCfg)");
+
+ l_pTimer = &m_errorEventTimers[kSSL_ERROR_EVENT_TIMER_LOGGING_START_RSPN];
+ l_pTimer->Initialize(
+ f_hApp, SS_LOGGER_ERROR_EVENT_TIMER_ID_LOGGING_START_RSPN,
+ boost::bind(&CErrorEvent::OnLogStartResponseTimeout, this, _1)); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+
+ l_pTimer = &m_errorEventTimers[kSSL_ERROR_EVENT_TIMER_ARTIFACT_RSPN];
+ l_pTimer->Initialize(
+ f_hApp, SS_LOGGER_ERROR_EVENT_TIMER_ID_ARTIFACT_RESPONSE,
+ boost::bind(&CErrorEvent::OnArtifactResponseTimeout, this, _1)); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ m_ServiceName = "";
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : RegisterSessionErrorEvent
+// brief : Register session event. This function is called within the
+// context of the System Manager session acknowledgment handler.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::RegisterSessionErrorEvent(HANDLE f_hSession) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ l_eStatus = FrameworkunifiedRegisterEvent(f_hSession, SS_SM_EVENT_ERROR_TO_SSL);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedRegisterEvent(SS_SM_EVENT_ERROR_TO_SSL)"); // LCOV_EXCL_BR_LINE 5:macro
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnOpenSession
+// brief : Called when a requester opens a session with SS_Logger
+// service. This function attaches error event callbacks
+// to the dispatcher with the source set to the requester.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnOpenSession(HANDLE f_hApp, PCSTR f_pRequesterName,
+ HANDLE f_hSession) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher(f_hApp, f_pRequesterName,
+ &m_requesterCallbacksVec[0],
+ static_cast<UI_32>(m_requesterCallbacksVec.size()),
+ f_hSession);
+
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedAttachCallbacksToDispatcher(f_hSession)"); // LCOV_EXCL_BR_LINE 5:macro
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnOpenSession
+// brief : Called when a requester opens a session with SS_Logger
+// service. This function attaches error event callbacks
+// to the dispatcher with the source set to the requester.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnCloseSession(HANDLE f_hApp, PCSTR f_pRequesterName,
+ HANDLE f_hSession) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_32 l_cmdIdArr[m_requesterCallbacksVec.size()]; // NOLINT (runtime/arrays)
+
+ for (UI_32 i = 0; i < m_requesterCallbacksVec.size(); i++) {
+ l_cmdIdArr[i] = m_requesterCallbacksVec[i].iCmd;
+ }
+
+ l_eStatus = FrameworkunifiedDetachCallbacksFromDispatcher(f_hApp, f_pRequesterName,
+ l_cmdIdArr,
+ static_cast<UI_32>(m_requesterCallbacksVec.size()),
+ f_hSession);
+
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedAttachCallbacksToDispatcher()"); // LCOV_EXCL_BR_LINE 5:macro
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnStartLogging
+// brief : Called by SS_Logger and external services to begin logging
+// artifact collection. This function sends a logging request
+// to System Manager. See SS_SM_EVENT_ERROR_TO_SSL.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnStartLogging(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ SMErrorEventNtfData l_eventErrorNtfData;
+
+ INTERFACEUNIFIEDLOG_RECEIVED_FROM(f_hApp); // LCOV_EXCL_BR_LINE 5:macro
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<SMErrorEventNtfData>(f_hApp, l_eventErrorNtfData))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // when failed to ReadMsg, we can't know event-type for action, so nothing is able to do.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_LINE 200:To ensure success
+ } else {
+ if (TRUE == this->m_pLoggerCfg->IsLoggingEnabled()) { // LCOV_EXCL_BR_LINE 200:As it is always TRUE
+ if (TRUE == m_bIsPrevEventCompleted) {
+ TLoggerErrorEvent l_eventData = l_eventErrorNtfData;
+
+ if (IsNeedVerify(l_eventData.EventType)) {
+ // if need output log to external storage, check whether device is authenticated or not.
+ VerifyExtStorage(l_eventData);
+ }
+
+ uint8_t status;
+// Clock_getSystemTimeY2K38(&m_time, &status);
+ m_currentEventTriggerNumber = m_pLoggerCfg->GetUserInvokedCounter();
+ l_eStatus = m_loggerUtil.checkDestinationAvailable(l_eventData);
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ m_bIsPrevEventCompleted = false; /* See timer start / timeout handler below. */
+
+ m_artifactResponseVec.clear();
+
+ m_errorEventNtfData = l_eventErrorNtfData; /* Overwrite m_eventErrorNtfData when logging complete. */
+ m_errorEventNtfData.EventBitMask = m_errorEventCfg
+ .GetEventsForErrorEvent(l_eventErrorNtfData.EventType);
+ l_eStatus = SendLogStartRequestToSystemManager(
+ m_errorEventNtfData.EventType);
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "SendLogStartRequestToSystemManager()");
+ l_eStatus = m_loggerCanEvent.PublishStartEvent(f_hApp,
+ m_errorEventNtfData);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "m_loggerCanEvent.PublishStartEvent(f_hApp,m_errorEventNtfData);");
+
+ bool result =
+ m_errorEventTimers[kSSL_ERROR_EVENT_TIMER_LOGGING_START_RSPN]
+ .Start(m_loggingStartRspnToSec, 0, 0, 0);
+ if (FALSE == result) { // LCOV_EXCL_BR_LINE 200:As it is always TRUE
+ // LCOV_EXCL_START 200:As it is always TRUE
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. Failed to start timer kSSL_ERROR_EVENT_TIMER_LOGGING_START_RSPN.");
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Warning. Destination not available. ");
+ m_errorEventNtfData = l_eventErrorNtfData; /* Overwrite m_eventErrorNtfData when logging complete. */
+ m_errorEventNtfData.EventBitMask = m_errorEventCfg
+ .GetEventsForErrorEvent(l_eventErrorNtfData.EventType);
+ l_eStatus = OnStorageResponseNotFound(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "OnStorageResponseNotFound(f_hApp)");
+ }
+ } else {
+ // Not-Need Resp to SM, because of keep logging sequance.
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Logging already in progress. Event dropped.");
+ }
+ } else {
+ // LCOV_EXCL_START 200:As it is always TRUE
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (l_eventErrorNtfData.isNeedReboot == TRUE) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "System will reboot soon, so stop logging function.");
+ StopLoggingFunction(f_hApp);
+ }
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_INFO,
+ __FUNCTION__,
+ "Logging is disabled! Dropping Event. Sending Complete to SS_SystemManager");
+ l_eStatus = SendLogCompleteRequestToSystemManager(eFrameworkunifiedStatusFail);
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "SendLogCompleteRequestToSystemManager()");
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnLogStartResponse
+// brief : Called by System Manager after the acknowledgment of the
+// logging session start request. This function starts the
+// artifact collection process. See
+// SS_SM_ERROR_EVENT_LOGGING_START_RSPN.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnLogStartResponse(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ m_errorEventTimers[kSSL_ERROR_EVENT_TIMER_LOGGING_START_RSPN].Stop();
+ m_errorEventCfg.GetArtifactRequestVec(m_errorEventNtfData.EventType,
+ m_artifactRequestVec);
+
+ l_eStatus = RequestNextArtifact(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "RequestNextArtifact()");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnLogStartResponseTimeout
+// brief : Called when / if SM fails to respond to a logging start
+// request and the logging star response timer expires.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnLogStartResponseTimeout(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. SM failed to respond to a logging start request in the required amount of time.");
+
+ m_bIsPrevEventCompleted = TRUE;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : RequestNextArtifact
+// brief : This function requests the next artifact from the service
+// that owns the artifact. If no artifacts remain, this
+// function performs initiates artifact post processing.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::RequestNextArtifact(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_32 l_timeoutSec;
+ UI_32 l_timeoutMs;
+
+ if (0 != m_artifactRequestVec.size()) {
+ TLoggingArtifact &l_nextArtifact = m_artifactRequestVec.back();
+ l_eStatus = m_loggerPopups.ShowStartPopup(
+ f_hApp, m_errorEventNtfData, &m_artifactRequestVec,
+ m_loggerUtil.getDestination(m_errorEventNtfData));
+
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "m_loggerPopups.ShowStartPopup(f_hApp,m_errorEventNtfData,&m_artifactRequestVec )");
+
+ TEXT(__FUNCTION__,
+ "Requesting next artifact ID:%d from:%s, with timeout:%d ms.",
+ l_nextArtifact.ArtifactId,
+ l_nextArtifact.Information.OwnerServiceName.c_str(),
+ l_nextArtifact.Information.RequestTimeoutMs);
+
+ l_timeoutSec = l_nextArtifact.Information.RequestTimeoutMs / 1000;
+ l_timeoutMs = l_nextArtifact.Information.RequestTimeoutMs % 1000;
+ bool result =
+ m_errorEventTimers[kSSL_ERROR_EVENT_TIMER_ARTIFACT_RSPN].Start(
+ l_timeoutSec, l_timeoutMs, 0, 0);
+ if (FALSE == result) { // LCOV_EXCL_BR_LINE 200:As it is always TRUE
+ // LCOV_EXCL_START 200:As it is always TRUE
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to start timer kSSL_ERROR_EVENT_TIMER_ARTIFACT_RSPN.");
+ // LCOV_EXCL_STOP
+ }
+ switch (l_nextArtifact.Information.Cb.Type) {
+ case eCbTypePath: {
+ l_eStatus = CheckPathForArtifact(f_hApp, l_nextArtifact);
+ }
+ break;
+
+ case eCbTypeFunction: {
+ if (l_nextArtifact.Information.Cb.Function == NULL) { // LCOV_EXCL_BR_LINE 200:As it is not always NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer; // LCOV_EXCL_LINE 200:As it is not always NULL
+ } else {
+ l_eStatus = l_nextArtifact.Information.Cb.Function(f_hApp,
+ l_nextArtifact);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "l_nextArtifact.Information.Cb.Function(f_hApp, l_nextArtifact)");
+ }
+ }
+ break;
+
+ case eCbTypeInvalid:
+ default:
+ {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. Unknown artifact or artifact owner for artifact ID:"
+ " %d. Invalid logging artifact configuration likely.",
+ l_nextArtifact.ArtifactId);
+ }
+ break;
+ }
+ } else {
+ if ((m_errorEventNtfData.EventType == eErrorEventTypeUserInvokedClearLogs)
+ || (m_errorEventNtfData.EventType
+ == eErrorEventTypeUserInvokedCollectNaviLog)) {
+ l_eStatus = this->OnStorageResponseOk(f_hApp);
+ return (l_eStatus);
+ }
+ uint8_t status;
+// Clock_getSystemTimeY2K38(&m_time, &status);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Info. All logging error event artifacts have been collected.");
+ l_eStatus = m_loggerUtil.checkDestinationAvailable(m_errorEventNtfData);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "m_loggerUtil.checkDestinationAvailable(m_errorEventNtfData)");
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ /* Check one last time after all logs have been collected */
+ /* if we should show popup for archiving and writing to USB */
+ l_eStatus = m_loggerPopups.ShowStartPopup(
+ f_hApp, m_errorEventNtfData, &m_artifactRequestVec,
+ m_loggerUtil.getDestination(m_errorEventNtfData));
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "m_loggerPopups.ShowStartPopup(f_hApp,m_errorEventNtfData,&m_artifactRequestVec )");
+
+ l_eStatus = m_loggerUtil.getFilePathAndName(f_hApp, m_errorEventNtfData,
+ m_time, m_archiveDestination);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "m_loggerUtil.getFilePathAndName()");
+
+ std::string destination_path = m_loggerUtil.getDestination(
+ m_errorEventNtfData);
+ if (destination_path.compare(m_pLoggerCfg->m_emmcOutputPath) == 0) {
+ if (eFrameworkunifiedStatusOK
+ != m_loggerUtil.deleteOldEmmcLog(m_archiveDestination,
+ m_errorEventNtfData.EventType)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. m_loggerUtil.deleteOldEmmcLog()");
+ }
+ }
+
+ l_eStatus = this->m_loggerStorage.Start(m_archiveDestination,
+ this->m_artifactResponseVec,
+ m_time);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "m_loggerStorage.Start()");
+ if (l_eStatus != eFrameworkunifiedStatusOK) {
+ l_eStatus = this->OnStorageResponseWriteFailed(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "this->OnStorageResponseWriteFailed(f_hApp)");
+ }
+ } else {
+ l_eStatus = this->OnStorageResponseNotFound(f_hApp);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "this->OnStorageResponseNotFound(f_hApp)");
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnArtifactResponse
+// brief : This function is called when an artifact has been made ready
+// by the owning service.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnArtifactResponse(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ ARTIFACT_RESPONSE l_artifactResponse;
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<ARTIFACT_RESPONSE>(f_hApp, l_artifactResponse))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()"); // LCOV_EXCL_LINE 200:To ensure success
+ } else {
+ m_errorEventTimers[kSSL_ERROR_EVENT_TIMER_ARTIFACT_RSPN].Stop();
+
+ // Prevent processing of artifacts that arrive after the error event logging session has completed.
+ if (m_artifactRequestVec.size() > 0) {
+ TEXT(__FUNCTION__, "Artifact ID:%d received.",
+ l_artifactResponse.ArtifactId);
+
+ TLoggingArtifact &l_artifactCurr = m_artifactRequestVec.back();
+ if (l_artifactCurr.ArtifactId != l_artifactResponse.ArtifactId) {
+ TEXT(
+ __FUNCTION__,
+ "Failure collecting current artifact. Expected artifact ID:%d, received artifact ID:%d."
+ " Ignoring received artifact.",
+ l_artifactCurr.ArtifactId, l_artifactResponse.ArtifactId);
+ } else {
+ TLoggingArtifactResponse l_response;
+ l_response.ArtifactId = l_artifactResponse.ArtifactId;
+ l_response.Filepath = l_artifactResponse.FilePathAndName;
+ l_response.Remove = l_artifactCurr.Information.Remove;
+ m_artifactResponseVec.push_back(l_response);
+ m_artifactRequestVec.pop_back(); // Remove received artifact from request vector.
+ l_eStatus = RequestNextArtifact(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "RequestNextArtifact()");
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. Received spurious artifact ID: %d. No error event logging session active.",
+ l_artifactResponse.ArtifactId); // LCOV_EXCL_BR_LINE 5:macro
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnArtifactResponseTimeout
+// brief : This function is called when a requested artifact response
+// fails to arrive in the required amount of time.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnArtifactResponseTimeout(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (m_artifactRequestVec.size() > 0) { // LCOV_EXCL_BR_LINE 200:As it cannot always be 0
+ TLoggingArtifact &l_artifactCurr = m_artifactRequestVec.back();
+
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Artifact response timer expired for artifact ID: %d.",
+ l_artifactCurr.ArtifactId);
+
+ // Remove artifact from request vector.
+ m_artifactRequestVec.pop_back();
+
+ RequestNextArtifact(f_hApp);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnArtifactRequest
+// brief : This function services an artifact request generated by
+// the error event sub system. The requested artifact will
+// be one of the artifacts owned by SSL.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnArtifactRequest(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ EArtifactId l_requestedArtifactId;
+
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<EArtifactId>(f_hApp, l_requestedArtifactId))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ switch (l_requestedArtifactId) {
+ case eArtifactIdInterfaceunifiedDebugLog:
+ l_eStatus = OnObtainLoggerserviceLogRequest(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "OnObtainLoggerserviceLogRequest()");
+ break;
+
+ case eArtifactIdTransmitLog:
+ l_eStatus = OnObtainTransmitLogRequest(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "OnObtainTransmitLogRequest()");
+ break;
+
+ case eArtifactIdPerformanceLog:
+ l_eStatus = OnObtainPerformanceLogRequest(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "OnObtainPerformanceLogRequest()");
+ break;
+
+ case eArtifactIdScreenShot:
+ l_eStatus = OnObtainScreenShotRequest(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "OnObtainScreenShotRequest()");
+ break;
+
+ case eArtifactIdKernelLog:
+ l_eStatus = OnObtainKernelLogInfoRequest(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "OnObtainKernelLogInfoRequest()");
+ break;
+
+ case eArtifactIdDRInitialLog:
+ l_eStatus = OnObtainDRInitialLogRequest(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "OnObtainDRInitialLogRequest()");
+ break;
+
+ case eArtifactIdDRLocationLog:
+ l_eStatus = OnObtainDRLocationLogRequest(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "OnObtainDRLocationLogRequest()");
+ break;
+
+ case eArtifactIdClearAllLog:
+ l_eStatus = OnClearAllLogRequest(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "OnClearAllLogRequest()");
+ break;
+
+ case eArtifactIdNaviLog:
+ l_eStatus = OnNaviLogRequest(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "OnNaviLogRequest()");
+ break;
+
+ default:
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Unsupported logging artifact requested: %d.",
+ l_requestedArtifactId);
+ break;
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnStorageResponseOk
+// brief : This function services response from the storage thread. It
+// is called when the logs have been stored successfully.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnStorageResponseOk(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ l_eStatus = this->m_loggerPopups.ShowEndPopup(f_hApp, m_errorEventNtfData,
+ m_archiveDestination);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "this->m_loggerPopups.ShowEndPopup(f_hApp,m_errorEventNtfData,m_archiveDestination)");
+
+ if (m_errorEventNtfData.EventType == eErrorEventTypeDiagEvent) {
+ l_eStatus = sendDiagEventResponse();
+ LOG_STATUS_IF_ERRORED(l_eStatus, "sendDiagEventResponse()");
+ }
+ if (m_errorEventNtfData.isNeedReboot == TRUE) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "System will reboot soon, so stop logging function.");
+ StopLoggingFunction(f_hApp);
+ }
+ m_bIsPrevEventCompleted = true;
+ l_eStatus = SendLogCompleteRequestToSystemManager(eFrameworkunifiedStatusOK);
+
+ l_eStatus = m_loggerCanEvent.PublishEndEvent(f_hApp, m_errorEventNtfData,
+ m_currentEventTriggerNumber,
+ m_time);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "m_loggerCanEvent.PublishEndEvent();");
+ LOG_STATUS_IF_ERRORED(l_eStatus, "SendLogCompleteRequestToSystemManager()");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnStorageResponseWriteFailed
+// brief : This function services response from the storage thread. It
+// is called when the logs failed to be written to the target
+// destination.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnStorageResponseWriteFailed(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ l_eStatus = m_loggerPopups.ShowErrorPopup(f_hApp, m_errorEventNtfData,
+ (UI_16) eWriteToDeviceFailed);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus, "m_loggerPopups.ShowErrorPopup(f_hApp, eWriteToDeviceFailed)");
+
+ if (m_errorEventNtfData.EventType == eErrorEventTypeDiagEvent) {
+ sendDiagEventErrorResponse(eDEVICE_WRITE_ERROR);
+ }
+ if (m_errorEventNtfData.isNeedReboot == TRUE) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "System will reboot soon, so stop logging function.");
+ StopLoggingFunction(f_hApp);
+ }
+ m_bIsPrevEventCompleted = true;
+ l_eStatus = SendLogCompleteRequestToSystemManager(eFrameworkunifiedStatusFail);
+
+ l_eStatus = m_loggerCanEvent.PublishErrorEvent(f_hApp, m_errorEventNtfData,
+ TRUE,
+ m_currentEventTriggerNumber,
+ m_time);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "m_loggerCanEvent.PublishErrorEvent();");
+
+ LOG_STATUS_IF_ERRORED(l_eStatus, "SendLogCompleteRequestToSystemManager()");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnStorageResponseNotFound
+// brief : This function services response from the storage thread. It
+// is called when the logs failed to be written to the target
+// destination because the target was not found
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnStorageResponseNotFound(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ l_eStatus = m_loggerPopups.ShowErrorPopup(f_hApp, m_errorEventNtfData,
+ (UI_16) eSelectedDeviceNotFound);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "m_loggerPopups.ShowErrorPopup(f_hApp, eSelectedDeviceNotFound)");
+
+ if (m_errorEventNtfData.EventType == eErrorEventTypeDiagEvent) {
+ l_eStatus = sendDiagEventErrorResponse(eDEVICE_NOT_AVAILABLE);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "sendDiagEventErrorResponse(eDEVICE_NOT_AVAILABLE)");
+ }
+ if (m_errorEventNtfData.isNeedReboot == TRUE) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "System will reboot soon, so stop logging function.");
+ StopLoggingFunction(f_hApp);
+ }
+ m_bIsPrevEventCompleted = true;
+ l_eStatus = SendLogCompleteRequestToSystemManager(eFrameworkunifiedStatusFail);
+
+ l_eStatus = m_loggerCanEvent.PublishErrorEvent(f_hApp, m_errorEventNtfData,
+ TRUE,
+ m_currentEventTriggerNumber,
+ m_time);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "m_loggerCanEvent.PublishErrorEvent();");
+
+ LOG_STATUS_IF_ERRORED(l_eStatus, "SendLogCompleteRequestToSystemManager()");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnStorageResponseNoWritten
+// brief : This function services response from the storage thread. It
+// is called when no logs where found.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnStorageResponseNoWritten(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ l_eStatus = m_loggerPopups.ShowErrorPopup(f_hApp, m_errorEventNtfData,
+ (UI_16) eNoLogToStore);
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "m_loggerPopups.ShowErrorPopup(f_hApp, eNoLogToStore)");
+
+ if (m_errorEventNtfData.EventType == eErrorEventTypeDiagEvent) {
+ l_eStatus = sendDiagEventErrorResponse(eNO_ERROR_INFO);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "sendDiagEventErrorResponse(eNO_ERROR_INFO)");
+ }
+ if (m_errorEventNtfData.isNeedReboot == TRUE) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "System will reboot soon, so stop logging function.");
+ StopLoggingFunction(f_hApp);
+ }
+ m_bIsPrevEventCompleted = true;
+ l_eStatus = SendLogCompleteRequestToSystemManager(eFrameworkunifiedStatusOK);
+
+ l_eStatus = m_loggerCanEvent.PublishErrorEvent(f_hApp, m_errorEventNtfData,
+ TRUE,
+ m_currentEventTriggerNumber,
+ m_time);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "m_loggerCanEvent.PublishErrorEvent();");
+
+ LOG_STATUS_IF_ERRORED(l_eStatus, "SendLogCompleteRequestToSystemManager()");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CErrorEvent::sendDiagEventErrorResponse(EELL_ErrorCode f_errCode) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ if (this->m_ServiceName.length() > 0) {
+ l_eStatus = sendDiagEventErrorResponse(f_errCode, this->m_ServiceName);
+ this->m_ServiceName = "";
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CErrorEvent::sendDiagEventErrorResponse(EELL_ErrorCode f_errCode,
+ std::string f_destName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ 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]
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "SS_LOGGERCOPYEMERGENCYLOGS_ERROR_RESP Msg send failed = %x",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CErrorEvent::sendDiagEventResponse(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendMsg(m_diagsessionhandle, SS_LOGGERCOPYEMERGENCYLOGS_SUCCESS_RESP, 0, NULL))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "SS_LOGGERCOPYEMERGENCYLOGS_SUCCESS_RESP Msg send failed = %x",
+ l_eStatus);
+ }
+
+ m_ServiceName = "";
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CErrorEvent::SetDiagEventSourceName(std::string f_serviceName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ if ((f_serviceName.length() > 0)
+ && (this->m_ServiceName.length() == 0)) {
+ this->m_ServiceName = f_serviceName;
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. f_serviceName(%s), m_serviceName(%s)",
+ f_serviceName.c_str(), m_ServiceName.c_str());
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+void CErrorEvent::SetDiagSessionHandle(HANDLE f_sessionhandle) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ m_diagsessionhandle = f_sessionhandle;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+void CErrorEvent::SetMileage(UI_32 f_mileage) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ this->m_loggerUtil.SetMilage(f_mileage);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+// LCOV_EXCL_START 200:
+EFrameworkunifiedStatus CErrorEvent::SaveNaviLog(EPWR_SHUTDOWN_TRIGGER_TYPE errType) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_32 l_logMaxNum = 0;
+ std::string l_Filename = "";
+
+ uint32_t l_time;
+ uint8_t status;
+// Clock_getSystemTimeY2K38(&l_time, &status);
+ l_eStatus = m_loggerUtil.getEmmcNaviLogParams(l_time, errType, l_Filename,
+ l_logMaxNum);
+
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error: getEmmcNaviLogParams NaviLog update failed %d", l_eStatus);
+ } else {
+ if (l_logMaxNum == 0) {
+ /*OutputNaviLogNmlMax or OutputNaviLogErrMax = 0. */
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_WARN,
+ __FUNCTION__,
+ " Warning: Not update NaviLog. OutputNaviLogNmlMax or OutputNaviLogErrMax = 0");
+ } else {
+ FILE *fp;
+ void *p;
+// p = EL_mem_exram_mmap_simple(EL_MEM_ID_NAVI_LOG, PROT_READ | PROT_WRITE,
+// MAP_SHARED,
+// EL_MEM_CACHE_INVALID);
+// if (p == MAP_FAILED) {
+// FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+// "Error : EL_mem_exram_mmap_simple MAP_FAILD");
+// l_eStatus = eFrameworkunifiedStatusFail;
+// } else {
+// fp = fopen(l_Filename.c_str(), "wb");
+// if (fp == NULL) {
+// FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Could not open file %s",
+// l_Filename.c_str());
+// l_eStatus = eFrameworkunifiedStatusAccessError;
+// } else {
+// fwrite(p, sizeof(unsigned char), EL_mem_getLength(EL_MEM_ID_NAVI_LOG),
+// fp);
+// fclose(fp);
+// }
+// if (0 != EL_mem_exram_munmap(p, EL_mem_getLength(EL_MEM_ID_NAVI_LOG))) {
+// FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error : EL_mem_exram_munmap");
+// }
+// }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CErrorEvent::VerifyExtStorage(TLoggerErrorEvent event) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ std::string f_path;
+
+ f_path = m_pLoggerCfg->getUsb0MountPath();
+
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+
+ if (eFrameworkunifiedStatusFail == l_eStatus) {
+ // timeout or error
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error : get secure log failed or timeout");
+ }
+ } else {
+ // timeout
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error : ticket verify timeout.");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+bool CErrorEvent::IsNeedVerify(EErrorEventType type) {
+ bool ret = false;
+ switch (type) {
+ case eErrorEventTypeUserInvokedCollectScreenShot:
+ case eErrorEventTypeUserInvokedCollectAllLogs:
+ case eErrorEventTypeUserInvokedCollectInterfaceunifiedLogs:
+ case eErrorEventTypeInterfaceunifiedEmmcLogs:
+ case eErrorEventTypeEelExport:
+ case eErrorEventTypeDiagEvent:
+ case eErrorEventTypeCanEvent:
+ ret = true;
+ break;
+ default:
+ break;
+ }
+ return ret;
+}
diff --git a/logger_service/server/src/ss_logger_error_event_archive.cpp b/logger_service/server/src/ss_logger_error_event_archive.cpp
new file mode 100644
index 00000000..3672d002
--- /dev/null
+++ b/logger_service/server/src/ss_logger_error_event_archive.cpp
@@ -0,0 +1,413 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief This file supports error event logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "ss_logger_error_event_archive.h"
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <dirent.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <libtar_listhash.h>
+#include <libtar.h>
+#include <zlib.h>
+#include <stdio.h>
+#include <boost/bind.hpp>
+#include <native_service/frameworkunified_framework_if.h>
+#include <system_service/ss_services.h>
+#include <system_service/ss_templates.h>
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <vector>
+#include "ss_logger_util.h"
+#include "loggerservicedebug_loggerservicelog.h"
+#include "ss_logger_fs_directory.h"
+
+// GZF save variables
+static gzFile g_gzFile;
+
+CErrorEventArchive::CErrorEventArchive(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ m_pTarInfo = NULL;
+ g_gzFile = NULL;
+ m_gztype.openfunc = (openfunc_t) &CErrorEventArchive::gzOpenArchive;
+ m_gztype.closefunc = (closefunc_t) &CErrorEventArchive::gzCloseArchive;
+ m_gztype.readfunc = (readfunc_t) &CErrorEventArchive::gzReadArchive;
+ m_gztype.writefunc = (writefunc_t) &CErrorEventArchive::gzWriteArchive;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+CErrorEventArchive::~CErrorEventArchive(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ if (NULL != m_pTarInfo) { // LCOV_EXCL_BR_LINE 6: it will close after close
+ // LCOV_EXCL_START 6: it will close after close
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ (void) closeArchive();
+ m_pTarInfo = NULL;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+EFrameworkunifiedStatus CErrorEventArchive::openArchive(std::string f_pathAndName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ if (NULL == m_pTarInfo) { // LCOV_EXCL_BR_LINE 6: closeArchive will be set to null
+ m_pathAndName = f_pathAndName;
+
+ /* check if directory exists */
+ size_t l_found = f_pathAndName.find_last_of('/');
+ std::string l_path = f_pathAndName.substr(0, l_found);
+
+ if (0 != access(l_path.c_str(), F_OK)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Directory does not exist. Creating...");
+ l_eFrameworkunifiedStatus = CFSDirectory::CreateDirectory(l_path);
+ }
+
+ /* create archive in tmp */
+ m_tmpName = "/tmp/log.tar.gz";
+
+ int l_tarRetVal = tar_open(&m_pTarInfo, const_cast<char*>(m_tmpName.c_str()),
+ &m_gztype,
+ O_WRONLY | O_CREAT,
+ TARMODE,
+ TAR_GNU);
+
+ if ((l_tarRetVal != 0) || (m_pTarInfo == NULL) || (g_gzFile == NULL)) { // LCOV_EXCL_BR_LINE 5: tar_open's error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 5: tar_open's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Could not open TAR-Archive!");
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusAccessError;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 6: closeArchive will be set to null
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Tar is still open");
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eFrameworkunifiedStatus);
+}
+
+EFrameworkunifiedStatus CErrorEventArchive::addToArchive(std::string f_filePathAndName,
+ std::string f_destinationName,
+ UI_8 f_depth) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusFileLoadError;
+ struct stat l_stat;
+ int l_statRetVal;
+
+ if (0 != access(f_filePathAndName.c_str(), F_OK)) { // LCOV_EXCL_BR_LINE 200: file is aways exist
+ // LCOV_EXCL_START 200: file is aways exist
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. The specified file path and name does not exist: %s",
+ f_filePathAndName.c_str());
+ // LCOV_EXCL_STOP
+ } else if (0 != (l_statRetVal = stat(f_filePathAndName.c_str(), &l_stat))) { // LCOV_EXCL_BR_LINE 5: stat's error case. // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 5: stat's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. stat() for file or directory returned error: %s -> %d",
+ f_filePathAndName.c_str(), l_statRetVal);
+ // LCOV_EXCL_STOP
+ } else if (0 != S_ISDIR(l_stat.st_mode)) {
+ if (0 < f_depth) { // LCOV_EXCL_BR_LINE 6: it aways 4
+ l_eFrameworkunifiedStatus = addDirectoryToArchive(f_filePathAndName, f_destinationName,
+ f_depth);
+ } else {
+ // LCOV_EXCL_START 6: it aways 4
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ "Maximum recursive depth reached! File %s not added to archive.",
+ f_filePathAndName.c_str());
+ // LCOV_EXCL_STOP
+ }
+ } else if (0 != S_ISREG(l_stat.st_mode)) { // LCOV_EXCL_BR_LINE 200: it can not be a symbolic link
+ l_eFrameworkunifiedStatus = addFileToArchive(f_filePathAndName, f_destinationName);
+ } else {
+ // LCOV_EXCL_START 200: it can not be a symbolic link
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. specified file may be a symbolic link or other non 'regular' type. File: %s, mode: 0x%04X.",
+ f_filePathAndName.c_str(), l_stat.st_mode);
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eFrameworkunifiedStatus);
+}
+
+// LCOV_EXCL_START 8: can not be called
+EFrameworkunifiedStatus CErrorEventArchive::addToArchive(
+ std::vector<std::string> f_filePathAndNameList) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+
+ std::vector<std::string>::iterator l_vIter = f_filePathAndNameList.begin();
+ while ((eFrameworkunifiedStatusOK == l_eFrameworkunifiedStatus)
+ && (l_vIter != f_filePathAndNameList.end())) {
+ l_eFrameworkunifiedStatus = addToArchive(*l_vIter, *l_vIter);
+ l_vIter++;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eFrameworkunifiedStatus);
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CErrorEventArchive::closeArchive(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (0 != tar_append_eof(m_pTarInfo)) { // LCOV_EXCL_BR_LINE 5: tar_append_eof's error case.
+ // LCOV_EXCL_START 5: tar_append_eof's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __PRETTY_FUNCTION__, "tar_append_eof()");
+ l_eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+ if (0 != tar_close(m_pTarInfo)) { // LCOV_EXCL_BR_LINE 5: tar_close's error case.
+ // LCOV_EXCL_START 5: tar_close's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Could not close archive");
+ l_eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ } else {
+ m_pTarInfo = NULL;
+ g_gzFile = NULL;
+ }
+
+ if (eFrameworkunifiedStatusOK == l_eStatus) { // LCOV_EXCL_BR_LINE 6: it aways be ok
+#ifdef RELEASE_BUILD
+ l_eStatus = CLoggerUtil::PathCheckAndCopyFile(m_tmpName, m_pathAndName);
+#else
+ l_eStatus = CLoggerUtil::CopyFile(m_tmpName, m_pathAndName);
+#endif // RELEASE_BUILD
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ l_eStatus =
+ (0 == remove(m_tmpName.c_str())) ? eFrameworkunifiedStatusOK : eFrameworkunifiedStatusFault;
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 5: remove's error case.
+ // LCOV_EXCL_START 5: remove's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_WARN,
+ __FUNCTION__,
+ " Warning. Failed to remove temporary archive. Will overwrite on next event");
+ // LCOV_EXCL_STOP
+ }
+ } else if (eFrameworkunifiedStatusErrNoEAGAIN == l_eStatus) { // LCOV_EXCL_BR_LINE 200: write can not be ErrNoEAGAIN
+ // LCOV_EXCL_START 200: write can not be ErrNoEAGAIN
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // disk space full
+ struct stat st_buf;
+ size_t req_size;
+ if (stat(m_tmpName.c_str(), &st_buf) != -1) { // LCOV_EXCL_BR_LINE 5: stat's error case.
+ req_size = st_buf.st_size;
+ if (eFrameworkunifiedStatusOK
+ == CLoggerUtil::forceDeleteOldLog(m_pathAndName, req_size)) {
+#ifdef RELEASE_BUILD
+ l_eStatus = CLoggerUtil::PathCheckAndCopyFile(m_tmpName, m_pathAndName);
+#else
+ l_eStatus = CLoggerUtil::CopyFile(m_tmpName, m_pathAndName);
+#endif // RELEASE_BUILD
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 200: PathCheckAndCopyFile can not be fail
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ "Try Again but Error. Failed to copy to destination.%s, size=%d",
+ m_pathAndName.c_str(), req_size);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error. force delete failed.%s, size=%d",
+ m_pathAndName.c_str(), req_size);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " emmc full: dest=%s, size=%d",
+ m_pathAndName.c_str(), req_size);
+ } else {
+ // LCOV_EXCL_START 5: stat's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Warning. Failed to get tmp log file stat. dest=%s",
+ m_pathAndName.c_str());
+ // LCOV_EXCL_STOP
+ }
+ // LCOV_EXCL_STOP
+ } else {
+ /*should we copy lost archive to emmc??*/
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Failed to copy to destination. %s", m_pathAndName.c_str());
+ }
+ remove(m_tmpName.c_str());
+ m_tmpName = "";
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CErrorEventArchive::addFileToArchive(std::string f_filename,
+ std::string f_destinationName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK; /*check if Tar is open and if file can be read */
+
+ char path[PATH_MAX];
+
+ if ((NULL != m_pTarInfo) && (0 != f_destinationName.length()) // LCOV_EXCL_BR_LINE 200: it will awalys be true
+ && (realpath(f_filename.c_str(), path) != NULL)) {
+ int l_tarRetVal = tar_append_file(m_pTarInfo, path,
+ const_cast<char*>(f_destinationName. c_str()));
+ if (0 != l_tarRetVal) { // LCOV_EXCL_BR_LINE 5: tar_append_file's error case.
+ // LCOV_EXCL_START 5: tar_append_file's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Could not add file \'%s\' to tar archive.", f_filename.c_str());
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusAccessError;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 200: it will awalys be true
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Archive not opened or could not access file: \"%s\"",
+ f_filename.c_str());
+ l_eFrameworkunifiedStatus = eFrameworkunifiedStatusInvldParam;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eFrameworkunifiedStatus);
+}
+
+EFrameworkunifiedStatus CErrorEventArchive::addDirectoryToArchive(
+ std::string f_path, std::string f_destinationName, UI_8 f_depth) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eFrameworkunifiedStatus = eFrameworkunifiedStatusOK;
+ struct dirent l_pDirent;
+ struct dirent* next;
+
+ DIR *l_pDir = opendir(f_path.c_str());
+ if (l_pDir != NULL) { // LCOV_EXCL_BR_LINE 5: opendir's error case.
+ while (0 == readdir_r(l_pDir, &l_pDirent, &next) && next != NULL) {
+ if ((0 != strcmp(l_pDirent.d_name, ".")) && /* Ignore special . directory. */
+ (0 != strcmp(l_pDirent.d_name, "..")) && /* Ignore special .. directory. */
+ (0 != strcmp(l_pDirent.d_name, "lost+found")) && /* Ignore lost+found. */
+ ('.' != l_pDirent.d_name[0])) { /* Ignore hidden files */
+ std::string l_extension = "/";
+ std::string l_fileName = f_path;
+ std::string l_destName = f_destinationName;
+ l_extension.append(l_pDirent.d_name);
+ l_fileName.append(l_extension);
+ l_destName.append(l_extension);
+ l_eFrameworkunifiedStatus = addToArchive(l_fileName, l_destName, static_cast<UI_8>(f_depth - 1));
+ }
+ }
+
+ closedir(l_pDir);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eFrameworkunifiedStatus);
+}
+
+SI_32 CErrorEventArchive::gzOpenArchive(PCHAR f_pcPathname, SI_32 f_siOflags,
+ SI_32 f_siMode) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ SI_32 l_siFileDescriptor = -1;
+
+ if (f_pcPathname) { // LCOV_EXCL_BR_LINE 6: Pathname is awalys be set
+ PCHAR l_pcGzoflags;
+
+ switch (f_siOflags & O_ACCMODE) { // LCOV_EXCL_BR_LINE 6: only O_WRONLY be set
+ case O_WRONLY: {
+ l_pcGzoflags = (PCHAR) "wb";
+ break;
+ }
+ // LCOV_EXCL_START 6: only O_WRONLY be set
+ case O_RDONLY: {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_pcGzoflags = (PCHAR) "rb";
+ break;
+ }
+ // LCOV_EXCL_STOP
+ case O_RDWR:
+ default: {
+ return -1;
+ }
+ }
+
+ if (-1 == (l_siFileDescriptor = // LCOV_EXCL_BR_LINE 5: open's error case.
+ open(f_pcPathname, f_siOflags, f_siMode))) {
+ // LCOV_EXCL_START 5: open's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return -1;
+ // LCOV_EXCL_STOP
+ }
+
+ if ((f_siOflags & O_CREAT) // LCOV_EXCL_BR_LINE 5: fchmod's error case.
+ && fchmod(l_siFileDescriptor, f_siMode)) {
+ // LCOV_EXCL_START 5: fchmod's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ close(l_siFileDescriptor);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return -1;
+ // LCOV_EXCL_STOP
+ }
+
+ g_gzFile = gzdopen(l_siFileDescriptor, l_pcGzoflags);
+ if (!g_gzFile) { // LCOV_EXCL_BR_LINE 5: gzdopen's error case.
+ // LCOV_EXCL_START 5: gzdopen's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ close(l_siFileDescriptor);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return -1;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Source Path empty.");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (SI_32) l_siFileDescriptor;
+}
+SI_32 CErrorEventArchive::gzCloseArchive() {
+ return gzclose(g_gzFile);
+}
+
+ssize_t CErrorEventArchive::gzWriteArchive(int fd, const void* buf,
+ size_t count) {
+ return gzwrite(g_gzFile, const_cast<void*>(buf), (unsigned int) count);
+}
+
+ssize_t CErrorEventArchive::gzReadArchive(int fd, void* buf, size_t count) {
+ return gzread(g_gzFile, buf, (unsigned int) count);
+}
diff --git a/logger_service/server/src/ss_logger_error_event_can_evt_reply.cpp b/logger_service/server/src/ss_logger_error_event_can_evt_reply.cpp
new file mode 100644
index 00000000..f8c70ffc
--- /dev/null
+++ b/logger_service/server/src/ss_logger_error_event_can_evt_reply.cpp
@@ -0,0 +1,147 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief This file supports notifying CAN abou HK and CAN error events
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <stdio.h>
+#include <time.h>
+//#include <vehicle_service/Clock_API.h>
+#include "ss_logger_error_event_can_evt_reply.h"
+CLoggerErrorEventCANEvtReply::CLoggerErrorEventCANEvtReply() {
+}
+
+CLoggerErrorEventCANEvtReply::~CLoggerErrorEventCANEvtReply() { // LCOV_EXCL_START 14:globle instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CLoggerErrorEventCANEvtReply::Initialize(CLoggerCfg* f_pLoggerCfg) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+BOOL CLoggerErrorEventCANEvtReply::IsEventNeeded(TLoggerErrorEvent f_event) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ BOOL l_ret =
+ ((f_event.EventBitMask & EVENT_BIT_CAN_NOTIFICATION) != 0) ? TRUE : FALSE;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_ret);
+}
+
+EFrameworkunifiedStatus CLoggerErrorEventCANEvtReply::PublishStartEvent(
+ HANDLE f_hApp, TLoggerErrorEvent f_event) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ if (TRUE == IsEventNeeded(f_event)) {
+ l_eStatus = FrameworkunifiedPublishPublicEvent(f_hApp, eSSLoggerCANEventStart, NULL, 0);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "FrameworkunifiedPublishPublicEvent(f_hApp,eSSLoggerCANEventStart,NULL,0)");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerErrorEventCANEvtReply::PublishEndEvent(
+ HANDLE f_hApp, TLoggerErrorEvent f_event, UI_32 f_triggerNumber,
+ uint32_t f_time) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ if (TRUE == IsEventNeeded(f_event)) {
+ STEventCANLoggerEventInfo l_info;
+ struct tm l_tm;
+// CLOCK_RETURN clock_ret = Clock_getLocalTimeY2K38(&f_time, &l_tm);
+// if (CLOCK_OK == clock_ret) {
+// l_info.valid = TRUE;
+// l_info.success = TRUE;
+// l_info.triggerNumber = f_triggerNumber;
+// l_info.dateAndTime.DateTime_Stat = 0;
+// l_info.dateAndTime.DateTimeDay = static_cast<UI_8>(l_tm.tm_mday);
+// l_info.dateAndTime.DateTimeHour = static_cast<UI_8>(l_tm.tm_hour);
+// l_info.dateAndTime.DateTimeMinute = static_cast<UI_8>(l_tm.tm_min);
+// l_info.dateAndTime.DateTimeMonth = static_cast<UI_8>(l_tm.tm_mon + 1);
+// l_info.dateAndTime.DateTimeSecond = static_cast<UI_8>(l_tm.tm_sec);
+// l_info.dateAndTime.DateTimeYear = static_cast<UI_8>(l_tm.tm_year % 100);
+// l_info.dateAndTime.TimeFormat = 0;
+// FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+// " Info. Time sent to CAN is: 20%2d/%2d/%2d %2d:%2d:%2d",
+// l_info.dateAndTime.DateTimeYear, l_info.dateAndTime.DateTimeMonth,
+// l_info.dateAndTime.DateTimeDay, l_info.dateAndTime.DateTimeHour,
+// l_info.dateAndTime.DateTimeMinute,
+// l_info.dateAndTime.DateTimeSecond);
+//
+// } else {
+// l_info.success = TRUE;
+// l_info.valid = FALSE;
+// FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Passed time is invalid.");
+// }
+ l_eStatus = FrameworkunifiedPublishPublicEvent(f_hApp, eSSLoggerCANEventFinished,
+ &l_info, sizeof(l_info));
+
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "FrameworkunifiedPublishPublicEvent(f_hApp,eSSLoggerCANEventFinished,NULL,0)");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerErrorEventCANEvtReply::PublishErrorEvent(
+ HANDLE f_hApp, TLoggerErrorEvent f_event, BOOL f_isValid,
+ UI_32 f_triggerNumber, uint32_t f_time) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ if (TRUE == IsEventNeeded(f_event)) {
+ STEventCANLoggerEventInfo l_info;
+ struct tm l_tm;
+// CLOCK_RETURN clock_ret = Clock_getLocalTimeY2K38(&f_time, &l_tm);
+ l_info.valid = f_isValid;
+ l_info.success = FALSE;
+// if (CLOCK_OK == clock_ret) {
+// l_info.triggerNumber = f_triggerNumber;
+// l_info.dateAndTime.DateTime_Stat = 0;
+// l_info.dateAndTime.DateTimeDay = static_cast<UI_8>(l_tm.tm_mday);
+// l_info.dateAndTime.DateTimeHour = static_cast<UI_8>(l_tm.tm_hour);
+// l_info.dateAndTime.DateTimeMinute = static_cast<UI_8>(l_tm.tm_min);
+// l_info.dateAndTime.DateTimeMonth = static_cast<UI_8>(l_tm.tm_mon + 1);
+// l_info.dateAndTime.DateTimeSecond = static_cast<UI_8>(l_tm.tm_sec);
+// l_info.dateAndTime.DateTimeYear = static_cast<UI_8>(l_tm.tm_year % 100);
+// l_info.dateAndTime.TimeFormat = 0;
+// FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+// " Info. Time sent to CAN is: 20%2d/%2d/%2d %2d:%2d:%2d",
+// l_info.dateAndTime.DateTimeYear, l_info.dateAndTime.DateTimeMonth,
+// l_info.dateAndTime.DateTimeDay, l_info.dateAndTime.DateTimeHour,
+// l_info.dateAndTime.DateTimeMinute,
+// l_info.dateAndTime.DateTimeSecond);
+//
+// } else {
+// l_info.valid = FALSE;
+// FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Passed time is invalid.");
+// }
+ l_eStatus = FrameworkunifiedPublishPublicEvent(f_hApp, eSSLoggerCANEventFinished,
+ &l_info, sizeof(l_info));
+ LOG_STATUS_IF_ERRORED( // LCOV_EXCL_BR_LINE 15: macro
+ l_eStatus,
+ "FrameworkunifiedPublishPublicEvent(f_hApp,eSSLoggerCANEventFinished,NULL,0)");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
diff --git a/logger_service/server/src/ss_logger_error_event_cfg.cpp b/logger_service/server/src/ss_logger_error_event_cfg.cpp
new file mode 100644
index 00000000..ccc6082d
--- /dev/null
+++ b/logger_service/server/src/ss_logger_error_event_cfg.cpp
@@ -0,0 +1,348 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief This file supports error event logging configuration.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <string.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <system_service/ss_logger_service.h>
+#include <system_service/ss_services.h>
+#include <system_service/ss_templates.h>
+#include <vector>
+#include "loggerservicedebug_loggerservicelog.h"
+#include "ss_logger_error_event_cfg.h"
+
+enum ARTIFACT_BIT {
+ ARTIFACT_BIT_NONE = 0x00000000,
+ ARTIFACT_BIT_LOGGERSERVICE_DEBUG_LOG = 1 << (UI_32) eArtifactIdInterfaceunifiedDebugLog,
+ ARTIFACT_BIT_TRANSMIT_LOG = 1 << (UI_32) eArtifactIdTransmitLog,
+ ARTIFACT_BIT_PERFORMANCE_LOG = 1 << (UI_32) eArtifactIdPerformanceLog,
+ ARTIFACT_BIT_BOOT_MICRO_LOG = 1 << (UI_32) eArtifactIdBootMicroLog,
+ ARTIFACT_BIT_SYSTEM_DATA_LOG = 1 << (UI_32) eArtifactIdSystemDataCsv,
+ ARTIFACT_BIT_SHOW_MEM_TXT = 1 << (UI_32) eArtifactIdShowMemTxt,
+ ARTIFACT_BIT_PROCESS_CORE = 1 << (UI_32) eArtifactIdProcessCore,
+ ARTIFACT_BIT_DEBUG_DUMP_LOG = 1 << (UI_32) eArtifactIdDebugDumpLog,
+ ARTIFACT_BIT_KERNEL_LOG = 1 << (UI_32) eArtifactIdKernelLog,
+ ARTIFACT_BIT_KERNEL_BOOT_LOG = 1 << (UI_32) eArtifactIdKernelBootLog,
+ ARTIFACT_BIT_DRINITIAL_LOG = 1 << (UI_32) eArtifactIdDRInitialLog,
+ ARTIFACT_BIT_DRLOCATION_LOG = 1 << (UI_32) eArtifactIdDRLocationLog,
+ ARTIFACT_BIT_CHLM_MC_LOGS = 1 << (UI_32) eArtifactIdCpuHighLoadMonteCarloLogs,
+ ARTIFACT_BIT_METACORE_LOGS = 1 << (UI_32) eArtifactIdMetaCoreLogs,
+ ARTIFACT_BIT_SCREEN_SHOT = 1 << (UI_32) eArtifactIdScreenShot,
+ ARTIFACT_BIT_CMS_LOGS = 1 << (UI_32) eArtifactIdCmsLogs,
+ ARTIFACT_BIT_INTERNAL_DTC_LOG = 1 << (UI_32) eArtifactIDInternalDTC,
+ ARTIFACT_BIT_CLEAR_ALL_LOG = 1 << (UI_32) eArtifactIdClearAllLog,
+ ARTIFACT_BIT_NAVI_LOG = 1 << (UI_32) eArtifactIdNaviLog,
+ ARTIFACT_BIT_DEBUG_FOLDER_CONTENT = 1
+ << (UI_32) eArtifactIdDebugFolderContent,
+ ARTIFACT_BIT_DEBUG_FOLDER2_CONTENT = 1
+ << (UI_32) eArtifactIdDebugFolder2Content,
+ ARTIFACT_BIT_COM_LOG = 1 << (UI_32) eArtifactIdComDebugLog,
+ ARTIFACT_BIT_RADIO_LOG = 1 << (UI_32) eArtifactIdRadioDebugLog,
+ ARTIFACT_BIT_CONNECTIVITY_LOG = 1 << (UI_32) eArtifactIdConnectivityDebugLog,
+ ARTIFACT_BIT_GRAPHICS_LOG = 1 << (UI_32) eArtifactIdGraphicsDebugLog,
+ ARTIFACT_BIT_SYS_LOG = 1 << (UI_32) eArtifactIdSysLog,
+ ARTIFACT_BIT_PSTORE_LOG = 1 << (UI_32) eArtifactIdPstoreLog,
+ ARTIFACT_BIT_WINSYS_LOG = 1 << (UI_32) eArtifactIdWinSysLog,
+ ARTIFACT_BIT_APPFW_LOG = 1 << (UI_32) eArtifactIdAppFwLog,
+ ARTIFACT_BIT_TOMOYO_LOG = 1 << (UI_32) eArtifactIdTomoyoLog
+};
+
+//////////////////////////////////////////////////////////////////////////////////////////
+///// Definition for Logging Artifact Filepaths
+//////////////////////////////////////////////////////////////////////////////////////////
+const char LAF_DEBUG_FOLDER[] = "/nv/log";
+const char LAF_DEBUG_FOLDER2[] = "/nv/log2";
+const char LAF_MONTECARLO_FN[] = "/tmp/MonteCarlo";
+const char LAF_METACORE_FN[] = "/tmp/MetaCore";
+const char LAF_CMS_FN[] = "/tmp/cms";
+const char LAF_INT_DTC_FN[] = "/tmp/dtc_error.log";
+const char LAF_LOGGERSERVICELOG_COM[] = "/ramd/log/frameworkunifiedlog/communication";
+const char LAF_LOGGERSERVICELOG_RDO[] = "/ramd/log/frameworkunifiedlog/radio";
+const char LAF_LOGGERSERVICELOG_CONNECTIVITY[] = "/ramd/log/frameworkunifiedlog/connectivity";
+const char LAF_GRAPHICS_FN[] = "/ramd/log/frameworkunifiedlog/graphics.log";
+const char LAF_KERNEL_BOOT_FN[] = "/ramd/log/frameworkunifiedlog/kernelboot.log";
+const char LAF_SYSLOG[] = "/ramd/log/frameworkunifiedlog/syslog";
+const char LAF_PSTORELOG[] = "/dev/pstore";
+const char LAF_WINSYS_FN[] = "/ramd/log/frameworkunifiedlog/winsys.log";
+const char LAF_APPFW[] = "/ramd/log/frameworkunifiedlog/appfw";
+const char LAF_TOMOYO[] = "/nv/ptdata/sec/tomoyo";
+
+#define ARTIFACT_BIT_ALL_OUTPUT_LOG (ARTIFACT_BIT_LOGGERSERVICE_DEBUG_LOG | \
+ ARTIFACT_BIT_DEBUG_DUMP_LOG | \
+ ARTIFACT_BIT_SYSTEM_DATA_LOG | \
+ ARTIFACT_BIT_SHOW_MEM_TXT | \
+ ARTIFACT_BIT_COM_LOG | \
+ ARTIFACT_BIT_RADIO_LOG | \
+ ARTIFACT_BIT_CONNECTIVITY_LOG | \
+ ARTIFACT_BIT_KERNEL_LOG | \
+ ARTIFACT_BIT_KERNEL_BOOT_LOG | \
+ ARTIFACT_BIT_SCREEN_SHOT | \
+ ARTIFACT_BIT_TRANSMIT_LOG | \
+ ARTIFACT_BIT_PERFORMANCE_LOG | \
+ ARTIFACT_BIT_DRINITIAL_LOG | \
+ ARTIFACT_BIT_DRLOCATION_LOG | \
+ ARTIFACT_BIT_CHLM_MC_LOGS | \
+ ARTIFACT_BIT_INTERNAL_DTC_LOG | \
+ ARTIFACT_BIT_GRAPHICS_LOG | \
+ ARTIFACT_BIT_SYS_LOG | \
+ ARTIFACT_BIT_METACORE_LOGS | \
+ ARTIFACT_BIT_PSTORE_LOG | \
+ ARTIFACT_BIT_WINSYS_LOG | \
+ ARTIFACT_BIT_APPFW_LOG | \
+ ARTIFACT_BIT_TOMOYO_LOG)
+
+TLoggingArtifactCfg CErrorEventCfg::m_loggerErrorEventCfgTbl[eErrorEventTypeMaxValue] = {
+ { eErrorEventTypeProcessCrash, { (ARTIFACT_BIT_ALL_OUTPUT_LOG
+ | ARTIFACT_BIT_NAVI_LOG), (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeProcessExit, { (ARTIFACT_BIT_ALL_OUTPUT_LOG
+ | ARTIFACT_BIT_NAVI_LOG), (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeHeartBeatFailure, { (ARTIFACT_BIT_ALL_OUTPUT_LOG
+ | ARTIFACT_BIT_NAVI_LOG), (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeSystemLowMemory, { (ARTIFACT_BIT_ALL_OUTPUT_LOG
+ | ARTIFACT_BIT_NAVI_LOG), (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeUserInvokedUserForceReset, { ARTIFACT_BIT_ALL_OUTPUT_LOG,
+ (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeUserInvokedCollectAllLogs, { ARTIFACT_BIT_ALL_OUTPUT_LOG,
+ (EVENT_BIT_POPUP | EVENT_BIT_CAN_NOTIFICATION) } },
+
+ { eErrorEventTypeUserInvokedCollectScreenShot, { (ARTIFACT_BIT_NONE
+ | ARTIFACT_BIT_SCREEN_SHOT),
+
+ (EVENT_BIT_POPUP | EVENT_BIT_CAN_NOTIFICATION) } },
+
+ { eErrorEventTypeUserInvokedCollectInterfaceunifiedLogs, { ARTIFACT_BIT_ALL_OUTPUT_LOG,
+ (EVENT_BIT_POPUP | EVENT_BIT_CAN_NOTIFICATION) } },
+
+ { eErrorEventTypeUserInvokedCollectDevLogs, { ARTIFACT_BIT_ALL_OUTPUT_LOG,
+ (EVENT_BIT_NONE) }
+ },
+
+ { eErrorEventTypeBootMicroReset, { (ARTIFACT_BIT_ALL_OUTPUT_LOG
+ | ARTIFACT_BIT_NAVI_LOG), (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeEelExport, { ARTIFACT_BIT_ALL_OUTPUT_LOG,
+ (EVENT_BIT_POPUP | EVENT_BIT_CAN_NOTIFICATION) } },
+
+ { eErrorEventTypeInterfaceunifiedEmmcLogs, { (ARTIFACT_BIT_DEBUG_FOLDER_CONTENT
+ | ARTIFACT_BIT_DEBUG_FOLDER2_CONTENT),
+
+ (EVENT_BIT_POPUP | EVENT_BIT_CAN_NOTIFICATION) } },
+
+ { eErrorEventTypeDiagEvent, { ARTIFACT_BIT_ALL_OUTPUT_LOG,
+ (EVENT_BIT_DIAG) } },
+
+ { eErrorEventTypeCanEvent, { ARTIFACT_BIT_ALL_OUTPUT_LOG,
+ (EVENT_BIT_CAN_NOTIFICATION) } },
+
+ { eErrorEventTypeDtcEvent, { (ARTIFACT_BIT_ALL_OUTPUT_LOG
+ | ARTIFACT_BIT_NAVI_LOG),
+
+ (EVENT_BIT_CAN_NOTIFICATION) } },
+
+ { eErrorEventTypeModConnFailed, { (ARTIFACT_BIT_ALL_OUTPUT_LOG
+ | ARTIFACT_BIT_NAVI_LOG), (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeStartRespFailed, { (ARTIFACT_BIT_ALL_OUTPUT_LOG
+ | ARTIFACT_BIT_NAVI_LOG), (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeModuleInvokedResetRequest, { (ARTIFACT_BIT_ALL_OUTPUT_LOG
+ | ARTIFACT_BIT_NAVI_LOG), (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeModuleInvokedCollectDebugLogs,
+ { (ARTIFACT_BIT_ALL_OUTPUT_LOG | ARTIFACT_BIT_NAVI_LOG),
+ (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeUserInvokedClearLogs, { (ARTIFACT_BIT_NONE
+ | ARTIFACT_BIT_CLEAR_ALL_LOG), (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeUserInvokedCollectNaviLog, { (ARTIFACT_BIT_NONE
+ | ARTIFACT_BIT_NAVI_LOG), (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeGroupRelaunch, { (ARTIFACT_BIT_ALL_OUTPUT_LOG
+ | ARTIFACT_BIT_NAVI_LOG), (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeReserved1, { (ARTIFACT_BIT_NONE), (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeReserved2, { (ARTIFACT_BIT_NONE), (EVENT_BIT_NONE) } },
+
+ { eErrorEventTypeReserved3, { (ARTIFACT_BIT_NONE), (EVENT_BIT_NONE) } } };
+
+TLoggingArtifact CErrorEventCfg::m_loggerErrorArtifactCfgTbl[eArtifactIdMaxValue] = { // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ /*Artifact ID Owner Timeout Callback Type Path CallBack Function Delete tmp artifact*/
+ { eArtifactIdInterfaceunifiedDebugLog, { SERVICE_LOGGER, 5000, { eCbTypeFunction, "",
+ SSLogger_SendtoSelf }, TRUE } }, { eArtifactIdTransmitLog,
+ { SERVICE_LOGGER, 5000, { eCbTypeFunction, "", SSLogger_SendtoSelf },
+ TRUE } }, { eArtifactIdPerformanceLog, { SERVICE_LOGGER, 5, {
+ eCbTypeFunction, "", SSLogger_SendtoSelf }, FALSE } }, {
+ eArtifactIdBootMicroLog, { SERVICE_SYSMANAGER, 1000, { eCbTypeFunction,
+ "", SSLogger_SendtoSM }, TRUE } }, { eArtifactIdSystemDataCsv, {
+ SERVICE_SYSMANAGER, 5000, { eCbTypeFunction, "", SSLogger_SendtoSM },
+ TRUE } }, { eArtifactIdShowMemTxt, { SERVICE_SYSMANAGER, 8000, {
+ eCbTypeFunction, "", SSLogger_SendtoSM }, TRUE } }, {
+ eArtifactIdProcessCore, { SERVICE_SYSMANAGER, 5000, { eCbTypeFunction,
+ "", SSLogger_SendtoSM }, TRUE } }, { eArtifactIdDebugDumpLog, {
+ SERVICE_SYSMANAGER, 4000, { eCbTypeFunction, "", SSLogger_SendtoSM },
+ TRUE } }, { eArtifactIdScreenShot, { SERVICE_LOGGER, 1100, {
+ eCbTypeFunction, "", SSLogger_SendtoSelf }, TRUE } }, {
+ eArtifactIdDebugFolderContent, { SERVICE_LOGGER, 50000, { eCbTypePath,
+ LAF_DEBUG_FOLDER, NULL }, FALSE } }, {
+ eArtifactIdDebugFolder2Content, { SERVICE_LOGGER, 50000, { eCbTypePath,
+ LAF_DEBUG_FOLDER2, NULL }, FALSE } }, { eArtifactIdKernelLog,
+ { SERVICE_LOGGER, 5000, { eCbTypeFunction, "", SSLogger_SendtoSelf },
+ TRUE } }, { eArtifactIdKernelBootLog, { SERVICE_LOGGER, 5000, {
+ eCbTypePath, LAF_KERNEL_BOOT_FN, NULL }, FALSE } }, {
+ eArtifactIdDRInitialLog, { SERVICE_LOGGER, 500, { eCbTypeFunction, "",
+ SSLogger_SendtoSelf }, TRUE } }, { eArtifactIdDRLocationLog,
+ { SERVICE_LOGGER, 500, { eCbTypeFunction, "", SSLogger_SendtoSelf },
+ TRUE } }, { eArtifactIdCpuHighLoadMonteCarloLogs, { SERVICE_LOGGER,
+ 50, { eCbTypePath, LAF_MONTECARLO_FN, NULL }, TRUE } }, {
+ eArtifactIdMetaCoreLogs, { SERVICE_LOGGER, 50, { eCbTypePath,
+ LAF_METACORE_FN, NULL }, TRUE } }, { eArtifactIdCmsLogs, {
+ SERVICE_LOGGER, 500, { eCbTypePath, LAF_CMS_FN, NULL }, TRUE } }, {
+ eArtifactIDInternalDTC, { SERVICE_LOGGER, 500, { eCbTypePath,
+ LAF_INT_DTC_FN, NULL }, TRUE } }, { eArtifactIdComDebugLog, {
+ SERVICE_LOGGER, 500, { eCbTypePath, LAF_LOGGERSERVICELOG_COM, NULL }, FALSE } }, {
+ eArtifactIdRadioDebugLog, { SERVICE_LOGGER, 500, { eCbTypePath,
+ LAF_LOGGERSERVICELOG_RDO, NULL }, FALSE } }, {
+ eArtifactIdConnectivityDebugLog, { SERVICE_LOGGER, 500, { eCbTypePath,
+ LAF_LOGGERSERVICELOG_CONNECTIVITY, NULL }, FALSE } }, {
+ eArtifactIdGraphicsDebugLog, { SERVICE_LOGGER, 50, { eCbTypePath,
+ LAF_GRAPHICS_FN, NULL }, FALSE } }, { eArtifactIdSysLog, {
+ SERVICE_LOGGER, 50, { eCbTypePath, LAF_SYSLOG, NULL }, FALSE } }, {
+ eArtifactIdPstoreLog, { SERVICE_LOGGER, 50, { eCbTypePath,
+ LAF_PSTORELOG, NULL }, FALSE } }, { eArtifactIdClearAllLog,
+ { SERVICE_LOGGER, 500, { eCbTypeFunction, "", SSLogger_SendtoSelf },
+ FALSE } }, { eArtifactIdNaviLog, { SERVICE_LOGGER, 5000, {
+ eCbTypeFunction, "", SSLogger_SendtoSelf }, FALSE } }, {
+ eArtifactIdWinSysLog, { SERVICE_LOGGER, 50, { eCbTypePath,
+ LAF_WINSYS_FN, NULL }, FALSE } }, { eArtifactIdAppFwLog, {
+ SERVICE_LOGGER, 500, { eCbTypePath, LAF_APPFW, NULL }, FALSE } }, {
+ eArtifactIdTomoyoLog, { SERVICE_LOGGER, 50, { eCbTypePath, LAF_TOMOYO,
+ NULL }, TRUE } } }; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+
+CErrorEventCfg::CErrorEventCfg() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+CErrorEventCfg::~CErrorEventCfg() { // LCOV_EXCL_START 14:globle instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CErrorEventCfg::Initialize(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_32 l_cnt;
+
+ for (l_cnt = 0; l_cnt < eArtifactIdMaxValue; l_cnt++) {
+ EArtifactId l_artifactId = m_loggerErrorArtifactCfgTbl[l_cnt].ArtifactId;
+ TLoggingArtifactInformation l_artifactInformation =
+ m_loggerErrorArtifactCfgTbl[l_cnt].Information;
+ m_errorArtifactMap[l_artifactId] = l_artifactInformation; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ }
+ for (l_cnt = 0; l_cnt < eErrorEventTypeMaxValue; l_cnt++) {
+ EErrorEventType l_eventType = m_loggerErrorEventCfgTbl[l_cnt].ErrorType;
+ TLoggingErrorEventInformation l_errorEvtInformation =
+ m_loggerErrorEventCfgTbl[l_cnt].Information;
+ m_errorEventTypeToArtifactBitMaskMap[l_eventType] = l_errorEvtInformation;
+ }
+
+ l_eStatus = (EFrameworkunifiedStatus) ValidateConfiguration();
+ LOG_STATUS_IF_ERRORED(l_eStatus, "ValidateConfiguration()"); // LCOV_EXCL_BR_LINE 5:macro
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+UI_32 CErrorEventCfg::ValidateConfiguration(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ UI_32 l_return = 0;
+ if (eArtifactIdMaxValue != m_errorArtifactMap.size()) { // LCOV_EXCL_BR_LINE 6:Be sure not to exceed the eArtifactIdMaxValue
+ // LCOV_EXCL_START 6:Be sure not to exceed the eArtifactIdMaxValue
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Artifact map size mismatch: Expected: %d, Found: %d",
+ eArtifactIdMaxValue, m_errorArtifactMap.size());
+ l_return |= 1;
+ // LCOV_EXCL_STOP
+ }
+ if (eErrorEventTypeMaxValue != m_errorEventTypeToArtifactBitMaskMap.size()) { // LCOV_EXCL_BR_LINE 6:Be sure not to exceed the eErrorEventTypeMaxValue
+ // LCOV_EXCL_START 6:Be sure not to exceed the eErrorEventTypeMaxValue
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error event map size mismatch: Expected: %d, Found: %d",
+ eErrorEventTypeMaxValue, m_errorEventTypeToArtifactBitMaskMap.size());
+ l_return |= 4;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_return);
+}
+
+void CErrorEventCfg::GetArtifactRequestVec(
+ EErrorEventType f_eventType,
+ std::vector<TLoggingArtifact> &f_refArtifactRequestVec) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ ARTIFACT_BIT_MASK l_artifactRequestBits = 0;
+ ARTIFACT_BIT l_artifactBit;
+ TLoggingArtifact l_artifact;
+ UI_32 l_artifactId;
+
+ f_refArtifactRequestVec.clear();
+
+ if (f_eventType < eErrorEventTypeMaxValue) {
+ l_artifactRequestBits = m_errorEventTypeToArtifactBitMaskMap[f_eventType]
+ .ArtifactBitMask;
+ }
+
+ if (l_artifactRequestBits > 0) {
+ for (l_artifactId = 0; l_artifactId < eArtifactIdMaxValue; l_artifactId++) {
+ l_artifactBit = (ARTIFACT_BIT) (1 << l_artifactId);
+ if ((l_artifactRequestBits & l_artifactBit) > 0) {
+ l_artifact.ArtifactId = (EArtifactId) l_artifactId;
+ l_artifact.Information = m_errorArtifactMap[l_artifact.ArtifactId];
+ f_refArtifactRequestVec.push_back(l_artifact);
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+EVENT_BIT_MASK CErrorEventCfg::GetEventsForErrorEvent(
+ EErrorEventType f_eventType) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EVENT_BIT_MASK l_events = EVENT_BIT_NONE;
+ if (f_eventType < eErrorEventTypeMaxValue) { // LCOV_EXCL_BR_LINE 6:Be sure not to exceed the eErrorEventTypeMaxValue
+ l_events = m_errorEventTypeToArtifactBitMaskMap[f_eventType].EventBitMask;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_events);
+} // LCOV_EXCL_BR_LINE 10:the last line
diff --git a/logger_service/server/src/ss_logger_error_event_responses.cpp b/logger_service/server/src/ss_logger_error_event_responses.cpp
new file mode 100644
index 00000000..ec8bbd48
--- /dev/null
+++ b/logger_service/server/src/ss_logger_error_event_responses.cpp
@@ -0,0 +1,764 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief This file supports error event logging.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <string.h>
+#include <unistd.h>
+#include <sys/wait.h>
+#include <boost/bind.hpp>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/klog.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_multithreading.h>
+#include <native_service/ns_sharedmem.h>
+#include <native_service/ns_sharedmem_reader.h>
+#include <native_service/ns_ringbuffer.h>
+#include <native_service/ns_logger_if.h>
+#include <system_service/ss_sm_client_if.h>
+#include <system_service/ss_logger_service_protocol.h>
+#include <system_service/ss_services.h>
+#include <system_service/ss_templates.h>
+#include <native_service/cl_process.h>
+#include <native_service/cl_lockid.h>
+#include <sstream>
+#include <string>
+#include "loggerservicedebug_loggerservicelog.h"
+#include "loggerservicedebug_thread_if.h"
+#include "ss_logger_error_event.h"
+#include "ss_logger_service_callbacks.h"
+#include "ss_logger_scrshot.h"
+#include "ss_logger_fs_directory.h"
+#include "ss_logger_common.h"
+#include "ss_logger_types.h"
+
+EFrameworkunifiedStatus SSLogger_SendtoSM(HANDLE f_hApp, TLoggingArtifact f_artifact) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ l_eStatus = SendLogArtifactRequestToSystemManager(f_artifact.ArtifactId);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. SendLogArtifactRequestToSystemManager returned: %d for artifact ID: %d",
+ l_eStatus, f_artifact.ArtifactId);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus SSLogger_SendtoSelf(HANDLE f_hApp, TLoggingArtifact f_artifact) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusNullPointer;
+ if (NULL != f_hApp) { // LCOV_EXCL_BR_LINE 6: double check
+ l_eStatus = FrameworkunifiedSendSelf(f_hApp, SS_LOGGER_ERROR_EVENT_ARTIFACT_REQ,
+ sizeof(f_artifact.ArtifactId),
+ &f_artifact.ArtifactId);
+
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. FrameworkunifiedSendSelf(SS_LOGGER_ERROR_EVENT_ARTIFACT_REQ) returned error: %d for artifact ID: %d.",
+ l_eStatus, f_artifact.ArtifactId);
+ // LCOV_EXCL_STOP
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+///////////////////////////////////////////////////////////////////////////
+// Function : SendLogArtifactResponseToSelf
+// brief : Collect frameworkunifiedlog artifact and return a response to
+// SS_Logger.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::SendLogArtifactResponseToSelf(
+ HANDLE f_hApp, EArtifactId f_artifactId,
+ std::string f_artifactFilePathAndName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ ARTIFACT_RESPONSE l_artifactResponse;
+
+ l_artifactResponse.ArtifactId = f_artifactId;
+
+ strncpy(l_artifactResponse.FilePathAndName, f_artifactFilePathAndName.c_str(),
+ sizeof(l_artifactResponse.FilePathAndName) - 1);
+
+ l_eStatus = FrameworkunifiedSendSelf(f_hApp, SS_SM_ERROR_EVENT_ARTIFACT_RSPN,
+ sizeof(l_artifactResponse), &l_artifactResponse);
+
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "FrameworkunifiedSendSelf(SS_SM_ERROR_EVENT_ARTIFACT_RSPN)");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnObtainLoggerserviceLogRequest
+// brief : Collect frameworkunifiedlog artifact and return a response to
+// SS_Logger.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnObtainLoggerserviceLogRequest(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ std::string dir_path = DEBUG_LOG_PATH_DIR;
+
+ l_eStatus = CFSDirectory::CreateDirectory(dir_path);
+ if (l_eStatus != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: Create FRAMEWORKUNIFIEDLOG tmp directory %d",
+ l_eStatus);
+ } else {
+ UI_32 l_DumpSize = 0;
+ std::string src_file_path;
+ std::string dst_file_path;
+ PCSTR file_name;
+ UI_32 num;
+ bool log_clear = true;
+
+ switch (m_errorEventNtfData.EventType) {
+ // _DIAG
+ case eErrorEventTypeUserInvokedUserForceReset:
+ case eErrorEventTypeUserInvokedCollectAllLogs:
+ case eErrorEventTypeUserInvokedCollectScreenShot:
+ case eErrorEventTypeUserInvokedCollectInterfaceunifiedLogs:
+ case eErrorEventTypeDiagEvent:
+ case eErrorEventTypeCanEvent:
+ case eErrorEventTypeDtcEvent:
+ case eErrorEventTypeModuleInvokedCollectDebugLogs:
+ // _DEBUG
+ case eErrorEventTypeUserInvokedCollectDevLogs:
+ log_clear = false;
+ break;
+ default:
+ break;
+ }
+
+ num = NSLogGetFrameworkunifiedlogFileTotalNum();
+ for (UI_32 cont = 0; cont < num; cont++) {
+ file_name = NSLogGetFrameworkunifiedlogFileName(cont);
+ if (file_name == NULL) {
+ break;
+ }
+ src_file_path = FRAMEWORKUNIFIEDLOG_RAMDISC_PATH;
+ src_file_path.append("/");
+ src_file_path.append(file_name);
+ dst_file_path = DEBUG_LOG_PATH_DIR;
+ dst_file_path.append("/");
+ dst_file_path.append(file_name);
+ CNSRingBuffer* l_pLoggerservicelog;
+ int index;
+ index = NSLogGetFrameworkunifiedlogIndex(src_file_path.c_str());
+ l_pLoggerservicelog = new (std::nothrow) CNSRingBuffer(
+ src_file_path, 0, index + LOCK_NSLOG_ACCES_IF_1);
+ if (l_pLoggerservicelog == NULL) { // LCOV_EXCL_BR_LINE 5: new's error case
+ // LCOV_EXCL_START 5: new's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FRAMEWORKUNIFIEDLOG RingBuffer handle is NULL %s",
+ src_file_path.c_str());
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pLoggerservicelog->Open())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FRAMEWORKUNIFIEDLOG RingBuffer Open failed %s %d",
+ src_file_path.c_str(), l_eStatus);
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pLoggerservicelog->DumpToFile(dst_file_path.c_str(),
+ &l_DumpSize))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FRAMEWORKUNIFIEDLOG RingBuffer DumpToFile failed %s %d",
+ src_file_path.c_str(), l_eStatus);
+ }
+ if (NULL != l_pLoggerservicelog) { // LCOV_EXCL_BR_LINE 5: new's error case
+ if (log_clear) {
+ if (eFrameworkunifiedStatusOK != (l_eStatus = l_pLoggerservicelog->ClearBuf())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: FRAMEWORKUNIFIEDLOG RingBuffer ClearBuf failed %s %d",
+ src_file_path.c_str(), l_eStatus);
+ }
+ }
+ (void) l_pLoggerservicelog->Close();
+ delete l_pLoggerservicelog;
+ }
+ }
+ l_eStatus = SendLogArtifactResponseToSelf(f_hApp, eArtifactIdInterfaceunifiedDebugLog,
+ DEBUG_LOG_PATH_DIR);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus, "SendLogArtifactResponseToSelf(eArtifactIdInterfaceunifiedDebugLog)");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnObtainLoggerserviceLogRequest
+// brief : Collect frameworkunifiedlog artifact and return a response to
+// SS_Logger.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnObtainTransmitLogRequest(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ std::string l_RootPath;
+
+ l_eStatus = m_pReaderWriterControl->FlushCache(eReaderWriterLogTransmit);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "m_pReaderWriterControl->FlushCache(eReaderWriterLogTransmit)");
+ l_RootPath = TRANSMIT_LOG_PATH_FN;
+ if (access(l_RootPath.c_str(), R_OK) != 0) {
+ l_RootPath = "";
+ }
+ l_eStatus = SendLogArtifactResponseToSelf(f_hApp, eArtifactIdTransmitLog,
+ l_RootPath.c_str());
+
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "SendLogArtifactResponseToSelf(eArtifactIdTransmitLog)");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnObtainLoggerserviceLogRequest
+// brief : Collect frameworkunifiedlog artifact and return a response to
+// SS_Logger.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnObtainPerformanceLogRequest(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ l_eStatus = m_pReaderWriterControl->FlushCache(eReaderWriterLogPerformance);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "m_pReaderWriterControl->FlushCache(eReaderWriterLogPerformance)");
+ l_eStatus = SendLogArtifactResponseToSelf(f_hApp, eArtifactIdPerformanceLog,
+ PERFORMANCE_LOG_PATH_FN);
+
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus, "SendLogArtifactResponseToSelf(eArtifactIdPerformanceLog)");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+#define SCREEN_SHOT_INTVAL 500000 // 500msec
+#define SCRREN_SHOT_CAPTURE_RETRY_CNT 2
+
+static EFrameworkunifiedStatus SaveScreenShot(char *chldexe, char **argv, int m_sfd,
+ CL_ProcessAttr_t *attr) {
+ int selection = -1;
+ fd_set fds;
+ struct timeval tv;
+ pid_t childpid;
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ int retry = 0;
+
+ while (1) {
+ childpid = CL_ProcessCreate(chldexe, argv, NULL, attr);
+ if (childpid == -1) { // LCOV_EXCL_BR_LINE 5: c code case
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "create process failed returned: %d",
+ errno);
+ } else {
+ do {
+ tv.tv_sec = 5;
+ tv.tv_usec = 0;
+ FD_ZERO(&fds);
+ FD_SET(m_sfd, &fds);
+ selection = select(m_sfd + 1, &fds, NULL, NULL, &tv);
+ } while ((selection < 0) && (errno == EINTR)); // LCOV_EXCL_BR_LINE 5: c code case
+ if (selection < 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "select failed %d", errno);
+ } else {
+ if (FD_ISSET(m_sfd, &fds)) { // LCOV_EXCL_BR_LINE 5: FD_ISSET's error case
+ CL_ProcessCleanupInfo_t cinfo;
+ int ret;
+
+ ret = CL_ProcessCleanup(m_sfd, &cinfo);
+ if ((ret != -1) && (cinfo.code == CLD_EXITED)) {
+ if (cinfo.status != 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Save Error! cinfo.status:%d",
+ cinfo.status);
+ } else {
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ }
+ } else {
+ // LCOV_EXCL_START 5: FD_ISSET's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // (FD_ISSET() failed Error
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "fd Not Exist fd Error\n");
+ // LCOV_EXCL_STOP
+ }
+ }
+ }
+ if ((l_eStatus == eFrameworkunifiedStatusOK)
+ || (retry >= (SCRREN_SHOT_CAPTURE_RETRY_CNT - 1))) {
+ break;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "retry!");
+ usleep(SCREEN_SHOT_INTVAL); // interval
+ retry++;
+ }
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnObtainScreenShotRequest
+// brief : Collect screen shot artifact from PLM and return a response
+// to SS_Logger.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnObtainScreenShotRequest(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ std::string dir_path = SCREEN_SHOT_PATH;
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ EFrameworkunifiedStatus l_eStatusCh0 = eFrameworkunifiedStatusFail;
+ EFrameworkunifiedStatus l_eStatusCh1 = eFrameworkunifiedStatusFail;
+
+ char *c_argv0[4] = { NULL, const_cast<char*>(JPEG_PATH_CH0), const_cast<char*>("0"), NULL };
+ char *c_argv1[4] = { NULL, const_cast<char*>(JPEG_PATH_CH1), const_cast<char*>("1"), NULL };
+ char *chldexe;
+
+ /*check m_sfd vlue*/
+ if (m_sfd == -1) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "SS_Logger_SaveScreenShot m_sfd error -1");
+ return l_eStatus;
+ }
+
+ /*check chldexe value*/
+ chldexe = realpath(SCRSHOT_EXE_PATH, NULL);
+ if (chldexe == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "SS_Logger_SaveScreenShot realpath failed %d", errno);
+ return l_eStatus;
+ }
+
+ c_argv0[0] = chldexe;
+ c_argv1[0] = chldexe;
+ l_eStatus = CFSDirectory::CreateDirectory(dir_path);
+ if (l_eStatus != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "SS_Logger_SaveScreenShot tmp directory failed");
+ free(chldexe);
+ return l_eStatus;
+ } else {
+ CL_ProcessAttr_t attr;
+ CL_ProcessCreateAttrInit(&attr);
+
+ /* Save Picture Ch0(E2) */
+ l_eStatusCh0 = SaveScreenShot(chldexe, c_argv0, m_sfd, &attr);
+ if (l_eStatusCh0 == eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 200:As there are no ScreenShot processes
+ // LCOV_EXCL_START 200:As there are no ScreenShot processes
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ /* Start Save Picture Ch1(M2) */
+ l_eStatusCh1 = SaveScreenShot(chldexe, c_argv1, m_sfd, &attr);
+ if (l_eStatusCh1 != eFrameworkunifiedStatusOK) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "SS_Logger_SaveScreenShot Ch1(M2) failed");
+ }
+ // LCOV_EXCL_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "SS_Logger_SaveScreenShot Ch0(E2) failed");
+ }
+ }
+
+ // Send Artifact Responce.
+ if ((l_eStatusCh0 == eFrameworkunifiedStatusOK) || (l_eStatusCh1 == eFrameworkunifiedStatusOK)) { // LCOV_EXCL_BR_LINE 200:As there are no ScreenShot processes
+ // LCOV_EXCL_START 200:As there are no ScreenShot processes
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // Set "SCREEN_SHOT_PATH" to save two pictures(ch0(E2) and ch1(M2))
+ l_eStatus = SendLogArtifactResponseToSelf(f_hApp, eArtifactIdScreenShot,
+ SCREEN_SHOT_PATH);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus, "SendLogArtifactResponseToSelf(eArtifactIdScreenShot)");
+ // LCOV_EXCL_STOP
+ } else {
+ // If both Ch0 and Ch1 is failed,
+ // update l_eStatus to eFrameworkunifiedStatusFail and delete directory.
+ l_eStatus = eFrameworkunifiedStatusFail;
+ if (CFSDirectory::DoesDirectoryExist(dir_path)) {
+ if (CFSDirectory::RemoveDirectory(dir_path)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "SS_Logger_SaveScreenShot directory delete successful.");
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "SS_Logger_SaveScreenShot directory delete unsuccessful");
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "SS_Logger_SaveScreenShot Save Failed returned:%d", l_eStatus);
+ }
+ free(chldexe);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnObtainScreenShotResponse
+// brief : Callback from PLM when the screen shot file has been written
+// to storage. The data received contains the file path and
+// name to the written screen shot file. See
+// SS_LOGGER_SCREENCAPTURE_EVT_ACK.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnObtainScreenShotResponse(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ STScreenCaptureEvt l_ScreenCaptureEvtAck;
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<STScreenCaptureEvt>(f_hApp, l_ScreenCaptureEvtAck))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()");
+ // LCOV_EXCL_STOP
+ } else {
+ if (FALSE == l_ScreenCaptureEvtAck.fSucessful) {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. Screen shot acquisition failed. l_ScreenCaptureEvtAck.fSucessful == FALSE.");
+ l_ScreenCaptureEvtAck.strNameAndLocation[0] = '\0';
+ }
+
+ l_eStatus = SendLogArtifactResponseToSelf(
+ f_hApp, eArtifactIdScreenShot,
+ l_ScreenCaptureEvtAck.strNameAndLocation); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+
+ LOG_STATUS_IF_ERRORED( // LCOV_EXCL_BR_LINE 5:macro
+ l_eStatus, "SendLogArtifactResponseToSelf(eArtifactIdScreenShot)");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnObtainKernelLogInfoRequest
+// brief : Collect kernel log artifact and return a response to
+// SS_Logger.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnObtainKernelLogInfoRequest(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+
+ EFrameworkunifiedStatus l_eStatus = CreateKernelLog(f_hApp, SS_LOGGER_KLOG_GET);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnObtainDRInitialLogRequest
+// brief : Collect DRInitialLog artifact and return a response to
+// SS_Logger.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnObtainDRInitialLogRequest(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_32 l_DumpSize = 0;
+
+ CNSSharedMemReader* l_pDRInitial = new (std::nothrow) CNSSharedMemReader(
+ SHMEM_DRINITIALLOG, FALSE);
+
+ if (NULL == l_pDRInitial) { // LCOV_EXCL_BR_LINE 5: new's error case
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: DRInitial SharedMem handle is NULL");
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pDRInitial->Open())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: DRInitial Open failed %d", l_eStatus);
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pDRInitial->DumpToFile(DRINITIAL_LOG_PATH_FN,
+ &l_DumpSize))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: DRInitial DumpToFile failed %d",
+ l_eStatus);
+ } else {
+ l_eStatus = SendLogArtifactResponseToSelf(f_hApp, eArtifactIdDRInitialLog,
+ DRINITIAL_LOG_PATH_FN);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus, "SendLogArtifactResponseToSelf(eArtifactIdDRInitialLog)");
+ }
+
+ if (NULL != l_pDRInitial) { // LCOV_EXCL_BR_LINE 5: new's error case
+ (void) l_pDRInitial->Close();
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnObtainDRLocationLogRequest
+// brief : Collect DRLocationLog artifact and return a response to
+// SS_Logger.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnObtainDRLocationLogRequest(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_32 l_DumpSize = 0;
+
+ CNSSharedMemReader* l_pDRLocation = new (std::nothrow) CNSSharedMemReader(
+ SHMEM_DRLOCATIONLOG, FALSE);
+
+ if (NULL == l_pDRLocation) { // LCOV_EXCL_BR_LINE 5: new's error case
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: DRInitial SharedMem handle is NULL");
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pDRLocation->Open())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: DRLocation Open failed %d",
+ l_eStatus);
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = l_pDRLocation->DumpToFile(DRLOCATION_LOG_PATH_FN,
+ &l_DumpSize))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: DRLocation DumpToFile failed %d",
+ l_eStatus);
+ } else {
+ l_eStatus = SendLogArtifactResponseToSelf(f_hApp, eArtifactIdDRLocationLog,
+ DRLOCATION_LOG_PATH_FN);
+
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus, "SendLogArtifactResponseToSelf(eArtifactIdDRLocationLog)");
+ }
+
+ if (NULL != l_pDRLocation) { // LCOV_EXCL_BR_LINE 5: new's error case
+ (void) l_pDRLocation->Close();
+ delete l_pDRLocation;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnClearAllLogRequest
+// brief : Callback from LoggerService when the event log file has been delete
+// from storage. The data received contains the file path.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnClearAllLogRequest(HANDLE f_hApp) {
+ std::string clear_file_path = CLEAR_LOG_PATH_FN;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ if (CFSDirectory::RemoveSubDirectory(clear_file_path)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "SS_Logger Clear %s directory delete successful.",
+ clear_file_path.c_str());
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "SS_Logger Clear %s directory delete failed.",
+ clear_file_path.c_str());
+ }
+
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ clear_file_path = "/nv/log2/awlog/";
+ if (CFSDirectory::RemoveSubDirectory(clear_file_path)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "SS_Logger Clear %s directory delete successful.",
+ clear_file_path.c_str());
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "SS_Logger Clear %s directory delete failed.",
+ clear_file_path.c_str());
+ }
+
+ clear_file_path = "/nv/log2/core/";
+ if (CFSDirectory::RemoveSubDirectory(clear_file_path)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "SS_Logger Clear %s directory delete successful.",
+ clear_file_path.c_str());
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "SS_Logger Clear %s directory delete failed.",
+ clear_file_path.c_str());
+ }
+ // LCOV_EXCL_STOP
+
+ l_eStatus = SendLogArtifactResponseToSelf(f_hApp, eArtifactIdClearAllLog,
+ clear_file_path.c_str());
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "SendLogArtifactResponseToSelf(eArtifactIdClearAllLog)");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : OnNaviLogRequest
+// brief : Callback from LoggerService when the event log file has been xxxxxx BUGBUG
+// from storage. The data received contains the file path.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CErrorEvent::OnNaviLogRequest(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ // LCOV_EXCL_START 13:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus naviLog_status;
+ switch (m_errorEventNtfData.EventType) {
+ case eErrorEventTypeProcessCrash:
+ case eErrorEventTypeProcessExit:
+ case eErrorEventTypeHeartBeatFailure:
+ case eErrorEventTypeSystemLowMemory:
+ case eErrorEventTypeBootMicroReset:
+ case eErrorEventTypeModConnFailed:
+ case eErrorEventTypeStartRespFailed:
+ case eErrorEventTypeModuleInvokedResetRequest:
+ case eErrorEventTypeGroupRelaunch:
+ naviLog_status = SaveNaviLog(epssdmsdtGENERIC_ERROR_RESET);
+ break;
+ default:
+ naviLog_status = SaveNaviLog(epssdmsdtNORMAL_RESET);
+ break;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: Fail to save Navi Log %d",
+ naviLog_status);
+ // LCOV_EXCL_STOP
+
+ l_eStatus = SendLogArtifactResponseToSelf(f_hApp, eArtifactIdNaviLog, "");
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "SendLogArtifactResponseToSelf(eArtifactIdNaviLog)");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CErrorEvent::CheckPathForArtifact(HANDLE f_hApp,
+ TLoggingArtifact f_artifact) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldParam;
+ std::string l_Path;
+
+ if (f_artifact.Information.Cb.Type == eCbTypePath) {
+ l_Path = f_artifact.Information.Cb.Path;
+ if (access(l_Path.c_str(), R_OK) != 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "File/Directory %s not found. Returning empty string.",
+ l_Path.c_str());
+ l_Path = "";
+ }
+ l_eStatus = SendLogArtifactResponseToSelf(f_hApp, f_artifact.ArtifactId,
+ l_Path.c_str());
+
+ LOG_STATUS_IF_ERRORED(l_eStatus, "SendLogArtifactResponseToSelf()");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+/* Read all messages remaining in the ring buffer. (allowed for non-root) */
+#define SYSLOG_ACTION_READ_ALL 3
+/* Return size of the log buffer */
+#define SYSLOG_ACTION_SIZE_BUFFER 10
+
+EFrameworkunifiedStatus CErrorEvent::CreateKernelLog(HANDLE f_hApp,
+ SS_LOGGER_KLOG_OPE_TYPE type) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ int len;
+ int fd;
+ char* buf;
+ ssize_t wr_len;
+
+ len = klogctl(SYSLOG_ACTION_SIZE_BUFFER, NULL, 0);
+ if (len < 0) { // LCOV_EXCL_BR_LINE 5: klogctl's error case
+ // LCOV_EXCL_START 5: klogctl's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error. Failed to get syslog buffer size: %d, %s", errno,
+ strerror(errno));
+ // LCOV_EXCL_STOP
+ } else {
+ buf = reinterpret_cast<char*>(malloc(len));
+ if (buf != NULL) { // LCOV_EXCL_BR_LINE 5: new's error case
+ len = klogctl(SYSLOG_ACTION_READ_ALL, buf, len);
+ if ((len < 0) || (len == 0)) { // LCOV_EXCL_BR_LINE 5: klogctl's error case
+ // LCOV_EXCL_START 5: klogctl's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error. Failed to read syslog buffer: %d, %s", errno,
+ strerror(errno));
+ // LCOV_EXCL_STOP
+ } else {
+ std::string file_put_path = "";
+ EArtifactId artifact_id = eArtifactIdMaxValue;
+ switch (type) {
+ case SS_LOGGER_KLOG_GET:
+ file_put_path = KERNEL_LOG_PATH_FN;
+ artifact_id = eArtifactIdKernelLog;
+ fd = open(file_put_path.c_str(),
+ O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644);
+ break;
+ case SS_LOGGER_KBOOTLOG_CREATE:
+ file_put_path = KERNEL_BOOT_LOG_PATH_FN;
+ artifact_id = eArtifactIdKernelBootLog;
+ fd = open(file_put_path.c_str(),
+ O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644);
+ break;
+ default:
+ fd = -1;
+ break;
+ }
+
+ if (fd == -1) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error. Failed to open file: %s: %d, %s",
+ file_put_path.c_str(), errno, strerror(errno));
+ } else {
+ wr_len = write(fd, buf, len);
+ if (wr_len == -1) { // LCOV_EXCL_BR_LINE 5: write's error case
+ // LCOV_EXCL_START 5: write's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. File write failed. errno: %d, %s", errno,
+ strerror(errno));
+ // LCOV_EXCL_STOP
+ }
+ fsync(fd);
+ close(fd);
+
+ if (SS_LOGGER_KLOG_GET == type) {
+ l_eStatus = SendLogArtifactResponseToSelf(f_hApp, artifact_id,
+ file_put_path.c_str());
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ "SendLogArtifactResponseToSelf failed. EFrameworkunifiedStatus:%d, ArtifactID:%d, Path:%s",
+ l_eStatus, artifact_id, file_put_path.c_str());
+ // LCOV_EXCL_STOP
+ }
+ }
+ }
+ }
+ free(buf);
+ } else {
+ // LCOV_EXCL_START 5: new's error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Memory allocation Failed %s",
+ strerror(errno));
+ // LCOV_EXCL_STOP
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
diff --git a/logger_service/server/src/ss_logger_error_event_storage.cpp b/logger_service/server/src/ss_logger_error_event_storage.cpp
new file mode 100644
index 00000000..1bbec7cf
--- /dev/null
+++ b/logger_service/server/src/ss_logger_error_event_storage.cpp
@@ -0,0 +1,628 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// INCLUDES
+///////////////////////////////////////////////////////////////////////////////
+#include "ss_logger_error_event_storage.h"
+#include <stdlib.h>
+#include <sched.h>
+#include <string.h>
+#include <errno.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <string>
+#include "ss_logger_util.h"
+#include "ss_logger_error_event_archive.h"
+#include "ss_logger_fs_directory.h"
+#include "ss_logger_common.h"
+
+CLoggerErrorEventStorage::CLoggerErrorEventStorage()
+ : m_parentMcQueue(NULL),
+ m_thread(-1),
+ m_sendQueue(-1),
+ m_receiveQueue(-1),
+ m_destination(""),
+ m_mutexInit(-1),
+ m_pLoggerCfg(NULL),
+ m_logTime(0) {
+ m_responseVec.clear();
+ m_mqattr.mq_flags = 0;
+ m_mqattr.mq_maxmsg = 1;
+ m_mqattr.mq_msgsize = 32;
+ m_mqattr.mq_curmsgs = 0;
+}
+
+CLoggerErrorEventStorage::~CLoggerErrorEventStorage() { // LCOV_EXCL_START 14:globle instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ this->Cleanup();
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CLoggerErrorEventStorage::Initialize(HANDLE f_hApp,
+ std::string f_ParentName,
+ CLoggerCfg *f_pLoggerCfg) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ pthread_attr_t l_attr;
+ struct sched_param l_params;
+
+ /* Open the queue */
+ if (NULL == (m_pLoggerCfg = f_pLoggerCfg)) { // LCOV_EXCL_BR_LINE 200:As it is not always NULL
+ // LCOV_EXCL_START 200:As it is not always NULL
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Parameter f_pLoggerCfg is NULL.");
+ // LCOV_EXCL_STOP
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus = m_pLoggerCfg->GetLoggerStorageInfo(m_loggerStorageInfo))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. GetLoggerStorageInfo(m_loggerStorageInfo)");
+ // LCOV_EXCL_STOP
+ } else if (NULL == (m_parentMcQueue = McOpenSender(f_ParentName.c_str()))) { // LCOV_EXCL_BR_LINE 4:NSFW
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusErrOther;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. McOpenSender(f_ParentName)");
+ // LCOV_EXCL_STOP
+ } else if (-1 == (this->m_sendQueue = mq_open(m_loggerStorageInfo.Name.c_str(), O_CREAT | O_WRONLY, 0666, &m_mqattr))) { // LCOV_EXCL_BR_LINE 5:C code eror // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 5:C code eror
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusErrOther;
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. mq_open(ERROR_EVENT_STORAGE_QUEUE_NAME,O_CREAT | O_WRONLY, 0666, NULL)");
+ // LCOV_EXCL_STOP
+ } else if (-1 == (this->m_receiveQueue = mq_open(m_loggerStorageInfo.Name.c_str(), O_RDONLY))) { // LCOV_EXCL_BR_LINE 5:C code eror // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 5:C code eror
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusSessionLimitMaxedOut;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. mq_open(ERROR_EVENT_STORAGE_QUEUE_NAME,O_RDONLY)");
+ // LCOV_EXCL_STOP
+ } else if (EOK != (m_mutexInit = pthread_mutex_init(&this->m_mutex, NULL))) { // LCOV_EXCL_BR_LINE 5:C code eror
+ // LCOV_EXCL_START 5:C code eror
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. pthread_mutex_init(&this->m_mutex, NULL)");
+ // LCOV_EXCL_STOP
+ } else if (EOK != pthread_attr_init(&l_attr)) { // LCOV_EXCL_BR_LINE 5:C code eror
+ // LCOV_EXCL_START 5:C code eror
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusSemUnlockFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. pthread_attr_init()");
+ // LCOV_EXCL_STOP
+ } else if (EOK != pthread_attr_getschedparam(&l_attr, &l_params)) { // LCOV_EXCL_BR_LINE 5:C code eror
+ // LCOV_EXCL_START 5:C code eror
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusSemCloseFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. pthread_attr_getschedparam()");
+ // LCOV_EXCL_STOP
+ } else {
+ l_params.sched_priority = m_loggerStorageInfo.Priority;
+ if (EOK != pthread_attr_setinheritsched(&l_attr, PTHREAD_EXPLICIT_SCHED)) { // LCOV_EXCL_BR_LINE 5:C code eror
+ // LCOV_EXCL_START 5:C code eror
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. pthread_attr_setinheritsched()");
+ // LCOV_EXCL_STOP
+ } else if (EOK != pthread_attr_setschedparam(&l_attr, &l_params)) { // LCOV_EXCL_BR_LINE 5:C code eror
+ l_eStatus = eFrameworkunifiedStatusDbResultError;
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error but continue. pthread_attr_setschedparam(), priority = %d: %s",
+ m_loggerStorageInfo.Priority, strerror(errno)); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ if (EOK != pthread_create(&this->m_thread, &l_attr, &CLoggerErrorEventStorage::ThreadFunctionWrapper, this)) { // LCOV_EXCL_BR_LINE 5:C code eror // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 5:C code eror
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusDbRecNotFound;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. pthread_create()");
+ // LCOV_EXCL_STOP
+ } else {
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ }
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ this->Cleanup(); // LCOV_EXCL_LINE 200:To ensure success
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %d", l_eStatus);
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerErrorEventStorage::Start(
+ std::string f_target, TArtifactResponseVec f_responseVector,
+ uint32_t f_time) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ /* Start the thread*/
+ if (EOK == pthread_mutex_lock(&this->m_mutex)) { // LCOV_EXCL_BR_LINE 200:To ensure success
+ this->m_destination = f_target;
+ this->m_responseVec = f_responseVector;
+ this->m_logTime = f_time;
+ (void) pthread_mutex_unlock(&this->m_mutex);
+ }
+ UI_8 l_cmd[MAX_QUEUE_MSG_SIZE];
+ l_cmd[0] = 1;
+ if (-1 == mq_send(this->m_sendQueue, reinterpret_cast<CHAR*>(l_cmd), m_mqattr.mq_msgsize, 0)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. mq_send(this->m_sendQueue %d) return %s", m_sendQueue,
+ strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %d", l_eStatus);
+ return (l_eStatus);
+}
+
+void CLoggerErrorEventStorage::ThreadFunction(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ char l_data[MAX_QUEUE_MSG_SIZE] = { };
+ SI_32 l_bytesRead = -1;
+ SI_32 l_oldState;
+ ELoggerStorageThreadCommands l_cmdId = eLoggerStorageThreadCmdWriteFailed;
+ EFrameworkunifiedStatus l_eStatus;
+
+ (void) pthread_setname_np(pthread_self(), ERROR_EVENT_STORAGE_QUEUE_NAME);
+
+ pthread_cleanup_push(&CLoggerErrorEventStorage::CleanupWrapper, this);
+ while (-1 // LCOV_EXCL_BR_LINE 200: mq_send can not send size of -1
+ != (l_bytesRead =
+ static_cast<SI_32>(mq_receive(this->m_receiveQueue, reinterpret_cast<char *>(l_data),
+ (size_t) m_mqattr.mq_msgsize, NULL)))) {
+ std::string l_target;
+ TArtifactResponseVec l_responseVec;
+ uint32_t l_logTime;
+ uint8_t status;
+// Clock_getSystemTimeY2K38(&l_logTime, &status);
+ (void) pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &l_oldState);
+ if (EOK == pthread_mutex_lock(&this->m_mutex)) { // LCOV_EXCL_BR_LINE 5: pthread_mutex_lock's error case.
+ l_target = this->m_destination;
+ l_responseVec = this->m_responseVec;
+ l_logTime = this->m_logTime;
+ this->m_responseVec.clear();
+ this->m_destination = "";
+
+ (void) pthread_mutex_unlock(&this->m_mutex);
+ }
+ (void) pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &l_oldState);
+ if (access(l_target.c_str(), F_OK) == 0) {
+ if (CFSDirectory::IsDirectory(l_target)) { // LCOV_EXCL_BR_LINE 6: can not be a dir
+ // LCOV_EXCL_START 6: new file create, it can not be find
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ BOOL isDeleteFiles = FALSE;
+ SI_32 l_filesCopied = this->CopyFiles(l_target, l_responseVec,
+ isDeleteFiles);
+
+ switch (l_filesCopied) {
+ case -1:
+ /*Error while moving files*/
+ l_cmdId = eLoggerStorageThreadCmdWriteFailed;
+ break;
+ case 0:
+ /*No files where moved*/
+ l_cmdId = eLoggerStorageThreadCmdNoWritten;
+ break;
+ default:
+ if (l_filesCopied > 0) {
+ l_cmdId = eLoggerStorageThreadCmdOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Info. %d files successfully copied.", l_filesCopied);
+ }
+ break;
+ }
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = this->PackageAndPlaceArtifacts(l_target,
+ l_responseVec,
+ l_logTime))) {
+ /*Write Error.*/
+ l_cmdId = eLoggerStorageThreadCmdWriteFailed;
+ } else {
+ l_cmdId = eLoggerStorageThreadCmdOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Info. Archive successfully written.");
+ }
+ if (eFrameworkunifiedStatusOK != RemoveDeprecatedArtifacts(l_responseVec)) {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_WARN, __FUNCTION__,
+ " Warning. Wasn't able to delete all deprecated log artifacts.");
+ }
+ }
+
+ std::string l_usb_path;
+ size_t l_usb_path_length = 0;
+ if (m_pLoggerCfg != NULL) { // LCOV_EXCL_BR_LINE 6: m_pLoggerCfg can not be null
+ l_usb_path = m_pLoggerCfg->getUsb0MountPath();
+ l_usb_path_length = l_usb_path.length();
+ if ((l_usb_path_length > 1)
+ && (l_usb_path[l_usb_path.length() - 1] == '/')) {
+ l_usb_path_length--;
+ }
+ }
+ if ((l_usb_path_length > 0)
+ && (l_target.compare(0, l_usb_path_length, l_usb_path, 0,
+ l_usb_path_length) != 0)) {
+ l_usb_path_length = 0;
+ }
+ if ((l_usb_path_length == 0)
+ && (l_target.compare(0, sizeof(DEBUG_USB_PATH) - 1, DEBUG_USB_PATH, 0,
+ sizeof(DEBUG_USB_PATH) - 1) == 0)) {
+ l_usb_path = DEBUG_USB_PATH;
+ l_usb_path_length = sizeof(DEBUG_USB_PATH) - 1;
+ }
+ if (l_usb_path_length > 1) { // if USB path is '/' only, length is 1.
+ // So conditions to be syncfs is greater than 1
+ // sync usb device
+ DIR* l_dirp = opendir(l_usb_path.c_str());
+ if (l_dirp != NULL) { // LCOV_EXCL_BR_LINE 5: c code error case
+ int fd = dirfd(l_dirp);
+ if (fd != -1) { // LCOV_EXCL_BR_LINE 5: c code error case
+ if (syncfs(fd) == -1) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. syncfs failed path=%s [%s]", l_usb_path.c_str(),
+ strerror(errno));
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. syncfs get fd failed path=%s, [%s]",
+ l_usb_path.c_str(), strerror(errno));
+ }
+ closedir(l_dirp);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. syncfs opendir failed path=%s, [%s]",
+ l_usb_path.c_str(), strerror(errno));
+ }
+ {
+#define USB_MEMORY_SYNC_WAITTIME 8 // 8 sec
+ const struct timespec intval = { USB_MEMORY_SYNC_WAITTIME, 0 };
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "%d sec:Waiting for USB Memory Synchronization.(%s)",
+ USB_MEMORY_SYNC_WAITTIME, l_usb_path.c_str());
+ nanosleep(&intval, NULL);
+ }
+ }
+ if (eFrameworkunifiedStatusOK
+ != McSend(this->m_parentMcQueue, m_loggerStorageInfo.Name.c_str(),
+ l_cmdId, 0, NULL)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. McSend(this->m_parentMcQueue)");
+ }
+ }
+ pthread_cleanup_pop(1);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+void CLoggerErrorEventStorage::Cleanup(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ if (-1 != this->m_receiveQueue) { // LCOV_EXCL_BR_LINE 200: m_receiveQueue cam not be -1
+ if (-1 == mq_close(this->m_receiveQueue)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. mq_close()");
+ }
+ this->m_receiveQueue = -1;
+ }
+ if (-1 != this->m_sendQueue) { // LCOV_EXCL_BR_LINE 200: m_sendQueue cam not be -1
+ if (-1 == mq_close(this->m_sendQueue)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. mq_close()");
+ }
+ this->m_sendQueue = -1;
+ if (-1 == mq_unlink(m_loggerStorageInfo.Name.c_str())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. mq_unlink()");
+ }
+ }
+
+ if (-1 != m_mutexInit) { // LCOV_EXCL_BR_LINE 200: m_mutexInit cam not be -1
+ if (EOK != pthread_mutex_destroy(&this->m_mutex)) { // LCOV_EXCL_BR_LINE 5: c code error case
+ // LCOV_EXCL_START 5: c code error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. mq_unlink()");
+ // LCOV_EXCL_STOP
+ }
+ m_mutexInit = -1;
+ }
+
+ if (NULL != m_parentMcQueue) { // LCOV_EXCL_BR_LINE 200: m_parentMcQueue cam not be null
+ if (eFrameworkunifiedStatusOK != McClose(m_parentMcQueue)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. McClose()");
+ }
+ this->m_parentMcQueue = NULL;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+void* CLoggerErrorEventStorage::ThreadFunctionWrapper(void* param) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ CLoggerErrorEventStorage* l_pObj =
+ reinterpret_cast<CLoggerErrorEventStorage *>(param);
+
+ l_pObj->ThreadFunction();
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return NULL;
+}
+
+void CLoggerErrorEventStorage::CleanupWrapper(void* param) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ CLoggerErrorEventStorage* l_pObj =
+ reinterpret_cast<CLoggerErrorEventStorage *>(param);
+
+ l_pObj->Cleanup();
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Function : PackageAndPlaceArtifacts
+// brief : This function creates an archive for all collected artifacts
+// and places the archive in the required location depending
+// on the event type and required naming criteria.
+///////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerErrorEventStorage::PackageAndPlaceArtifacts(
+ std::string f_archiveDestination, TArtifactResponseVec &f_responseVector,
+ uint32_t f_logTime) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ std::string l_coreFileName = "";
+ SI_32 l_ret = 0;
+
+ if (f_archiveDestination.size() == 0) {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. Unknown package file path and name. Logging artifacts not stored!");
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ CErrorEventArchive l_archiver;
+ l_eStatus = l_archiver.openArchive(f_archiveDestination);
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 6: it can not be fail
+ // LCOV_EXCL_START 6: it can not be fail
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. Failed to create logging archive: %s. Log archive will not be stored!",
+ f_archiveDestination.c_str());
+ // LCOV_EXCL_STOP
+ } else {
+ for (UI_32 i = 0; (i < f_responseVector.size()); i++) {
+ if (f_responseVector[i].Filepath != std::string("")) {
+ std::string l_destName = f_responseVector[i].Filepath;
+
+ if ((f_responseVector[i].Filepath.find(".bmp") // LCOV_EXCL_BR_LINE 200: no bmp file be set
+ == f_responseVector[i].Filepath.find_last_of('.'))
+ && (f_responseVector[i].Filepath.find(".bmp")
+ != std::string::npos)) {
+ // LCOV_EXCL_START 200: no bmp file be set
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ char buffer[20];
+ struct tm local_time;
+// Clock_getLocalTimeY2K38(&f_logTime, &local_time);
+ if (0
+ != strftime(buffer, sizeof(buffer), "%Y%m%d%H%M%S.bmp",
+ &local_time)) {
+ l_destName = buffer;
+ }
+ // LCOV_EXCL_STOP
+ } else {
+ l_destName = f_responseVector[i].Filepath.substr(
+ f_responseVector[i].Filepath.find_last_of('/') + 1);
+ }
+ if (f_responseVector[i].ArtifactId == eArtifactIdPstoreLog) { // LCOV_EXCL_BR_LINE 200: can not be eArtifactIdPstoreLog // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_destName = KERNEL_LOG_PATH_DIR; // LCOV_EXCL_LINE 200: can not be eArtifactIdPstoreLog
+ }
+ l_eStatus = l_archiver.addToArchive(f_responseVector[i].Filepath,
+ l_destName);
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 200: can not be fail
+ // LCOV_EXCL_START 200: can not be fail
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. Failed to add artifact: %s to archive %s. Continuing with next artifact.",
+ f_responseVector[i].Filepath.c_str(),
+ f_archiveDestination.c_str());
+ // LCOV_EXCL_STOP
+ }
+ l_ret++;
+ if ((l_ret % m_loggerStorageInfo.TimeoutAfter) == 0) {
+ usleep(m_loggerStorageInfo.Timeout);
+ }
+ }
+ }
+
+ if (eFrameworkunifiedStatusOK != l_archiver.closeArchive()) { // LCOV_EXCL_BR_LINE 200: closeArchive can not be fail
+ // LCOV_EXCL_START 200: closeArchive can not be fail
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. l_archiver.closeArchive()");
+ // LCOV_EXCL_STOP
+ } else {
+ // Cleanup artifacts that are no longer required.
+ int rc = access(f_archiveDestination.c_str(), F_OK);
+ if (0 != rc) { // LCOV_EXCL_BR_LINE 5: f_archiveDestination is aways exist
+ // LCOV_EXCL_START 5: f_archiveDestination is aways exist
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Archive verification failed. Errno: %d, %s.", errno,
+ strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ } else {
+ TEXT(__FUNCTION__,
+ " Error Event: A archive successfully written to: %s.",
+ f_archiveDestination.c_str());
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////
+/// File Copy
+/// arg:
+/// isDeleteFiles : TRUE - delete original files after copy.
+/// FALSE - not delete after copy.
+/// returns:
+/// -1: error while writing
+/// else, number of files written
+///////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////
+// LCOV_EXCL_START 8: can not be called
+SI_32 CLoggerErrorEventStorage::CopyFiles(
+ std::string f_destination, TArtifactResponseVec &f_responseVector,
+ BOOL isDeleteFiles) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ SI_32 l_ret = 0;
+ BOOL l_isFaile = FALSE;
+ for (UI_32 i = 0; i < f_responseVector.size(); i++) {
+ if (f_responseVector[i].Filepath != "") {
+ if (CFSDirectory::IsDirectory(f_responseVector[i].Filepath)) {
+ DIR * l_pDir = opendir(f_responseVector[i].Filepath.c_str());
+ if (l_pDir == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Could not open directory: %s",
+ f_responseVector[i].Filepath.c_str());
+ } else {
+ struct dirent l_pDirent;
+ struct dirent* next;
+ while (0 == readdir_r(l_pDir, &l_pDirent, &next) && next != NULL) {
+ if ((0 != strcmp(l_pDirent.d_name, ".")) && /* Ignore special . directory. */
+ (0 != strcmp(l_pDirent.d_name, "..")) && /* Ignore special .. directory. */
+ (0 != strcmp(l_pDirent.d_name, "lost+found")) && /* Ignore lost+found. */
+ ('.' != l_pDirent.d_name[0])) { /* Ignore hidden files */
+ std::string l_fileSource = f_responseVector[i].Filepath;
+ std::string l_fileDestination = f_destination;
+ l_fileSource.append("/");
+ l_fileSource.append(l_pDirent.d_name);
+ l_fileDestination.append("/");
+ l_fileDestination.append(l_pDirent.d_name);
+ EFrameworkunifiedStatus loggerserviceRet = eFrameworkunifiedStatusOK;
+ if (isDeleteFiles == TRUE) {
+ loggerserviceRet = CLoggerUtil::MoveUntyped(l_fileSource,
+ l_fileDestination);
+ } else {
+ loggerserviceRet = CLoggerUtil::CopyUntyped(l_fileSource,
+ l_fileDestination);
+ }
+
+ if (eFrameworkunifiedStatusOK == loggerserviceRet) {
+ l_ret++;
+ if ((l_ret % m_loggerStorageInfo.TimeoutAfter) == 0) {
+ usleep(m_loggerStorageInfo.Timeout);
+ }
+ } else {
+ l_isFaile = TRUE;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Could not move: %s",
+ l_fileSource.c_str());
+ }
+ }
+ }
+ (void) closedir(l_pDir);
+ }
+ } else {
+ std::string l_filename = f_responseVector[i].Filepath.substr(
+ f_responseVector[i].Filepath.find_last_of('/'));
+ std::string l_destination = std::string(f_destination).append(
+ l_filename);
+ if (eFrameworkunifiedStatusOK
+ == CLoggerUtil::MoveUntyped(f_responseVector[i].Filepath,
+ l_destination)) {
+ l_ret++;
+ if ((l_ret % m_loggerStorageInfo.TimeoutAfter) == 0) {
+ usleep(m_loggerStorageInfo.Timeout);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Could not move: %s",
+ f_responseVector[i].Filepath.c_str());
+ l_isFaile = TRUE;
+ }
+ }
+ }
+ }
+ if (l_isFaile)
+ l_ret = -1;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_ret);
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CLoggerErrorEventStorage::RemoveDeprecatedArtifacts(
+ TArtifactResponseVec &f_responseVector) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ BOOL l_success = TRUE;
+ for (UI_32 i = 0; i < f_responseVector.size(); i++) {
+ if ((f_responseVector[i].Filepath != "")
+ && (TRUE == f_responseVector[i].Remove)) {
+ if (CFSDirectory::IsDirectory(f_responseVector[i].Filepath)) {
+ if (TRUE
+ != CFSDirectory::RemoveDirectory(f_responseVector[i].Filepath)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Warning. Directory %s failed to be deleted.",
+ f_responseVector[i].Filepath.c_str());
+ l_success &= FALSE;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Info. Directory %s has been successfully deleted.",
+ f_responseVector[i].Filepath.c_str());
+ }
+
+ } else {
+ errno = 0;
+ if (0 != remove(f_responseVector[i].Filepath.c_str())) { // LCOV_EXCL_BR_LINE 5: c code error case
+ // LCOV_EXCL_START 5: c code error case
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (errno == ENOENT) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Info. %s not available. Skipping file deletion.",
+ f_responseVector[i].Filepath.c_str());
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
+ " Warning. File %s failed to be deleted.",
+ f_responseVector[i].Filepath.c_str());
+ l_success &= FALSE;
+ }
+ errno = 0;
+ // LCOV_EXCL_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Info. File %s has been successfully deleted.",
+ f_responseVector[i].Filepath.c_str());
+ }
+ }
+ }
+ }
+ l_eStatus = (l_success == TRUE) ? eFrameworkunifiedStatusOK : eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
diff --git a/logger_service/server/src/ss_logger_fs_directory.cpp b/logger_service/server/src/ss_logger_fs_directory.cpp
new file mode 100644
index 00000000..6228f265
--- /dev/null
+++ b/logger_service/server/src/ss_logger_fs_directory.cpp
@@ -0,0 +1,236 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief This file contains declaration of class CFSDirectory.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "ss_logger_fs_directory.h"
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <string>
+#include "loggerservicedebug_loggerservicelog.h"
+#include "ss_logger_types.h"
+#include "ss_logger_util.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CFSDirectory
+/// Constructor of CFSDirectory class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CFSDirectory::CFSDirectory() { // LCOV_EXCL_START 14:static instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CFSDirectory
+/// Destructor of CFSDirectory class
+////////////////////////////////////////////////////////////////////////////////////////////////////
+CFSDirectory::~CFSDirectory() { // LCOV_EXCL_START 14:static instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// CreateDirectory
+/// Method to create a directory.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CFSDirectory::CreateDirectory(std::string &f_cDirPath) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (!f_cDirPath.empty()) { // LCOV_EXCL_BR_LINE 6: f_cDirPath is aways not empty
+ PSTR l_cTempDirPath;
+ PSTR l_cParsedDirPath;
+ PCSTR l_cCopypath = f_cDirPath.c_str();
+
+ l_cTempDirPath = const_cast<PSTR>(f_cDirPath.c_str());
+ while (l_eStatus == eFrameworkunifiedStatusOK
+ && (l_cParsedDirPath = std::strchr(l_cTempDirPath, '/')) != 0) {
+ if (l_cParsedDirPath != l_cTempDirPath) {
+ /* Neither root nor double slash in path */
+ *l_cParsedDirPath = '\0';
+ if (0
+ != mkdir(l_cCopypath,
+ S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
+ if (EEXIST != errno) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error Cannot Create directory %s",
+ l_cCopypath);
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ // file already exist
+ }
+ }
+ *l_cParsedDirPath = '/';
+ }
+ l_cTempDirPath = l_cParsedDirPath + 1;
+ }
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ if (0
+ != mkdir(l_cCopypath,
+ S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
+ if (EEXIST != errno) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error Cannot Create directory %s",
+ l_cCopypath);
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ // file already exist
+ }
+ }
+ }
+ } else {
+ // LCOV_EXCL_START 6: f_cDirPath is aways not empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "String Empty.");
+ l_eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// DoesDirectoryExist
+/// Method to check if a directory exists.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CFSDirectory::DoesDirectoryExist(std::string &f_cDirPath) {
+ DIR* l_pDirDescriptor = opendir(f_cDirPath.c_str());
+ if (NULL != l_pDirDescriptor) {
+ closedir(l_pDirDescriptor);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// IsDirectory
+/// Method to check if the entity is a directory.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CFSDirectory::IsDirectory(std::string &f_cPath) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ BOOL l_bReturn = FALSE;
+
+ if (!f_cPath.empty()) { // LCOV_EXCL_BR_LINE 6: f_cPath can not be empty
+ struct stat st_buf;
+ if (-1 == stat(f_cPath.c_str(), &st_buf)) { // LCOV_EXCL_BR_LINE 5: c code.
+ // LCOV_EXCL_START 5: c code.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Error: stat failed for path/file %s, errno %d", f_cPath.c_str(),
+ errno);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ l_bReturn = FALSE;
+ return l_bReturn;
+ // LCOV_EXCL_STOP
+ }
+
+ // Get the status of the file
+ if (S_ISREG(st_buf.st_mode)) {
+ l_bReturn = FALSE; // return false if f_cPath is a regular file
+ }
+ if (S_ISDIR(st_buf.st_mode)) {
+ l_bReturn = TRUE; // return true if f_cPath is a directory
+ }
+ } else {
+ // LCOV_EXCL_START 6: f_cPath can not be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Pathname empty.");
+ l_bReturn = FALSE;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_bReturn;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// RemoveDirectory
+/// Method to remove a directory.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CFSDirectory::RemoveDirectory(std::string &f_cPath) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ BOOL l_bReturn = FALSE;
+
+ if (RemoveSubDirectory(f_cPath)) {
+ // delete the parent directory
+ if (0 == rmdir(f_cPath.c_str())) { // LCOV_EXCL_BR_LINE 5: c code error case
+ l_bReturn = TRUE;
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_bReturn;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// RemoveSubDirectory
+/// Method to remove a sub directory.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+BOOL CFSDirectory::RemoveSubDirectory(std::string &f_cPath) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ BOOL l_bReturn = TRUE;
+
+ if (!f_cPath.empty()) { // LCOV_EXCL_BR_LINE 6: f_cPath can not be empty
+ std::string l_cFilePath = "";
+
+ struct dirent l_Dirent;
+ struct dirent* next;
+ DIR *l_pDir = NULL;
+
+ l_pDir = opendir(f_cPath.c_str());
+ if (NULL != l_pDir) { // LCOV_EXCL_BR_LINE 5: c code.
+ if ('/' != f_cPath[f_cPath.length() - 1]) {
+ f_cPath.append("/");
+ }
+
+ while (0 == readdir_r(l_pDir, &l_Dirent, &next) && next != NULL) {
+ if (0 != std::strcmp(l_Dirent.d_name, ".")
+ && 0 != std::strcmp(l_Dirent.d_name, "..")
+ && 0 != std::strcmp(l_Dirent.d_name, "lost+found")) {
+ l_cFilePath.assign(f_cPath);
+ l_cFilePath.append(l_Dirent.d_name); // concatenate the strings to get the complete f_cPath
+
+ if (TRUE == IsDirectory(l_cFilePath)) {
+ l_bReturn = RemoveDirectory(l_cFilePath);
+ } else {
+ // it's a file, we can use unlink
+ if (unlink(l_cFilePath.c_str()) == -1) {
+ l_bReturn = FALSE;
+ }
+ }
+ }
+ }
+ closedir(l_pDir); // close the directory
+ CLoggerUtil::SyncDir(f_cPath);
+ } else {
+ // LCOV_EXCL_START 5: c code.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "l_pDir is NULL");
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 6: f_cPath can not be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Pathname empty.");
+ l_bReturn = FALSE;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_bReturn;
+}
diff --git a/logger_service/server/src/ss_logger_popups.cpp b/logger_service/server/src/ss_logger_popups.cpp
new file mode 100644
index 00000000..54170dcd
--- /dev/null
+++ b/logger_service/server/src/ss_logger_popups.cpp
@@ -0,0 +1,176 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// INCLUDES
+///////////////////////////////////////////////////////////////////////////////
+#include "ss_logger_popups.h"
+#include <string>
+#include <vector>
+CLoggerPopups::CLoggerPopups()
+ : m_pLoggerCfg(NULL),
+ m_startShown(FALSE) {
+}
+
+CLoggerPopups::~CLoggerPopups() { // LCOV_EXCL_START 14:globle instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CLoggerPopups::Initialize(CLoggerCfg* f_pLoggerCfg) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ this->m_pLoggerCfg = f_pLoggerCfg;
+ l_eStatus = (m_pLoggerCfg == NULL) ? eFrameworkunifiedStatusNullPointer : eFrameworkunifiedStatusOK;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+BOOL CLoggerPopups::IsPopupNeeded(TLoggerErrorEvent f_event) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ BOOL l_ret = ((f_event.EventBitMask & EVENT_BIT_POPUP) != 0) ? TRUE : FALSE;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_ret);
+}
+
+BOOL CLoggerPopups::CanShowStartPopup(
+ std::vector<TLoggingArtifact>* f_remainingArtifact) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ BOOL l_ret = FALSE;
+ if (f_remainingArtifact != NULL) {
+ l_ret = TRUE;
+ std::vector<TLoggingArtifact>::iterator l_iter;
+ for (l_iter = f_remainingArtifact->begin();
+ f_remainingArtifact->end() != l_iter; l_iter++) {
+ if (l_iter->ArtifactId == eArtifactIdScreenShot) {
+ l_ret = FALSE;
+ break;
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_ret);
+}
+
+std::string CLoggerPopups::getDeviceName(std::string f_dest) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ std::string l_ret = "";
+ if (f_dest.length() == 0) {
+ } else if (f_dest.find(this->m_pLoggerCfg->m_usb0MountPath) != std::string::npos) {
+ l_ret = "USB 1";
+ } else if (f_dest.find(this->m_pLoggerCfg->m_usb1MountPath) != std::string::npos) {
+ l_ret = "USB 2";
+ } else if (f_dest.find(this->m_pLoggerCfg->m_sdMountPath) != std::string::npos) {
+ l_ret = "SD card";
+ } else if (f_dest.find(this->m_pLoggerCfg->m_emmcOutputPath)
+ != std::string::npos) {
+ l_ret = "Emmc";
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. No matching Path found for %s",
+ f_dest.c_str());
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %s", l_ret.c_str());
+ return (l_ret);
+}
+
+EFrameworkunifiedStatus CLoggerPopups::ShowStartPopup(
+ HANDLE f_hApp, TLoggerErrorEvent f_event,
+ std::vector<TLoggingArtifact>* f_remainingArtifact, std::string f_dest) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ if (this->m_startShown != FALSE) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Pop up already shown");
+ } else if (TRUE != IsPopupNeeded(f_event)) {
+ this->m_startShown = TRUE;
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Start pop up not needed for event %d.",
+ f_event.EventType);
+ } else if (TRUE != CanShowStartPopup(f_remainingArtifact)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Screenshot still in artifact vector.");
+ } else {
+ this->m_startShown = TRUE;
+ STLoggerFolderInfo l_folderInfo;
+ l_folderInfo.FoldernameAndLogname[0] = '\0';
+ std::string l_dest = this->getDeviceName(f_dest);
+ std::size_t l_len = l_dest.copy(l_folderInfo.StorageTarget,
+ sizeof(l_folderInfo.StorageTarget) - 1u, 0);
+ l_folderInfo.StorageTarget[l_len] = '\0';
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Info. Show start pop up. Destination: %s",
+ l_folderInfo.StorageTarget);
+ l_eStatus = FrameworkunifiedPublishEvent(f_hApp, SS_LOGGER_LOGSTARTED_EVT,
+ NULL,
+ &l_folderInfo, sizeof(l_folderInfo));
+
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "FrameworkunifiedPublishEvent(SS_LOGGER_LOGSTARTED_EVT)");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerPopups::ShowEndPopup(HANDLE f_hApp, TLoggerErrorEvent f_event,
+ std::string f_dest) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ this->m_startShown = FALSE;
+ if (TRUE != IsPopupNeeded(f_event)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Info. No pop up needed at end of Logging.");
+ } else {
+ STLoggerFolderInfo l_folderInfo;
+ std::size_t l_len = f_dest.copy(
+ l_folderInfo.FoldernameAndLogname,
+ sizeof(l_folderInfo.FoldernameAndLogname) - 1u,
+ f_dest.find_last_of('/') + 1);
+ l_folderInfo.FoldernameAndLogname[l_len] = '\0';
+
+ std::string l_dest = this->getDeviceName(f_dest);
+ l_len = l_dest.copy(l_folderInfo.StorageTarget,
+ sizeof(l_folderInfo.StorageTarget) - 1, 0);
+ l_folderInfo.StorageTarget[l_len] = '\0';
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Info. Show end pop up. Filepath: %s, Device: %s",
+ l_folderInfo.FoldernameAndLogname, l_folderInfo.StorageTarget);
+ l_eStatus = FrameworkunifiedPublishEvent(f_hApp, SS_LOGGER_LOGINFO_EVT,
+ NULL,
+ &l_folderInfo, sizeof(l_folderInfo));
+
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedPublishEvent(SS_LOGGER_LOGINFO_EVT)");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerPopups::ShowErrorPopup(HANDLE f_hApp,
+ TLoggerErrorEvent f_event,
+ UI_16 f_errCode) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_16 l_errorcode = (UI_16) f_errCode;
+ this->m_startShown = FALSE;
+ if (IsPopupNeeded(f_event) == TRUE) {
+ l_eStatus = FrameworkunifiedPublishEvent(f_hApp, SS_LOGGER_ERRORINFO_EVT,
+ NULL,
+ &l_errorcode, sizeof(l_errorcode));
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedPublishEvent(SS_LOGGER_ERRORINFO_EVT)");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
diff --git a/logger_service/server/src/ss_logger_reader_writer_control.cpp b/logger_service/server/src/ss_logger_reader_writer_control.cpp
new file mode 100644
index 00000000..b6b6b7e7
--- /dev/null
+++ b/logger_service/server/src/ss_logger_reader_writer_control.cpp
@@ -0,0 +1,151 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * ss_logger_reader_writer_control.cpp
+ */
+#include "ss_logger_reader_writer_control.h"
+#include <boost/bind.hpp>
+#include <native_service/ns_sharedmem.h>
+#include <native_service/ns_transmit_log.h>
+#include <native_service/ns_logger_if.h>
+#include <string>
+#include "ss_logger_common.h"
+
+#define LOGGERSERVICELOG_REMOTE_IP_PORT 3500
+#define TRANSMIT_REMOTE_IP_PORT 3500
+
+CReaderWriterControl::CReaderWriterControl()
+ : m_pLoggerCfg(NULL) { // LCOV_EXCL_BR_LINE 11:Unexpected branch
+}
+
+CReaderWriterControl::~CReaderWriterControl() { // LCOV_EXCL_START 14:globle instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CReaderWriterControl::Initialize(CLoggerCfg * f_pLoggerCfg) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ if (NULL != f_pLoggerCfg) { // LCOV_EXCL_BR_LINE 200:As it is not always NULL
+ this->m_pLoggerCfg = f_pLoggerCfg;
+
+ l_eStatus = m_debugReaderWriter.Initialize( // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ f_pLoggerCfg, ReaderWriter::eReaderWriterTypeMem, std::string(FRAMEWORKUNIFIEDLOG_SHAREDMEM_NAME),
+ FRAMEWORKUNIFIEDLOG_SHAREDMEM_SIZE, ReaderWriter::eReaderWriterTypeUdp,
+ std::string("169.254.80.9"), LOGGERSERVICELOG_REMOTE_IP_PORT, "", 0); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ if (eFrameworkunifiedStatusOK == l_eStatus) { // LCOV_EXCL_BR_LINE 200:To ensure success
+ l_eStatus = m_debugReaderWriter.Start(std::string("pdg.LogQueR"));
+ }
+
+ LOG_STATUS_IF_ERRORED( // LCOV_EXCL_BR_LINE 15:macro
+ l_eStatus, "m_debugReaderWriter.Start(std::string(pdg.TransQueR)");
+
+
+ l_eStatus = m_transmitReaderWriter.Initialize( // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ f_pLoggerCfg, ReaderWriter::eReaderWriterTypeMem,
+ std::string(TRANSMIT_LOG_SHAREDMEM_NAME), TRANSMIT_LOG_SHAREDMEM_SIZE,
+ ReaderWriter::eReaderWriterTypeUdp, std::string("169.254.80.9"),
+ TRANSMIT_REMOTE_IP_PORT, "", 0); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ if (eFrameworkunifiedStatusOK == l_eStatus) { // LCOV_EXCL_BR_LINE 6:it can not be fail
+ l_eStatus = m_transmitReaderWriter.Start(std::string("pdg.TransQueR")); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ }
+
+ LOG_STATUS_IF_ERRORED( // LCOV_EXCL_BR_LINE 15:macro
+ l_eStatus, "m_transmitReaderWriter.Start(std::string(pdg.TransQueR)");
+
+
+ l_eStatus = m_performanceReaderWriter.Initialize( // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ f_pLoggerCfg, ReaderWriter::eReaderWriterTypeQueue, std::string("/NSplog"), 0,
+ ReaderWriter::eReaderWriterTypeFile, std::string(PERFORMANCE_LOG_PATH_FN),
+ f_pLoggerCfg->m_performanceLogMaxFileSize, std::string("169.254.80.9"),
+ 0); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+
+ if (eFrameworkunifiedStatusOK == l_eStatus) { // LCOV_EXCL_BR_LINE 6:it can not be fail
+ l_eStatus = m_performanceReaderWriter.Start(
+ std::string("pdg.PerformQueR")); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ }
+
+ LOG_STATUS_IF_ERRORED( // LCOV_EXCL_BR_LINE 15:macro
+ l_eStatus,
+ "m_performanceReaderWriter.Start(std::string(pdg.PerformQueR)");
+
+
+ this->m_pLoggerCfg->AddLoggingParamCB(
+ boost::bind(&CReaderWriterControl::UpdateLoggingParams, this, _1));
+ }
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CReaderWriterControl::UpdateLoggingParams(void* param) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ l_eStatus = this->m_debugReaderWriter.UpdateLoggingParameters();
+ LOG_STATUS_IF_ERRORED(l_eStatus, // LCOV_EXCL_BR_LINE 15:macro
+ "this->m_debugReaderWriter.UpdateLoggingParameters()");
+
+ l_eStatus = this->m_transmitReaderWriter.UpdateLoggingParameters();
+ LOG_STATUS_IF_ERRORED( // LCOV_EXCL_BR_LINE 15:macro
+ l_eStatus, "this->m_transmitReaderWriter.UpdateLoggingParameters()");
+
+ l_eStatus = this->m_performanceReaderWriter.UpdateLoggingParameters();
+ LOG_STATUS_IF_ERRORED( // LCOV_EXCL_BR_LINE 15:macro
+ l_eStatus,
+ "this->m_performanceReaderWriter."
+ "UpdateLoggingParameters()");
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "- : %d", l_eStatus);
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CReaderWriterControl::FlushCache(EReaderWriterType f_type) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldParam;
+ switch (f_type) { // LCOV_EXCL_BR_LINE 8: eReaderWriterLogDebug and eReaderWriterLogInvalid can not be called
+ // LCOV_EXCL_START 8: dead code
+ case eReaderWriterLogDebug:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = this->m_debugReaderWriter.FlushCache(
+ std::string(DEBUG_LOG_PATH_FN));
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus, "this->m_debugReaderWriter.FlushCache(DEBUG_LOG_PATH_FN)");
+ break;
+ // LCOV_EXCL_STOP
+ case eReaderWriterLogTransmit:
+ l_eStatus = this->m_transmitReaderWriter.FlushCache(
+ std::string(TRANSMIT_LOG_PATH_FN));
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "this->m_debugReaderWriter.FlushCache(TRANSMIT_LOG_PATH_FN)");
+ break;
+
+ case eReaderWriterLogPerformance:
+ l_eStatus = this->m_performanceReaderWriter.FlushCache(
+ std::string(PERFORMANCE_LOG_PATH_FN));
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "this->m_debugReaderWriter.FlushCache(PERFORMANCE_LOG_PATH_FN)");
+ break;
+ // LCOV_EXCL_START 8: dead code
+ case eReaderWriterLogInvalid:
+ default:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ break;
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "- : %d", l_eStatus);
+ return (l_eStatus);
+}
+
diff --git a/logger_service/server/src/ss_logger_server_callbacks.cpp b/logger_service/server/src/ss_logger_server_callbacks.cpp
new file mode 100644
index 00000000..2cdf12cf
--- /dev/null
+++ b/logger_service/server/src/ss_logger_server_callbacks.cpp
@@ -0,0 +1,900 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief This file contains the callback for Notifications and Protocol
+/// commands.
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "ss_logger_service_callbacks.h"
+#include <string.h>
+#include <boost/bind.hpp>
+#include <errno.h>
+#include <native_service/frameworkunified_framework_if.h>
+#include <native_service/frameworkunified_multithreading.h>
+#include <system_service/ss_logger_service.h>
+#include <ss_logger_common.h>
+#include <system_service/ss_logger_service_notifications.h>
+#include <system_service/ss_logger_service_protocol.h>
+#include <native_service/ns_config_parser_if.h>
+#include <native_service/nslogutil_cmd_if.h>
+#include <system_service/ss_sm_client_if.h>
+#include <queue>
+#include <new>
+#include <string>
+#include "ss_logger_error_event.h"
+#include "loggerservicedebug_loggerservicelog.h"
+#include "loggerservicedebug_thread_if.h"
+extern CErrorEvent g_errorEventHandler;
+extern HANDLE g_thrdEvntLogWriter;
+
+// Global variables
+STCanCurrentDateTime g_stDateAndTime = { 0 };
+UEvtLoggerCommonInfo g_uEvtLoggerCommonInfo;
+UI_16 g_u16DiagId = 0;
+
+CLoggerServiceCallbacks::CLoggerServiceCallbacks()
+ : m_pLoggerCfg(NULL),
+ m_pErrorEvent(NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FrameworkunifiedProtocolCallbackHandler l_protocolHandlers[kNUMBER_PROTOCOL_HANDLERS] =
+ { { SS_LOGGER_MILEAGE_DATA, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_SetMileageData, this, _1) },
+ { SS_LOGGER_SET_PARAMS, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_SetLoggerParams, this, _1) },
+ { SS_LOGGER_UDP_LOGGING, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_UDPLogging, this, _1) },
+ { SS_LOGGERCOPYEVENTUSB, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_OnCopyEvntLog, this,_1) },
+ { SS_LOGGERCLEAREVENT, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_OnClearEvntLog, this, _1) },
+ { SS_LOGGER_READ_STATL_COUNTER, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_OnReadStatCounter, this, _1) },
+ { SS_LOGGER_EVENT_COMMONINFO, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_UpdateCommonInfo, this, _1) },
+ { SS_LOGGER__CWORD56__EVENT_INFO, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_Handle_CWORD56_Events, this, _1) },
+ { SS_LOGGER_RESET_STATL_COUNTER, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_OnResetStatCounter, this, _1) },
+ { SS_LOGGER_SET_VIN, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_OnSetVIN, this, _1) },
+ { SS_LOGGERCOPYEMERGENCYLOGS, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_OnCopyEmergencyLog, this, _1) },
+ { eSSLoggerCANProtocolIDCANTrigger, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_OnCANTrigger, this, _1) },
+ { eSSLoggerCANProtocolIDDTCTrigger, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_OnDTCTrigger, this, _1) },
+ { SS_LOGGER_SHUTDOWN_COMPLETE, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_On_SHTDWN_Complete, this, _1) },
+ { SS_LOGGER_ENG_READ_NUMOFEVENTS, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_OnReadNumberOfEvents, this, _1) },
+ { SS_LOGGER_SET_DIAGID, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_OnSetDiagID, this, _1) },
+ { SS_LOGGER_UPLOAD_EVENTLOG, boost::bind(
+ &CLoggerServiceCallbacks::LoggerServer_UploadEventLog, this, _1) } }; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+
+ for (UI_8 i = 0u; i < kNUMBER_PROTOCOL_HANDLERS; i++) {
+ m_protocolHandlers[i].iCmd = l_protocolHandlers[i].iCmd;
+ m_protocolHandlers[i].callBack = l_protocolHandlers[i].callBack; // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+CLoggerServiceCallbacks::~CLoggerServiceCallbacks() { // LCOV_EXCL_START 14:globle instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CLoggerServiceCallbacks::Initialize(HANDLE f_hApp,
+ CLoggerCfg *f_pLoggerCfg,
+ CErrorEvent* f_pErrorEvent) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ m_pLoggerCfg = f_pLoggerCfg;
+ m_pErrorEvent = f_pErrorEvent;
+
+ if ((NULL == m_pLoggerCfg) || (NULL == m_pErrorEvent)) { // LCOV_EXCL_BR_LINE 200:As it is always TRUE
+ // LCOV_EXCL_START 200:As it is always TRUE
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "NULL pointer passed to Initialize function!!!!!");
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ // LCOV_EXCL_STOP
+ } else {
+ // Attach callback : Open Session Request
+ 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]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ "FrameworkunifiedAttachCallbackToDispatcher PROTOCOL_OPEN_SESSION_REQ (FRAMEWORKUNIFIED_ANY_SOURCE) Failed Status:0x%x ",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ } else if ( eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedRegisterServiceAvailabilityNotification(f_hApp, NTFY_SS_LoggerService_Availability))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Failed to set service availability notification:0x%x ", l_eStatus);
+ // LCOV_EXCL_STOP
+ } else {
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+//////////////////////////////////////////
+// Function : DevDetectionServerOnOpenSession
+// Callback for PROTOCOL_OPEN_SESSION_REQ
+//////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServerOnOpenSession(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ HANDLE l_hClientService = NULL;
+ HANDLE l_hSession = NULL;
+
+ // Get the requester name
+ PCSTR pRequester = FrameworkunifiedGetMsgSrc(hApp);
+ OpenSessionAck tOpenAck;
+
+ if (pRequester) { // LCOV_EXCL_BR_LINE 4:NSFW
+ l_hClientService = FrameworkunifiedMcOpenSender(hApp, pRequester);
+
+ if (l_hClientService) { // LCOV_EXCL_BR_LINE 4:NSFW
+ // Create a session
+ l_hSession = FrameworkunifiedCreateSession(hApp, pRequester);
+ UI_32 l_nSessionId = 0;
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedAttachCallbacksToDispatcher( hApp, pRequester, m_protocolHandlers, kNUMBER_PROTOCOL_HANDLERS, l_hSession))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __PRETTY_FUNCTION__,
+ "FrameworkunifiedAttachCallbacksToDispatcher ss_logger_server_protocol_handlers Failed Status:0x%x ",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ }
+
+ l_eStatus = this->m_pErrorEvent->OnOpenSession(hApp, pRequester,
+ l_hSession);
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 200:To ensure success
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. m_pErrorEvent->OnOpenSession(%s, %p) returned: %d.",
+ pRequester, l_hSession, l_eStatus);
+ // LCOV_EXCL_STOP
+ }
+
+ // Attach callback : close Session Request
+ 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]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ "FrameworkunifiedAttachCallbackToDispatcher " "PROTOCOL_CLOSE_SESSION_REQ (FRAMEWORKUNIFIED_ANY_SOURCE) Failed Status:0x%x ",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ }
+
+ l_nSessionId = FrameworkunifiedGetSessionId(l_hSession);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Session id is %d", l_nSessionId); // LCOV_EXCL_BR_LINE 15:macro
+ // sending the session open
+ tOpenAck.eStatus = eFrameworkunifiedStatusOK;
+ tOpenAck.sessionId = l_nSessionId;
+ tOpenAck.sessionType = 1;
+
+ // Copy session name to data structure
+ strncpy(tOpenAck.cSessionName, FrameworkunifiedGetAppName(hApp),
+ MAX_QUEUE_NAME_SIZE - 1);
+ tOpenAck.cSessionName[MAX_QUEUE_NAME_SIZE - 1] = '\0';
+
+ // send OpenSession ACK
+ 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]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
+ "FrameworkunifiedSendMsg PROTOCOL_OPEN_SESSION_ACK Failed Status:0x%x ",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ } else {
+ l_eStatus = FrameworkunifiedSetSessionHandle(hApp, FrameworkunifiedGetMsgSrc(hApp), l_hSession);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedSetSessionHandle()"); // LCOV_EXCL_BR_LINE 15:macro
+ }
+ }
+ l_eStatus = FrameworkunifiedMcClose(l_hClientService);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedMcClose()"); // LCOV_EXCL_BR_LINE 15:macro
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+
+ return l_eStatus;
+}
+
+//////////////////////////////////////////
+// Function : DevDetectionServerOnCloseSession
+// Callback for PROTOCOL_CLOSE_SESSION_REQ
+//////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServerOnCloseSession(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ HANDLE hSession = NULL;
+ HANDLE l_hClientService = NULL;
+ // Get the requester name
+ PCSTR pRequester = FrameworkunifiedGetMsgSrc(hApp);
+ CloseSessionAck tCloseAck;
+ CloseSessionReq tClose;
+
+ if (pRequester) { // LCOV_EXCL_BR_LINE 4:NSFW
+ l_hClientService = FrameworkunifiedMcOpenSender(hApp, pRequester);
+ if (l_hClientService) { // LCOV_EXCL_BR_LINE 4:NSFW
+ // Read the data from the message
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &tClose, sizeof(tClose), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedGetMsgDataOfSize Failed");
+
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedMcClose(l_hClientService))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedMcClose failed");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+ // LCOV_EXCL_STOP
+ }
+
+ hSession = FrameworkunifiedGetSessionHandle(hApp, pRequester, tClose.sessionId);
+
+ // Create a list of commands to be detached from the dispatcher
+ UI_32 cmd_array[kNUMBER_PROTOCOL_HANDLERS] = { 0 };
+ for (UI_32 i = 0; i < kNUMBER_PROTOCOL_HANDLERS; i++) {
+ cmd_array[i] = m_protocolHandlers[i].iCmd;
+ }
+
+ if (NULL != hSession) { // LCOV_EXCL_BR_LINE 4:NSFW
+ // Detach callbacks associated with client
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedDetachCallbacksFromDispatcher(hApp, pRequester, cmd_array, kNUMBER_PROTOCOL_HANDLERS, hSession))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __PRETTY_FUNCTION__,
+ "FrameworkunifiedAttachCallbacksToDispatcher ss_logger_server_protocol_handlers Failed Status:0x%x ",
+ eStatus);
+ // LCOV_EXCL_STOP
+ }
+
+ eStatus = m_pErrorEvent->OnCloseSession(hApp, pRequester, hSession);
+ if (eFrameworkunifiedStatusOK != eStatus) { // LCOV_EXCL_BR_LINE 200:To ensure success
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. m_pErrorEvent->OnCloseSession(%s, %p) returned: %d.",
+ pRequester, hSession, eStatus);
+ // LCOV_EXCL_STOP
+ }
+
+ // API to destroy the session handle and remove it from the Application Framework.
+ // LCOV_EXCL_BR_START 4:NSFW
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedDestroySession(hApp, // Application Handle
+ hSession))) { // Session Handle
+ // LCOV_EXCL_BR_STOP
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Session destroy failed");
+ // LCOV_EXCL_STOP
+ }
+ }
+ // sending the session close ack
+ tCloseAck.eStatus = eFrameworkunifiedStatusOK;
+ tCloseAck.sessionId = tClose.sessionId;
+
+ // send CloseSession ACK
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedSendMsg(l_hClientService, PROTOCOL_CLOSE_SESSION_ACK, sizeof(CloseSessionAck), (PVOID) &tCloseAck))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__,
+ "FrameworkunifiedSendMsg PROTOCOL_CLOSE_SESSION_ACK Failed Status:0x%x ",
+ eStatus);
+ // LCOV_EXCL_STOP
+ }
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedMcClose(l_hClientService))) { // LCOV_EXCL_BR_LINE 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedMcClose failed"); // LCOV_EXCL_LINE 15:macro
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+//////////////////////////////////////////
+// Function : LoggerServer_SetMileageData
+// Callback for SS_LOGGER_MILEAGE_DATA
+//////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_SetMileageData(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ STLOGGER_CANDIAGSTAT MileageInfo_t;
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ memset(&MileageInfo_t, 0x00, sizeof(STLOGGER_CANDIAGSTAT));
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &MileageInfo_t, sizeof(MileageInfo_t), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " FrameworkunifiedGetMsgDataOfSize Failed");
+ l_eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ } else {
+ UI_32 l_mileage = (MileageInfo_t.Odo_MSB_H << 24
+ | MileageInfo_t.Odo_MSB_L << 16 | MileageInfo_t.Odo_LSB_H << 8
+ | MileageInfo_t.Odo_LSB_L);
+ // if value set to SNA
+ if (0xFFFFFFFF != l_mileage) {
+ this->m_pErrorEvent->SetMileage(l_mileage);
+ // Immediate Persist Event Log
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdEvntLogWriter, eThrdCmdMileageData, sizeof(UI_32), &l_mileage))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedSendChild msg failed:%d", l_eStatus); // LCOV_EXCL_LINE 15:macro
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+//////////////////////////////////////////
+// Function : LoggerServer_SetLoggerParams
+// Callback for SS_LOGGER_SET_PARAMS
+//////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_SetLoggerParams(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ STLoggerSetParams l_stLoggerSetParams = { eInvalid_LoggerState, eDevUSB1 };
+
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &l_stLoggerSetParams, sizeof(l_stLoggerSetParams), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedGetMsgDataOfSize Failed");
+ eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+ // LCOV_EXCL_STOP
+ } else {
+ eStatus = m_pLoggerCfg->SetLoggingParams(hApp, l_stLoggerSetParams);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+//////////////////////////////////////////
+// Function : LoggerServer_SetLoggerParams
+// Callback for SS_LOGGER_SET_PARAMS
+//////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_UDPLogging(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ ELOGGER_STAT l_eUDPLoggingStatus = eInvalid_LoggerState;
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &l_eUDPLoggingStatus, sizeof(l_eUDPLoggingStatus), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedGetMsgDataOfSize Failed");
+ l_eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ } else {
+ l_eStatus = m_pLoggerCfg->SetUDPLogging(hApp, l_eUDPLoggingStatus);
+ LOG_STATUS_IF_ERRORED( // LCOV_EXCL_BR_LINE 15:macro
+ l_eStatus,
+ "m_pLoggerCfg->SetUDPLogging()");
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_UpdateCommonInfo(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+
+ 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]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " FrameworkunifiedGetMsgDataOfSize Failed");
+ eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_Handle_CWORD56_Events(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
+ STEventLoggerEventInfo l_stEventLoggingEventInfo;
+ UI_16 l_evtid = 0;
+
+ if (eFrameworkunifiedStatusOK != (eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &l_stEventLoggingEventInfo, sizeof(l_stEventLoggingEventInfo), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " FrameworkunifiedGetMsgDataOfSize Failed");
+ eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ }
+ l_evtid = static_cast<UI_16>(((l_stEventLoggingEventInfo.EventGroup & 0x00FF) << 8)
+ | (l_stEventLoggingEventInfo.EventIdentifier & 0x00FF));
+ FRAMEWORKUNIFIEDLOG_EVT(ZONE_INFO, l_evtid, 4, l_stEventLoggingEventInfo.EventData[3],
+ l_stEventLoggingEventInfo.EventData[2],
+ l_stEventLoggingEventInfo.EventData[1],
+ l_stEventLoggingEventInfo.EventData[0]);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eStatus;
+}
+
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnCopyEmergencyLog(
+ HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ EDevNumber l_eDevNumber;
+ std::string l_path = "";
+ std::string l_srcName = "";
+
+ if (NULL != f_hApp) { // LCOV_EXCL_BR_LINE 6: it can't be null.
+ PCSTR l_tmp_srcname = FrameworkunifiedGetMsgSrc(f_hApp);
+ if (NULL != l_tmp_srcname) { // LCOV_EXCL_BR_LINE 6: it can't be null.
+ l_srcName = l_tmp_srcname;
+ }
+
+ if (eFrameworkunifiedStatusOK
+ == (l_eStatus = FrameworkunifiedGetMsgDataOfSize(f_hApp, &l_eDevNumber,
+ sizeof(l_eDevNumber), eSMRRelease))) {
+ switch (l_eDevNumber) {
+ case eEEL_USB1:
+ l_path = m_pLoggerCfg->m_usb0MountPath;
+ break;
+
+ case eEEL_USB2:
+ l_path = m_pLoggerCfg->m_usb1MountPath;
+ break;
+
+ case eEEL_SD:
+ l_path = m_pLoggerCfg->m_sdMountPath;
+ break;
+
+ default:
+ /*send back error response wrong param*/
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ break;
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Could not get msg Data.");
+ }
+
+ HANDLE l_hSession = NULL;
+ if (NULL == (l_hSession = FrameworkunifiedGetCurrentSessionHandle(f_hApp))) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetCurrentSessionHandle()");
+ // LCOV_EXCL_STOP
+ } else {
+ m_pErrorEvent->SetDiagSessionHandle(l_hSession);
+ }
+ if (0 == l_srcName.length()) { // LCOV_EXCL_BR_LINE 6: it can't be 0.
+ // LCOV_EXCL_START 6: it can't be 0.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Could not get name of source service.");
+ // LCOV_EXCL_STOP
+ l_eStatus = eFrameworkunifiedStatusInvldHandle;
+ } else if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Invalid parameter l_eDevNumber(%d).", l_eDevNumber);
+ l_eStatus = m_pErrorEvent->sendDiagEventErrorResponse(eNO_ERROR_INFO,
+ l_srcName);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "m_pErrorEvent->sendDiagEventErrorResponse(l_srcName)");
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ } else if (eFrameworkunifiedStatusOK
+ != (l_eStatus = m_pErrorEvent->SetDiagEventSourceName(l_srcName))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. m_pErrorEvent->SetDiagEventSourceName() returned %d.", l_eStatus);
+ l_eStatus = m_pErrorEvent->sendDiagEventErrorResponse(eNO_ERROR_INFO,
+ l_srcName);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "m_pErrorEvent->sendDiagEventErrorResponse(l_srcName)");
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else if (eFrameworkunifiedStatusOK != (l_eStatus =
+ SendDiagLoggingRequestToSystemManager(l_path))) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
+ // LCOV_EXCL_START 4: NSFW error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ /* call System Manager interface*/
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. SendDiagLoggingRequestToSystemManager() returned %d.", l_eStatus);
+ l_eStatus = m_pErrorEvent->sendDiagEventErrorResponse(eNO_ERROR_INFO);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "m_pErrorEvent->sendDiagEventErrorResponse()");
+ l_eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Log Request passed to SystemManager.");
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnCANTrigger(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ l_eStatus = SendCANLoggingRequestToSystemManager();
+ LOG_STATUS_IF_ERRORED(l_eStatus, "SendCANLoggingRequestToSystemManager()"); // LCOV_EXCL_BR_LINE 15:macro
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnDTCTrigger(HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_32 l_dtc;
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedGetMsgDataOfSize(f_hApp, &l_dtc, sizeof(l_dtc), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Could not get msg Data.");
+ // LCOV_EXCL_STOP
+ } else {
+ l_eStatus = SendDTCLoggingRequestToSystemManager(l_dtc);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "SendDTCLoggingRequestToSystemManager(dtc)"); // LCOV_EXCL_BR_LINE 15:macro
+ // Immediate Persist Event Log
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendChild(f_hApp, g_thrdEvntLogWriter, eThrdCmdImmPersistEvtLog, 0x00, NULL))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "FrameworkunifiedSendChild msg failed:%X", l_eStatus);
+ // LCOV_EXCL_STOP
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_On_SHTDWN_Complete(
+ HANDLE f_hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ l_eStatus = LoggerService_OnStop(f_hApp);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "LoggerService_OnStop()"); // LCOV_EXCL_BR_LINE 15:macro
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :LoggerServer_OnSetVIN
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnSetVIN(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ STVIN_NUMBER l_stVIN_Number;
+
+ if (eFrameworkunifiedStatusOK == (l_eStatus = FrameworkunifiedGetMsgDataOfSize(hApp, &l_stVIN_Number, sizeof(l_stVIN_Number), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ 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]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "FrameworkunifiedSendChild msg failed:%X", l_eStatus);
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "FrameworkunifiedGetMsgDataOfSize failed errval: %X",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :LoggerServer_OnCopyEvntLog
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnCopyEvntLog(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ TWriteFilesToUsbCmdData l_stCmdData;
+ HANDLE l_hSession = NULL;
+
+ if (hApp != NULL) { // LCOV_EXCL_BR_LINE 6: it can not be null
+ PCSTR l_tmp_srcname = FrameworkunifiedGetMsgSrc(hApp);
+ if (NULL != l_tmp_srcname) { // LCOV_EXCL_BR_LINE 6: it can not be null
+ l_stCmdData.stSessiondata.strSrcName = l_tmp_srcname;
+ }
+ if (l_stCmdData.stSessiondata.strSrcName.empty()) { // LCOV_EXCL_BR_LINE 6: it can not be empty
+ // LCOV_EXCL_START 6: it can not be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetMsgSrc()");
+ // LCOV_EXCL_STOP
+ } else if (NULL == (l_hSession = FrameworkunifiedGetCurrentSessionHandle(hApp))) { // LCOV_EXCL_BR_LINE 6: it can not be null
+ // LCOV_EXCL_START 6: it can not be null
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetCurrentSessionHandle()");
+ // LCOV_EXCL_STOP
+ } else {
+ l_stCmdData.stSessiondata.session_id = FrameworkunifiedGetSessionId(l_hSession);
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<EEvtLogUSBDevNumber>(hApp, l_stCmdData.eDevId))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdEvntLogWriter, // LCOV_EXCL_BR_LINE 4:NSFW
+ eThrdCmdWriteEvntFilesToUsb,
+ sizeof(TWriteFilesToUsbCmdData),
+ &l_stCmdData))) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedSendChild()"); // LCOV_EXCL_LINE 4:NSFW
+ }
+ }
+ }
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Invalid App handler"); // LCOV_EXCL_LINE 6: it can not be null
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :LoggerServer_OnClearEvntLog
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnClearEvntLog(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (hApp != NULL) { // LCOV_EXCL_BR_LINE 200:As it is not always NULL
+ TSessionData l_sessiondata;
+ HANDLE l_hSession = NULL;
+ PCSTR l_tmp_srcname = FrameworkunifiedGetMsgSrc(hApp); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ if (NULL != l_tmp_srcname) { // LCOV_EXCL_BR_LINE 4:NSFW
+ l_sessiondata.strSrcName = l_tmp_srcname;
+ }
+ if (l_sessiondata.strSrcName.empty()) { // LCOV_EXCL_BR_LINE 4:As it is guaranteed by NSFW and is not always an empty string
+ // LCOV_EXCL_START 4:As it is guaranteed by NSFW and is not always an empty string
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetMsgSrc()");
+ // LCOV_EXCL_STOP
+ } else if (NULL == (l_hSession = FrameworkunifiedGetCurrentSessionHandle(hApp))) { // LCOV_EXCL_BR_LINE 4:NSFW
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetCurrentSessionHandle()");
+ // LCOV_EXCL_STOP
+ } else {
+ l_sessiondata.session_id = FrameworkunifiedGetSessionId(l_hSession); // LCOV_EXCL_BR_LINE 11:Unexpected branch
+ if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdEvntLogWriter, eThrdCmdClearEvntLogs, sizeof(TSessionData), &l_sessiondata))) { // LCOV_EXCL_BR_LINE 4:NSFW // NOLINT[whitespace/line_length]
+ // LCOV_EXCL_START 4:NSFW
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedSendChild()");
+ // LCOV_EXCL_STOP
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :LoggerServer_OnReadStatCounter
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnReadStatCounter(
+ HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (hApp != NULL) { // LCOV_EXCL_BR_LINE 6: it can not be null
+ TStatisticalCountersCmd l_stCmdData;
+ HANDLE l_hSession = NULL;
+
+ PCSTR l_tmp_srcname = FrameworkunifiedGetMsgSrc(hApp);
+ if (NULL != l_tmp_srcname) { // LCOV_EXCL_BR_LINE 6: it can not be null
+ l_stCmdData.stSessiondata.strSrcName = l_tmp_srcname;
+ }
+ if (l_stCmdData.stSessiondata.strSrcName.empty()) { // LCOV_EXCL_BR_LINE 6: it can not be empty
+ // LCOV_EXCL_START 6: it can not be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetMsgSrc()");
+ // LCOV_EXCL_STOP
+ } else if (NULL == (l_hSession = FrameworkunifiedGetCurrentSessionHandle(hApp))) { // LCOV_EXCL_BR_LINE 6: it can not be null
+ // LCOV_EXCL_START 6: it can not be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetCurrentSessionHandle()");
+ // LCOV_EXCL_STOP
+ } else {
+ l_stCmdData.stSessiondata.session_id = FrameworkunifiedGetSessionId(l_hSession);
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<EStatCounterGroupID>(hApp,
+ l_stCmdData.eGroupId))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdEvntLogWriter, // LCOV_EXCL_BR_LINE 4:NSFW
+ eThrdCmdStatisticalCounter,
+ sizeof(TStatisticalCountersCmd),
+ &l_stCmdData))) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedSendChild()");// LCOV_EXCL_LINE 4:NSFW
+ }
+ }
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :LoggerServer_OnResetStatCounter
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnResetStatCounter(
+ HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ if (hApp != NULL) { // LCOV_EXCL_BR_LINE 6: it can not be null
+ TStatisticalCountersCmd l_stCmdData;
+ HANDLE l_hSession = NULL;
+ PCSTR l_tmp_srcname = FrameworkunifiedGetMsgSrc(hApp);
+ if (NULL != l_tmp_srcname) { // LCOV_EXCL_BR_LINE 6: it can not be null
+ l_stCmdData.stSessiondata.strSrcName = l_tmp_srcname;
+ }
+ if (l_stCmdData.stSessiondata.strSrcName.empty()) { // LCOV_EXCL_BR_LINE 6: it can not be empty
+ // LCOV_EXCL_START 6: it can not be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetMsgSrc()");
+ // LCOV_EXCL_STOP
+ } else if (NULL == (l_hSession = FrameworkunifiedGetCurrentSessionHandle(hApp))) { // LCOV_EXCL_BR_LINE 6: it can not be null
+ // LCOV_EXCL_START 6: it can not be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetCurrentSessionHandle()");
+ // LCOV_EXCL_STOP
+ } else {
+ l_stCmdData.stSessiondata.session_id = FrameworkunifiedGetSessionId(l_hSession);
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = ReadMsg<EStatCounterGroupID>(hApp,
+ l_stCmdData.eGroupId))) {
+ LOG_ERROR("ReadMsg()");
+ } else {
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdEvntLogWriter, // LCOV_EXCL_BR_LINE 4:NSFW
+ eThrdCmdResetStatisticalCntrs,
+ sizeof(TStatisticalCountersCmd),
+ &l_stCmdData))) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedSendChild()"); // LCOV_EXCL_LINE 4:NSFW
+ }
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :LoggerServer_OnReadNumberOfEvents
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnReadNumberOfEvents(
+ HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ TSessionData l_sessiondata;
+ HANDLE l_hSession = NULL;
+
+ l_sessiondata.strSrcName = FrameworkunifiedGetMsgSrc(hApp);
+ if (l_sessiondata.strSrcName.empty()) { // LCOV_EXCL_BR_LINE 6: it can not be empty
+ // LCOV_EXCL_START 6: it can not be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetMsgSrc()");
+ // LCOV_EXCL_STOP
+ } else if (NULL == (l_hSession = FrameworkunifiedGetCurrentSessionHandle(hApp))) { // LCOV_EXCL_BR_LINE 6: it can not be null
+ // LCOV_EXCL_START 6: it can not be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetCurrentSessionHandle()");
+ // LCOV_EXCL_STOP
+ } else {
+ l_sessiondata.session_id = FrameworkunifiedGetSessionId(l_hSession);
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdEvntLogWriter, // LCOV_EXCL_BR_LINE 4:NSFW
+ eThrdCmdGetNumberOfEventsLogged,
+ sizeof(TSessionData), &l_sessiondata))) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedSendChild()"); // LCOV_EXCL_LINE 4:NSFW
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :LoggerServer_OnSetDiagID
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_OnSetDiagID(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_16 l_DiagId = 0;
+
+ if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<UI_16>(hApp, l_DiagId))) { // LCOV_EXCL_BR_LINE 200:To ensure success
+ // LCOV_EXCL_START 200:To ensure success
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("ReadMsg()");
+ // LCOV_EXCL_STOP
+ } else {
+ g_u16DiagId = l_DiagId;
+ }
+ return l_eStatus;
+}
+
+///////////////////////////////////////////////////////////////////////
+/// Function :LoggerServer_UploadEventLog
+///////////////////////////////////////////////////////////////////////
+EFrameworkunifiedStatus CLoggerServiceCallbacks::LoggerServer_UploadEventLog(HANDLE hApp) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ TSessionData l_sessiondata;
+ HANDLE l_hSession = NULL;
+
+ PCSTR l_tmp_srcname = FrameworkunifiedGetMsgSrc(hApp);
+ if (NULL != l_tmp_srcname) { // LCOV_EXCL_BR_LINE 6: it can not be null
+ l_sessiondata.strSrcName = l_tmp_srcname;
+ }
+ if (l_sessiondata.strSrcName.empty()) { // LCOV_EXCL_BR_LINE 6: it can not be empty
+ // LCOV_EXCL_START 6: it can not be empty
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetMsgSrc()");
+ // LCOV_EXCL_STOP
+ } else if (NULL == (l_hSession = FrameworkunifiedGetCurrentSessionHandle(hApp))) { // LCOV_EXCL_BR_LINE 6: it can not be null
+ // LCOV_EXCL_START 6: it can not be null
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ LOG_ERROR("FrameworkunifiedGetCurrentSessionHandle()");
+ // LCOV_EXCL_STOP
+ } else {
+ l_sessiondata.session_id = FrameworkunifiedGetSessionId(l_hSession);
+ if (eFrameworkunifiedStatusOK
+ != (l_eStatus = FrameworkunifiedSendChild(hApp, g_thrdEvntLogWriter, // LCOV_EXCL_BR_LINE 4:NSFW
+ eThrdCmdUploadEventLog,
+ sizeof(TSessionData), &l_sessiondata))) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ LOG_ERROR("FrameworkunifiedSendChild()"); // LCOV_EXCL_LINE 4:NSFW
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
diff --git a/logger_service/server/src/ss_logger_util.cpp b/logger_service/server/src/ss_logger_util.cpp
new file mode 100644
index 00000000..a0467b2d
--- /dev/null
+++ b/logger_service/server/src/ss_logger_util.cpp
@@ -0,0 +1,1273 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief Provide support for SS Logger module utility functions.
+///
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// INCLUDES
+///////////////////////////////////////////////////////////////////////////////
+#include "ss_logger_util.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+//#include <vehicle_service/Clock_API.h>
+#include <iomanip>
+#include <sstream>
+#include <string>
+#include <algorithm>
+#include <vector>
+#include "ss_logger_common.h"
+
+#include <system_service/ss_logger_store_logs.h>
+
+#define SS_STORE_FILENAME_SYSILG_TERM "_SYS_ILG_RESET.tar.gz"
+#define SS_STORE_FILENAME__CWORD52__TERM "__CWORD52_.log"
+
+
+char CLoggerUtil::m_usbpath[USB_PATH_SIZE];
+
+///////////////////////////////////////////////////////////////////////////////
+// CLASS METHODS
+///////////////////////////////////////////////////////////////////////////////
+CLoggerUtil::CLoggerUtil(void)
+ : m_pCfg(NULL),
+ m_Milage(0),
+ m_bootCount(0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ m_usbpath[0] = '\0';
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+
+CLoggerUtil::~CLoggerUtil(void) { // LCOV_EXCL_START 14:globle instance
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CLoggerUtil::Initialize(CLoggerCfg *f_pLoggerCfg) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus;
+
+ m_pCfg = f_pLoggerCfg;
+ l_eStatus = (NULL != f_pLoggerCfg) ? eFrameworkunifiedStatusOK : eFrameworkunifiedStatusInvldParam;
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+std::string CLoggerUtil::getDestination(TLoggerErrorEvent &f_eventNtfData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+: %d ", f_eventNtfData.EventType);
+ std::string l_path = "";
+ EFrameworkunifiedStatus l_eStatus;
+
+ switch (f_eventNtfData.EventType) {
+ case eErrorEventTypeProcessCrash:
+ case eErrorEventTypeHeartBeatFailure:
+ case eErrorEventTypeSystemLowMemory:
+ case eErrorEventTypeBootMicroReset:
+ case eErrorEventTypeProcessExit:
+ case eErrorEventTypeUserInvokedUserForceReset:
+ case eErrorEventTypeModConnFailed:
+ case eErrorEventTypeStartRespFailed:
+ case eErrorEventTypeUserInvokedCollectDevLogs:
+ case eErrorEventTypeModuleInvokedResetRequest:
+ case eErrorEventTypeModuleInvokedCollectDebugLogs:
+ case eErrorEventTypeDtcEvent:
+ case eErrorEventTypeUserInvokedClearLogs:
+ case eErrorEventTypeGroupRelaunch:
+ l_eStatus = m_pCfg->GetEmmcDestination(l_path);
+ break;
+
+ case eErrorEventTypeUserInvokedCollectNaviLog:
+ l_eStatus = m_pCfg->GetEmmcNaviLogDestination(l_path);
+ break;
+
+ case eErrorEventTypeEelExport:
+ l_path = f_eventNtfData.ModuleName;
+ l_eStatus = eFrameworkunifiedStatusOK;
+ break;
+
+ case eErrorEventTypeInterfaceunifiedEmmcLogs:
+ l_path = f_eventNtfData.ModuleName;
+ l_eStatus = eFrameworkunifiedStatusOK;
+ break;
+
+ case eErrorEventTypeUserInvokedCollectAllLogs:
+ case eErrorEventTypeUserInvokedCollectScreenShot:
+ case eErrorEventTypeUserInvokedCollectInterfaceunifiedLogs:
+ case eErrorEventTypeCanEvent:
+ l_eStatus = m_pCfg->GetUserInvokedDestination(l_path);
+ break;
+
+ case eErrorEventTypeDiagEvent:
+ l_path = f_eventNtfData.ModuleName;
+ l_eStatus = eFrameworkunifiedStatusOK;
+ break;
+
+ default:
+ l_eStatus = eFrameworkunifiedStatusFail;
+ break;
+ }
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Could not get filepath ");
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %s", l_path.c_str());
+ return (l_path);
+}
+EFrameworkunifiedStatus CLoggerUtil::checkDestinationAvailable(
+ TLoggerErrorEvent &f_eventNtfData) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ std::string l_path = CLoggerUtil::getDestination(f_eventNtfData);
+ std::string::size_type ret;
+
+ if (l_path.length() > 0) {
+ ret = l_path.find(DEBUG_USB_PATH);
+ if (ret != std::string::npos && ret == 0) {
+ if (0 == access(m_usbpath, W_OK)) { // LCOV_EXCL_BR_LINE 5:C code
+ // LCOV_EXCL_START 5:C code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ std::string path = l_path.substr(sizeof(DEBUG_USB_PATH) - 1);
+ f_eventNtfData.ModuleName = m_usbpath;
+ f_eventNtfData.ModuleName.append(path);
+ l_eStatus = eFrameworkunifiedStatusOK;
+ // LCOV_EXCL_STOP
+ }
+ } else {
+ if (0 == access(l_path.c_str(), W_OK)) { // LCOV_EXCL_BR_LINE 5:C code
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ }
+ }
+
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. Failed the check path: l_eStatus(%d), l_path(%s)",
+ l_eStatus, l_path.c_str()); // LCOV_EXCL_BR_LINE 11:except,C++ STL
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+static void SetSuffixFromType(std::string &pathAndName, EErrorEventType type) { // NOLINT (runtime/references)
+ switch (type) {
+ case eErrorEventTypeProcessCrash:
+ case eErrorEventTypeHeartBeatFailure:
+ case eErrorEventTypeSystemLowMemory:
+ case eErrorEventTypeBootMicroReset:
+ case eErrorEventTypeProcessExit:
+ case eErrorEventTypeModConnFailed:
+ case eErrorEventTypeStartRespFailed:
+ case eErrorEventTypeModuleInvokedResetRequest:
+ pathAndName.insert(pathAndName.find(".tar.gz"), "_ERR");
+ break;
+ case eErrorEventTypeUserInvokedUserForceReset:
+ case eErrorEventTypeUserInvokedCollectAllLogs:
+ case eErrorEventTypeUserInvokedCollectScreenShot:
+ case eErrorEventTypeUserInvokedCollectInterfaceunifiedLogs:
+ case eErrorEventTypeDiagEvent:
+ case eErrorEventTypeCanEvent:
+ case eErrorEventTypeDtcEvent:
+ case eErrorEventTypeModuleInvokedCollectDebugLogs:
+ pathAndName.insert(pathAndName.find(".tar.gz"), "_DIAG");
+ break;
+ case eErrorEventTypeUserInvokedCollectDevLogs:
+ pathAndName.insert(pathAndName.find(".tar.gz"), "_DEBUG");
+ break;
+ case eErrorEventTypeGroupRelaunch:
+ pathAndName.insert(pathAndName.find(".tar.gz"), "_GRP_RELAUNCH");
+ break;
+ default:
+ break;
+ }
+}
+
+EFrameworkunifiedStatus CLoggerUtil::getFilePathAndName(HANDLE f_hApp,
+ TLoggerErrorEvent &f_eventNtfData,
+ uint32_t f_time,
+ std::string &f_pathAndName) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ f_pathAndName = "";
+
+ switch (f_eventNtfData.EventType) { // LCOV_EXCL_BR_LINE 200: eErrorEventTypeEelExport ex. can not be run
+ case eErrorEventTypeProcessCrash:
+ case eErrorEventTypeProcessExit:
+ case eErrorEventTypeHeartBeatFailure:
+ case eErrorEventTypeSystemLowMemory:
+ case eErrorEventTypeBootMicroReset:
+ case eErrorEventTypeModConnFailed:
+ case eErrorEventTypeStartRespFailed:
+ case eErrorEventTypeGroupRelaunch:
+ l_eStatus = m_pCfg->GetEmmcDestination(f_pathAndName);
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 6:it will aways return ok
+ // LCOV_EXCL_START 6:it will aways return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. GetEmmcDestination() returned %d.",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ } else {
+ f_pathAndName.append("/");
+ f_pathAndName.append(GetEmmcFilename(f_time));
+ }
+ break;
+
+ case eErrorEventTypeUserInvokedUserForceReset:
+ case eErrorEventTypeUserInvokedCollectDevLogs:
+ l_eStatus = m_pCfg->GetEmmcDestination(f_pathAndName);
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 6:it will aways return ok
+ // LCOV_EXCL_START 6:it will aways return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. GetEmmcDestination() returned %d.",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ } else {
+ f_pathAndName.append("/");
+ f_pathAndName.append(GetEmmcFilename(f_time));
+ }
+ break;
+ case eErrorEventTypeModuleInvokedResetRequest:
+ case eErrorEventTypeModuleInvokedCollectDebugLogs:
+ case eErrorEventTypeDtcEvent:
+ l_eStatus = m_pCfg->GetEmmcDestination(f_pathAndName);
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 6:it will aways return ok
+ // LCOV_EXCL_START 6:it will aways return ok
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. GetEmmcDestination() returned %d.",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ } else {
+ f_pathAndName.append("/");
+ f_pathAndName.append(GetEmmcFilename(f_time));
+ if (!f_eventNtfData.ModuleName.empty()) { // LCOV_EXCL_BR_LINE 6: ModuleName can not be empty
+ size_t l_pos = f_pathAndName.find(".tar.gz");
+ if (l_pos != std::string::npos) { // LCOV_EXCL_BR_LINE 6: ".tar.gz" is aways exist
+ f_pathAndName.insert(l_pos, f_eventNtfData.ModuleName);
+ }
+ }
+ }
+ break;
+ case eErrorEventTypeEelExport: // LCOV_EXCL_START 6: impossible to confirm because it can not get in
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ f_pathAndName = f_eventNtfData.ModuleName;
+ f_pathAndName.append("/");
+ f_pathAndName.append("loggerservicelogs_export_");
+ f_pathAndName.append(GetTimeString(f_time));
+ f_pathAndName.append(".tar.gz");
+ break;
+ // LCOV_EXCL_STOP
+ case eErrorEventTypeInterfaceunifiedEmmcLogs: // LCOV_EXCL_START 6: impossible to confirm because it can not get in
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ // store the target location on event trigger
+ f_pathAndName = f_eventNtfData.ModuleName;
+ break;
+ // LCOV_EXCL_STOP
+ case eErrorEventTypeUserInvokedCollectAllLogs:
+ l_eStatus = m_pCfg->GetUserInvokedDestination(f_pathAndName);
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 6: impossible to confirm because it can not be fail
+ // LCOV_EXCL_START 6: impossible to confirm because it can not be fail
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. GetUserInvokedDestination() returned %d.",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ } else {
+ std::string l_emmc_path = m_pCfg->getEmmcOutputPath();
+ f_pathAndName.append(l_emmc_path);
+ f_pathAndName.append("/");
+ f_pathAndName.append(GetUserInvokedFilename(f_hApp, f_time));
+ if (!f_eventNtfData.ModuleName.empty()) { // LCOV_EXCL_BR_LINE 6: it can not be empty
+ size_t l_pos = f_pathAndName.find(".tar.gz");
+ if (l_pos != std::string::npos) { // LCOV_EXCL_BR_LINE 6: ".tar.gz" is aways exist
+ f_pathAndName.insert(l_pos, f_eventNtfData.ModuleName);
+ }
+ }
+ }
+ break;
+
+ case eErrorEventTypeUserInvokedCollectScreenShot:
+ case eErrorEventTypeUserInvokedCollectInterfaceunifiedLogs:
+ case eErrorEventTypeCanEvent:
+ l_eStatus = m_pCfg->GetUserInvokedDestination(f_pathAndName);
+ if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 6: impossible to confirm because it can not be fail
+ // LCOV_EXCL_START 6: impossible to confirm because it can not be fail
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. GetUserInvokedDestination() returned %d.",
+ l_eStatus);
+ // LCOV_EXCL_STOP
+ } else {
+ f_pathAndName.append("/");
+ f_pathAndName.append(GetUserInvokedFilename(f_hApp, f_time));
+ }
+ break;
+
+ case eErrorEventTypeDiagEvent: // LCOV_EXCL_START 6: impossible to confirm because it can not get in
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ f_pathAndName = f_eventNtfData.ModuleName;
+ f_pathAndName.append("/");
+ f_pathAndName.append(GetUserInvokedFilename(f_hApp, f_time));
+ l_eStatus = eFrameworkunifiedStatusOK;
+ break;
+ // LCOV_EXCL_STOP
+ case eErrorEventTypeUserInvokedClearLogs:
+ case eErrorEventTypeUserInvokedCollectNaviLog:
+ l_eStatus = eFrameworkunifiedStatusOK;
+ break;
+
+ default:
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Unknown event type: %d.",
+ f_eventNtfData.EventType);
+ l_eStatus = eFrameworkunifiedStatusFail;
+ break;
+ }
+
+ SetSuffixFromType(f_pathAndName, f_eventNtfData.EventType);
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+// LCOV_EXCL_START 13:
+EFrameworkunifiedStatus CLoggerUtil::getNaviLogFilePathAndName(std::string &f_prefix,
+ uint32_t f_time,
+ std::string &f_pathAndName) { // LCOV_EXCL_BR_LINE 13:
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ l_eStatus = m_pCfg->GetEmmcNaviLogDestination(f_pathAndName);
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. GetEmmNaviLogDestination() returned %d.",
+ l_eStatus);
+ } else {
+ f_pathAndName.append("/");
+ f_pathAndName.append(f_prefix);
+ f_pathAndName.append(GetEmmcNaviLogFilename(f_time));
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 200:
+EFrameworkunifiedStatus CLoggerUtil::getEmmcNaviLogParams(
+ uint32_t f_time, EPWR_SHUTDOWN_TRIGGER_TYPE errorType,
+ std::string &f_pathName, UI_32 &f_logMax) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ DIR *l_dirp = NULL;
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ std::string l_prefix = "";
+
+ std::vector<std::string> l_vector;
+ std::string l_path = m_pCfg->getEmmcOutputNaviLogPath();
+
+ if ((errorType == epssdmsdtGENERIC_ERROR_RESET)
+ || (errorType == epssdmsdtFATAL_ERROR_RESET)) {
+ /*When reset occured !!*/
+ f_logMax = m_pCfg->m_emmcOutputNaviLogErrMax;
+ l_prefix = "ERR_";
+ } else {
+ /* ACC OFF occured*/
+ f_logMax = m_pCfg->m_emmcOutputNaviLogNmlMax;
+ l_prefix = "NML_";
+ }
+
+ if (f_logMax == 0) {
+ l_eStatus = eFrameworkunifiedStatusOK;
+ return l_eStatus;
+ }
+
+ l_dirp = opendir(l_path.c_str());
+ if (l_dirp != NULL) {
+ struct dirent l_dirent;
+ struct dirent* next;
+
+ while (0 == readdir_r(l_dirp, &l_dirent, &next) && next != NULL) {
+ std::string l_findFileName = l_dirent.d_name;
+ size_t l_find_pos_top = l_findFileName.find(l_prefix.c_str());
+ size_t l_find_pos = l_findFileName.find(".log");
+ if (std::string::npos != l_find_pos
+ && std::string::npos != l_find_pos_top) {
+ l_vector.push_back(l_findFileName);
+ }
+ }
+ closedir(l_dirp);
+ }
+ std::sort(l_vector.begin(), l_vector.end());
+
+ for (UI_32 i = static_cast<UI_32>(l_vector.size()); i != 0; i--) {
+ std::string l_FilePath = l_path;
+ std::string l_FileName = l_vector.at(i - 1);
+ l_FilePath.append("/");
+ l_FilePath.append(l_FileName.c_str());
+
+ if (i < f_logMax) {
+ size_t l_pos = l_FileName.find("_", l_prefix.size());
+ if (std::string::npos != l_pos) {
+ std::string l_renameFilePath = l_path;
+ std::stringstream l_numStream;
+ l_numStream << std::setw(5) << std::setfill('0') << std::right << std::dec << (i + 1);
+ l_renameFilePath.append("/");
+ l_renameFilePath.append(l_prefix);
+ l_renameFilePath.append(l_numStream.str());
+ l_renameFilePath.append(l_FileName, l_pos, (l_FileName.size() - l_pos));
+ if (0 != rename(l_FilePath.c_str(), l_renameFilePath.c_str())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. rename navilog file %s:%d.",
+ l_FilePath.c_str(), errno);
+ }
+ }
+ } else {
+ if (0 != unlink(l_FilePath.c_str())) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. delete navilog file %s:%d.",
+ l_FilePath.c_str(), errno);
+ }
+ }
+ }
+ // sync parent directory
+ SyncDir(l_path);
+
+ l_eStatus = getNaviLogFilePathAndName(l_prefix, f_time, f_pathName);
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 200: can not be called
+size_t CLoggerUtil::deleteRequestLogs(std::string f_emmcpath,
+ ELOGGERSERVICELOGTYPE f_reqtype, size_t f_reqsize,
+ ELOGGERSERVICELOGTYPE f_deltype) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ DIR* l_dirp = NULL;
+ std::vector<std::string> vect;
+ std::vector<std::string>::iterator it;
+ UI_32 l_count = 0;
+ size_t l_totalsize = 0;
+
+ // create saved file list on eMMC
+ l_dirp = opendir(f_emmcpath.c_str());
+ if (l_dirp != NULL) {
+ struct dirent l_dirent;
+ struct dirent* next;
+ while (0 == readdir_r(l_dirp, &l_dirent, &next) && next != NULL) {
+ std::string l_filename = l_dirent.d_name;
+ if (CLoggerUtil::QueryLoggerservicelogType(l_filename) == f_deltype) {
+ vect.push_back(l_filename);
+ }
+ }
+ closedir(l_dirp);
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " open failed eMMC path: %s",
+ f_emmcpath.c_str());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return 0;
+ }
+
+ // get num of delete logs
+ std::sort(vect.begin(), vect.end());
+ for (it = vect.begin(); it != vect.end(); it++) {
+ l_count++;
+
+ std::string l_filename = *it;
+ struct stat st_buf;
+ std::string l_tmpstr = f_emmcpath;
+ l_tmpstr.append(l_filename.c_str());
+ if (stat(l_tmpstr.c_str(), &st_buf) != -1) {
+ l_totalsize += st_buf.st_size;
+ }
+
+ if (l_totalsize > f_reqsize) {
+ break;
+ }
+ }
+
+ // start delete logs
+ if ((l_totalsize > f_reqsize) || (f_reqtype == eLoggerservicelogTypeAbnormal)
+ || (f_reqtype == eLoggerservicelogTypeGrpRelaunch)) {
+ for (it = vect.begin(); it != vect.end() && l_count > 0; it++) {
+ l_count--;
+
+ std::string l_filename = *it;
+ std::string l_tmpstr = f_emmcpath;
+ l_tmpstr.append(l_filename.c_str());
+ if (unlink(l_tmpstr.c_str()) != 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " unlink failed %s:%d.",
+ l_tmpstr.c_str(), errno);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " del-file=%s total=%d", l_tmpstr.c_str(),
+ l_totalsize);
+ }
+ SyncDir(f_emmcpath);
+ } else {
+ l_totalsize = 0;
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_INFO,
+ __FUNCTION__,
+ " nothing to delete logs req-type=%d del-logtype=%d total=%d, log_count=%d",
+ f_reqtype, f_deltype, l_totalsize, l_count);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_totalsize;
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 200: can not be called
+EFrameworkunifiedStatus CLoggerUtil::forceDeleteOldLog(std::string f_archive_destination,
+ size_t f_req_size) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ std::string l_emmc_path;
+ size_t l_delsize = 0;
+ ELOGGERSERVICELOGTYPE l_logtype = eLoggerservicelogTypeOther;
+
+ size_t l_pos = f_archive_destination.find_last_of('/');
+ if (std::string::npos != l_pos) {
+ l_emmc_path = f_archive_destination.substr(0, l_pos);
+ l_emmc_path.append("/");
+ l_logtype = CLoggerUtil::QueryLoggerservicelogType(
+ f_archive_destination.substr(l_pos + 1,
+ f_archive_destination.size() - l_pos + 1));
+ }
+
+ if (l_logtype == eLoggerservicelogTypeOther) {
+ // not found
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Invalid Parameter. dest=%s",
+ f_archive_destination.c_str());
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return eFrameworkunifiedStatusFail;
+ }
+
+ // remove dirty-file if exist
+ if (unlink(f_archive_destination.c_str()) != 0) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " unlink failed %s:%d.",
+ f_archive_destination.c_str(), errno);
+ }
+
+ // delete normal log
+ l_delsize = deleteRequestLogs(l_emmc_path, l_logtype, f_req_size,
+ eLoggerservicelogTypeNormal);
+ if (l_delsize >= f_req_size) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " delete normal logs success: req-size=%d, del-size=%d", f_req_size,
+ l_delsize);
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else if (l_logtype == eLoggerservicelogTypeAbnormal) {
+ // delete abnormal log if request type is abnormal
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " continue delete abnormal logs: req-size=%d, del-size=%d",
+ f_req_size, l_delsize);
+ size_t l_tmpsize = f_req_size;
+ l_tmpsize -= l_delsize;
+ l_delsize = deleteRequestLogs(l_emmc_path, l_logtype, l_tmpsize,
+ eLoggerservicelogTypeAbnormal);
+ if (l_delsize >= l_tmpsize) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " delete abnormal logs success: req-size=%d, del-size=%d",
+ f_req_size, l_delsize);
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " abnormal log delete not complete. req-size=%d, del-size=%d",
+ f_req_size, l_delsize);
+ }
+ } else if (l_logtype == eLoggerservicelogTypeGrpRelaunch) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " continue delete group relaunch logs: req-size=%d, del-size=%d",
+ f_req_size, l_delsize);
+ size_t l_tmpsize = f_req_size;
+ l_tmpsize -= l_delsize;
+ l_delsize = deleteRequestLogs(l_emmc_path, l_logtype, l_tmpsize,
+ eLoggerservicelogTypeGrpRelaunch);
+ if (l_delsize >= l_tmpsize) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " delete group relaunch logs success: req-size=%d, del-size=%d",
+ f_req_size, l_delsize);
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR, __FUNCTION__,
+ " group relaunch log delete not complete. req-size=%d, del-size=%d",
+ f_req_size, l_delsize);
+ }
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " normal log del not complete. req-size=%d, del-size=%d", f_req_size,
+ l_delsize);
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CLoggerUtil::deleteOldLog(std::string log_path,
+ std::vector<std::string>& l_vector,
+ std::string& f_archive_destination,
+ UI_32 max_num) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ size_t l_pos = f_archive_destination.find_last_of('/');
+ if (std::string::npos != l_pos) { // LCOV_EXCL_BR_LINE 200: there is always '/' in f_destination
+ std::sort(l_vector.begin(), l_vector.end());
+ std::vector<std::string>::iterator itr = l_vector.begin();
+ for (UI_32 i = static_cast<UI_32>(l_vector.size()); (max_num - 1) < i; i--, itr++) {
+ if (itr == l_vector.end()) { // LCOV_EXCL_BR_LINE 200: (max_num - 1) can not be -1.
+ break;
+ }
+ std::string l_FilePath = log_path;
+ std::string l_FileName = *itr;
+ l_FilePath.append("/");
+ l_FilePath.append(l_FileName.c_str());
+ if (0 != unlink(l_FilePath.c_str())) {
+ l_eStatus = eFrameworkunifiedStatusAccessError;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. delete old log file %s:%d.",
+ l_FilePath.c_str(), errno);
+ }
+ }
+ SyncDir(log_path);
+ } else {
+ // LCOV_EXCL_START 200: there is always '/' in f_destination
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusFail;
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. delete target not found. %s",
+ f_archive_destination.c_str());
+ // LCOV_EXCL_STOP
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+EFrameworkunifiedStatus CLoggerUtil::deleteOldEmmcLog(std::string& f_archive_destination,
+ EErrorEventType type) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ DIR *l_dirp = NULL;
+ std::vector<std::string> vect_abnrm; /* ILLEGAL RESET LOG INFO or ERROR EXIT LOG INFO */
+ std::vector<std::string> vect_nrm; /* NORMAL LOG INFO */
+ std::vector<std::string> vect_rlnc; /* RELAUNCH LOG INFO */
+ std::string l_emmc_path = m_pCfg->getEmmcOutputPath();
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+
+ UI_32 abnrm_count = 0;
+
+ l_dirp = opendir(l_emmc_path.c_str());
+ if (l_dirp != NULL) { // LCOV_EXCL_BR_LINE 5: opendir's error case.
+ struct dirent l_dirent;
+ struct dirent* next;
+ while (0 == readdir_r(l_dirp, &l_dirent, &next) && next != NULL) {
+ std::string l_findFileName = l_dirent.d_name;
+
+// if ((std::string::npos != l_findFileName.find("_ILG_RESET.tar.gz"))
+// || (std::string::npos != l_findFileName.find("_ERR.tar.gz"))) {
+// vect_abnrm.push_back(l_findFileName);
+ if ((l_findFileName == ".") || (l_findFileName == "..")) {
+ continue;
+ } else if (std::string::npos != l_findFileName.find(SS_STORE_FILENAME_SYSILG_TERM)) {
+ vect_abnrm.push_back(l_findFileName);
+ } else if(std::string::npos != l_findFileName.find(SS_STORE_FILENAME__CWORD52__TERM)) { // LCOV_EXCL_BR_LINE 8: SS_STORE_FILENAME__CWORD52__TERM can not be set // NOLINT[whitespace/line_length]
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ vect_abnrm.push_back(l_findFileName); // LCOV_EXCL_LINE 8: SS_STORE_FILENAME_SYSILG_TERM can not be set // NOLINT[whitespace/line_length]
+ } else if((std::string::npos != l_findFileName.find("_ILG_RESET.tar.gz")) ||
+ (std::string::npos != l_findFileName.find("_ERR.tar.gz"))) {
+ vect_abnrm.push_back(l_findFileName);
+ abnrm_count++;
+
+ } else if (std::string::npos
+ != l_findFileName.find("_GRP_RELAUNCH.tar.gz")) {
+ vect_rlnc.push_back(l_findFileName);
+ } else if (std::string::npos != l_findFileName.find(".tar.gz")) {
+ vect_nrm.push_back(l_findFileName);
+ }
+ }
+ closedir(l_dirp);
+ }
+
+ switch (type) {
+ case eErrorEventTypeProcessCrash:
+ case eErrorEventTypeProcessExit:
+ case eErrorEventTypeHeartBeatFailure:
+ case eErrorEventTypeSystemLowMemory:
+ case eErrorEventTypeBootMicroReset:
+ case eErrorEventTypeModConnFailed:
+ case eErrorEventTypeStartRespFailed:
+ case eErrorEventTypeModuleInvokedResetRequest:
+
+// if ((UI_32) m_pCfg->m_emmcOutputErrMax <= vect_abnrm.size()) {
+// l_eStatus = deleteOldLog(l_emmc_path, vect_abnrm, f_archive_destination,
+// (UI_32) m_pCfg->m_emmcOutputErrMax);
+ if ((UI_32)m_pCfg->m_emmcOutputErrMax <= abnrm_count) {
+ l_eStatus = SS_LoggerStoreLogs_deleteOldLogAbnrm(l_emmc_path, vect_abnrm, f_archive_destination,
+ (UI_32)m_pCfg->m_emmcOutputErrMax, abnrm_count);
+
+ }
+ break;
+ case eErrorEventTypeGroupRelaunch:
+ if ((UI_32) m_pCfg->m_emmcOutputGrpRelaunchMax <= vect_rlnc.size()) {
+ l_eStatus = deleteOldLog(l_emmc_path, vect_rlnc, f_archive_destination,
+ (UI_32) m_pCfg->m_emmcOutputGrpRelaunchMax);
+ }
+ break;
+ default:
+ if ((UI_32) m_pCfg->m_emmcOutputMax <= vect_nrm.size()) {
+ l_eStatus = deleteOldLog(l_emmc_path, vect_nrm, f_archive_destination,
+ (UI_32) m_pCfg->m_emmcOutputMax);
+ }
+ break;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return l_eStatus;
+}
+
+void CLoggerUtil::SetMilage(UI_32 f_Milage) {
+ m_Milage = f_Milage;
+}
+
+std::string CLoggerUtil::GetUserInvokedFilename(HANDLE f_hApp, uint32_t f_time) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ std::string l_ret = "";
+ std::stringstream l_nameStream;
+ UI_32 l_seqNumber = 0;
+
+ EFrameworkunifiedStatus l_eStatus = m_pCfg->GetIncrementAndPersistUserInvokedCounter(
+ f_hApp, l_seqNumber);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "GetIncrementAndPersistUserInvokedCounter()");
+
+ /* new counter value was not persisted if l_eStatus != eFrameworkunifiedStatusOK */
+
+ l_nameStream << std::setw(5) << std::setfill('0') << std::right << std::dec << l_seqNumber << '_';
+ l_nameStream << std::setw(8) << std::setfill('0') << std::right << std::dec << m_Milage << '_';
+ l_nameStream << std::setw(5) << std::setfill('0') << std::right << std::dec << m_bootCount << '_';
+ l_nameStream << std::setw(15) << GetTimeString(f_time) << ".tar.gz";
+
+ l_ret = l_nameStream.str();
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_ret);
+}
+
+std::string CLoggerUtil::GetEmmcFilename(uint32_t f_time) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ std::string l_ret = "";
+ std::stringstream l_nameStream;
+ UI_32 l_counter = 0;
+
+ m_pCfg->GetAndIncrementEmmcCounter(l_counter);
+ l_nameStream << std::setw(5) << std::setfill('0') << std::right << std::dec << l_counter << '_';
+ l_nameStream << std::setw(15) << this->GetTimeString(f_time) << ".tar.gz";
+
+ l_ret = l_nameStream.str();
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_ret);
+}
+
+// LCOV_EXCL_START 8: dead code
+std::string CLoggerUtil::GetEmmcErrorFilename(uint32_t f_time) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ std::string l_ret = "";
+ std::stringstream l_nameStream;
+ UI_32 l_counter = 0;
+
+ m_pCfg->GetAndIncrementEmmcCounter(l_counter);
+ l_nameStream << std::setw(5) << std::setfill('0') << std::right << std::dec << l_counter << '_';
+ l_nameStream << std::setw(15) << this->GetTimeString(f_time) << "_ERR.tar.gz";
+
+ l_ret = l_nameStream.str();
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_ret);
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 13:
+std::string CLoggerUtil::GetEmmcNaviLogFilename(uint32_t f_time) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ std::string l_ret = "";
+ std::stringstream l_nameStream;
+ UI_32 l_counter = 1;
+
+ l_nameStream << std::setw(5) << std::setfill('0') << std::right << std::dec << l_counter << '_';
+ l_nameStream << std::setw(15) << this->GetTimeString(f_time) << ".log";
+
+ l_ret = l_nameStream.str();
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_ret);
+}
+// LCOV_EXCL_STOP
+
+std::string CLoggerUtil::GetTimeString(uint32_t f_time) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ std::string l_ret = "00000000_000000";
+ struct tm local_time;
+// Clock_getLocalTimeY2K38(&f_time, &local_time);
+ char buffer[20];
+ if (0
+ != strftime(buffer, sizeof(buffer), "%Y%m%d_%H%M%S", // LCOV_EXCL_BR_LINE 5: c code
+ &local_time)) {
+ l_ret = buffer;
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_ret);
+}
+
+void CLoggerUtil::SetUsbMountPath(std::string usbpath) {
+ strncpy(m_usbpath, usbpath.c_str(), USB_PATH_SIZE - 1);
+ m_usbpath[USB_PATH_SIZE - 1] = '\0';
+}
+#ifdef RELEASE_BUILD
+EFrameworkunifiedStatus CLoggerUtil::PathCheckAndCopyFile(std::string f_source,
+ std::string f_destination) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ std::string::size_type ret;
+
+ ret = f_destination.find(m_usbpath);
+ l_eStatus = CopyFile(f_source, f_destination);
+
+ return l_eStatus;
+}
+#endif // RELEASE_BUILD
+/////////////////////////////////////////////////////////////////////////
+///// Static Functions
+/////////////////////////////////////////////////////////////////////////
+
+EFrameworkunifiedStatus CLoggerUtil::CopyFile(std::string f_source,
+ std::string f_destination) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ ssize_t l_nrd;
+ ssize_t l_nwr;
+ char l_buf[BUF_MAX_SIZE];
+
+ int l_if = open(f_source.c_str(), O_RDONLY | O_CLOEXEC, 0);
+ if (-1 == l_if) { // LCOV_EXCL_BR_LINE 5: open's error case.
+ // LCOV_EXCL_START 5: open's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "src open fail:%s,errno:%d,msg:%s",
+ f_source.c_str(), errno, strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ } else {
+ bool isWebdav = false;
+ std::string l_tmpDest;
+ size_t l_pos = f_destination.find_last_of('/');
+
+ l_tmpDest = f_destination;
+ if (f_destination.find("/mnt/import") != std::string::npos) { // LCOV_EXCL_BR_LINE 13:
+ // if output to webdav's directory, don't create temporary file.
+ // because of being unable to rename the file on it.
+ isWebdav = true;
+ }
+
+ int l_of = open(l_tmpDest.c_str(), O_WRONLY | O_CREAT | O_CLOEXEC, 0640);
+ if (-1 == l_of) { // LCOV_EXCL_BR_LINE 5: open's error case.
+ // LCOV_EXCL_START 5: open's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "dest open fail:%s,errno:%d,msg:%s",
+ l_tmpDest.c_str(), errno, strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusFail;
+ // LCOV_EXCL_STOP
+ } else {
+ do {
+ l_nrd = read(l_if, l_buf, sizeof(l_buf));
+ if (l_nrd == -1) { // LCOV_EXCL_BR_LINE 5: read's error case.
+ // LCOV_EXCL_START 5: read's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "read fail:%s,errno:%d,msg:%s",
+ f_source.c_str(), errno, strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusAccessError;
+ break;
+ // LCOV_EXCL_STOP
+ }
+
+ l_nwr = write(l_of, l_buf, l_nrd);
+ if (l_nwr == -1) { // LCOV_EXCL_BR_LINE 5: write's error case.
+ // LCOV_EXCL_START 5: write's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (ENOSPC == errno) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "write fail(ENOSPC):%s,errno:%d,msg:%s", l_tmpDest.c_str(),
+ errno, strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusErrNoEAGAIN;
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "write fail:%s,errno:%d,msg%s",
+ l_tmpDest.c_str(), errno, strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusAccessError;
+ }
+ break;
+ // LCOV_EXCL_STOP
+ }
+ } while (l_nrd > 0);
+
+ fsync(l_of);
+ close(l_of);
+
+ if (l_eStatus != eFrameworkunifiedStatusOK) { // LCOV_EXCL_BR_LINE 6: can not be fail
+ // LCOV_EXCL_START 6: can not be fail
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ close(l_if);
+ return l_eStatus;
+ // LCOV_EXCL_STOP
+ }
+
+ {
+ struct stat istat_buf, ostat_buf;
+ int ret;
+ ret = fstat(l_if, &istat_buf);
+ if (ret < 0) { // LCOV_EXCL_BR_LINE 5: fstat's error case.
+ // LCOV_EXCL_START 5: fstat's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. stat(%s). errno: %d, %s",
+ f_source.c_str(), errno, strerror(errno));
+ // LCOV_EXCL_STOP
+ } else {
+ while (1) {
+ ret = stat(l_tmpDest.c_str(), &ostat_buf);
+ if (ret < 0) { // LCOV_EXCL_BR_LINE 5: stat's error case.
+ // LCOV_EXCL_START 5: stat's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. stat(%s). errno: %d, %s",
+ l_tmpDest.c_str(), errno, strerror(errno));
+ break;
+ // LCOV_EXCL_STOP
+ }
+ if (ostat_buf.st_size >= istat_buf.st_size) { // LCOV_EXCL_BR_LINE 5: read and write can not fail, so the size is same // NOLINT[whitespace/line_length]
+ break;
+ }
+ usleep(10000); // interval
+ }
+ }
+ }
+ }
+ close(l_if);
+
+ if (!isWebdav) { // LCOV_EXCL_BR_LINE 6: isWebdav is aways false
+ if (rename(l_tmpDest.c_str(), f_destination.c_str()) != 0) { // LCOV_EXCL_BR_LINE 5: rename's error case.
+ // LCOV_EXCL_START 5: rename's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "rename %s to %s fail,errno:%d,msg:%s",
+ l_tmpDest.c_str(), f_destination.c_str(), errno, strerror(errno));
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ if (std::string::npos != l_pos) { // LCOV_EXCL_BR_LINE 200: there is always '/' in f_destination
+ std::string l_destPath = f_destination.substr(0, l_pos);
+ SyncDir(l_destPath);
+ } else {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "dest invalid:%s", f_destination.c_str()); // LCOV_EXCL_LINE 200: there is always '/' in f_destination // NOLINT[whitespace/line_length]
+ }
+ }
+
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+
+// LCOV_EXCL_START 8: can not be called
+EFrameworkunifiedStatus CLoggerUtil::CopyUntyped(std::string f_source,
+ std::string f_destination) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ struct stat l_stat;
+ int l_statRetVal;
+ if (0 != access(f_source.c_str(), F_OK)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. The specified file path and name does not exist: %s",
+ f_source.c_str());
+ } else if (0 != (l_statRetVal = lstat(f_source.c_str(), &l_stat))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. stat() for file or directory returned error: %s -> %d",
+ f_source.c_str(), l_statRetVal);
+ } else if (0 != S_ISDIR(l_stat.st_mode)) {
+ l_eStatus = CopyDirectory(f_source, f_destination);
+ } else if (0 != S_ISLNK(l_stat.st_mode)) {
+ // avoid duplicate copy for eErrorEventTypeInterfaceunifiedEmmcLogs: /nv/log/awlog -> /nv/log2/awlog
+ if (f_source.find("/nv/log/awlog") == std::string::npos) {
+ l_eStatus = CopyDirectory(f_source, f_destination);
+ }
+ } else if (0 != S_ISREG(l_stat.st_mode)) {
+#ifdef RELEASE_BUILD
+ l_eStatus = PathCheckAndCopyFile(f_source, f_destination);
+#else
+ l_eStatus = CopyFile(f_source, f_destination);
+#endif // RELEASE_BUILD
+ } else {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. specified file may be a symbolic link or other non 'regular' type. File: %s, mode: 0x%04X.",
+ f_source.c_str(), l_stat.st_mode);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 8: can not be called
+EFrameworkunifiedStatus CLoggerUtil::CopyDirectory(std::string f_source,
+ std::string f_destination) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ DIR * l_pDir = opendir(f_source.c_str());
+
+ if (l_pDir == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Could not open directory: %s",
+ f_source.c_str());
+ } else {
+ if (mkdir(f_destination.c_str(), 0775) == -1) {
+ if (errno == EEXIST) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Directory: %s already exists.",
+ f_destination.c_str());
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Could not create directory: %s. Errno: %s",
+ f_destination.c_str(), strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ } else {
+ SyncDir(f_destination);
+ size_t l_pos = f_destination.find_last_of('/');
+ if (l_pos != std::string::npos) {
+ std::string l_destPath = f_destination.substr(0, l_pos);
+ SyncDir(l_destPath);
+ }
+ }
+
+ struct dirent l_pDirent;
+ struct dirent* next;
+ while (0 == readdir_r(l_pDir, &l_pDirent, &next) && next != NULL) {
+ if ((0 != strcmp(l_pDirent.d_name, ".")) && /* Ignore special . directory. */
+ (0 != strcmp(l_pDirent.d_name, "..")) && /* Ignore special .. directory. */
+ (0 != strcmp(l_pDirent.d_name, "lost+found")) && /* Ignore lost+found. */
+ ('.' != l_pDirent.d_name[0])) { /* Ignore hidden files */
+ std::string l_fileSource = f_source;
+ std::string l_fileDestination = f_destination;
+ l_fileSource.append("/");
+ l_fileSource.append(l_pDirent.d_name);
+ l_fileDestination.append("/");
+ l_fileDestination.append(l_pDirent.d_name);
+ l_eStatus = CopyUntyped(l_fileSource, l_fileDestination);
+ }
+ }
+
+ closedir(l_pDir);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 8: can not be called
+EFrameworkunifiedStatus CLoggerUtil::MoveFile(std::string f_source,
+ std::string f_destination) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+#ifdef RELEASE_BUILD
+ l_eStatus = CLoggerUtil::PathCheckAndCopyFile(f_source, f_destination);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "CLoggerUtil::PathCheckAndCopyFile()");
+#else
+ l_eStatus = CLoggerUtil::CopyFile(f_source, f_destination);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "CLoggerUtil::CopyFile()");
+#endif // RELEASE_BUILD
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ l_eStatus = (0 == remove(f_source.c_str())) ? eFrameworkunifiedStatusOK : eFrameworkunifiedStatusFail;
+ if (l_eStatus == eFrameworkunifiedStatusOK) {
+ size_t l_pos = f_source.find_last_of('/');
+ if (std::string::npos != l_pos) {
+ std::string l_emmc_path = f_source.substr(0, l_pos);
+ SyncDir(l_emmc_path);
+ }
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 8: can not be called
+EFrameworkunifiedStatus CLoggerUtil::MoveUntyped(std::string f_source,
+ std::string f_destination) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ struct stat l_stat;
+ int l_statRetVal;
+ if (0 != access(f_source.c_str(), F_OK)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. The specified file path and name does not exist: %s",
+ f_source.c_str());
+ } else if (0 != (l_statRetVal = stat(f_source.c_str(), &l_stat))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. stat() for file or directory returned error: %s -> %d",
+ f_source.c_str(), l_statRetVal);
+ } else if (0 != S_ISDIR(l_stat.st_mode)) {
+ l_eStatus = CLoggerUtil::MoveDirectory(f_source, f_destination);
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus, "CLoggerUtil::MoveDirectory(f_source, f_destination);");
+ } else if (0 != S_ISREG(l_stat.st_mode)) {
+ l_eStatus = CLoggerUtil::MoveFile(f_source, f_destination);
+ LOG_STATUS_IF_ERRORED(l_eStatus,
+ "CLoggerUtil::MoveFile(f_source, f_destination)");
+ } else {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_ERR,
+ __FUNCTION__,
+ " Error. specified file may be a symbolic link or other non 'regular' type. File: %s, mode: 0x%04X.",
+ f_source.c_str(), l_stat.st_mode);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 8: can not be called
+EFrameworkunifiedStatus CLoggerUtil::MoveDirectory(std::string f_source,
+ std::string f_destination) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ DIR * l_pDir = opendir(f_source.c_str());
+
+ if (l_pDir == NULL) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Could not open directory: %s",
+ f_source.c_str());
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else {
+ errno = 0;
+ if (mkdir(f_destination.c_str(), 0666) == -1) {
+ if (errno == EEXIST) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Directory: %s already exists.",
+ f_destination.c_str());
+ } else {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "Could not create directory: %s. Errno: %s",
+ f_destination.c_str(), strerror(errno));
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ errno = 0;
+ } else {
+ SyncDir(f_destination);
+ size_t l_pos = f_destination.find_last_of('/');
+ if (l_pos != std::string::npos) {
+ std::string l_destPath = f_destination.substr(0, l_pos);
+ SyncDir(l_destPath);
+ }
+ }
+
+ if (eFrameworkunifiedStatusOK == l_eStatus) { /* if directory already exists or has been newly created */
+ struct dirent l_pDirent;
+ struct dirent* next;
+
+ while (0 == readdir_r(l_pDir, &l_pDirent, &next) && next != NULL) {
+ if ((0 != strcmp(l_pDirent.d_name, ".")) && /* Ignore special . directory. */
+ (0 != strcmp(l_pDirent.d_name, "..")) && /* Ignore special .. directory. */
+ (0 != strcmp(l_pDirent.d_name, "lost+found")) && /* Ignore lost+found. */
+ ('.' != l_pDirent.d_name[0])) { /* Ignore hidden files */
+ std::string l_fileSource = f_source;
+ std::string l_fileDestination = f_destination;
+ l_fileSource.append("/");
+ l_fileSource.append(l_pDirent.d_name);
+ l_fileDestination.append("/");
+ l_fileDestination.append(l_pDirent.d_name);
+ l_eStatus = MoveUntyped(l_fileSource, l_fileDestination);
+ }
+ }
+ } else {
+ }
+ closedir(l_pDir);
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 200: can not be called
+ELOGGERSERVICELOGTYPE CLoggerUtil::QueryLoggerservicelogType(std::string f_logname) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+// if (f_logname.find("_ILG_RESET.tar.gz") != std::string::npos
+ if (f_logname.find(SS_STORE_FILENAME_SYSILG_TERM) != std::string::npos) {
+ return eLoggerservicelogTypeAbnormal;
+ } else if (f_logname.find(SS_STORE_FILENAME__CWORD52__TERM) != std::string::npos) {
+ return eLoggerservicelogTypeAbnormal;
+ } else if (f_logname.find("_ILG_RESET.tar.gz") != std::string::npos
+
+ || f_logname.find("_ERR.tar.gz") != std::string::npos) {
+ return eLoggerservicelogTypeAbnormal;
+ } else if (f_logname.find("_GRP_RELAUNCH.tar.gz") != std::string::npos) {
+ return eLoggerservicelogTypeGrpRelaunch;
+ } else if (f_logname.find(".tar.gz") != std::string::npos) {
+ return eLoggerservicelogTypeNormal;
+ } else {
+ return eLoggerservicelogTypeOther;
+ }
+}
+// LCOV_EXCL_STOP
+
+void CLoggerUtil::SyncDir(std::string f_dir_path) {
+ int fd = open(f_dir_path.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC);
+#define OPE_ERR_MSG "%s %s failed. errno:%d,msg:%s"
+ if (fd == -1) { // LCOV_EXCL_BR_LINE 5: open's error case.
+ // LCOV_EXCL_START 5: open's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, OPE_ERR_MSG, f_dir_path.c_str(), "open",
+ errno, strerror(errno));
+ // LCOV_EXCL_STOP
+ } else {
+ if (fsync(fd) == -1) { // LCOV_EXCL_BR_LINE 5: open's error case.
+ // LCOV_EXCL_START 5: open's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, OPE_ERR_MSG, f_dir_path.c_str(), "fsync",
+ errno, strerror(errno));
+ // LCOV_EXCL_STOP
+ }
+ if (close(fd) == -1) { // LCOV_EXCL_BR_LINE 5: open's error case.
+ // LCOV_EXCL_START 5: open's error case.
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, OPE_ERR_MSG, f_dir_path.c_str(), "close",
+ errno, strerror(errno));
+ // LCOV_EXCL_STOP
+ }
+ }
+#undef OPE_ERR_MSG
+}
+
diff --git a/logger_service/server/src/testapps/fopen b/logger_service/server/src/testapps/fopen
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/logger_service/server/src/testapps/fopen
diff --git a/logger_service/server/src/testapps/testapps.log b/logger_service/server/src/testapps/testapps.log
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/logger_service/server/src/testapps/testapps.log
diff --git a/logger_service/server/src/testapps/testapps.tar.gz b/logger_service/server/src/testapps/testapps.tar.gz
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/logger_service/server/src/testapps/testapps.tar.gz
diff --git a/logger_service/server/src/udp_file_writer.cpp b/logger_service/server/src/udp_file_writer.cpp
new file mode 100644
index 00000000..ce04ae00
--- /dev/null
+++ b/logger_service/server/src/udp_file_writer.cpp
@@ -0,0 +1,161 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "readerWriter/writer/udp_file_writer.h"
+#include "readerWriter/writer/file_writer.h"
+#include "readerWriter/writer/cached_file_writer.h"
+
+namespace ReaderWriter {
+
+// LCOV_EXCL_START 8:dead code
+CUdpFileWriter::CUdpFileWriter()
+ : m_pUdpWriter(NULL),
+ m_pFileWriter(NULL),
+ m_pLoggerCfg(NULL),
+ m_ipAddress(""),
+ m_port(0),
+ m_FileName(""),
+ m_FileSize(0) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+}
+// LCOV_EXCL_STOP
+
+CUdpFileWriter::~CUdpFileWriter() { // LCOV_EXCL_START 8:dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (this->m_pFileWriter != NULL) {
+ delete (this->m_pFileWriter);
+ this->m_pFileWriter = NULL;
+ }
+ if (this->m_pUdpWriter != NULL) {
+ delete (this->m_pUdpWriter);
+ this->m_pUdpWriter = NULL;
+ }
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 8:dead code
+EFrameworkunifiedStatus CUdpFileWriter::Initialize(CLoggerCfg* f_pLoggerCfg,
+ std::string f_Name1, UI_32 f_size1,
+ std::string f_Name2, UI_32 f_size2) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ if ((NULL == this->m_pFileWriter) && (NULL == this->m_pUdpWriter)
+ && (NULL != f_pLoggerCfg)) {
+ this->m_pFileWriter = new (std::nothrow) CCachedFileWriter();
+ this->m_pUdpWriter = new (std::nothrow) CUdpWriter();
+ m_pLoggerCfg = f_pLoggerCfg;
+ m_ipAddress = f_Name2;
+ m_port = f_size2;
+ m_FileName = f_Name1;
+ m_FileSize = f_size1;
+ EFrameworkunifiedStatus l_eStatus1 = this->m_pUdpWriter->Initialize(m_pLoggerCfg,
+ m_ipAddress, m_port,
+ "", 0);
+ EFrameworkunifiedStatus l_eStatus2 = this->m_pFileWriter->Initialize(m_pLoggerCfg,
+ m_FileName,
+ m_FileSize, "", 0);
+ l_eStatus =
+ ((l_eStatus1 != eFrameworkunifiedStatusOK) || (eFrameworkunifiedStatusOK != l_eStatus2)) ?
+ eFrameworkunifiedStatusFail : eFrameworkunifiedStatusOK;
+ if (l_eStatus == eFrameworkunifiedStatusOK) {
+ l_eStatus = this->Open();
+ }
+ } else {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %d", l_eStatus);
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CUdpFileWriter::Open(void) { // LCOV_EXCL_START 8:dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ if ((NULL != this->m_pFileWriter) && (NULL != this->m_pUdpWriter)) {
+ EFrameworkunifiedStatus l_eStatus1 = this->m_pUdpWriter->Open();
+ EFrameworkunifiedStatus l_eStatus2 = this->m_pFileWriter->Open();
+ l_eStatus =
+ ((l_eStatus1 != eFrameworkunifiedStatusOK) || (eFrameworkunifiedStatusOK != l_eStatus2)) ?
+ eFrameworkunifiedStatusFail : eFrameworkunifiedStatusOK;
+ }
+
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+BOOL CUdpFileWriter::IsOpen(void) { // LCOV_EXCL_START 8:dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ BOOL l_ret = FALSE;
+ if ((this->m_pUdpWriter != NULL) && (this->m_pFileWriter != NULL)) {
+ l_ret = (m_pUdpWriter->IsOpen() && m_pFileWriter->IsOpen());
+ }
+ return l_ret;
+}
+// LCOV_EXCL_STOP
+
+// LCOV_EXCL_START 8:dead code
+EFrameworkunifiedStatus CUdpFileWriter::Write(UI_8* f_data, UI_32 f_length,
+ SI_32& f_bytesWritten) {
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ if ((NULL != this->m_pUdpWriter)) {
+ l_eStatus = this->m_pUdpWriter->Write(f_data, f_length, f_bytesWritten);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "this->m_pUdpWriter->Write() failed.");
+ }
+
+ if ((NULL != this->m_pFileWriter)) {
+ l_eStatus = this->m_pFileWriter->Write(f_data, f_length, f_bytesWritten);
+ LOG_STATUS_IF_ERRORED(l_eStatus, "this->m_pFileWriter->Write() failed.");
+ } else {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+ return (l_eStatus);
+}
+// LCOV_EXCL_STOP
+
+void CUdpFileWriter::Close() { // LCOV_EXCL_START 8:dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (this->m_pFileWriter != NULL) {
+ this->m_pFileWriter->Close();
+ delete (this->m_pFileWriter);
+ this->m_pFileWriter = NULL;
+ }
+ if (this->m_pUdpWriter != NULL) {
+ this->m_pUdpWriter->Close();
+ delete (this->m_pUdpWriter);
+ this->m_pUdpWriter = NULL;
+ }
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CUdpFileWriter::FlushCache(void) { // LCOV_EXCL_START 8:dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return (this->m_pFileWriter->FlushCache());
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CUdpFileWriter::UpdateLoggingParameters(void) { // LCOV_EXCL_START 8:dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ return (this->m_pUdpWriter->UpdateLoggingParameters());
+}
+} // namespace ReaderWriter
+
+// LCOV_EXCL_STOP
diff --git a/logger_service/server/src/udp_writer.cpp b/logger_service/server/src/udp_writer.cpp
new file mode 100644
index 00000000..d4ef747a
--- /dev/null
+++ b/logger_service/server/src/udp_writer.cpp
@@ -0,0 +1,295 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#include "readerWriter/writer/udp_writer.h"
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <errno.h>
+#include <string.h>
+#include <inttypes.h>
+#ifdef AGL_STUB
+#include <other_service/PosixBasedOS001ClockCycleApi.h>
+#else
+#include <sys/syspage.h>
+#include <sys/neutrino.h>
+#endif
+#include <native_service/ns_logger_if.h>
+#include <string>
+#include <algorithm>
+
+#define TIME_UNTIL_UDP_START (UI_32)25
+
+namespace ReaderWriter {
+
+CUdpWriter::CUdpWriter()
+ : m_SocketHandle(-1),
+ m_IPAddress(""),
+ m_index(0),
+ m_port(REMOTE_IP_PORT),
+ m_InitialTimeElapsed(FALSE) {
+ std::memset(&m_oSAInfo, 0, sizeof(sockaddr_in));
+ std::memset(&m_buffer[0], 0, UDP_CACHED_BLOCK_SIZE);
+}
+
+CUdpWriter::~CUdpWriter() {
+ if (m_SocketHandle != -1) {
+ this->Close();
+ }
+}
+
+EFrameworkunifiedStatus CUdpWriter::Initialize(CLoggerCfg* f_pLoggerCfg, std::string f_Name1,
+ UI_32 f_size1, std::string f_Name2,
+ UI_32 f_size2) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ this->m_pLoggerCfg = f_pLoggerCfg;
+ this->m_IPAddress = f_Name1;
+ if (NULL == f_pLoggerCfg) { // LCOV_EXCL_BR_LINE 200: f_pLoggerCfg can not be null
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ l_eStatus = eFrameworkunifiedStatusNullPointer; // LCOV_EXCL_LINE 200: f_pLoggerCfg can not be null
+ } else if ((f_pLoggerCfg->IsUDPLoggingEnabled())) {
+ if (m_IPAddress.length() > 0) {
+ this->m_port = f_size1;
+ l_eStatus = this->Open();
+ LOG_STATUS_IF_ERRORED(
+ l_eStatus,
+ "this->Open() failed. UDP logging disabled. Enable via Engineering Menu.");
+ // Continue without UDP Logging;
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ }
+ } else {
+ this->m_SocketHandle = -1;
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %d", l_eStatus);
+ return (l_eStatus);
+}
+
+BOOL CUdpWriter::IsOpen(void) {
+ BOOL l_ret = (-1 != m_SocketHandle) ? TRUE : FALSE;
+ if (TRUE == l_ret) {
+#ifdef AGL_STUB
+ UI_32 l_elapsed = ((UI_32)((F_64)ClockCycle()/1000000));
+#else
+ UI_32 l_elapsed = ((UI_32) ((F_64) ClockCycle()
+ / (F_64) (SYSPAGE_ENTRY(qtime)->cycles_per_sec)));
+#endif
+ // check if 20 Seconds have elapsed since startup
+ if (TIME_UNTIL_UDP_START <= l_elapsed) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ "%d seconds elapsed. Starting UDP logging", l_elapsed);
+ m_InitialTimeElapsed = TRUE;
+ l_ret = TRUE;
+
+ } else {
+ FRAMEWORKUNIFIEDLOG(
+ ZONE_INFO,
+ __FUNCTION__,
+ "Time before starting UDP not yet elapsed. Waiting for %d more seconds",
+ (TIME_UNTIL_UDP_START - l_elapsed));
+ usleep((TIME_UNTIL_UDP_START - l_elapsed)*1000);
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Starting UDP now!");
+ }
+ }
+ return l_ret;
+}
+
+EFrameworkunifiedStatus CUdpWriter::Open() {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
+ if ((m_IPAddress.length() > 0)) {
+ int l_SocketOption = 1;
+ // Set the domain using the classes domain value.
+ m_oSAInfo.sin_family = AF_INET;
+ m_oSAInfo.sin_addr.s_addr = inet_addr(OWN_ADDRESS); // m_IPAddress.c_str()); // "192.168.1.2");//htonl(INADDR_ANY);
+ m_oSAInfo.sin_port = htons(this->m_port);
+ if (FALSE == this->m_pLoggerCfg->IsUDPLoggingEnabled()) {
+ this->Close();
+ l_eStatus = eFrameworkunifiedStatusFail;
+ } else if (this->m_SocketHandle != -1) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
+ " Info. socket already opened. No action required");
+ l_eStatus = eFrameworkunifiedStatusOK;
+ } else if (-1 == (this->m_SocketHandle = socket(AF_INET, SOCK_DGRAM, 0))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. socket(AF_INET, SOCK_DGRAM, 0) returned -1. errno: %s",
+ strerror(errno));
+ errno = 0;
+ l_eStatus = eFrameworkunifiedStatusDbExecuteFail;
+ } else if (setsockopt(m_SocketHandle, SOL_SOCKET, SO_REUSEADDR,
+ &l_SocketOption, sizeof(l_SocketOption)) == -1) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "setsockopt(SO_REUSEADDR) failed.errno: %s", strerror(errno));
+ errno = 0;
+ l_eStatus = eFrameworkunifiedStatusDbResultError;
+ }
+#ifdef AGL_STUB
+ else if (setsockopt(m_SocketHandle, SOL_SOCKET, SO_REUSEADDR , // LCOV_EXCL_BR_LINE 6: the same calls will get the same return // NOLINT (readability/braces)
+ &l_SocketOption, sizeof(l_SocketOption)) == -1)
+#else
+ else if (setsockopt(m_SocketHandle, SOL_SOCKET, SO_REUSEPORT, // NOLINT (readability/braces)
+ &l_SocketOption, sizeof(l_SocketOption)) == -1)
+#endif
+ {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "setsockopt(SO_REUSEPORT) failed. errno: %s", strerror(errno));
+ errno = 0;
+ l_eStatus = eFrameworkunifiedStatusDbResultError;
+ } else if (setsockopt(m_SocketHandle, SOL_SOCKET, SO_DONTROUTE,
+ &l_SocketOption, sizeof(l_SocketOption)) == -1) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ "setsockopt(SO_DONTROUTE) failed. errno: %s", strerror(errno));
+ errno = 0;
+ l_eStatus = eFrameworkunifiedStatusDbResultError;
+ } else if (INADDR_NONE == m_oSAInfo.sin_addr.s_addr) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Invalid local address.");
+ l_eStatus = eFrameworkunifiedStatusDbRecNotFound;
+ } else if (0
+ != bind(this->m_SocketHandle, (const struct sockaddr *) &m_oSAInfo,
+ sizeof(m_oSAInfo))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
+ " Error. bind() returned not zero. errno: %s", strerror(errno));
+ errno = 0;
+ l_eStatus = eFrameworkunifiedStatusSemUnlockFail;
+ } else {
+ m_oSAInfo.sin_addr.s_addr = inet_addr(m_IPAddress.c_str());
+ if (INADDR_NONE == m_oSAInfo.sin_addr.s_addr) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Invalid target address.");
+ l_eStatus = eFrameworkunifiedStatusFault;
+ } else {
+ l_eStatus = eFrameworkunifiedStatusOK;
+ }
+ }
+
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ this->Close();
+ m_SocketHandle = -1;
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "- : %d", l_eStatus);
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CUdpWriter::WriteData(UI_8 *f_data, UI_32 f_length,
+ SI_32 &f_bytesWritten) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ UI_8 l_retry = SEND_RETRY_VALUE;
+ if (this->m_SocketHandle == -1) {
+ l_eStatus = eFrameworkunifiedStatusInvldParam;
+ } else {
+ while ((0 != l_retry)
+ && ((f_bytesWritten >= 0) && ((UI_32) f_bytesWritten != f_length))) {
+ SI_32 l_bytesWritten = (SI_32)(sendto(m_SocketHandle, &f_data[f_bytesWritten],
+ f_length - f_bytesWritten, 0,
+ (const struct sockaddr *) &m_oSAInfo,
+ sizeof(m_oSAInfo)));
+ f_bytesWritten += l_bytesWritten;
+ l_eStatus = (l_bytesWritten >= 0) ? eFrameworkunifiedStatusOK : eFrameworkunifiedStatusFail;
+ if (eFrameworkunifiedStatusOK != l_eStatus) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "l_retry: %d, errno: %s", l_retry,
+ strerror(errno));
+ errno = 0;
+ l_retry--;
+ usleep(100);
+ } else {
+ l_retry = SEND_RETRY_VALUE;
+ }
+ }
+ }
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CUdpWriter::Write(UI_8* f_data, UI_32 f_length,
+ SI_32& f_bytesWritten) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ f_bytesWritten = 0;
+ if ((f_data == NULL)) {
+ l_eStatus = eFrameworkunifiedStatusNullPointer;
+ } else if ((-1 == m_SocketHandle)) {
+ l_eStatus = eFrameworkunifiedStatusFail;
+ }
+
+ if (eFrameworkunifiedStatusOK == l_eStatus) {
+ if (f_length > UDP_MAX_LENGTH) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Possible memory corruption.");
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. Length(%d) bigger than cache. ",
+ f_length);
+ } else {
+ UI_32 l_remainingIndex = 0;
+
+ while (l_remainingIndex != f_length) {
+ UI_32 l_offset = (UDP_CACHED_BLOCK_SIZE - this->m_index);
+ l_offset = std::min(l_offset, (f_length - l_remainingIndex));
+ (void) std::memcpy(&this->m_buffer[this->m_index],
+ &f_data[l_remainingIndex], l_offset);
+ l_remainingIndex += l_offset;
+ this->m_index += l_offset;
+ if (this->m_index == UDP_CACHED_BLOCK_SIZE) {
+ (void) this->FlushCache();
+ this->m_index = 0;
+ }
+ }
+ f_bytesWritten = f_length;
+ }
+ }
+ return (l_eStatus);
+}
+void CUdpWriter::Close() {
+ if (m_SocketHandle != -1) {
+ (void) close(m_SocketHandle);
+ m_SocketHandle = -1;
+ }
+}
+
+EFrameworkunifiedStatus CUdpWriter::UpdateLoggingParameters(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ if (this->m_pLoggerCfg != NULL) {
+ BOOL l_enabled = this->m_pLoggerCfg->IsUDPLoggingEnabled();
+ if ((TRUE == l_enabled) && (m_SocketHandle == -1)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Info. Opening UDP.");
+ l_eStatus = this->Open();
+ } else if (((FALSE == l_enabled) && (m_SocketHandle != -1))) {
+ FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Info. Closing UDP.");
+ l_eStatus = eFrameworkunifiedStatusOK;
+ this->Close();
+ } else {
+ }
+ }
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "- :%d", l_eStatus);
+ return (l_eStatus);
+}
+
+EFrameworkunifiedStatus CUdpWriter::FlushCache(void) {
+ EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
+ SI_32 l_written = 0;
+ SI_32 l_writtenTotal = 0;
+ while (((l_writtenTotal >= 0) && ((UI_32) l_writtenTotal < this->m_index))
+ && (eFrameworkunifiedStatusOK == l_eStatus)) {
+ l_eStatus = this->WriteData(&this->m_buffer[l_writtenTotal],
+ this->m_index - l_writtenTotal, l_written);
+ l_writtenTotal += l_written;
+ l_written = 0;
+ }
+ this->m_index = 0;
+ return l_eStatus;
+}
+} // namespace ReaderWriter
diff --git a/logger_service/server/src/writer.cpp b/logger_service/server/src/writer.cpp
new file mode 100644
index 00000000..f6c6ab24
--- /dev/null
+++ b/logger_service/server/src/writer.cpp
@@ -0,0 +1,86 @@
+/*
+ * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+/// \ingroup tag_SS_LoggerService
+/// \brief TODO
+///
+///////////////////////////////////////////////////////////////////////////////
+#include <string>
+#include <new>
+#include <iostream>
+#include "readerWriter/writer/writer.h"
+#include "readerWriter/writer/file_writer.h"
+#include "readerWriter/writer/udp_writer.h"
+#include "readerWriter/writer/udp_file_writer.h"
+#include "readerWriter/writer/cached_file_writer.h"
+
+namespace ReaderWriter {
+
+CWriter::CWriter()
+ : m_pLoggerCfg(NULL) {
+}
+
+CWriter::~CWriter() {
+}
+
+CWriter* CWriter::OpenWriter(CLoggerCfg* f_pLoggerCfg, EReaderType f_type,
+ std::string f_Name1, UI_32 f_size1,
+ std::string f_Name2, UI_32 f_size2) {
+ CWriter* l_ret = NULL;
+ if ((f_Name1.length() != 0) && (f_pLoggerCfg != NULL)) { // LCOV_EXCL_BR_LINE 200:As it is always TRUE
+ switch (f_type) {// LCOV_EXCL_BR_LINE 200:As it must be eReaderWriterTypeQueue or eReaderWriterTypeMem
+ case eReaderWriterTypeFile:
+ l_ret = new (std::nothrow) CCachedFileWriter(); // LCOV_EXCL_BR_LINE 5:Cannot pass because it cannot be new
+ break;
+
+ case eReaderWriterTypeUdp:
+ l_ret = new (std::nothrow) CUdpWriter(); // LCOV_EXCL_BR_LINE 5:Cannot pass because it cannot be new
+ break;
+ case eReaderWriterTypeUdpAndFile: // LCOV_EXCL_START 8:dead code
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ if (f_Name2.length() != 0) {
+ l_ret = new (std::nothrow) CUdpFileWriter();
+ }
+ // LCOV_EXCL_STOP
+ default:
+ break;
+ }
+ }
+ if (NULL != l_ret) { // LCOV_EXCL_BR_LINE 200:As it is not always NULL
+ if (eFrameworkunifiedStatusOK != l_ret->Initialize(f_pLoggerCfg, f_Name1, f_size1, f_Name2, f_size2)) {
+ FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Open Writer Failed");
+ delete (l_ret);
+ l_ret = NULL;
+ }
+ }
+
+ return l_ret;
+}
+
+EFrameworkunifiedStatus CWriter::FlushCache(void) { // LCOV_EXCL_START 8:Base class virtual functions
+ AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Default function called!");
+ return (eFrameworkunifiedStatusOK);
+}
+// LCOV_EXCL_STOP
+
+EFrameworkunifiedStatus CWriter::UpdateLoggingParameters(void) {
+ FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Default function called!");
+ return (eFrameworkunifiedStatusOK);
+}
+} // namespace ReaderWriter
+
diff --git a/logger_service/server/work/Makefile b/logger_service/server/work/Makefile
new file mode 100644
index 00000000..2b60ed70
--- /dev/null
+++ b/logger_service/server/work/Makefile
@@ -0,0 +1,128 @@
+#
+# @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+######### installed program #############
+INST_PROGS = SS_LoggerService
+
+
+######### compiled sources #############
+SS_LoggerService_SRCS += mod_version.c
+SS_LoggerService_SRCS += cached_file_writer.cpp
+SS_LoggerService_SRCS += file_writer.cpp
+SS_LoggerService_SRCS += mem_reader.cpp
+SS_LoggerService_SRCS += loggerservice_application.cpp
+SS_LoggerService_SRCS += loggerservice_main.cpp
+SS_LoggerService_SRCS += loggerservicedebug_child_thread.cpp
+SS_LoggerService_SRCS += loggerservicedebug_writer_Evntworker.cpp
+SS_LoggerService_SRCS += queue_reader.cpp
+SS_LoggerService_SRCS += reader.cpp
+SS_LoggerService_SRCS += reader_writer.cpp
+SS_LoggerService_SRCS += ss_logger_cfg.cpp
+SS_LoggerService_SRCS += ss_logger_device_detection.cpp
+SS_LoggerService_SRCS += ss_logger_error_event.cpp
+SS_LoggerService_SRCS += ss_logger_error_event_archive.cpp
+SS_LoggerService_SRCS += ss_logger_error_event_can_evt_reply.cpp
+SS_LoggerService_SRCS += ss_logger_error_event_cfg.cpp
+SS_LoggerService_SRCS += ss_logger_error_event_responses.cpp
+SS_LoggerService_SRCS += ss_logger_error_event_storage.cpp
+SS_LoggerService_SRCS += ss_logger_fs_directory.cpp
+SS_LoggerService_SRCS += ss_logger_popups.cpp
+SS_LoggerService_SRCS += ss_logger_reader_writer_control.cpp
+SS_LoggerService_SRCS += ss_logger_server_callbacks.cpp
+SS_LoggerService_SRCS += ss_logger_util.cpp
+SS_LoggerService_SRCS += udp_writer.cpp
+SS_LoggerService_SRCS += writer.cpp
+SS_LoggerService_SRCS += udp_file_writer.cpp
+
+######## add source path #############
+VPATH += ../src
+VPATH += ../include/$(COMPONENT_NAME)
+VPATH += -I../include/readerWriter/reader
+VPATH += -I../include/readerWriter/writer
+
+
+######### add include path #############
+CPPFLAGS += -I./
+CPPFLAGS += -I../include
+CPPFLAGS += -I../include/readerWriter
+CPPFLAGS += -I../include/readerWriter/reader
+CPPFLAGS += -I../include/readerWriter/writer
+CPPFLAGS += -Wl,--no-undefined
+CPPFLAGS += -Werror=implicit-function-declaration
+CPPFLAGS += -Werror=format-security
+
+CPPFLAGS += -Wconversion
+CPPFLAGS += -Wint-to-pointer-cast
+CPPFLAGS += -Wpointer-arith
+CPPFLAGS += -Wformat
+######### add compile option #############
+CPPFLAGS += -DRELEASE_BUILD
+CPPFLAGS += -DLINUX
+CPPFLAGS += -DFRAMEWORKUNIFIEDLOGOPTIONS=0x08 -DFRAMEWORKUNIFIEDLOGAPPZONES=31,30,29,28,27,26,9,8,3
+CPPFLAGS += -DIMPL_AGL_APPLICATION_CALLBACKS_PRE_BACKGROUND
+CXXFLAGS += -std=c++11
+
+CPPFLAGS_mem_reader.o = -fno-exceptions
+CPPFLAGS_reader.o = -fno-exceptions
+CPPFLAGS_reader_writer.o = -fno-exceptions
+CPPFLAGS_ss_logger_error_event.o = -fno-exceptions
+CPPFLAGS_ss_logger_error_event_archive.o = -fno-exceptions
+CPPFLAGS_ss_logger_error_event_can_evt_reply.o = -fno-exceptions
+CPPFLAGS_ss_logger_error_event_cfg.o = -fno-exceptions
+CPPFLAGS_ss_logger_error_event_responses.o = -fno-exceptions
+CPPFLAGS_ss_logger_error_event_storage.o = -fno-exceptions
+CPPFLAGS_ss_logger_fs_directory.o = -fno-exceptions
+CPPFLAGS_ss_logger_popups.o = -fno-exceptions
+CPPFLAGS_ss_logger_reader_writer_control.o = -fno-exceptions
+CPPFLAGS_ss_logger_server_callbacks.o = -fno-exceptions
+CPPFLAGS_ss_logger_util.o = -fno-exceptions
+CPPFLAGS_writer.o = -fno-exceptions
+CPPFLAGS_mod_version.o = -fno-exceptions
+CPPFLAGS_cashed_file_writer.o = -fno-exceptions
+CPPFLAGS_file_writer.o = -fno-exceptions
+CPPFLAGS_loggerservice_application.o = -fno-exceptions
+CPPFLAGS_loggerservice_main.o = -fno-exceptions
+CPPFLAGS_loggerservicedebug_child_thread.o = -fno-exceptions
+CPPFLAGS_loggerservicedebug_writer_Evntworker.o = -fno-exceptions
+CPPFLAGS_queue_reader.o = -fno-exceptions
+CPPFLAGS_ss_logger_device_detection.o = -fno-exceptions
+CPPFLAGS_udp_file_writer.o = -fno-exceptions
+CPPFLAGS_udp_writer.o = -fno-exceptions
+
+######### linked library #############
+LDFLAGS += -L../lib/
+LDLIBS += -Wl,-Bstatic -lSS_LoggerStoreLogs
+#LDLIBS += -Wl,-Bstatic -lPFDRECThread
+
+######### linked library (dynamic) #############
+LDLIBS += -Wl,-Bdynamic -lc #Substitute for libsocket
+LDLIBS += -Wl,-Bdynamic -lstdc++
+LDLIBS += -Wl,-Bdynamic -lrt # for mq_xxx
+LDLIBS += -Wl,-Bdynamic -lNS_FrameworkUnified
+LDLIBS += -Wl,-Bdynamic -ltar
+LDLIBS += -Wl,-Bdynamic -lz
+LDLIBS += -Wl,-Bdynamic -lSS_SystemIfUnified
+LDLIBS += -Wl,-Bdynamic -lPosixBasedOS001legacy
+LDLIBS += -Wl,-Bdynamic -lvp
+LDLIBS += -Wl,-Bdynamic -lns_backup #for PFDRECTread
+LDLIBS += -Wl,-Bdynamic -lcommon
+LDLIBS += -Wl,-Bdynamic -lcrypto
+#LDLIBS += -Wl,-Bdynamic -lextension
+#LDLIBS += -Wl,-Bdynamic -lClock_API
+
+
+LINK_CXX=Y
+include ../../../system_service.mk
diff --git a/system_service.mk b/system_service.mk
new file mode 100644
index 00000000..a8a06b06
--- /dev/null
+++ b/system_service.mk
@@ -0,0 +1,44 @@
+#############################################################
+#
+# Common Makefile for system_service
+# Copyright (C) 2017-2019 TOYOTA MOTOR CORPORATION
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#############################################################
+
+CURRENT_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
+
+#############################################################
+# COMPONENT_NAME must not be blank and be named snake_case
+
+COMPONENT_NAME := system_service
+
+#############################################################
+
+
+
+#############################################################
+# You can add several flags and libraries.
+# When you add -I or -L path, DO NOT USE relative path.
+# Instead, use $(CURRENT_DIR) variable
+# that indicates the path this .mk file is stored.
+
+COMPONENT_CFLAGS :=
+COMPONENT_CXXFLAGS :=
+COMPONENT_LDLIBS :=
+COMPONENT_LDFLAGS :=
+
+##############################################################
+
+include $(SDKTARGETSYSROOT)/usr/agl/share/agl.mk