common_library: gettid is multiple declaration in cl_error
[staging/basesystem.git] / video_in_hal / nsframework / notification_persistent_service / server / src / ns_npp_persistence_manager.cpp
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 ////////////////////////////////////////////////////////////////////////////////////////////////////
18 /// \ingroup  tag_NPPService
19 /// \brief    This file contains implementation of class CPersistenceManager.
20 ///
21 ///
22 ////////////////////////////////////////////////////////////////////////////////////////////////////
23
24 #include <stdio.h>
25 #include <dirent.h>
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>
32 #include <string>
33 #include <native_service/ns_np_service_nor_persistence_internal.h>
34 #include "ns_npp.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"
47
48 extern const CHAR AppName[];  // NOLINT (readability/naming)
49
50 // Initialisation of static class member for disabling persistence
51 BOOL CPersistenceManager::m_bPersistenceDisabled = FALSE;
52
53 ////////////////////////////////////////////////////////////////////////////////////////////////////
54 /// CPersistenceManager
55 /// Constructor of CPersistenceManager class
56 ////////////////////////////////////////////////////////////////////////////////////////////////////
57 CPersistenceManager::CPersistenceManager() {
58   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
59
60   m_cUserNotificationTag = USERNOTIFICATIONFILE;
61
62   m_poDataAccesser = NULL;
63
64   m_cNotificationPersistFilepath = CPersistence::GetStoragePath();    // LCOV_EXCL_BR_LINE 11: unexpected branch
65
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]
67
68   m_cNotificationPersistFilepath += AppName;
69   m_cNotificationPersistFilepath += "/";
70
71   m_hNSImmediatePersistenceThread = NULL;
72   m_bAllFilePersisted = FALSE;
73   m_bImmediatedDataPersisted = FALSE;
74
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]
78   }
79
80   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
81 }
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__, "+");
89
90   if (NULL != m_poDataAccesser) {
91     delete m_poDataAccesser;
92   }
93
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;
99     }
100   }
101
102   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
103 }
104 // LCOV_EXCL_STOP
105
106 EFrameworkunifiedStatus CPersistenceManager::Init() {
107   EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
108   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
109
110   m_mPersist_Type[ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE] = new(std::nothrow) CFilePersistence();    // LCOV_EXCL_BR_LINE 11:unexpected branch
111
112   m_mPersist_Type[ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER] = new(std::nothrow) CFolderPersistence();    // LCOV_EXCL_BR_LINE 11:unexpected branch  // NOLINT[whitespace/line_length]
113
114   m_poDataAccesser = new(std::nothrow) CBinaryAccesser();  // Save data in binary format.   // LCOV_EXCL_BR_LINE 11:unexpected branch  // NOLINT[whitespace/line_length]
115
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();
119
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;
126         break;
127       }
128       // LCOV_EXCL_STOP
129     }
130   } else {
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
133   }
134
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;
139     }
140
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;
146       }
147     }
148     // LCOV_EXCL_STOP
149   }
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);
157       }
158     }
159   }
160
161   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
162   return l_estatus;
163 }
164
165 ////////////////////////////////////////////////////////////////////////////////////////////////
166 /// NotificationpersistentserviceRegister
167 /// Registers a tag for the file/folder. This tag will be used for releasing or loading
168 /// a file/folder.
169 ////////////////////////////////////////////////////////////////////////////////////////////////
170 EFrameworkunifiedStatus CPersistenceManager::NotificationpersistentserviceRegister(std::string f_cappname,
171                                             std::string f_ctag,
172                                             ENotificationpersistentservicePersistType f_epersisttype,
173                                             BOOL bisuserpersistence) {
174   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
175   EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusFail;
176
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]
180   } else {
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]
184         // register tag
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();
188       } else {
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]
191       }
192     } else {
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]
195     }
196   }
197   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
198   return l_estatus;
199 }
200
201 ////////////////////////////////////////////////////////////////////////////////////////////////
202 /// NotificationpersistentserviceRelease
203 /// Entry for the file/folder is stored in map for persistence.
204 ////////////////////////////////////////////////////////////////////////////////////////////////
205 EFrameworkunifiedStatus CPersistenceManager::NotificationpersistentserviceRelease(std::string f_cappname,
206                                            std::string f_ctag,
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;
213
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]
217   } else {
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]
220       // release file
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,
223                                                              f_ctag,
224                                                              f_cmempath,
225                                                              enotificationpersistentservicereleasetype,
226                                                              f_cusername);    // LCOV_EXCL_BR_LINE 11: unexpected branch
227       } else {
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]
230       }
231     } else {
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]
234     }
235   }
236   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
237   return l_estatus;
238 }
239
240 ////////////////////////////////////////////////////////////////////////////////////////////////
241 /// NotificationpersistentserviceLoad
242 /// Load file/folder from persistent memory to the specified location.
243 ////////////////////////////////////////////////////////////////////////////////////////////////
244 EFrameworkunifiedStatus CPersistenceManager::NotificationpersistentserviceLoad(std::string f_cappname,
245                                         std::string f_ctag,
246                                         std::string f_cretrievepath,
247                                         ENotificationpersistentservicePersistType f_epersisttype,
248                                         std::string f_cusername) {
249   EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusFail;
250   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
251
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]
255   } else {
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]
259         // load file
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]
261       } else {
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]
264       }
265     } else {
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]
268     }
269   }
270   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
271   return l_estatus;
272 }
273
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__, "+");
282
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]
286   } else {
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);
293       } else {
294         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Persistence object for %d is null.", f_epersisttype);
295       }
296     } else {
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]
299     }
300   }
301   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
302   return l_estatus;
303 }
304
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__, "+");
312
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]
316   } else {
317     EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
318     std::string l_cNotificationFilePath = "";
319
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);
328     }
329
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);
338     }
339
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);
348     }
349
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);
358     }
359   }
360
361   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
362   return eFrameworkunifiedStatusOK;
363 }
364
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__, "+");
373
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]
377   } else {
378     l_estatus = m_poDataAccesser->PersistData(m_cNotificationUserMemFilepath,
379                                               f_vpersistentnotificationlist,
380                                               eFrameworkunifiedPersistedStateUserVar);   // LCOV_EXCL_BR_LINE 11: unexpected branch
381   }
382
383   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
384   return l_estatus;
385 }
386
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__, "+");
394
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 = "";
398
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);
406     }
407
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);
415     }
416
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);
424     }
425
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);
433     }
434   }
435
436   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
437   return eFrameworkunifiedStatusOK;
438 }
439
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__, "+");
448
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
453   }
454
455   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
456   return l_estatus;
457 }
458
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__, "+");
466
467   ENotificationpersistentservicePersistType l_ePersistType = ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST;
468   l_ePersistType = (ENotificationpersistentservicePersistType)(l_ePersistType + 1);
469
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.
476       }
477     } else {
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]
479     }
480
481     l_ePersistType = (ENotificationpersistentservicePersistType)(l_ePersistType + 1);
482   }
483
484   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
485   return l_estatus;
486 }
487
488
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__, "+");
496
497   ENotificationpersistentservicePersistType l_ePersistType = ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST;
498   l_ePersistType = (ENotificationpersistentservicePersistType)(l_ePersistType + 1);
499
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();
504     } else {
505       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Persistence object for %d is null.", l_ePersistType);
506     }
507
508     l_ePersistType = (ENotificationpersistentservicePersistType)(l_ePersistType + 1);
509   }
510
511   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
512   return l_estatus;
513 }
514
515
516
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__, "+");
523
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);
531       }
532     }
533   }
534
535   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
536 }
537
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__, "+");
544
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);
552       }
553     }
554   }
555
556   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
557 }
558
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__, "+");
565
566   if (NULL != f_hwritethread) {   // LCOV_EXCL_BR_LINE 6: f_hwritethread would not be null
567     m_hNSImmediatePersistenceThread = f_hwritethread;
568   }
569
570   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
571 }
572
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]
583     } else {
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);
588       // LCOV_EXCL_STOP
589     }
590   } else {
591     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
592     l_estatus = eFrameworkunifiedStatusNullPointer;  // LCOV_EXCL_LINE 4: NSFW error case.
593   }
594
595   return l_estatus;
596 }
597
598
599 ////////////////////////////////////////////////////////////////////////////////////////////
600 /// SetUserPersistentPath
601 ///
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;
610 }
611
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__, "+");
618
619   BOOL l_bUserPersistence = FALSE;
620
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]
624       // load file
625       l_bUserPersistence = m_mPersist_Type[f_epersisttype]->IsUserPersistence(f_ctag);    // LCOV_EXCL_BR_LINE 11:unexpected branch  // NOLINT[whitespace/line_length]
626     } else {
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]
629     }
630   } else {
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]
633   }
634
635   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
636   return l_bUserPersistence;
637 }
638
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__, "+");
646
647   // check if all files are persisted
648   if (FALSE == m_bAllFilePersisted) {
649     ENotificationpersistentservicePersistType l_ePersistType = ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST;
650     l_ePersistType = (ENotificationpersistentservicePersistType)(l_ePersistType + 1);
651
652     std::string l_cTagNotReleased = "";
653     std::string l_cTagList = "";    // LCOV_EXCL_BR_LINE 11:except,C++ STL
654
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)) {
661           l_bRetVal = FALSE;
662           l_cTagList.append(l_cTagNotReleased);
663         }
664       } else {
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]
666       }
667
668       l_ePersistType = (ENotificationpersistentservicePersistType)(l_ePersistType + 1);
669     }
670
671     if (0 != l_cTagList.size()) {
672       FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__, "Tags not released:: %s", l_cTagList.c_str());
673     }
674   }
675
676   if (TRUE == l_bRetVal) {
677     m_bAllFilePersisted = TRUE;
678
679     // if all files are persisted set the return value to the status of immediate data persistency
680     l_bRetVal = m_bImmediatedDataPersisted;
681   }
682
683   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
684   return l_bRetVal;
685 }
686
687 ////////////////////////////////////////////////////////////////////////////////////////////
688 /// ResetPersistFlag
689 ///
690 ////////////////////////////////////////////////////////////////////////////////////////////
691 VOID CPersistenceManager::ResetPersistFlag() {
692   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
693   ENotificationpersistentservicePersistType l_ePersistType = ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST;
694   l_ePersistType = (ENotificationpersistentservicePersistType)(l_ePersistType + 1);
695
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();
700     } else {
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]
702     }
703
704     l_ePersistType = (ENotificationpersistentservicePersistType)(l_ePersistType + 1);
705   }
706
707   m_bAllFilePersisted = FALSE;
708
709   m_bImmediatedDataPersisted = FALSE;
710
711   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
712 }
713
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__, "+");
722
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]
725   }
726
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]
729   }
730
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]
733   }
734
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]
737   }
738
739   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
740   return l_estatus;
741 }
742
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;
750
751   // persistence memory path to be cleared
752   std::string l_cPath = "";
753
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());
758       }
759       break;
760
761     case eFrameworkunifiedClearAllApplicationData: {
762         // TODO(my_username): clears all the application folder in persistence memory
763         // don't delete the NS_NPS folder
764       }
765       break;
766
767     case eFrameworkunifiedClearAllNotificationData: {
768         // TODO(my_username): deletes the NS_NPS folder
769       }
770       break;
771
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
775       }
776       break;
777
778     case eFrameworkunifiedClearCurrentUserApplicationData: {
779         // TODO(my_username): deletes the user folder from all the application folder
780       }
781       break;
782
783     case eFrameworkunifiedClearCurrentUserNotificationData: {
784         // TODO(my_username): deletes the user folder from the NS_NPS folder
785       }
786       break;
787
788     default: {
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;
793         // LCOV_EXCL_STOP
794       }
795       break;
796   }
797
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());
802       } else {
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;
807         // LCOV_EXCL_STOP
808       }
809     }
810   } else {
811     l_estatus = eFrameworkunifiedStatusErrOther;
812   }
813
814   // delete NOR data
815   l_cPath.clear();
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());
821       } else {
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;
826         // LCOV_EXCL_STOP
827       }
828     }
829   } else {
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
832   }
833
834   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
835   return l_estatus;
836 }
837
838 ////////////////////////////////////////////////////////////////////////////////////////////////
839 /// NotificationpersistentserviceSetPersistentCategory
840 /// Sets the persist type of file or folder.
841 ////////////////////////////////////////////////////////////////////////////////////////////////
842 EFrameworkunifiedStatus CPersistenceManager::NotificationpersistentserviceSetPersistentCategory(std::string f_crequestorname,
843                                                          std::string f_ctag,
844                                                          EFrameworkunifiedPersistCategory f_epersistcategory,
845                                                          ENotificationpersistentservicePersistType f_epersisttype) {
846   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
847   EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
848
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
852   } else {
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,
858                                                                            f_ctag,
859                                                                            f_epersistcategory);
860       } else {
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]
863       }
864     } else {
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]
867     }
868   }
869
870   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
871   return l_estatus;
872 }
873
874 ////////////////////////////////////////////////////////////////////////////////////////////////
875 /// PersistNORData
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;
882
883   TImmediateShutdown l_tImmShutdown = {};
884   l_tImmShutdown.f_eshutdowntype = f_eshutdowntype;
885   l_tImmShutdown.f_uinotificationpersistentservicepersistcategoryflag = f_uinotificationpersistentservicepersistcategoryflag;
886
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]
892     }
893   }
894
895   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
896   return l_estatus;
897 }
898
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__, "+");
905
906   m_bImmediatedDataPersisted = f_bstatus;
907
908   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
909 }
910
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__, "+");
917
918   m_bAllFilePersisted = f_bstatus;
919
920   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
921 }
922
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__, "+");
933
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
938
939   PCSTR l_pPublisherName = NULL;
940   PSTR l_pData = NULL;
941   UI_32 l_uiDataSize = 0;
942
943   NC_NorPersistentData l_ptNorPersistentData = {};
944
945   TFileList l_pTFileList;
946
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 '/'
950   }
951
952   switch (f_epersistcategory) {
953     case eFrameworkunifiedFactoryData: {
954         l_pcPath.append(FACTORYDATADIR);  // LCOV_EXCL_BR_LINE 11:except,C++ STL
955       }
956       break;
957
958     case eFrameworkunifiedFactoryCustomerData: {
959         l_pcPath.append(FACTORYCUSTOMERDATADIR);  // LCOV_EXCL_BR_LINE 11:except,C++ STL
960       }
961       break;
962
963     case eFrameworkunifiedDealerData: {
964         l_pcPath.append(DEALERDATADIR);   // LCOV_EXCL_BR_LINE 11:except,C++ STL
965       }
966       break;
967
968     case eFrameworkunifiedUserData:
969     default: {
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
972       }
973       break;
974   }
975
976   l_pcPath.append(IMMEDIATEDATADIR);    // LCOV_EXCL_BR_LINE 11:except,C++ STL
977
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++) {
981         l_uiDataSize = 0;
982
983         // get the persistent notification name from vector
984         l_cNotificationName = l_pTFileList.at(l_uiCount);
985
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);
990
991           if (NULL != l_pData) {  // LCOV_EXCL_BR_LINE 6: l_pData can't be null
992             l_pPublisherName = NULL;
993
994             // clear the memory
995             std::memset(&l_ptNorPersistentData, 0, sizeof(NC_NorPersistentData));
996
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(),
1001                                                                (PVOID)l_pData,
1002                                                                l_uiDataSize,
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();
1008
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);
1013
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);
1016
1017                     l_objCNotificationsToPersist->m_uiMaxMsgLength = l_ptNorPersistentData.uiMaxSize;
1018                     l_objCPersistentData->m_uiMsgSize = l_ptNorPersistentData.dataSize;
1019                     l_objCNotificationsToPersist->m_ePersistentType = eFrameworkunifiedImmediatePersistedStateVar;
1020
1021                     l_objCNotificationsToPersist->m_cNotificationName = l_ptNorPersistentData.notificationName;
1022                     l_objCNotificationsToPersist->m_cPublisherName = l_ptNorPersistentData.pPublisherName;
1023                     l_objCNotificationsToPersist->m_uiDelay = l_ptNorPersistentData.uiDelay;
1024
1025                     l_objCNotificationsToPersist->m_pPersistentData = l_objCPersistentData;
1026
1027                     l_objCNotificationsToPersist->m_ePersistCategory = f_epersistcategory;
1028
1029                     f_vpersistentnotificationlist->push_back(l_objCNotificationsToPersist);
1030                   } else {
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);
1035
1036                     if (NULL != l_objCNotificationsToPersist) {
1037                       delete l_objCNotificationsToPersist;
1038                       l_objCNotificationsToPersist = NULL;
1039                     }
1040
1041                     if (NULL != l_objCPersistentData) {
1042                       delete l_objCPersistentData;
1043                       l_objCPersistentData = NULL;
1044                     }
1045                     // LCOV_EXCL_STOP
1046                   }
1047                 } else {
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");
1051
1052                   if (NULL != l_objCNotificationsToPersist) {
1053                     delete l_objCNotificationsToPersist;
1054                     l_objCNotificationsToPersist = NULL;
1055                   }
1056                   // LCOV_EXCL_STOP
1057                 }
1058               } else {
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]
1061               }
1062             } else {
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(",");
1067               // LCOV_EXCL_STOP
1068             }
1069
1070             delete[] l_pData;
1071             l_pData = NULL;
1072           } else {
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());
1077             // LCOV_EXCL_STOP
1078           }
1079         } else {
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(",");
1084           // LCOV_EXCL_STOP
1085         }
1086       }
1087
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());
1093       }
1094       // LCOV_EXCL_STOP
1095     } else {
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]
1098     }
1099   } else {
1100     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Unable to get the list of files from Immediate persistent location :: %s",
1101            l_pcPath.c_str());
1102     l_estatus = eFrameworkunifiedStatusFail;
1103   }
1104
1105   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1106   return l_estatus;
1107 }
1108
1109 #ifdef NPP_PROFILEINFO_ENABLE
1110
1111 EFrameworkunifiedStatus CPersistenceManager::GetPersistenceProfilingData(std::string &f_cpersistenceprofileinfo) {
1112   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1113   EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
1114
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");
1121
1122   CPersistence *l_pPersistence = m_mPersist_Type[ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE];
1123   l_pPersistence->GetPersistenceProfilingData(f_cpersistenceprofileinfo);
1124
1125   l_pPersistence = m_mPersist_Type[ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER];
1126   l_pPersistence->GetPersistenceProfilingData(f_cpersistenceprofileinfo);
1127
1128   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1129   return l_estatus;
1130 }
1131
1132 #endif