2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 ///////////////////////////////////////////////////////////////////////////////
18 /// \ingroup tag_SS_LoggerService
21 ///////////////////////////////////////////////////////////////////////////////
22 ///////////////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////////////
25 #include "ss_logger_popups.h"
28 CLoggerPopups::CLoggerPopups()
33 CLoggerPopups::~CLoggerPopups() { // LCOV_EXCL_START 14:globle instance
34 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
38 EFrameworkunifiedStatus CLoggerPopups::Initialize(CLoggerCfg* f_pLoggerCfg) {
39 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
40 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
41 this->m_pLoggerCfg = f_pLoggerCfg;
42 l_eStatus = (m_pLoggerCfg == NULL) ? eFrameworkunifiedStatusNullPointer : eFrameworkunifiedStatusOK;
43 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
47 BOOL CLoggerPopups::IsPopupNeeded(TLoggerErrorEvent f_event) {
48 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
49 BOOL l_ret = ((f_event.EventBitMask & EVENT_BIT_POPUP) != 0) ? TRUE : FALSE;
50 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
54 BOOL CLoggerPopups::CanShowStartPopup(
55 std::vector<TLoggingArtifact>* f_remainingArtifact) {
56 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
58 if (f_remainingArtifact != NULL) {
60 std::vector<TLoggingArtifact>::iterator l_iter;
61 for (l_iter = f_remainingArtifact->begin();
62 f_remainingArtifact->end() != l_iter; l_iter++) {
63 if (l_iter->ArtifactId == eArtifactIdScreenShot) {
69 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
73 std::string CLoggerPopups::getDeviceName(std::string f_dest) {
74 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
75 std::string l_ret = "";
76 if (f_dest.length() == 0) {
77 } else if (f_dest.find(this->m_pLoggerCfg->m_usb0MountPath) != std::string::npos) {
79 } else if (f_dest.find(this->m_pLoggerCfg->m_usb1MountPath) != std::string::npos) {
81 } else if (f_dest.find(this->m_pLoggerCfg->m_sdMountPath) != std::string::npos) {
83 } else if (f_dest.find(this->m_pLoggerCfg->m_emmcOutputPath)
84 != std::string::npos) {
87 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, " Error. No matching Path found for %s",
90 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-: %s", l_ret.c_str());
94 EFrameworkunifiedStatus CLoggerPopups::ShowStartPopup(
95 HANDLE f_hApp, TLoggerErrorEvent f_event,
96 std::vector<TLoggingArtifact>* f_remainingArtifact, std::string f_dest) {
97 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
98 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
99 if (this->m_startShown != FALSE) {
100 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Pop up already shown");
101 } else if (TRUE != IsPopupNeeded(f_event)) {
102 this->m_startShown = TRUE;
103 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Start pop up not needed for event %d.",
105 } else if (TRUE != CanShowStartPopup(f_remainingArtifact)) {
106 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Screenshot still in artifact vector.");
108 this->m_startShown = TRUE;
109 STLoggerFolderInfo l_folderInfo;
110 l_folderInfo.FoldernameAndLogname[0] = '\0';
111 std::string l_dest = this->getDeviceName(f_dest);
112 std::size_t l_len = l_dest.copy(l_folderInfo.StorageTarget,
113 sizeof(l_folderInfo.StorageTarget) - 1u, 0);
114 l_folderInfo.StorageTarget[l_len] = '\0';
115 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, " Info. Show start pop up. Destination: %s",
116 l_folderInfo.StorageTarget);
117 l_eStatus = FrameworkunifiedPublishEvent(f_hApp, SS_LOGGER_LOGSTARTED_EVT,
119 &l_folderInfo, sizeof(l_folderInfo));
121 LOG_STATUS_IF_ERRORED(l_eStatus,
122 "FrameworkunifiedPublishEvent(SS_LOGGER_LOGSTARTED_EVT)");
124 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
128 EFrameworkunifiedStatus CLoggerPopups::ShowEndPopup(HANDLE f_hApp, TLoggerErrorEvent f_event,
129 std::string f_dest) {
130 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
131 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
132 this->m_startShown = FALSE;
133 if (TRUE != IsPopupNeeded(f_event)) {
134 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
135 " Info. No pop up needed at end of Logging.");
137 STLoggerFolderInfo l_folderInfo;
138 std::size_t l_len = f_dest.copy(
139 l_folderInfo.FoldernameAndLogname,
140 sizeof(l_folderInfo.FoldernameAndLogname) - 1u,
141 f_dest.find_last_of('/') + 1);
142 l_folderInfo.FoldernameAndLogname[l_len] = '\0';
144 std::string l_dest = this->getDeviceName(f_dest);
145 l_len = l_dest.copy(l_folderInfo.StorageTarget,
146 sizeof(l_folderInfo.StorageTarget) - 1, 0);
147 l_folderInfo.StorageTarget[l_len] = '\0';
148 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
149 " Info. Show end pop up. Filepath: %s, Device: %s",
150 l_folderInfo.FoldernameAndLogname, l_folderInfo.StorageTarget);
151 l_eStatus = FrameworkunifiedPublishEvent(f_hApp, SS_LOGGER_LOGINFO_EVT,
153 &l_folderInfo, sizeof(l_folderInfo));
155 LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedPublishEvent(SS_LOGGER_LOGINFO_EVT)");
157 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
161 EFrameworkunifiedStatus CLoggerPopups::ShowErrorPopup(HANDLE f_hApp,
162 TLoggerErrorEvent f_event,
164 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
165 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
166 UI_16 l_errorcode = (UI_16) f_errCode;
167 this->m_startShown = FALSE;
168 if (IsPopupNeeded(f_event) == TRUE) {
169 l_eStatus = FrameworkunifiedPublishEvent(f_hApp, SS_LOGGER_ERRORINFO_EVT,
171 &l_errorcode, sizeof(l_errorcode));
172 LOG_STATUS_IF_ERRORED(l_eStatus, "FrameworkunifiedPublishEvent(SS_LOGGER_ERRORINFO_EVT)");
174 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");