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_NPPService
19 /// \brief This file contains implementation of class CPersistenceManager.
22 ////////////////////////////////////////////////////////////////////////////////////////////////////
26 #include <sys/types.h>
27 #include <native_service/ns_np_service.h>
28 #include <native_service/ns_np_service_if.h>
29 #include <native_service/ns_util_directory.h>
30 #include <native_service/ns_np_service_protocol.h>
31 #include <native_service/frameworkunified_sm_framework_dispatch.h>
33 #include <native_service/ns_np_service_nor_persistence_internal.h>
35 #include "ns_npp_types.h"
36 #include "ns_npp_notificationpersistentservicelog.h"
37 #include "ns_npp_copy_worker.h"
38 #include "ns_npp_persistence.h"
39 #include "ns_npp_persist_file.h"
40 #include "ns_npp_fs_directory.h"
41 #include "ns_npp_persist_folder.h"
42 #include "ns_npp_persistent_data.h"
43 #include "ns_npp_binary_accesser.h"
44 #include "ns_npp_persistence_manager.h"
45 #include "ns_npp_nor_persistence_worker_thread.h"
46 #include "ns_npp_state_nor_persistence_notification.h"
48 extern const CHAR AppName[]; // NOLINT (readability/naming)
50 // Initialisation of static class member for disabling persistence
51 BOOL CPersistenceManager::m_bPersistenceDisabled = FALSE;
53 ////////////////////////////////////////////////////////////////////////////////////////////////////
54 /// CPersistenceManager
55 /// Constructor of CPersistenceManager class
56 ////////////////////////////////////////////////////////////////////////////////////////////////////
57 CPersistenceManager::CPersistenceManager() {
58 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
60 m_cUserNotificationTag = USERNOTIFICATIONFILE;
62 m_poDataAccesser = NULL;
64 m_cNotificationPersistFilepath = CPersistence::GetStoragePath(); // LCOV_EXCL_BR_LINE 11: unexpected branch
66 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Storage path for persistence=%s", m_cNotificationPersistFilepath.c_str()); // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT[whitespace/line_length]
68 m_cNotificationPersistFilepath += AppName;
69 m_cNotificationPersistFilepath += "/";
71 m_hNSImmediatePersistenceThread = NULL;
72 m_bAllFilePersisted = FALSE;
73 m_bImmediatedDataPersisted = FALSE;
75 if (eFrameworkunifiedStatusOK != Init()) { // LCOV_EXCL_BR_LINE 6: Init() must be return eFrameworkunifiedStatusOK
76 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
77 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Unable to initialize Persistent Manager."); // LCOV_EXCL_LINE 6: Init() must be return eFrameworkunifiedStatusOK // NOLINT[whitespace/line_length]
80 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
82 ////////////////////////////////////////////////////////////////////////////////////////////////////
83 /// CPersistenceManager
84 /// Destructor of CPersistenceManager class
85 ////////////////////////////////////////////////////////////////////////////////////////////////////
86 CPersistenceManager::~CPersistenceManager() { // LCOV_EXCL_START 14: Resident process, global instance not released
87 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
88 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
90 if (NULL != m_poDataAccesser) {
91 delete m_poDataAccesser;
94 Persist_Type_Iter l_itPersist_Type = m_mPersist_Type.begin();
95 // Remove memory allocated for persistence objects
96 for (; l_itPersist_Type != m_mPersist_Type.end(); ++l_itPersist_Type) {
97 if (NULL != (*l_itPersist_Type).second) {
98 delete(*l_itPersist_Type).second;
102 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
106 EFrameworkunifiedStatus CPersistenceManager::Init() {
107 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
108 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
110 m_mPersist_Type[ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE] = new(std::nothrow) CFilePersistence(); // LCOV_EXCL_BR_LINE 11:unexpected branch
112 m_mPersist_Type[ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER] = new(std::nothrow) CFolderPersistence(); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT[whitespace/line_length]
114 m_poDataAccesser = new(std::nothrow) CBinaryAccesser(); // Save data in binary format. // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT[whitespace/line_length]
116 // check if all object creation is successful
117 if (NULL != m_poDataAccesser) { // LCOV_EXCL_BR_LINE 5:m_poDataAccesser can`t be NULL
118 Persist_Type_Iter l_itPersist_Type = m_mPersist_Type.begin();
120 // check if all object creation is successful
121 for (; l_itPersist_Type != m_mPersist_Type.end();
122 ++l_itPersist_Type) {
123 if (NULL == (*l_itPersist_Type).second) { // LCOV_EXCL_START 6:(*l_itPersist_Type).second can`t be NULL
124 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
125 l_estatus = eFrameworkunifiedStatusFail;
131 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
132 l_estatus = eFrameworkunifiedStatusFail; // LCOV_EXCL_LINE 5: m_poDataAccesser can`t be NULL
135 if (eFrameworkunifiedStatusOK != l_estatus) { // LCOV_EXCL_START 6: l_estatus must be eFrameworkunifiedStatusOK
136 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
137 if (NULL != m_poDataAccesser) {
138 delete m_poDataAccesser;
141 Persist_Type_Iter l_itPersist_Type = m_mPersist_Type.begin();
142 // check if all object creation is successful
143 for (; l_itPersist_Type != m_mPersist_Type.end(); ++l_itPersist_Type) {
144 if (NULL != (*l_itPersist_Type).second) {
145 delete(*l_itPersist_Type).second;
150 std::string f_csourcepath = CPersistence::GetStoragePath();
151 if (f_csourcepath.length() > 0) { // LCOV_EXCL_BR_LINE 6: f_csourcepath.length() is always bigger then 0
152 f_csourcepath.append(RELEASETEMP_DIR); // LCOV_EXCL_BR_LINE 11:unexpected branch
153 if (CFSDirectory::DoesDirecotryExist(f_csourcepath)) {
154 f_csourcepath.append(RELEASETEMP_FILENAME);
155 if (0 != remove(f_csourcepath.c_str())) {
156 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Temporary file not deleted::%s, errno:%d", f_csourcepath.c_str(), errno);
161 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
165 ////////////////////////////////////////////////////////////////////////////////////////////////
166 /// NotificationpersistentserviceRegister
167 /// Registers a tag for the file/folder. This tag will be used for releasing or loading
169 ////////////////////////////////////////////////////////////////////////////////////////////////
170 EFrameworkunifiedStatus CPersistenceManager::NotificationpersistentserviceRegister(std::string f_cappname,
172 ENotificationpersistentservicePersistType f_epersisttype,
173 BOOL bisuserpersistence) {
174 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
175 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusFail;
177 if (f_cappname.empty() || f_ctag.empty()) { // LCOV_EXCL_BR_LINE 6: double check, f_cappname and f_ctag can't be empty // NOLINT[whitespace/line_length]
178 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
179 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Appname & tag should not be empty."); // LCOV_EXCL_LINE 6: f_cappname and f_ctag can't be empty // NOLINT[whitespace/line_length]
181 // check boundary conditions
182 if ((ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST < f_epersisttype) && (f_epersisttype < ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST)) { // LCOV_EXCL_BR_LINE 6: f_epersisttype is always bigger then ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST and less then ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST // NOLINT[whitespace/line_length]
183 if (NULL != m_mPersist_Type[f_epersisttype]) { // LCOV_EXCL_BR_LINE 6: m_mPersist_Type[f_epersisttype] would not be null // NOLINT[whitespace/line_length]
185 l_estatus = m_mPersist_Type[f_epersisttype]->Register(f_cappname, f_ctag,
186 bisuserpersistence); // f_eRegisterType, f_cUser); // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT[whitespace/line_length]
187 // m_mPersist_Type[f_ePersistFileType]->ListAllInMap();
189 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
190 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Persistence object for %d is null.", f_epersisttype); // LCOV_EXCL_LINE 6: m_mPersist_Type[f_epersisttype] would not be null // NOLINT[whitespace/line_length]
193 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
194 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Enum value %d is out of bound.", f_epersisttype); // LCOV_EXCL_LINE 6: f_epersisttype is always biger then ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST and less then ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST // NOLINT[whitespace/line_length]
197 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
201 ////////////////////////////////////////////////////////////////////////////////////////////////
202 /// NotificationpersistentserviceRelease
203 /// Entry for the file/folder is stored in map for persistence.
204 ////////////////////////////////////////////////////////////////////////////////////////////////
205 EFrameworkunifiedStatus CPersistenceManager::NotificationpersistentserviceRelease(std::string f_cappname,
207 std::string f_cmempath,
208 EFrameworkunifiedReleaseType enotificationpersistentservicereleasetype,
209 ENotificationpersistentservicePersistType f_epersisttype,
210 std::string f_cusername) {
211 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
212 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusFail;
214 if (f_cappname.empty() || f_ctag.empty() || f_cmempath.empty()) { // LCOV_EXCL_BR_LINE 6: double check, f_cappname, f_cmempath and f_ctag can't be empty // NOLINT[whitespace/line_length]
215 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
216 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Appname & tag should not be empty."); // LCOV_EXCL_LINE 6: double check, f_cappname, f_cmempath and f_ctag can't be empty // NOLINT[whitespace/line_length]
218 // check boundary conditions
219 if ((ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST < f_epersisttype) && (f_epersisttype < ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST)) { // LCOV_EXCL_BR_LINE 6: f_epersisttype is always bigger then ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST and less then ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST // NOLINT[whitespace/line_length]
221 if (NULL != m_mPersist_Type[f_epersisttype]) { // LCOV_EXCL_BR_LINE 6: m_mPersist_Type[f_epersisttype] would not be null // NOLINT[whitespace/line_length]
222 l_estatus = m_mPersist_Type[f_epersisttype]->Release(f_cappname,
225 enotificationpersistentservicereleasetype,
226 f_cusername); // LCOV_EXCL_BR_LINE 11: unexpected branch
228 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
229 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Persistence object for %d is null.", f_epersisttype); // LCOV_EXCL_LINE 6: m_mPersist_Type[f_epersisttype] would not be null // NOLINT[whitespace/line_length]
232 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
233 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Enum value %d is out of bound.", f_epersisttype); // LCOV_EXCL_LINE 6: f_epersisttype is always bigger then ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST and less then ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST // NOLINT[whitespace/line_length]
236 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
240 ////////////////////////////////////////////////////////////////////////////////////////////////
241 /// NotificationpersistentserviceLoad
242 /// Load file/folder from persistent memory to the specified location.
243 ////////////////////////////////////////////////////////////////////////////////////////////////
244 EFrameworkunifiedStatus CPersistenceManager::NotificationpersistentserviceLoad(std::string f_cappname,
246 std::string f_cretrievepath,
247 ENotificationpersistentservicePersistType f_epersisttype,
248 std::string f_cusername) {
249 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusFail;
250 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
252 if (f_cappname.empty() || f_ctag.empty() || f_cretrievepath.empty()) { // LCOV_EXCL_BR_LINE 6: double check, f_cretrievepath, f_cappname and f_ctag can't be empty // NOLINT[whitespace/line_length]
253 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
254 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Appname, tag & retrieve path should not be empty."); // LCOV_EXCL_LINE 6: double check, f_cretrievepath, f_cappname and f_ctag can't be empty // NOLINT[whitespace/line_length]
256 // check boundary conditions
257 if ((ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST < f_epersisttype) && (f_epersisttype < ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST)) { // LCOV_EXCL_BR_LINE 6: f_epersisttype is always bigger then ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST and less then ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST // NOLINT[whitespace/line_length]
258 if (NULL != m_mPersist_Type[f_epersisttype]) { // LCOV_EXCL_BR_LINE 6: m_mPersist_Type[f_epersisttype] would not be null // NOLINT[whitespace/line_length]
260 l_estatus = m_mPersist_Type[f_epersisttype]->Load(f_cappname, f_ctag, f_cretrievepath, f_cusername); // LCOV_EXCL_BR_LINE 11: unexpected branch // NOLINT[whitespace/line_length]
262 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
263 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Persistence object for %d is null.", f_epersisttype); // LCOV_EXCL_LINE 6: m_mPersist_Type[f_epersisttype] would not be null // NOLINT[whitespace/line_length]
266 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
267 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Enum value %d is out of bound.", f_epersisttype); // LCOV_EXCL_LINE 6: f_epersisttype is always bigger then ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST and less then ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST // NOLINT[whitespace/line_length]
270 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
274 ////////////////////////////////////////////////////////////////////////////////////////////////
275 /// AckReceivedFromWorker
276 /// Send release ack to file/folder persistence object.
277 ////////////////////////////////////////////////////////////////////////////////////////////////
278 EFrameworkunifiedStatus CPersistenceManager::AckReceivedFromWorker(PCSTR f_csource, PCSTR f_ctag, ENotificationpersistentservicePersistType f_epersisttype,
279 BOOL f_bcopystatus, ENPS_Loadtype f_eloadtype) {
280 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusFail;
281 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
283 if ((NULL == f_csource) || (NULL == f_ctag)) { // LCOV_EXCL_BR_LINE 6: f_csource and f_ctag can't be NULL
284 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
285 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "f_csource or f_ctag is NULL."); // LCOV_EXCL_LINE 6: f_csource and f_ctag can't be NULL // NOLINT[whitespace/line_length]
287 // check boundary conditions
288 if ((ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST < f_epersisttype) && (f_epersisttype < ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST)) { // LCOV_EXCL_BR_LINE 6: f_epersisttype is always bigger then ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST and less then ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST // NOLINT[whitespace/line_length]
289 if (NULL != m_mPersist_Type[f_epersisttype]) {
290 // Send release ack to file/folder persistence object.
291 l_estatus = m_mPersist_Type[f_epersisttype]->AckReceivedFromWorker(f_csource, f_ctag,
292 f_bcopystatus, f_eloadtype);
294 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Persistence object for %d is null.", f_epersisttype);
297 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
298 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Enum value %d is out of bound.", f_epersisttype); // LCOV_EXCL_LINE 6: f_epersisttype is always bigger then ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST and less then ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST // NOLINT[whitespace/line_length]
301 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
305 ////////////////////////////////////////////////////////////////////////////////////////////////
306 /// NotificationpersistentserviceSaveNotificationData
307 /// Save notification data in a persistent file.
308 ////////////////////////////////////////////////////////////////////////////////////////////////
309 EFrameworkunifiedStatus CPersistenceManager::NotificationpersistentserviceSaveNotificationData(Persistent_Notification_List_Type
310 *f_vpersistentnotificationlist) {
311 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
313 if ((NULL == m_poDataAccesser) || (NULL == f_vpersistentnotificationlist)) { // LCOV_EXCL_BR_LINE 6: m_poDataAccesser and f_vpersistentnotificationlist would not be null // NOLINT[whitespace/line_length]
314 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
315 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "m_poDataAccesser or f_vpersistentnotificationlist is NULL."); // LCOV_EXCL_LINE 6: m_poDataAccesser and f_vpersistentnotificationlist would not be null // NOLINT[whitespace/line_length]
317 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
318 std::string l_cNotificationFilePath = "";
320 l_cNotificationFilePath = m_cNotificationPersistFilepath;
321 l_cNotificationFilePath += NOTIFICATIONFILE;
322 if (eFrameworkunifiedStatusOK != (l_estatus = m_poDataAccesser->PersistData(l_cNotificationFilePath,
323 f_vpersistentnotificationlist,
324 eFrameworkunifiedPersistedStateVar,
325 eFrameworkunifiedUserData))) {
326 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error retrieving notification data from file : %s, status: %d",
327 l_cNotificationFilePath.c_str(), l_estatus);
330 l_cNotificationFilePath = m_cNotificationPersistFilepath;
331 l_cNotificationFilePath += FACTORYNOTIFICATIONFILE;
332 if (eFrameworkunifiedStatusOK != (l_estatus = m_poDataAccesser->PersistData(l_cNotificationFilePath,
333 f_vpersistentnotificationlist,
334 eFrameworkunifiedPersistedStateVar,
335 eFrameworkunifiedFactoryData))) {
336 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error retrieving notification data from file : %s, status: %d",
337 l_cNotificationFilePath.c_str(), l_estatus);
340 l_cNotificationFilePath = m_cNotificationPersistFilepath;
341 l_cNotificationFilePath += FACTORYCUSTOMERNOTIFICATIONFILE;
342 if (eFrameworkunifiedStatusOK != (l_estatus = m_poDataAccesser->PersistData(l_cNotificationFilePath,
343 f_vpersistentnotificationlist,
344 eFrameworkunifiedPersistedStateVar,
345 eFrameworkunifiedFactoryCustomerData))) {
346 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error retrieving notification data from file : %s, status: %d",
347 l_cNotificationFilePath.c_str(), l_estatus);
350 l_cNotificationFilePath = m_cNotificationPersistFilepath;
351 l_cNotificationFilePath += DEALERNOTIFICATIONFILE;
352 if (eFrameworkunifiedStatusOK != (l_estatus = m_poDataAccesser->PersistData(l_cNotificationFilePath,
353 f_vpersistentnotificationlist,
354 eFrameworkunifiedPersistedStateVar,
355 eFrameworkunifiedDealerData))) {
356 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error retrieving notification data from file : %s, status: %d",
357 l_cNotificationFilePath.c_str(), l_estatus);
361 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
362 return eFrameworkunifiedStatusOK;
365 ////////////////////////////////////////////////////////////////////////////////////////////////
366 /// NotificationpersistentserviceSaveUserNotificationData
367 /// Save user notification data in a persistent file.
368 ////////////////////////////////////////////////////////////////////////////////////////////////
369 EFrameworkunifiedStatus CPersistenceManager::NotificationpersistentserviceSaveUserNotificationData(Persistent_Notification_List_Type
370 *f_vpersistentnotificationlist) {
371 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusFail;
372 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
374 if ((NULL == m_poDataAccesser) || (NULL == f_vpersistentnotificationlist)) { // LCOV_EXCL_BR_LINE 6: m_poDataAccesser and f_vpersistentnotificationlist would not be null // NOLINT[whitespace/line_length]
375 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
376 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "m_poDataAccesser or f_vpersistentnotificationlist is NULL."); // LCOV_EXCL_LINE 6: m_poDataAccesser and f_vpersistentnotificationlist would not be null // NOLINT[whitespace/line_length]
378 l_estatus = m_poDataAccesser->PersistData(m_cNotificationUserMemFilepath,
379 f_vpersistentnotificationlist,
380 eFrameworkunifiedPersistedStateUserVar); // LCOV_EXCL_BR_LINE 11: unexpected branch
383 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
387 ////////////////////////////////////////////////////////////////////////////////////////////////
388 /// NotificationpersistentserviceReadNotificationData
389 /// Get the list of all persistent notifications from a persistent memory and store it in a map.
390 ////////////////////////////////////////////////////////////////////////////////////////////////
391 EFrameworkunifiedStatus CPersistenceManager::NotificationpersistentserviceReadNotificationData(Persistent_Notification_List_Type
392 * &f_vpersistentnotificationlist) {
393 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
395 if (NULL != m_poDataAccesser) { // LCOV_EXCL_BR_LINE 6: m_poDataAccesser would not be null
396 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
397 std::string l_cNotificationFilePath = "";
399 l_cNotificationFilePath = m_cNotificationPersistFilepath;
400 l_cNotificationFilePath += NOTIFICATIONFILE;
401 if (eFrameworkunifiedStatusOK != (l_estatus = m_poDataAccesser->RetrieveData(l_cNotificationFilePath,
402 f_vpersistentnotificationlist,
403 eFrameworkunifiedUserData))) {
404 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error retrieving notification data from file : %s, status: %d",
405 l_cNotificationFilePath.c_str(), l_estatus);
408 l_cNotificationFilePath = m_cNotificationPersistFilepath;
409 l_cNotificationFilePath += FACTORYNOTIFICATIONFILE;
410 if (eFrameworkunifiedStatusOK != (l_estatus = m_poDataAccesser->RetrieveData(l_cNotificationFilePath,
411 f_vpersistentnotificationlist,
412 eFrameworkunifiedFactoryData))) {
413 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error retrieving notification data from file : %s, status: %d",
414 l_cNotificationFilePath.c_str(), l_estatus);
417 l_cNotificationFilePath = m_cNotificationPersistFilepath;
418 l_cNotificationFilePath += FACTORYCUSTOMERNOTIFICATIONFILE;
419 if (eFrameworkunifiedStatusOK != (l_estatus = m_poDataAccesser->RetrieveData(l_cNotificationFilePath,
420 f_vpersistentnotificationlist,
421 eFrameworkunifiedFactoryCustomerData))) {
422 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error retrieving notification data from file : %s, status: %d",
423 l_cNotificationFilePath.c_str(), l_estatus);
426 l_cNotificationFilePath = m_cNotificationPersistFilepath;
427 l_cNotificationFilePath += DEALERNOTIFICATIONFILE;
428 if (eFrameworkunifiedStatusOK != (l_estatus = m_poDataAccesser->RetrieveData(l_cNotificationFilePath,
429 f_vpersistentnotificationlist,
430 eFrameworkunifiedDealerData))) {
431 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error retrieving notification data from file : %s, status: %d",
432 l_cNotificationFilePath.c_str(), l_estatus);
436 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
437 return eFrameworkunifiedStatusOK;
440 ////////////////////////////////////////////////////////////////////////////////////////////////
441 /// NotificationpersistentserviceReadUserNotificationData
442 /// Get the list of all user persistent notifications from a persistent memory and store it in a map.
443 ////////////////////////////////////////////////////////////////////////////////////////////////
444 EFrameworkunifiedStatus CPersistenceManager::NotificationpersistentserviceReadUserNotificationData(Persistent_Notification_List_Type
445 * &f_vpersistentnotificationlist) {
446 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusFail;
447 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
449 if (NULL != m_poDataAccesser) { // LCOV_EXCL_BR_LINE 6: m_poDataAccesser would not be null
450 l_estatus = m_poDataAccesser->RetrieveData(m_cNotificationUserMemFilepath,
451 f_vpersistentnotificationlist,
452 eFrameworkunifiedUserData); // LCOV_EXCL_BR_LINE 11:unexpected branch
455 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
459 ////////////////////////////////////////////////////////////////////////////////////////////////
460 /// PersistAllReleaseRequests
461 /// Persist all released files and folder contained in the map in persistent memory.
462 ////////////////////////////////////////////////////////////////////////////////////////////////
463 EFrameworkunifiedStatus CPersistenceManager::PersistAllReleaseRequests(UI_32 f_uinotificationpersistentservicepersistcategoryflag) {
464 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
465 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
467 ENotificationpersistentservicePersistType l_ePersistType = ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST;
468 l_ePersistType = (ENotificationpersistentservicePersistType)(l_ePersistType + 1);
470 // Persist all i.e files and folders
471 while (l_ePersistType < ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST) {
472 if (NULL != m_mPersist_Type[l_ePersistType]) {
473 if (eFrameworkunifiedStatusFail == m_mPersist_Type[l_ePersistType]->PersistAllReleaseRequests(f_uinotificationpersistentservicepersistcategoryflag)) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
474 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
475 l_estatus = eFrameworkunifiedStatusFail; // LCOV_EXCL_LINE 4: NSFW error case.
478 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Persistence object for %d is null.", l_ePersistType); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
481 l_ePersistType = (ENotificationpersistentservicePersistType)(l_ePersistType + 1);
484 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
489 ////////////////////////////////////////////////////////////////////////////////////////////////
490 /// NotificationpersistentservicePersistAllUserRequests
491 /// Persist all user files and folder contained in the map in persistent memory.
492 ////////////////////////////////////////////////////////////////////////////////////////////////
493 EFrameworkunifiedStatus CPersistenceManager::NotificationpersistentservicePersistAllUserRequests() {
494 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusFail;
495 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
497 ENotificationpersistentservicePersistType l_ePersistType = ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST;
498 l_ePersistType = (ENotificationpersistentservicePersistType)(l_ePersistType + 1);
500 // Persist all i.e files and folders
501 while (l_ePersistType < ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST) {
502 if (NULL != m_mPersist_Type[l_ePersistType]) {
503 l_estatus = m_mPersist_Type[l_ePersistType]->PersistAllUserRequests();
505 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Persistence object for %d is null.", l_ePersistType);
508 l_ePersistType = (ENotificationpersistentservicePersistType)(l_ePersistType + 1);
511 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
517 ////////////////////////////////////////////////////////////////////////////////////////////////
518 /// SetReadThreadHandle
519 /// Pass the handle of the read thread to the object of file/folder persistence
520 ////////////////////////////////////////////////////////////////////////////////////////////////
521 VOID CPersistenceManager::SetReadThreadHandle(HANDLE f_hreadthread) {
522 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
524 if (f_hreadthread != NULL) { // LCOV_EXCL_BR_LINE 6: f_hreadthread would not be null
525 // Set thread handle for object persistfile objects. i.e. for file/folder
526 for (Persist_Type_Iter l_itPersist_Type = m_mPersist_Type.begin();
527 l_itPersist_Type != m_mPersist_Type.end();
528 ++l_itPersist_Type) {
529 if (NULL != (*l_itPersist_Type).second) { // LCOV_EXCL_BR_LINE 6: (*l_itPersist_Type).second can't be NULL
530 (*l_itPersist_Type).second->SetReadThreadHandle(f_hreadthread);
535 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
538 ////////////////////////////////////////////////////////////////////////////////////////////////
539 /// SetWriteThreadHandle
540 /// Pass the handle of the write thread to the object of file/folder persistence
541 ////////////////////////////////////////////////////////////////////////////////////////////////
542 VOID CPersistenceManager::SetWriteThreadHandle(HANDLE f_hwritethread) {
543 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
545 if (NULL != f_hwritethread) { // LCOV_EXCL_BR_LINE 6: f_hwritethread would not be null
546 // Set thread handle for object persist objects. i.e. for file/folder
547 for (Persist_Type_Iter l_itPersist_Type = m_mPersist_Type.begin();
548 l_itPersist_Type != m_mPersist_Type.end();
549 ++l_itPersist_Type) {
550 if (NULL != (*l_itPersist_Type).second) { // LCOV_EXCL_BR_LINE 6: (*l_itPersist_Type).second can't be NULL
551 (*l_itPersist_Type).second->SetWriteThreadHandle(f_hwritethread);
556 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
559 ////////////////////////////////////////////////////////////////////////////////////////////////
560 /// SetWriteThreadHandle
561 /// Pass the handle of the write thread to the object of file/folder persistence
562 ////////////////////////////////////////////////////////////////////////////////////////////////
563 VOID CPersistenceManager::SetNorPersistenceThreadHandle(HANDLE f_hwritethread) {
564 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
566 if (NULL != f_hwritethread) { // LCOV_EXCL_BR_LINE 6: f_hwritethread would not be null
567 m_hNSImmediatePersistenceThread = f_hwritethread;
570 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
573 ////////////////////////////////////////////////////////////////////////////////////////////
574 /// NPServiceOnCpWorkerAckCmd
575 /// Handles when the CopyWorker sends an ack back for a message received .
576 ////////////////////////////////////////////////////////////////////////////////////////////
577 EFrameworkunifiedStatus NPServiceOnCpWorkerAckCmd(HANDLE f_happ) {
578 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
579 NSP_CopyAckMsg l_tack = {};
580 if (f_happ) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
581 if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(f_happ, (PVOID)&l_tack, sizeof(NSP_CopyAckMsg), eSMRRelease))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length] // NOLINT[whitespace/line_length]
582 FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "CP_WRK_ACK_CMD_COMPLETE for cmd 0x%X", l_tack.m_eworkerprotocol); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
584 // LCOV_EXCL_START 4: NSFW error case.
585 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
586 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
587 "Unable to get message data in NPServiceOnCpWorkerAckCmd, status : 0x%x", l_estatus);
591 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
592 l_estatus = eFrameworkunifiedStatusNullPointer; // LCOV_EXCL_LINE 4: NSFW error case.
599 ////////////////////////////////////////////////////////////////////////////////////////////
600 /// SetUserPersistentPath
602 ////////////////////////////////////////////////////////////////////////////////////////////
603 VOID CPersistenceManager::SetUserPersistentPath(std::string f_cusername) {
604 m_cNotificationUserMemFilepath = CPersistence::GetStoragePath();
605 m_cNotificationUserMemFilepath += AppName;
606 m_cNotificationUserMemFilepath += "/";
607 m_cNotificationUserMemFilepath += f_cusername;
608 m_cNotificationUserMemFilepath += "/";
609 m_cNotificationUserMemFilepath += m_cUserNotificationTag;
612 ////////////////////////////////////////////////////////////////////////////////////////////
613 /// IsUserPersistence
614 /// Check if tag is user persistence
615 ////////////////////////////////////////////////////////////////////////////////////////////
616 BOOL CPersistenceManager::IsUserPersistence(std::string f_ctag, ENotificationpersistentservicePersistType f_epersisttype) {
617 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
619 BOOL l_bUserPersistence = FALSE;
621 // check boundary conditions
622 if ((ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST < f_epersisttype) && (f_epersisttype < ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST)) { // LCOV_EXCL_BR_LINE 6: f_epersisttype is always bigger then ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST and less then ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST // NOLINT[whitespace/line_length]
623 if (NULL != m_mPersist_Type[f_epersisttype]) { // LCOV_EXCL_BR_LINE 6: m_mPersist_Type[f_epersisttype] can't be null // NOLINT[whitespace/line_length]
625 l_bUserPersistence = m_mPersist_Type[f_epersisttype]->IsUserPersistence(f_ctag); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT[whitespace/line_length]
627 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
628 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Persistence object for %d is null.", f_epersisttype); // LCOV_EXCL_LINE 6: m_mPersist_Type[f_epersisttype] can't be null // NOLINT[whitespace/line_length]
631 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
632 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Enum value %d is out of bound.", f_epersisttype); // LCOV_EXCL_LINE 6: f_epersisttype is always bigger then ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST and less then ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST // NOLINT[whitespace/line_length]
635 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
636 return l_bUserPersistence;
639 ////////////////////////////////////////////////////////////////////////////////////////////
640 /// HaveAllReleaseRequestsPersisted
641 /// Check if all release requests processed or not
642 ////////////////////////////////////////////////////////////////////////////////////////////
643 BOOL CPersistenceManager::HaveAllReleaseRequestsPersisted() {
644 BOOL l_bRetVal = TRUE;
645 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
647 // check if all files are persisted
648 if (FALSE == m_bAllFilePersisted) {
649 ENotificationpersistentservicePersistType l_ePersistType = ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST;
650 l_ePersistType = (ENotificationpersistentservicePersistType)(l_ePersistType + 1);
652 std::string l_cTagNotReleased = "";
653 std::string l_cTagList = ""; // LCOV_EXCL_BR_LINE 11:except,C++ STL
655 // Persist all i.e files and folders
656 while (l_ePersistType < ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST) {
657 if (NULL != m_mPersist_Type[l_ePersistType]) {
658 l_cTagNotReleased.assign(""); // LCOV_EXCL_BR_LINE 11:except,C++ STL
659 // if(eFrameworkunifiedStatusFail == m_mPersist_Type[l_ePersistType]->PersistAllReleaseRequests())
660 if (FALSE == m_mPersist_Type[l_ePersistType]->HaveAllReleaseRequestsPersisted(l_cTagNotReleased)) {
662 l_cTagList.append(l_cTagNotReleased);
665 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Persistence object for %d is null.", l_ePersistType); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
668 l_ePersistType = (ENotificationpersistentservicePersistType)(l_ePersistType + 1);
671 if (0 != l_cTagList.size()) {
672 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Tags not released:: %s", l_cTagList.c_str());
676 if (TRUE == l_bRetVal) {
677 m_bAllFilePersisted = TRUE;
679 // if all files are persisted set the return value to the status of immediate data persistency
680 l_bRetVal = m_bImmediatedDataPersisted;
683 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
687 ////////////////////////////////////////////////////////////////////////////////////////////
690 ////////////////////////////////////////////////////////////////////////////////////////////
691 VOID CPersistenceManager::ResetPersistFlag() {
692 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
693 ENotificationpersistentservicePersistType l_ePersistType = ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST;
694 l_ePersistType = (ENotificationpersistentservicePersistType)(l_ePersistType + 1);
696 // Persist all i.e files and folders
697 while (l_ePersistType < ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST) {
698 if (NULL != m_mPersist_Type[l_ePersistType]) {
699 m_mPersist_Type[l_ePersistType]->ResetPersistFlag();
701 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Persistence object for %d is null.", l_ePersistType); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
704 l_ePersistType = (ENotificationpersistentservicePersistType)(l_ePersistType + 1);
707 m_bAllFilePersisted = FALSE;
709 m_bImmediatedDataPersisted = FALSE;
711 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
714 ////////////////////////////////////////////////////////////////////////////////////////////////
715 /// NotificationpersistentserviceReadNorNotificationData
716 /// Get the list of all user persistent notifications from a persistent memory and store it in a map.
717 ////////////////////////////////////////////////////////////////////////////////////////////////
718 EFrameworkunifiedStatus CPersistenceManager::NotificationpersistentserviceReadNorNotificationData(Persistent_Notification_List_Type
719 * &f_vpersistentnotificationlist) {
720 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
721 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
723 if (eFrameworkunifiedStatusOK != ReadImmediateNotificationData(f_vpersistentnotificationlist, eFrameworkunifiedUserData)) {
724 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "No Immediate User data in persistent memory"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
727 if (eFrameworkunifiedStatusOK != ReadImmediateNotificationData(f_vpersistentnotificationlist, eFrameworkunifiedFactoryData)) {
728 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "No Immediate Factory data in persistent memory"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
731 if (eFrameworkunifiedStatusOK != ReadImmediateNotificationData(f_vpersistentnotificationlist, eFrameworkunifiedFactoryCustomerData)) {
732 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "No Immediate Factory Customer data in persistent memory"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
735 if (eFrameworkunifiedStatusOK != ReadImmediateNotificationData(f_vpersistentnotificationlist, eFrameworkunifiedDealerData)) {
736 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "No Immediate Dealer data in persistent memory"); // LCOV_EXCL_BR_LINE 15:marco defined in "native_service/ns_logger_if.h" // NOLINT[whitespace/line_length]
739 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
743 ////////////////////////////////////////////////////////////////////////////////////////////////
744 /// ClearPersistenceData
745 /// Deletes the data from the persistent memory.
746 ////////////////////////////////////////////////////////////////////////////////////////////////
747 EFrameworkunifiedStatus CPersistenceManager::ClearPersistenceData(const EFrameworkunifiedClearPersistence &f_enotificationpersistentserviceclearpersistencescope) {
748 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
749 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
751 // persistence memory path to be cleared
752 std::string l_cPath = "";
754 switch (f_enotificationpersistentserviceclearpersistencescope) { // LCOV_EXCL_BR_LINE 6: f_enotificationpersistentserviceclearpersistencescope must be eFrameworkunifiedClearAllData, eFrameworkunifiedClearAllApplicationData, eFrameworkunifiedClearAllNotificationData, eFrameworkunifiedClearCurrentUserData, eFrameworkunifiedClearCurrentUserApplicationData, eFrameworkunifiedClearCurrentUserNotificationData. // NOLINT[whitespace/line_length]
755 case eFrameworkunifiedClearAllData: {
756 // clears all the data from the persistent memory
757 l_cPath.append(CPersistence::GetStoragePath());
761 case eFrameworkunifiedClearAllApplicationData: {
762 // TODO(my_username): clears all the application folder in persistence memory
763 // don't delete the NS_NPS folder
767 case eFrameworkunifiedClearAllNotificationData: {
768 // TODO(my_username): deletes the NS_NPS folder
772 case eFrameworkunifiedClearCurrentUserData: {
773 // TODO(my_username): deletes the user folder from all the application folder in persisted memory
774 // as well as from the NS_NPS folder
778 case eFrameworkunifiedClearCurrentUserApplicationData: {
779 // TODO(my_username): deletes the user folder from all the application folder
783 case eFrameworkunifiedClearCurrentUserNotificationData: {
784 // TODO(my_username): deletes the user folder from the NS_NPS folder
789 // LCOV_EXCL_START 6: f_enotificationpersistentserviceclearpersistencescope must be eFrameworkunifiedClearAllData, eFrameworkunifiedClearAllApplicationData, eFrameworkunifiedClearAllNotificationData, eFrameworkunifiedClearCurrentUserData, eFrameworkunifiedClearCurrentUserApplicationData, eFrameworkunifiedClearCurrentUserNotificationData. // NOLINT[whitespace/line_length]
790 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
791 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Invalid _EFrameworkunifiedClearPersistence Parameter:: %d", f_enotificationpersistentserviceclearpersistencescope);
792 l_estatus = eFrameworkunifiedStatusInvldParam;
798 if (0 != l_cPath.size()) {
799 if (CFSDirectory::DoesDirecotryExist(l_cPath)) {
800 if (TRUE == CFSDirectory::RemoveDirectory(l_cPath)) { // LCOV_EXCL_BR_LINE 6: RemoveDirectory always return ok
801 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Delete persistent directory successful : %s", l_cPath.c_str());
803 // LCOV_EXCL_START 6: RemoveDirectory always return ok
804 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
805 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Delete persistent directory unsuccessful : %s", l_cPath.c_str());
806 l_estatus = eFrameworkunifiedStatusErrOther;
811 l_estatus = eFrameworkunifiedStatusErrOther;
816 l_cPath.append(IMMEDIATE_PERSISTENCE_STORAGE_V2);
817 if (0 != l_cPath.size()) { // LCOV_EXCL_BR_LINE 6: l_cPath.size can't be 0
818 if (CFSDirectory::DoesDirecotryExist(l_cPath)) {
819 if (TRUE == CFSDirectory::RemoveDirectory(l_cPath)) { // LCOV_EXCL_BR_LINE 6: RemoveDirectory always return ok
820 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Delete nor persistent directory successful : %s", l_cPath.c_str());
822 // LCOV_EXCL_START 6: RemoveDirectory always return ok
823 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
824 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Delete nor persistent directory unsuccessful : %s", l_cPath.c_str());
825 l_estatus = eFrameworkunifiedStatusErrOther;
830 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
831 l_estatus = eFrameworkunifiedStatusErrOther; // LCOV_EXCL_LINE 6: l_cPath.size can't be 0
834 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
838 ////////////////////////////////////////////////////////////////////////////////////////////////
839 /// NotificationpersistentserviceSetPersistentCategory
840 /// Sets the persist type of file or folder.
841 ////////////////////////////////////////////////////////////////////////////////////////////////
842 EFrameworkunifiedStatus CPersistenceManager::NotificationpersistentserviceSetPersistentCategory(std::string f_crequestorname,
844 EFrameworkunifiedPersistCategory f_epersistcategory,
845 ENotificationpersistentservicePersistType f_epersisttype) {
846 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
847 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
849 if (f_ctag.empty()) { // LCOV_EXCL_BR_LINE 6: double check, f_ctag.size can't be empty
850 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
851 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Tag name is empty."); // LCOV_EXCL_LINE 6: double check, f_ctag.size can't be empty
853 // check boundary conditions
854 if ((ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST < f_epersisttype) && (f_epersisttype < ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST)) { // LCOV_EXCL_BR_LINE 6: f_epersisttype is always bigger then ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST and less then ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST // NOLINT[whitespace/line_length]
855 if (NULL != m_mPersist_Type[f_epersisttype]) { // LCOV_EXCL_BR_LINE 6: m_mPersist_Type[f_epersisttype] can't be null // NOLINT[whitespace/line_length]
856 // set the persist type
857 l_estatus = m_mPersist_Type[f_epersisttype]->SetPersistentCategory(f_crequestorname,
861 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
862 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Persistence object for %d is null.", f_epersisttype); // LCOV_EXCL_LINE 6: m_mPersist_Type[f_epersisttype] can't be null // NOLINT[whitespace/line_length]
865 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
866 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Enum value %d is out of bound.", f_epersisttype); // LCOV_EXCL_LINE 6: f_epersisttype is always bigger then ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST and less then ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST // NOLINT[whitespace/line_length]
870 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
874 ////////////////////////////////////////////////////////////////////////////////////////////////
876 /// Sends the message to Immediate Persistence Thread to Persists the data immediately or reset
877 /// the NOR data depending on persist category flag during shutdown irrespective of delay.
878 ////////////////////////////////////////////////////////////////////////////////////////////////
879 EFrameworkunifiedStatus CPersistenceManager::PersistNORData(EFrameworkunifiedShutdownType f_eshutdowntype, UI_32 f_uinotificationpersistentservicepersistcategoryflag) {
880 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
881 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
883 TImmediateShutdown l_tImmShutdown = {};
884 l_tImmShutdown.f_eshutdowntype = f_eshutdowntype;
885 l_tImmShutdown.f_uinotificationpersistentservicepersistcategoryflag = f_uinotificationpersistentservicepersistcategoryflag;
887 // send the message to NOR to persist or reset the data during shutdown
888 if (NULL != CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread) { // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
889 if (eFrameworkunifiedStatusOK != (l_estatus = McSend(CStateNorPersistenceNotification::m_hNSImmediatePersistenceThread, AppName, NOR_PERSISTENCE_ONSHUTDOWN, sizeof(l_tImmShutdown), &l_tImmShutdown))) { // LCOV_EXCL_BR_LINE 4: NSFW error case // NOLINT[whitespace/line_length]
890 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
891 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "McSend for cmd 0x%X failed", NOR_PERSISTENCE_ONSHUTDOWN); // LCOV_EXCL_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
895 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
899 ////////////////////////////////////////////////////////////////////////////////////////////
900 /// SetImmediateDataPersistedStatus
901 /// Set/Reset the persistence status of immediate persistence data
902 ///////////////////////////////////////////////////////////////////////////////////////////
903 VOID CPersistenceManager::SetImmediateDataPersistedStatus(BOOL f_bstatus) {
904 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
906 m_bImmediatedDataPersisted = f_bstatus;
908 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
911 ////////////////////////////////////////////////////////////////////////////////////////////
912 /// SetFilePersistedStatus
913 /// Set/Reset the persistence status of files and folders
914 ///////////////////////////////////////////////////////////////////////////////////////////
915 VOID CPersistenceManager::SetFilePersistedStatus(BOOL f_bstatus) {
916 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
918 m_bAllFilePersisted = f_bstatus;
920 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
923 ////////////////////////////////////////////////////////////////////////////////////////////////
924 /// ReadImmediateNotificationData
925 /// Get the list of all immediate persistent notifications of f_epersistcategory from a
926 /// persistent memory and store it in a map.
927 ////////////////////////////////////////////////////////////////////////////////////////////////
928 EFrameworkunifiedStatus CPersistenceManager::ReadImmediateNotificationData(Persistent_Notification_List_Type
929 * &f_vpersistentnotificationlist,
930 const EFrameworkunifiedPersistCategory f_epersistcategory) {
931 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
932 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
934 std::string l_pcPath = IMMEDIATE_PERSISTENCE_STORAGE_V2;
935 std::string l_cNotificationName = ""; // LCOV_EXCL_BR_LINE 11:except,C++ STL
936 // stores the list of invalid immediate notification files at persistent location
937 std::string l_cInvalidFileList = ""; // LCOV_EXCL_BR_LINE 11:except,C++ STL
939 PCSTR l_pPublisherName = NULL;
941 UI_32 l_uiDataSize = 0;
943 NC_NorPersistentData l_ptNorPersistentData = {};
945 TFileList l_pTFileList;
947 if ('/' != l_pcPath[l_pcPath.length() - 1]) { // LCOV_EXCL_BR_LINE 6: the last char is always '/'
948 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
949 l_pcPath.append("/"); // LCOV_EXCL_LINE 6: the last char is always '/'
952 switch (f_epersistcategory) {
953 case eFrameworkunifiedFactoryData: {
954 l_pcPath.append(FACTORYDATADIR); // LCOV_EXCL_BR_LINE 11:except,C++ STL
958 case eFrameworkunifiedFactoryCustomerData: {
959 l_pcPath.append(FACTORYCUSTOMERDATADIR); // LCOV_EXCL_BR_LINE 11:except,C++ STL
963 case eFrameworkunifiedDealerData: {
964 l_pcPath.append(DEALERDATADIR); // LCOV_EXCL_BR_LINE 11:except,C++ STL
968 case eFrameworkunifiedUserData:
970 l_pcPath.append(USERDATADIR); // LCOV_EXCL_BR_LINE 11:except,C++ STL
971 l_pcPath.append(ALLUSERAPPDATADIR); // LCOV_EXCL_BR_LINE 11:except,C++ STL
976 l_pcPath.append(IMMEDIATEDATADIR); // LCOV_EXCL_BR_LINE 11:except,C++ STL
978 if (eFrameworkunifiedStatusOK == GetFileList(&l_pTFileList, l_pcPath.c_str())) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
979 if (!l_pTFileList.empty()) { // LCOV_EXCL_BR_LINE 200: if GetFileList() returns eFrameworkunifiedStatusOK, l_pTFileList can't be empty // NOLINT[whitespace/line_length]
980 for (UI_32 l_uiCount = 0; l_uiCount < l_pTFileList.size(); l_uiCount++) {
983 // get the persistent notification name from vector
984 l_cNotificationName = l_pTFileList.at(l_uiCount);
986 if (eFrameworkunifiedStatusOK == NPSynchronousGetPersistentDataSize(l_cNotificationName.c_str(), &l_uiDataSize, // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
987 f_epersistcategory) && (0 != l_uiDataSize)) {
988 l_pData = new(std::nothrow) CHAR[l_uiDataSize];
989 std::memset(l_pData, 0, l_uiDataSize);
991 if (NULL != l_pData) { // LCOV_EXCL_BR_LINE 6: l_pData can't be null
992 l_pPublisherName = NULL;
995 std::memset(&l_ptNorPersistentData, 0, sizeof(NC_NorPersistentData));
997 // As NS_NPP does a recursive filename read from directory it has the complete filename.
998 // So it does not require to pass the Publisher name i.e. l_pPublisherName.So it is being passed as NULL.
999 if (eFrameworkunifiedStatusOK == NPSynchronousGetPersistentData(l_pPublisherName, // LCOV_EXCL_BR_LINE 4: NSFW error case. // NOLINT[whitespace/line_length]
1000 l_cNotificationName.c_str(),
1003 l_ptNorPersistentData,
1004 f_epersistcategory)) {
1005 CNotificationsToPersist *l_objCNotificationsToPersist = new(std::nothrow) CNotificationsToPersist();
1006 if (NULL != l_objCNotificationsToPersist) { // LCOV_EXCL_BR_LINE 6: l_objCNotificationsToPersist can't be null // NOLINT[whitespace/line_length]
1007 CPersistentData *l_objCPersistentData = new(std::nothrow) CPersistentData();
1009 // fill the appropriate values in l_objCNotificationsToPersist
1010 if (NULL != l_objCPersistentData) { // LCOV_EXCL_BR_LINE 6: l_objCPersistentData can't be null
1011 l_objCPersistentData->m_pMessage = new(std::nothrow) CHAR[l_ptNorPersistentData.dataSize];
1012 std::memset(l_objCPersistentData->m_pMessage, 0, l_ptNorPersistentData.dataSize);
1014 if (NULL != l_objCPersistentData->m_pMessage) { // LCOV_EXCL_BR_LINE 6: l_objCPersistentData->m_pMessage can't be null // NOLINT[whitespace/line_length]
1015 std::memcpy(l_objCPersistentData->m_pMessage, l_pData, l_ptNorPersistentData.dataSize);
1017 l_objCNotificationsToPersist->m_uiMaxMsgLength = l_ptNorPersistentData.uiMaxSize;
1018 l_objCPersistentData->m_uiMsgSize = l_ptNorPersistentData.dataSize;
1019 l_objCNotificationsToPersist->m_ePersistentType = eFrameworkunifiedImmediatePersistedStateVar;
1021 l_objCNotificationsToPersist->m_cNotificationName = l_ptNorPersistentData.notificationName;
1022 l_objCNotificationsToPersist->m_cPublisherName = l_ptNorPersistentData.pPublisherName;
1023 l_objCNotificationsToPersist->m_uiDelay = l_ptNorPersistentData.uiDelay;
1025 l_objCNotificationsToPersist->m_pPersistentData = l_objCPersistentData;
1027 l_objCNotificationsToPersist->m_ePersistCategory = f_epersistcategory;
1029 f_vpersistentnotificationlist->push_back(l_objCNotificationsToPersist);
1031 // LCOV_EXCL_START 6: l_objCPersistentData->m_pMessage can't be null
1032 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1033 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Memory allocation error for notification data of size %d",
1034 l_ptNorPersistentData.dataSize);
1036 if (NULL != l_objCNotificationsToPersist) {
1037 delete l_objCNotificationsToPersist;
1038 l_objCNotificationsToPersist = NULL;
1041 if (NULL != l_objCPersistentData) {
1042 delete l_objCPersistentData;
1043 l_objCPersistentData = NULL;
1048 // LCOV_EXCL_START 6: l_objCPersistentData can't be null
1049 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1050 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Memory allocation error for CPersistentData object");
1052 if (NULL != l_objCNotificationsToPersist) {
1053 delete l_objCNotificationsToPersist;
1054 l_objCNotificationsToPersist = NULL;
1059 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1060 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Memory allocation error for CNotificationsToPersist object"); // LCOV_EXCL_LINE 6: l_objCNotificationsToPersist can't be null // NOLINT[whitespace/line_length]
1063 // LCOV_EXCL_START 4: NSFW error case.
1064 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1065 l_cInvalidFileList.append(l_cNotificationName);
1066 l_cInvalidFileList.append(",");
1073 // LCOV_EXCL_START 6: l_pData can't be null
1074 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1075 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Persistent data received as NULL from immediate notification file :: %s",
1076 l_cNotificationName.c_str());
1080 // LCOV_EXCL_START 4: NSFW error case.
1081 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1082 l_cInvalidFileList.append(l_cNotificationName);
1083 l_cInvalidFileList.append(",");
1088 if (0 != l_cInvalidFileList.size()) { // LCOV_EXCL_START 200: l_cInvalidFileList's size must be 0
1089 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1090 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
1091 "Unable to get persistent data for following immediate notification files :: %s",
1092 l_cInvalidFileList.c_str());
1096 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
1097 FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "No Immediate persistence data available at :: %s", l_pcPath.c_str()); // LCOV_EXCL_LINE 200: if GetFileList() returns eFrameworkunifiedStatusOK, l_pTFileList can't be empty // NOLINT[whitespace/line_length]
1100 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Unable to get the list of files from Immediate persistent location :: %s",
1102 l_estatus = eFrameworkunifiedStatusFail;
1105 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1109 #ifdef NPP_PROFILEINFO_ENABLE
1111 EFrameworkunifiedStatus CPersistenceManager::GetPersistenceProfilingData(std::string &f_cpersistenceprofileinfo) {
1112 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1113 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
1115 f_cpersistenceprofileinfo.append("Application Name,");
1116 f_cpersistenceprofileinfo.append("Tag Name,");
1117 f_cpersistenceprofileinfo.append("Type,");
1118 f_cpersistenceprofileinfo.append("UserSpecific,");
1119 f_cpersistenceprofileinfo.append("Released,");
1120 f_cpersistenceprofileinfo.append("Persisted");
1122 CPersistence *l_pPersistence = m_mPersist_Type[ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE];
1123 l_pPersistence->GetPersistenceProfilingData(f_cpersistenceprofileinfo);
1125 l_pPersistence = m_mPersist_Type[ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER];
1126 l_pPersistence->GetPersistenceProfilingData(f_cpersistenceprofileinfo);
1128 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");