common_library: gettid is multiple declaration in cl_error
[staging/basesystem.git] / video_in_hal / nsframework / notification_persistent_service / server / src / app_states.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 /// \defgroup <<Group Tag>> <<Group Name>>
19 /// \ingroup  tag_NS_NPPService
20 /// .
21 ////////////////////////////////////////////////////////////////////////////////////////////////////
22
23 ////////////////////////////////////////////////////////////////////////////////////////////////////
24 /// \ingroup  tag_NS_NPPService
25 /// \brief    This file contains implementation of internal transitions of state machine
26 ///
27 ////////////////////////////////////////////////////////////////////////////////////////////////////
28
29 #include <unistd.h>
30 #include <native_service/ns_np_service.h>
31 #include <native_service/frameworkunified_framework_if.h>
32 #include <native_service/ns_np_service_protocol.h>
33 #include <native_service/ns_np_service_notification.h>
34 #include <string>
35 #include <vector>
36 #include "app_states.h"
37 #include "ns_npp.h"
38 #include "ns_npp_notificationpersistentservicelog.h"
39 #include "ns_npp_notification_manager.h"
40 #include "ns_npp_persistence_manager.h"
41 #include "ns_npp_persistent_data.h"
42 #include "ns_npp_personalization_manager.h"
43
44
45 #ifdef NPP_PROFILEINFO_ENABLE
46 #include <ns_npp_profiling_protocols_internal.h>
47 #endif
48
49 #ifdef AGL_STUB
50 #include <other_service/strlcpy.h>
51 #endif
52
53 static size_t NppUIToA(unsigned int value, char *buf) {
54   static const char c[] = "0123456789";
55   char b[12];
56   char *p = b + sizeof(b);
57   int i = 0;
58
59   *--p = '\0';
60   do {
61     *--p = c[value % 10];
62     value /= 10;
63     ++i;
64   } while (value);
65   strcpy(buf, p); // NOLINT (runtime/printf)
66
67   return i;
68 }
69
70 static size_t NppStrlcpy(char *dst, const char *src, size_t siz) {
71   size_t ret = strlen(src);
72
73   if (siz) {  // LCOV_EXCL_BR_LINE 6: siz can't be 0
74     size_t len = (ret >= siz) ? siz - 1 : ret;
75     memcpy(dst, src, len);
76     dst[len] = '\0';
77   }
78   return ret;
79 }
80
81 #define NPP_SET_FIXSTR(buf, str) \
82   do { \
83     strcpy(buf, str); /* NOLINT (runtime/printf) */ \
84     buf += sizeof(str) - 1; \
85   } while (0)
86
87 #define NPP_SET_VARSTR(buf, str, siz) \
88     buf += NppStrlcpy(buf, str, siz)
89
90 extern CHAR g_csendreadyackto[];
91
92 ////////////////////////////////////////////////////////////////////////////////////////////////////
93 /// NotificationpersistentserviceOnNPRegisterNotifications
94 /// The state machine executes this transition when event for registering notification is triggered.
95 ////////////////////////////////////////////////////////////////////////////////////////////////////
96 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPRegisterNotifications) {  // NOLINT (readability/naming)
97   try {
98     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
99     EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
100
101     CHKNULL(f_pSourceState);
102     NC_register_multiple_notif_msg *l_pMsg = NULL;
103
104     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
105     CHKNULL(l_pHApp);
106
107     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
108     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
109
110     // get app name of message source
111     PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
112     CHKNULL(l_cMsgSource);
113
114     // get instance of notification manager
115     CNotificationManager *l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
116
117     if (NULL != l_pNotificationManager) {  // LCOV_EXCL_BR_LINE 6: l_pNotificationManager can't be NULL
118       UI_32 l_uiMsgLength = FrameworkunifiedGetMsgLength(l_pHApp);
119
120       if (l_uiMsgLength <= 0) {  // LCOV_EXCL_BR_LINE 6: l_uiMsgLength must be greater than 0
121         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
122         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't register notifications. Invalid message length received.");  // LCOV_EXCL_LINE 6: l_uiMsgLength must be greater than 0  // NOLINT[whitespace/line_length]
123       } else {
124         std::vector<CHAR> l_vData = std::vector<CHAR>(l_uiMsgLength);
125
126         // get the received data
127         if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(
128                                            l_pHApp, &l_vData[0], static_cast<UI_32>(l_vData.size()), eSMRRelease))) {
129           l_pMsg = reinterpret_cast<NC_register_multiple_notif_msg *>(&l_vData[0]);
130
131           if (NULL != l_pMsg) {  // LCOV_EXCL_BR_LINE 6: l_pMsg can't be NULL
132             NC_register_notif_msg *l_pEventInfo = NULL;
133
134             // register all the notifications
135             for (UI_32 l_uiCount = 0;
136                  l_uiCount < l_pMsg->numNotifications;
137                  ++l_uiCount) {
138               l_pEventInfo = &l_pMsg->notifierList[l_uiCount];
139
140               if (NULL != l_pEventInfo) {  // LCOV_EXCL_BR_LINE 6: l_pEventInfo can't be NULL
141                 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "Register Notfn request, src=%s, name=%s, len=%d, type=%d",
142                        l_cMsgSource, l_pEventInfo->notificationName, l_pEventInfo->maxLength, l_pEventInfo->persType);
143
144                 // register the notification
145                 if (eFrameworkunifiedStatusOK != l_pNotificationManager->NotificationpersistentserviceServiceOnRegisterEvents(l_cMsgSource,
146                                                                                        l_pEventInfo->notificationName,
147                                                                                        l_pEventInfo->maxLength,
148                                                                                        l_pEventInfo->persType)) {
149                   FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
150                          "Error in NotificationpersistentserviceServiceOnRegisterEvents :: %s", l_pEventInfo->notificationName);
151                 }
152               } else {
153                 // LCOV_EXCL_START 6: l_pEventInfo can't be NULL
154                 AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
155                 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
156                        "Can't register notification from source %s. l_pEventInfo is NULL", l_cMsgSource);
157                 // LCOV_EXCL_STOP
158               }
159             }
160           } else {
161             AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
162             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Invalid src mq");  // LCOV_EXCL_LINE 6: l_pMsg can't be NULL
163           }
164         } else {
165           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
166                  "Can't register notifications from source %s, Unable to get message data. Error Status: 0x%x",
167                  l_cMsgSource, l_estatus);
168         }
169       }
170     } else {
171       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
172       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "l_pNotificationManager is NULL");  // LCOV_EXCL_LINE 6: l_pNotificationManager can't be NULL  // NOLINT[whitespace/line_length]
173     }
174   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
175     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
176     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
177     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
178     return NULL;
179     // LCOV_EXCL_STOP
180   }
181   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
182   return f_pSourceState;
183 }
184
185 ////////////////////////////////////////////////////////////////////////////////////////////////////
186 /// NotificationpersistentserviceOnNPSubscribeToNotification
187 /// The state machine executes this transition when event for subscribing single notification is
188 /// triggered.
189 ////////////////////////////////////////////////////////////////////////////////////////////////////
190 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPSubscribeToNotification) {
191   try {
192     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
193     EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
194
195     CHKNULL(f_pSourceState);
196     NC_subscribe_msg l_objSubscribeMsg;
197
198     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
199     CHKNULL(l_pHApp);
200
201     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
202     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
203
204     PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
205     CHKNULL(l_cMsgSource);
206
207     // get instance of notification manager
208     CNotificationManager *l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
209
210     if (NULL != l_pNotificationManager) {  // LCOV_EXCL_BR_LINE 6: l_pNotificationManager can't be NULL
211       if (FrameworkunifiedGetMsgLength(l_pHApp) == sizeof(NC_subscribe_msg)) {  // LCOV_EXCL_BR_LINE 4: NSFW error case
212         // get the data received
213         if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(l_pHApp, static_cast<PVOID>(&l_objSubscribeMsg), sizeof(NC_subscribe_msg), eSMRRelease))) {  // LCOV_EXCL_BR_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
214 #ifdef NPP_PERFORMANCE_ANALYZE_ENABLE
215           char buf[128];
216           char *p = buf;
217           NPP_SET_FIXSTR(p, "Subscribing Notfn request, src=");
218           NPP_SET_VARSTR(p, l_cMsgSource, sizeof(buf) - (p - buf));
219           NPP_SET_FIXSTR(p, ", name=");
220           strcpy(p, l_objSubscribeMsg.notificationName); // NOLINT (runtime/printf)
221           FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, buf);
222         /* FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__,
223          * "Subscribing Notfn request, src=%s, name=%s",
224          *  l_cMsgSource, l_objSubscribeMsg.notificationName);*/
225 #endif  // ifdef NPP_PERFORMANCE_ANALYZE_ENABLE
226
227           // subscribe for notification
228           if (eFrameworkunifiedStatusOK != l_pNotificationManager->NotificationpersistentserviceServiceOnSubscribeToEvent(
229                       l_cMsgSource,
230                       l_objSubscribeMsg.notificationName)) {
231             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
232                    "Error in NotificationpersistentserviceServiceOnSubscribeToEvent :: %s", l_objSubscribeMsg.notificationName);
233           }
234         } else {
235           // LCOV_EXCL_START 4: NSFW error case
236           AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
237           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
238                  "Can't subscribe to notification from source %s. Unable to get msg data, status: 0x%x",
239                  l_cMsgSource, l_estatus);
240            // LCOV_EXCL_STOP
241         }
242       } else {
243         // LCOV_EXCL_START 4: NSFW error case
244         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
245         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
246                "Can't subscribe to notification from source %s. Invalid message length received.",
247                l_cMsgSource);
248         // LCOV_EXCL_STOP
249       }
250     } else {
251       // LCOV_EXCL_START 6: l_pNotificationManager can't be NULL
252       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
253       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't subscribe to notification from source %s. l_pNotificationManager is NULL",
254              l_cMsgSource);
255       // LCOV_EXCL_STOP
256     }
257   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
258     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
259     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
260     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
261     return NULL;
262     // LCOV_EXCL_STOP
263   }
264   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
265   return f_pSourceState;
266 }
267
268 ////////////////////////////////////////////////////////////////////////////////////////////////////
269 /// NotificationpersistentserviceOnNPSubscribeToNotifications
270 /// The state machine executes this transition when event for subscribing multiple notification is
271 /// triggered.
272 ////////////////////////////////////////////////////////////////////////////////////////////////////
273 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPSubscribeToNotifications) {
274   try {
275     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
276     EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
277
278     CHKNULL(f_pSourceState);
279     NC_subscribe_multiple_notif_msg *l_pMsg = NULL;
280
281     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
282     CHKNULL(l_pHApp);
283
284     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
285     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
286
287     PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
288     CHKNULL(l_cMsgSource);
289
290     // get instance of notification manager
291     CNotificationManager *l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
292
293     if (NULL != l_pNotificationManager) {  // LCOV_EXCL_BR_LINE 6: l_pNotificationManager can't be NULL
294       UI_32 l_uiMsgLength = FrameworkunifiedGetMsgLength(l_pHApp);
295
296       if (l_uiMsgLength <= 0) {  // LCOV_EXCL_BR_LINE 6: l_uiMsgLength must be greater than 0
297         // LCOV_EXCL_START 6: l_uiMsgLength must be greater than 0
298         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
299         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Invalid msg len");
300         // LCOV_EXCL_STOP
301       } else {
302         std::vector<CHAR> l_vData = std::vector<CHAR>(l_uiMsgLength);
303
304         // get the data received
305         if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(l_pHApp, &l_vData[0], static_cast<UI_32>(l_vData.size()), eSMRRelease))) {  // LCOV_EXCL_BR_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
306           l_pMsg = reinterpret_cast<NC_subscribe_multiple_notif_msg *>(&l_vData[0]);
307
308           if (NULL != l_pMsg) {  // LCOV_EXCL_BR_LINE 6: l_pMsg can't be NULL
309             NC_subscribe_msg *l_pEventInfo = NULL;
310
311             // subscribe to multiple notifications
312             for (UI_32 l_uiCount = 0;
313                  l_uiCount < l_pMsg->numNotifications;
314                  ++l_uiCount) {
315               l_pEventInfo = &l_pMsg->notificationList[l_uiCount];
316
317               if (NULL != l_pEventInfo) {  // LCOV_EXCL_BR_LINE 6: l_pEventInfo can't be NULL
318 #ifdef NPP_PERFORMANCE_ANALYZE_ENABLE
319                 char buf[128];
320                 char *p = buf;
321                 NPP_SET_FIXSTR(p, "Subscribe Notfn request, src=");
322                 NPP_SET_VARSTR(p, l_cMsgSource, sizeof(buf) - (p - buf));
323                 NPP_SET_FIXSTR(p, ", name=");
324                 strcpy(p, l_pEventInfo->notificationName); // NOLINT (runtime/printf)
325                 FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, buf);
326                 /* FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__,
327                         "Subscribe Notfn request, src=%s, name=%s",
328                         l_cMsgSource,
329                         l_pEventInfo->notificationName);*/
330 #endif  // ifdef NPP_PERFORMANCE_ANALYZE_ENABLE
331
332                 // subscribe to notification
333                 if (eFrameworkunifiedStatusOK != l_pNotificationManager->NotificationpersistentserviceServiceOnSubscribeToEvent(
334                             l_cMsgSource,
335                             l_pEventInfo->notificationName)) {
336                   FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
337                          "Error in NotificationpersistentserviceServiceOnSubscribeToEvent :: %s", l_pEventInfo->notificationName);
338                 }
339               } else {
340                 // LCOV_EXCL_START 6: l_pEventInfo can't be NULL
341                 AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
342                 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
343                       "Unable to subscribe to notifications from source %s, l_pEventInfo is NULL", l_cMsgSource);
344                 // LCOV_EXCL_STOP
345               }
346             }
347           } else {
348             // LCOV_EXCL_START 6: l_pMsg can't be NULL
349             AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
350             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
351                    "Unable to subscribe to notifications from source %s, Invalid src mq", l_cMsgSource);
352             // LCOV_EXCL_STOP
353           }
354
355           l_vData.clear();
356         } else {
357           // LCOV_EXCL_START 4: NSFW error case
358           AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
359           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
360                  "Unable to subscribe to notifications from source %s, error retrieving message data, status: 0x%x",
361                  l_cMsgSource,
362                  l_estatus);
363           // LCOV_EXCL_STOP
364         }
365       }
366     } else {
367       // LCOV_EXCL_START 6: l_pNotificationManager can't be NULL
368       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
369       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
370              "Unable to subscribe to notifications from source %s, l_pNotificationManager is NULL",
371              l_cMsgSource);
372       // LCOV_EXCL_STOP
373     }
374   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
375     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
376     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
377     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
378     return NULL;
379     // LCOV_EXCL_STOP
380   }
381   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
382   return f_pSourceState;
383 }
384
385 ////////////////////////////////////////////////////////////////////////////////////////////////////
386 /// NotificationpersistentserviceOnNPPublishNotification
387 /// The state machine executes this transition when event for publishing notification is triggered.
388 ////////////////////////////////////////////////////////////////////////////////////////////////////
389 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPPublishNotification) {
390   try {
391     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
392     EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
393
394     CHKNULL(f_pSourceState);
395
396     CHAR l_cData[MAX_SYS_INFO_SIZE];
397
398     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
399     CHKNULL(l_pHApp);
400
401     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
402     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
403
404     // get the app name of message source
405     PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
406     CHKNULL(l_cMsgSource);
407
408     // get instance of notification manager
409     CNotificationManager *l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
410
411     if (NULL != l_pNotificationManager) {  // LCOV_EXCL_BR_LINE 6: l_pNotificationManager can't be NULL
412       // retrieve notification name
413       FrameworkunifiedGetSystemInfo(l_pHApp, l_cData);
414
415       UI_32 l_uiMsgLength = FrameworkunifiedGetMsgLength(l_pHApp);
416
417       char buf[144];
418       char *p = buf;
419       NPP_SET_FIXSTR(p, "Publish Notfn request, src=");
420       NPP_SET_VARSTR(p, l_cMsgSource, sizeof(buf) - (p - buf));
421       NPP_SET_FIXSTR(p, ", name=");
422       NPP_SET_VARSTR(p, l_cData, sizeof(buf) - (p - buf));
423       NPP_SET_FIXSTR(p, ", len=");
424       NppUIToA(l_uiMsgLength, p);
425       FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, buf);
426       /* FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__,
427                 "Publish Notfn request, src=%s, name=%s, len=%d",
428                 l_cMsgSource, l_cData, l_uiMsgLength);*/
429
430       if (0 != l_uiMsgLength) {
431         std::vector<CHAR> pMsgData = std::vector<CHAR>(l_uiMsgLength);
432
433         // get the received data
434         if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(l_pHApp, &pMsgData[0], static_cast<UI_32>(pMsgData.size()), eSMRRelease))) {  // LCOV_EXCL_BR_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
435           // publish the notification
436           (VOID)l_pNotificationManager->NotificationpersistentserviceServiceOnPublishEvent(l_cMsgSource, l_cData,
437                                                                  (PVOID)&pMsgData[0], l_uiMsgLength);
438         } else {
439           // LCOV_EXCL_START 4: NSFW error case
440           AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
441           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
442                  "Can't publish notification from source %s, Unable to get messsage data, Error Status: 0x%x",
443                  l_cMsgSource, l_estatus);
444           // LCOV_EXCL_STOP 4: NSFW error case
445         }
446       } else {
447         // publish the notification
448         (VOID)l_pNotificationManager->NotificationpersistentserviceServiceOnPublishEvent(l_cMsgSource, l_cData, NULL, l_uiMsgLength);
449       }
450     } else {
451       // LCOV_EXCL_START 6: l_pNotificationManager can't be NULL
452       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
453       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't publish notification from source %s. l_pNotificationManager is NULL",
454              l_cMsgSource);
455       // LCOV_EXCL_STOP
456     }
457   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
458     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
459     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
460     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
461     return NULL;
462     // LCOV_EXCL_STOP
463   }
464   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
465   return f_pSourceState;
466 }
467
468 ////////////////////////////////////////////////////////////////////////////////////////////////////
469 /// NotificationpersistentserviceOnNPUnSubscribeFromNotification
470 /// The state machine executes this transition when event for unsubscribing notification is triggered.
471 ////////////////////////////////////////////////////////////////////////////////////////////////////
472 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPUnSubscribeFromNotification) {
473   try {
474     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
475     EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
476
477     CHKNULL(f_pSourceState);
478     NC_unsubscribe_frm_notif_msg unsubscribeMsg;
479
480     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
481     CHKNULL(l_pHApp);
482
483     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
484     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
485
486     // get the msg source name
487     PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
488     CHKNULL(l_cMsgSource);
489
490     // get instance of notification manager
491     CNotificationManager *l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
492
493     if (NULL != l_pNotificationManager) {  // LCOV_EXCL_BR_LINE 200: l_pNotificationManager can't be NULL
494       if (FrameworkunifiedGetMsgLength(l_pHApp) == sizeof(NC_unsubscribe_frm_notif_msg)) {  // LCOV_EXCL_BR_LINE 4: NSFW error case
495         // get the received data
496         if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(l_pHApp, static_cast<PVOID>(&unsubscribeMsg), sizeof(NC_unsubscribe_frm_notif_msg), eSMRRelease))) {  // LCOV_EXCL_BR_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
497           FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Source: %s is unsubscribing from notification: %s", l_cMsgSource,
498                  unsubscribeMsg.notificationName);
499
500           // unsubscribe from notification
501           if (eFrameworkunifiedStatusOK != l_pNotificationManager->NotificationpersistentserviceServiceOnUnSubscribeFromEvent(
502                       l_cMsgSource,
503                       unsubscribeMsg.notificationName)) {
504             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
505                    "Error in NotificationpersistentserviceServiceOnUnSubscribeFromEvent :: %s",
506                    unsubscribeMsg.notificationName);
507           }
508         } else {
509           // LCOV_EXCL_START 4: NSFW error case
510           AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
511           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
512                  "%s is unable to subscribe from notification, error getting message data, status: 0x%x",
513                  l_cMsgSource, l_estatus);
514           // LCOV_EXCL_STOP
515         }
516       } else {
517         // LCOV_EXCL_START 4: NSFW error case
518         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
519         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
520                "Can't unsubscribe to notification from source %s, Invalid Message size received.",
521                l_cMsgSource);
522         // LCOV_EXCL_STOP
523       }
524     } else {
525       // LCOV_EXCL_START 6: l_pNotificationManager can't be NULL
526       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
527       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
528              "Can't unsubscribe to notification from source %s, l_pNotificationManager is NULL",
529              l_cMsgSource);
530       // LCOV_EXCL_STOP
531     }
532   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
533     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
534     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
535     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
536     return NULL;
537     // LCOV_EXCL_STOP
538   }
539   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
540   return f_pSourceState;
541 }
542
543 ////////////////////////////////////////////////////////////////////////////////////////////////////
544 /// NotificationpersistentserviceOnNPUnSubscribeFromNotification
545 /// The state machine executes this transition when event for unsubscribing notification is triggered.
546 ////////////////////////////////////////////////////////////////////////////////////////////////////
547 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPUnSubscribeFromNotifications) {
548   try {
549     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
550     EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
551
552     CHKNULL(f_pSourceState);
553     NC_unsubscribe_multiple_notif_msg *l_pMsg = NULL;
554
555     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
556     CHKNULL(l_pHApp);
557
558     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
559     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
560
561     PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
562     CHKNULL(l_cMsgSource);
563
564     // get instance of notification manager
565     CNotificationManager *l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
566
567     if (NULL != l_pNotificationManager) {  // LCOV_EXCL_BR_LINE 6: l_pNotificationManager can't be NULL
568       UI_32 l_uiMsgLength = FrameworkunifiedGetMsgLength(l_pHApp);
569
570       if (l_uiMsgLength <= 0) {  // LCOV_EXCL_BR_LINE 6: l_uiMsgLength must be greater than 0
571         // LCOV_EXCL_START 6: l_uiMsgLength must be greater than 0
572         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
573         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
574                "Can't unsubscribe from notifications from source %s. Invalid message length received",
575                l_cMsgSource);
576         // LCOV_EXCL_STOP
577       } else {
578         std::vector<CHAR> l_vData = std::vector<CHAR>(l_uiMsgLength);
579
580         // get the data received
581         if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(l_pHApp, &l_vData[0], static_cast<UI_32>(l_vData.size()), eSMRRelease))) {  // LCOV_EXCL_BR_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
582           l_pMsg = reinterpret_cast<NC_unsubscribe_multiple_notif_msg *>(&l_vData[0]);
583
584           if (NULL != l_pMsg) {  // LCOV_EXCL_BR_LINE 6: l_pMsg can't be NULL
585             NC_unsubscribe_frm_notif_msg *l_pEventInfo = NULL;
586
587             // subscribe to multiple notifications
588             for (UI_32 l_uiCount = 0;
589                  l_uiCount < l_pMsg->numNotifications;
590                  ++l_uiCount) {
591               l_pEventInfo = &l_pMsg->notificationList[l_uiCount];
592
593               if (NULL != l_pEventInfo) {  // LCOV_EXCL_BR_LINE 6: l_pEventInfo can't be NULL
594                 FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Source: %s is unsubscribing from notification: %s", l_cMsgSource,
595                        l_pEventInfo->notificationName);
596
597                 // unsubscribe from notification
598                 if (eFrameworkunifiedStatusOK != l_pNotificationManager->NotificationpersistentserviceServiceOnUnSubscribeFromEvent(
599                             l_cMsgSource,
600                             l_pEventInfo->notificationName)) {
601                   FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
602                          "Error in NotificationpersistentserviceServiceOnUnSubscribeFromEvent :: %s", l_pEventInfo->notificationName);
603                 }
604
605               } else {
606                 // LCOV_EXCL_START 6: l_pEventInfo can't be NULL
607                 AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
608                 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
609                        "Can't unsubscribe from notifications from source %s. l_pEventInfo is NULL",
610                        l_cMsgSource);
611                 // LCOV_EXCL_STOP
612               }
613             }
614           } else {
615             // LCOV_EXCL_START 6: l_pMsg can't be NULL
616             AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
617             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
618                    "Can't unsubscribe from notifications from source %s. Invalid src mq", l_cMsgSource);
619             // LCOV_EXCL_STOP
620           }
621
622           l_vData.clear();
623         } else {
624           // LCOV_EXCL_START 4: NSFW error case
625           AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
626           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
627                  "Can't unsubscribe from notifications from source %s, error getting message data, status: 0x%x",
628                  l_cMsgSource,
629                  l_estatus);
630           // LCOV_EXCL_STOP
631         }
632       }
633     } else {
634       // LCOV_EXCL_START 6: l_pNotificationManager can't be NULL
635       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
636       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
637              "Can't unsubscribe from notifications from source %s. l_pNotificationManager is NULL",
638              l_cMsgSource);
639       // LCOV_EXCL_STOP
640     }
641   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
642     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
643     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
644     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
645     return NULL;
646     // LCOV_EXCL_STOP
647   }
648   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
649   return f_pSourceState;
650 }
651
652 ////////////////////////////////////////////////////////////////////////////////////////////////////
653 /// NotificationpersistentserviceOnNPUnRegisterNotifications
654 /// The state machine executes this transition when event for unregistering notifications is triggered.
655 ////////////////////////////////////////////////////////////////////////////////////////////////////
656 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPUnRegisterNotifications) {
657   try {
658     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
659     EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
660
661     CHKNULL(f_pSourceState);
662     NC_unregister_multiple_notif_msg *l_pMsg = NULL;
663
664     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
665     CHKNULL(l_pHApp);
666
667     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
668     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
669
670     // get the source name
671     PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
672     CHKNULL(l_cMsgSource);
673
674     // get instance of notification manager
675     CNotificationManager *l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
676
677     if (NULL != l_pNotificationManager) {  // LCOV_EXCL_BR_LINE 6: l_pNotificationManager can't be NULL
678       UI_32 l_uiMsgLength = FrameworkunifiedGetMsgLength(l_pHApp);
679
680       if (l_uiMsgLength <= 0) {  // LCOV_EXCL_BR_LINE 6: l_uiMsgLength must be greater than 0
681         // LCOV_EXCL_START 6: l_uiMsgLength must be greater than 0
682         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
683         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
684                "Can't unregister to notifications from source %s. Invalid message length received.",
685                l_cMsgSource);
686         // LCOV_EXCL_STOP
687       } else {
688         std::vector<CHAR>l_vData = std::vector<CHAR>(l_uiMsgLength);
689
690         // get the received data
691         if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(l_pHApp, &l_vData[0], static_cast<UI_32>(l_vData.size()), eSMRRelease))) {  // LCOV_EXCL_BR_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
692           l_pMsg = reinterpret_cast<NC_unregister_multiple_notif_msg *>(&l_vData[0]);
693
694           // unregister multiple notifications
695           if (NULL != l_cMsgSource && NULL != l_pMsg) {  // LCOV_EXCL_BR_LINE 6: l_cMsgSource and l_pMsg can't be NULL
696             NC_unregister_notif_msg *l_pEventInfo = NULL;
697
698             for (UI_32 l_uiCount = 0;
699                  l_uiCount < l_pMsg->numNotifications;
700                  ++l_uiCount) {
701               l_pEventInfo = &l_pMsg->notificationList[l_uiCount];
702
703               if (NULL != l_pEventInfo) {  // LCOV_EXCL_BR_LINE 6: l_pEventInfo can't be NULL
704                 FRAMEWORKUNIFIEDLOG(ZONE_NPP_INFO, __FUNCTION__, "Source %s is unregistering to notification %s", l_cMsgSource,
705                        l_pEventInfo->notificationName);
706
707                 // unregister notification
708                 if (eFrameworkunifiedStatusOK != l_pNotificationManager->NotificationpersistentserviceServiceOnUnRegisterEvents(
709                             l_cMsgSource,
710                             l_pEventInfo->notificationName)) {
711                   FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
712                          "Error in NotificationpersistentserviceServiceOnUnRegisterEvents :: %s", l_pEventInfo->notificationName);
713                 }
714               } else {
715                 // LCOV_EXCL_START 6: l_pEventInfo can't be NULL
716                 AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
717                 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
718                        "Can't unregister to notifications from source %s, l_pEventInfo is NULL", l_cMsgSource);
719                 // LCOV_EXCL_STOP
720               }
721             }
722           } else {
723             // LCOV_EXCL_START 6: l_cMsgSource and l_pMsg can't be NULL
724             AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
725             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
726                    "Can't unregister to notificationsfrom source %s, Invalid src mq ", l_cMsgSource);
727             // LCOV_EXCL_STOP
728           }
729
730           l_vData.clear();
731         } else {
732           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
733                  "Can't unregister to notifications from source %s, Unable to get message data, status: 0x%x",
734                  l_cMsgSource, l_estatus);
735         }
736       }
737     } else {
738       // LCOV_EXCL_START 6: l_pNotificationManager can't be NULL
739       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
740       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
741              "Can't unregister to notifications from source %s, l_pNotificationManager is NULL",
742              l_cMsgSource);
743       // LCOV_EXCL_STOP
744     }
745   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
746     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
747     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
748     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
749     return NULL;
750     // LCOV_EXCL_STOP
751   }
752   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
753   return f_pSourceState;
754 }
755
756 ////////////////////////////////////////////////////////////////////////////////////////////////////
757 /// NotificationpersistentserviceOnNPReadPersistedData
758 /// The state machine executes this transition when event for getting notification's persistent data
759 /// is triggered.
760 ////////////////////////////////////////////////////////////////////////////////////////////////////
761 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPReadPersistedData) {
762   try {
763     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
764     EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
765
766     CHKNULL(f_pSourceState);
767     NC_get_pers_data_msg l_tMsg;
768
769     l_tMsg.notificationName[0] = '\0';
770
771     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
772     CHKNULL(l_pHApp);
773
774     PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
775     CHKNULL(l_cMsgSource);
776
777     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
778     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
779
780     // get instance of notification manager
781     CNotificationManager *l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
782
783     if (NULL != l_pNotificationManager) {  // LCOV_EXCL_BR_LINE 6: l_pNotificationManager can't be NULL
784       if (FrameworkunifiedGetMsgLength(l_pHApp) == sizeof(NC_get_pers_data_msg)) {  // LCOV_EXCL_BR_LINE 4: NSFW error case
785         // get the message data received
786         if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(l_pHApp, static_cast<PVOID>(&l_tMsg), sizeof(NC_get_pers_data_msg), eSMRRelease))) {  // LCOV_EXCL_BR_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
787           FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Source %s is requesting to read data for persistent notification %s",
788                  l_cMsgSource, l_tMsg.notificationName);
789           // get persistent data related to notification
790           if (eFrameworkunifiedStatusOK != (l_estatus = l_pNotificationManager->NotificationpersistentserviceServiceOnGetPersistentData(
791                                    l_tMsg.notificationName,
792                                    l_cMsgSource))) {
793             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error in NotificationpersistentserviceServiceOnGetPersistentData :: %s", l_tMsg.notificationName);
794           }
795         } else {
796           // LCOV_EXCL_START 4: NSFW error case
797           AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
798           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
799                  "Can't read persistent data for source %s, Error getting message data, status: 0x%x",
800                  l_cMsgSource, l_estatus);
801           // LCOV_EXCL_STOP
802         }
803       } else {
804         // LCOV_EXCL_START 4: NSFW error case
805         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
806         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't read persistent data for source %s. Invalid Message size received.",
807                l_cMsgSource);
808         l_estatus = eFrameworkunifiedStatusFail;
809         // LCOV_EXCL_STOP
810       }
811     } else {
812       // LCOV_EXCL_START 6: l_pNotificationManager can't be NULL
813       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
814       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't read persistent data for source %s. l_pNotificationManager is NULL",
815              l_cMsgSource);
816       l_estatus = eFrameworkunifiedStatusFail;
817       // LCOV_EXCL_STOP
818     }
819
820     // if any error occurs while reading persistent data, send failed ack to the requestor
821     if (eFrameworkunifiedStatusOK != l_estatus) {
822       HANDLE l_hReceiverMq = McOpenSender(l_cMsgSource);
823       if (NULL != l_hReceiverMq) {   // LCOV_EXCL_BR_LINE 4: NSFW error case.
824         NC_get_persdata_failed_ack gpdFailed = {};
825         std::strncpy(&gpdFailed.notificationName[0], l_tMsg.notificationName, MAX_STRING_SIZE_NOTIFICATION);
826
827         // send the failure ack to requester
828         l_estatus = McSend(l_hReceiverMq, AppName, NPS_GET_PERS_DATA_FAILED_ACK, sizeof(gpdFailed), &gpdFailed);  // LCOV_EXCL_BR_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
829         FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__,
830                "Sent NPS_GET_PERS_DATA_FAILED_ACK to %s. Status: %d.",
831                l_cMsgSource, l_estatus);
832
833         McClose(l_hReceiverMq);
834       } else {
835         // LCOV_EXCL_START 4: NSFW error case.
836         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
837         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error in opening sender queue of %s. Can't send NPS_GET_PERS_DATA_FAILED_ACK",
838                l_cMsgSource);
839         // LCOV_EXCL_STOP
840       }
841     }
842   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
843     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
844     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
845     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
846     return NULL;
847   // LCOV_EXCL_STOP
848   }
849
850   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
851   return f_pSourceState;
852 }
853
854 ////////////////////////////////////////////////////////////////////////////////////////////////////
855 /// NotificationpersistentserviceOnNPPublishImmediateNotification
856 /// This transition is executed when service updates the immediate notification data
857 /// using synchronous API
858 ////////////////////////////////////////////////////////////////////////////////////////////////////
859 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPPublishImmediateNotification) {
860   try {
861     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
862     EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
863
864     CHKNULL(f_pSourceState);
865
866     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
867     CHKNULL(l_pHApp);
868
869     // get the app name of message source
870     PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
871     CHKNULL(l_cMsgSource);
872
873     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
874     CHKNULL(l_pNotificationpersistentserviceHSM);
875     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
876
877     // get instance of notification manager
878     CNotificationManager *l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
879     CHKNULL(l_pNotificationManager);
880
881     CHAR l_cNotfName[MAX_SYS_INFO_SIZE] = {};
882
883     // retrieve notification name
884     (VOID)FrameworkunifiedGetSystemInfo(l_pHApp, l_cNotfName);
885
886     UI_32 l_uiMsgLength = FrameworkunifiedGetMsgLength(l_pHApp);
887
888     FRAMEWORKUNIFIEDLOG(ZONE_WARN, __FUNCTION__,
889            "Warning::Notification %s published using sync API by %s, Data length: %d",
890            l_cNotfName,
891            l_cMsgSource, l_uiMsgLength);
892
893     if (0 != l_uiMsgLength) {
894       std::vector<CHAR> pMsgData = std::vector<CHAR>(l_uiMsgLength);
895
896       // get the received data
897       if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(l_pHApp, &pMsgData[0], l_uiMsgLength, eSMRRelease))) {  // LCOV_EXCL_BR_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
898         // publish the notification
899         (VOID)l_pNotificationManager->NotificationpersistentservicePublishImmediateNotification(l_cMsgSource, l_cNotfName, (PVOID)&pMsgData[0],
900                                                                       l_uiMsgLength);
901       } else {
902         // LCOV_EXCL_START 4: NSFW error case
903         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
904         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
905                "Can't publish notification %s from source %s, Unable to get messsage data, Error Status: 0x%x",
906                l_cNotfName,
907                l_cMsgSource, l_estatus);
908         // LCOV_EXCL_STOP
909       }
910     } else {
911       // publish the notification
912       (VOID)l_pNotificationManager->NotificationpersistentservicePublishImmediateNotification(l_cMsgSource, l_cNotfName, NULL, l_uiMsgLength);
913     }
914   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
915     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
916     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
917     f_pSourceState = NULL;
918     // LCOV_EXCL_STOP
919   }
920
921   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
922   return f_pSourceState;
923 }
924 ////////////////////////////////////////////////////////////////////////////////////////////////////
925 /// NotificationpersistentserviceOnNPPersistentSync
926 /// Processing which synchronizes by NPPService (syncfs)
927 ///
928 ////////////////////////////////////////////////////////////////////////////////////////////////////
929 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPPersistentSync) {
930   try {
931     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
932     CHKNULL(f_pSourceState);
933
934     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
935
936     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
937     CHKNULL(l_pNotificationpersistentserviceHSM);
938     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
939     CHKNULL(l_pnsnpp);
940
941     if (TRUE == l_pnsnpp->Syncfs()) {  // LCOV_EXCL_BR_LINE 6: always return true
942       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
943       FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "syncfs are processed.");  // LCOV_EXCL_LINE 6: always return true
944     }
945   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
946     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
947     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
948     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
949     return NULL;
950     // LCOV_EXCL_STOP
951   }
952
953   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
954   return f_pSourceState;
955 }
956
957 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPReleaseFileAck) {
958   try {
959     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
960
961     NSP_CopyStatusResponse l_tCpStatus = {};
962
963     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
964     CHKNULL(l_pHApp);
965
966     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
967     CHKNULL(l_pNotificationpersistentserviceHSM);
968
969     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
970
971     if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(l_pHApp, (PVOID)&l_tCpStatus, sizeof(l_tCpStatus), eSMRRelease)) {  // LCOV_EXCL_BR_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
972       FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "%s for tag: %s sender: %s, persist type:%d",
973              (l_tCpStatus.m_bpersistencechk ? "Successful copy" : "Non-Successful copy"),
974              l_tCpStatus.m_cpersistenttag, l_tCpStatus.m_crequesterappname, l_tCpStatus.m_eloadtype);
975
976       if (LOADTYPE_LOAD == l_tCpStatus.m_eloadtype) {  // ack for load file/folder
977         HANDLE hMq = NULL;
978         NC_LoadPersistedAck l_tMsgAck = {};
979
980         // HANDLE hMq = McOpenSender(l_tCpStatus.sender);
981         hMq = FrameworkunifiedMcOpenSender(l_pHApp, l_tCpStatus.m_crequesterappname);
982
983         // send NC_LoadPersistedAck to the requester
984         l_tMsgAck.eStatus = (TRUE == l_tCpStatus.m_bpersistencechk) ? eFrameworkunifiedStatusOK : eFrameworkunifiedStatusFail;
985
986 #ifdef AGL_PosixBasedOS001LEGACY_USED
987         strlcpy(l_tMsgAck.cTag, l_tCpStatus.m_cpersistenttag, sizeof(l_tMsgAck.cTag));
988 #endif
989
990         if (NULL == hMq) {  // LCOV_EXCL_BR_LINE 4: NSFW error case
991           AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
992           // catastrophic failure!
993           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "McOpenSender failed for %s ", l_tCpStatus.m_crequesterappname);  // LCOV_EXCL_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
994         } else {
995           if (ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE == l_tCpStatus.m_epersisttype) {
996             // send ack to requester for file successfully persisted
997             if (eFrameworkunifiedStatusOK != FrameworkunifiedSendMsg(hMq, NPS_GET_PERS_FILE_ACK, sizeof(l_tMsgAck), &l_tMsgAck)) {  // LCOV_EXCL_BR_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
998               // LCOV_EXCL_START 4: NSFW error case
999               AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1000               FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1001                      "ERROR :: Sending NPS_GET_PERS_FILE_ACK message to %s", l_tCpStatus.m_crequesterappname);
1002               // LCOV_EXCL_STOP
1003             } else {
1004               FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__,
1005                      "NPS_GET_PERS_FILE_ACK is sent to %s for file tag %s and load status: %d.",
1006                      l_tCpStatus.m_crequesterappname, l_tMsgAck.cTag, l_tMsgAck.eStatus);
1007             }
1008           } else if (ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER == l_tCpStatus.m_epersisttype) {  // LCOV_EXCL_BR_LINE 6: m_epersisttype must be ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE or ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER  // NOLINT[whitespace/line_length]
1009             // send ack to requester for folder successfully persisted
1010             if (eFrameworkunifiedStatusOK != FrameworkunifiedSendMsg(hMq, NPS_GET_PERS_FOLDER_ACK, sizeof(l_tMsgAck), &l_tMsgAck)) {  // LCOV_EXCL_BR_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
1011               // LCOV_EXCL_START 4: NSFW error case
1012               AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1013               FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1014                      "ERROR :: Sending NPS_GET_PERS_FOLDER_ACK message to %s", l_tCpStatus.m_crequesterappname);
1015               // LCOV_EXCL_STOP
1016             } else {
1017               FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__,
1018                      "NPS_GET_PERS_FOLDER_ACK is sent to %s for folder tag %s and load status: %d.",
1019                      l_tCpStatus.m_crequesterappname, l_tMsgAck.cTag, l_tMsgAck.eStatus);
1020             }
1021           } else {
1022             // do nothing
1023           }
1024           // close mq
1025           FrameworkunifiedMcClose(hMq);
1026           hMq = NULL;
1027         }
1028       }
1029
1030       // Update registry
1031       CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
1032       if (l_pPersistenceManager) {  // LCOV_EXCL_BR_LINE 6: unexpected branch can't be NULL
1033         l_pPersistenceManager->AckReceivedFromWorker(l_tCpStatus.m_crequesterappname,
1034                                                      l_tCpStatus.m_cpersistenttag,
1035                                                      l_tCpStatus.m_epersisttype,
1036                                                      l_tCpStatus.m_bpersistencechk,
1037                                                      l_tCpStatus.m_eloadtype);
1038       }
1039
1040       if (LOADTYPE_RELEASE == l_tCpStatus.m_eloadtype) {
1041         f_pSourceState->FrameworkunifiedPostEvent(EVENT(evCheckAllFilesPersisted));
1042       }
1043     } else {
1044       // LCOV_EXCL_START 4: NSFW error case
1045       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1046       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1047              "ERROR ::invalid length FrameworkunifiedGetMsgDataOfSize expected(%ld)", static_cast<long int>(sizeof(l_tCpStatus))); // NOLINT (runtime/int)
1048       // LCOV_EXCL_STOP
1049     }
1050   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
1051     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1052     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
1053     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1054     return NULL;
1055     // LCOV_EXCL_STOP
1056   }
1057   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1058   return f_pSourceState;
1059 }
1060
1061
1062 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnSaveDataAck) {  // LCOV_EXCL_START 6: unused code
1063   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1064   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
1065   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1066   return f_pSourceState;
1067 }
1068 // LCOV_EXCL_STOP
1069
1070 ////////////////////////////////////////////////////////////////////////////////////////////////////
1071 /// NotificationpersistentserviceOnUserChange
1072 /// The state machine executes this transition when event to set or change personality is received
1073 /// from the system.
1074 ////////////////////////////////////////////////////////////////////////////////////////////////////
1075 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnUserChange) {
1076   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
1077   EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
1078
1079   try {
1080     CHKNULL(f_pSourceState);
1081     NC_User l_tMsg;
1082     std::string l_cCurrentUsername;
1083
1084     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
1085     // TODO(my_username): Only accept user change from authorized app. Compare l_cMsgSource with authorized source.
1086     if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(l_pHApp, static_cast<PVOID>(&l_tMsg), sizeof(NC_User), eSMRRelease))) {  // LCOV_EXCL_BR_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
1087       CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
1088       CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
1089
1090       if (NULL != l_pnsnpp) {  // LCOV_EXCL_BR_LINE 6: l_pnsnpp can't be NULL
1091         CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
1092         CnotificationpersistentservicePersonalizationManager *l_pPersonalizationManager = l_pnsnpp->m_pPersonalizationManager;
1093
1094         if (NULL != l_pPersonalizationManager) {  // LCOV_EXCL_BR_LINE 6: l_pPersonalizationManager can't be NULL
1095           l_pPersonalizationManager->NotificationpersistentserviceGetPersonality(l_cCurrentUsername);
1096         }
1097
1098         // writes the temporary user files and folders to permanent memory
1099         if (NULL != l_pPersistenceManager) {  // LCOV_EXCL_BR_LINE 6: l_pPersistenceManager can't be NULL
1100           if (!l_cCurrentUsername.empty()) {  // LCOV_EXCL_BR_LINE 6: double check, l_cCurrentUsername can't be empty
1101             if (eFrameworkunifiedStatusOK != l_pPersistenceManager->NotificationpersistentservicePersistAllUserRequests()) {  // LCOV_EXCL_BR_LINE 6: NotificationpersistentservicePersistAllUserRequests will always return ok  // NOLINT[whitespace/line_length]
1102               AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1103               FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error while persisting user files and folders.");  // LCOV_EXCL_LINE 6: NotificationpersistentservicePersistAllUserRequests will always return ok  // NOLINT[whitespace/line_length]
1104             }
1105           }
1106         }
1107
1108         // save the user persistent notification data
1109         if (eFrameworkunifiedStatusOK != l_pnsnpp->NotificationpersistentserviceSaveNotificationPersistentData(eFrameworkunifiedPersistedStateUserVar)) {
1110           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error while NotificationpersistentserviceSaveNotificationPersistentData");
1111         }
1112       }
1113
1114       // set new personality
1115       SetPersonality(l_pHApp, l_tMsg);
1116     } else {
1117       // LCOV_EXCL_START 4: NSFW error case
1118       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1119       FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__,
1120              "Cannot set new personality, error getting message data, status: 0x%x", l_estatus);
1121       // LCOV_EXCL_STOP
1122     }
1123   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
1124     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1125     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
1126     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1127     return NULL;
1128     // LCOV_EXCL_STOP
1129   }
1130
1131   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1132   return f_pSourceState;
1133 }
1134
1135 // ===========Shutdown
1136 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnShutdownTimeout) {  // LCOV_EXCL_START 200: cannot test code
1137   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1138   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
1139   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1140   return f_pSourceState;
1141 }
1142 // LCOV_EXCL_STOP
1143
1144 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceCheckAllReleaseRequestsProcessed) {
1145   try {
1146     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
1147     CHKNULL(f_pSourceState);
1148
1149     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
1150
1151     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
1152     CHKNULL(l_pNotificationpersistentserviceHSM);
1153     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
1154
1155     CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
1156     CHKNULL(l_pPersistenceManager);
1157     if (TRUE == l_pPersistenceManager->HaveAllReleaseRequestsPersisted()) {  // LCOV_EXCL_BR_LINE 6: always return ok
1158       FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "All release requests are processed.");
1159       f_pSourceState->FrameworkunifiedPostEvent(EVENT(evIdle));
1160     }
1161   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
1162     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1163     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
1164     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1165     return NULL;
1166     // LCOV_EXCL_STOP
1167   }
1168
1169   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1170   return f_pSourceState;
1171 }
1172
1173 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceReInitShutdownTimer) {   // LCOV_EXCL_START 8: not be used
1174   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1175   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
1176   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1177   return f_pSourceState;
1178 }
1179 // LCOV_EXCL_STOP
1180
1181 CsNotificationpersistentserviceNPPStart::CsNotificationpersistentserviceNPPStart(std::string f_strName): CFrameworkunifiedOrthogonalState(f_strName) {
1182 }
1183
1184 CsNotificationpersistentserviceNPPStart::~CsNotificationpersistentserviceNPPStart() {  // LCOV_EXCL_START 200: cannot test code
1185   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1186 }
1187 // LCOV_EXCL_STOP
1188
1189 EFrameworkunifiedStatus CsNotificationpersistentserviceNPPStart::FrameworkunifiedOnEntry(CEventDataPtr f_peventdata) {
1190   EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusFail;
1191
1192   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
1193
1194   try {
1195     HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
1196     CHKNULL(l_pHApp);
1197
1198     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
1199     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
1200
1201     // Get instance of notification manager
1202     CNotificationManager *l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
1203
1204     if (l_pNotificationManager) {  // LCOV_EXCL_BR_LINE 6: l_pNotificationManager can't be NULL
1205       NC_User l_tMsg = {};
1206
1207       // register the user change notification
1208       if (eFrameworkunifiedStatusOK != l_pNotificationManager->NotificationpersistentserviceServiceOnRegisterEvents(AppName,  // LCOV_EXCL_BR_LINE 6: always return ok  // NOLINT[whitespace/line_length]
1209                                                                              NTFY_NPPService_UserChange,
1210                                                                              sizeof(NC_User),
1211                                                                              eFrameworkunifiedPersistedStateVar)) {
1212         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1213         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error in user change notification registration.");  // LCOV_EXCL_LINE 6: always return ok  // NOLINT[whitespace/line_length]
1214       }
1215
1216       // Set initial user. By default, NS_NPPService will set the current user as last user. If no
1217       // last user found set the default user.
1218       UI_32 l_uiUserNotificationDataSize = 0;
1219       EFrameworkunifiedStatus l_eGetNotificationDataStatus = eFrameworkunifiedStatusFail;
1220       l_eGetNotificationDataStatus = l_pNotificationManager->NPGetPersistentNotificationData(
1221                   NTFY_NPPService_UserChange,
1222                   (PVOID)&l_tMsg,
1223                   sizeof(l_tMsg));
1224
1225       if ((eFrameworkunifiedStatusOK != l_eGetNotificationDataStatus) || (l_uiUserNotificationDataSize <= 0)) {
1226         // set default user
1227 #ifdef AGL_PosixBasedOS001LEGACY_USED
1228         strlcpy(l_tMsg.cUsername, DEFAULTUSERNAME, sizeof(l_tMsg.cUsername));
1229 #endif
1230       }
1231
1232       l_estatus = SetPersonality(l_pHApp, l_tMsg);
1233     }
1234   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
1235     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1236     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
1237     l_estatus =  eFrameworkunifiedStatusInvldHandle;
1238     // LCOV_EXCL_STOP
1239   }
1240   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1241   return l_estatus;
1242 }
1243
1244 EFrameworkunifiedStatus SetPersonality(HANDLE l_pHApp, NC_User &f_tMsg) { // NOLINT (runtime/references)
1245   EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusFail;
1246   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
1247
1248   CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
1249   CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
1250
1251   if (NULL != l_pnsnpp) {  // LCOV_EXCL_BR_LINE 6: l_pnsnpp can't be NULL
1252     // Get the instance of personalization manager
1253     CnotificationpersistentservicePersonalizationManager *l_pNotificationpersistentservicePersonalizationManager = l_pnsnpp->m_pPersonalizationManager;
1254
1255     if (NULL != l_pNotificationpersistentservicePersonalizationManager) {  // LCOV_EXCL_BR_LINE 6: l_pNotificationpersistentservicePersonalizationManager can't be NULL
1256       // send msg to all notificationpersistentservice apps that user has change.
1257       // register user change notification
1258       FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "Personality :: %s", f_tMsg.cUsername);
1259
1260       if (eFrameworkunifiedStatusOK != (l_estatus = l_pNotificationpersistentservicePersonalizationManager->NotificationpersistentserviceSetPersonality(f_tMsg.cUsername))) {
1261         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Personality not set in Personality Manager :: user : %s", f_tMsg.cUsername);
1262       } else {
1263         // Get the instance of persistence manager
1264         CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
1265
1266         if (NULL != l_pPersistenceManager) {  // LCOV_EXCL_BR_LINE 6: l_pPersistenceManager can't be NULL
1267           l_pPersistenceManager->SetUserPersistentPath(f_tMsg.cUsername);
1268
1269           // save the user persistent notification data
1270           if (eFrameworkunifiedStatusOK != l_pnsnpp->NotificationpersistentserviceLoadPersistentNotificationData(eFrameworkunifiedPersistedStateUserVar)) {
1271             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error while loading user specific notification data.");
1272           }
1273
1274           // Get instance of notification manager
1275           CNotificationManager *l_pNotificationManager = NULL;
1276           l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
1277
1278           if (NULL != l_pNotificationManager) {  // LCOV_EXCL_BR_LINE 6: l_pNotificationManager can't be NULL
1279             // publish the user change notification
1280             if (eFrameworkunifiedStatusOK != (l_estatus = l_pNotificationManager->NotificationpersistentserviceServiceOnPublishEvent(AppName, NTFY_NPPService_UserChange, (PVOID)&f_tMsg, sizeof(f_tMsg)))) {  // LCOV_EXCL_BR_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
1281               AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1282               FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error in publish user change event.");  // LCOV_EXCL_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
1283             }
1284           }
1285         }
1286       }
1287     } else {
1288       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1289       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "l_pNotificationpersistentservicePersonalizationManager is NULL");  // LCOV_EXCL_LINE 6: l_pNotificationpersistentservicePersonalizationManager can't be NULL  // NOLINT[whitespace/line_length]
1290     }
1291   }
1292
1293   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1294   return l_estatus;
1295 }
1296
1297 EFrameworkunifiedStatus CsNotificationpersistentserviceNPPStart:: FrameworkunifiedOnExit(CEventDataPtr f_peventdata) {  // LCOV_EXCL_START 200: cannot test code
1298   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1299   return eFrameworkunifiedStatusOK;
1300   // LCOV_EXCL_STOP
1301 }
1302
1303 CsNotificationpersistentserviceShutdownDataSave::CsNotificationpersistentserviceShutdownDataSave(std::string f_strName): CFrameworkunifiedLeafState(f_strName) {
1304 }
1305
1306 CsNotificationpersistentserviceShutdownDataSave::~CsNotificationpersistentserviceShutdownDataSave() {  // LCOV_EXCL_START 200: cannot test code
1307   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1308 }
1309 // LCOV_EXCL_STOP
1310
1311 EFrameworkunifiedStatus CsNotificationpersistentserviceShutdownDataSave::FrameworkunifiedOnEntry(CEventDataPtr f_peventdata) {
1312   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
1313
1314   HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
1315   CHKNULL(l_pHApp);
1316
1317   PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
1318   m_cShutdownRequestor = l_cMsgSource;
1319   FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "NS_NPP received STOP message from %s.", l_cMsgSource);
1320
1321   CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
1322   CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
1323
1324   if (NULL != l_pnsnpp) {  // LCOV_EXCL_BR_LINE 6: can't be NULL
1325     CShutDownMsgData *l_pMsgData = dynamic_cast<CShutDownMsgData *>(f_peventdata.get());
1326     CHKNULL(l_pMsgData);
1327
1328     FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Shutdown Type=%d, Data received with shutdown message:: %x",
1329            l_pMsgData->m_eShutdownType, l_pMsgData->m_uiMsgData);
1330
1331     // save the persistent data on shutdown
1332     if (eFrameworkunifiedStatusOK != l_pnsnpp->NotificationpersistentservicePersistAll(l_pMsgData->m_eShutdownType, l_pMsgData->m_uiMsgData)) {  // LCOV_EXCL_BR_LINE 6: always return ok   // NOLINT[whitespace/line_length]
1333       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1334       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error in NotificationpersistentserviceOnSavePersistentData");  // LCOV_EXCL_LINE 6: always return ok
1335     }
1336   }
1337
1338   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1339   return eFrameworkunifiedStatusOK;
1340 }
1341
1342 EFrameworkunifiedStatus CsNotificationpersistentserviceShutdownDataSave:: FrameworkunifiedOnExit(CEventDataPtr f_peventdata) {
1343   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
1344   try {
1345     HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
1346     CHKNULL(l_pHApp);
1347
1348     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
1349     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
1350     CHKNULL(l_pnsnpp);
1351
1352     CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
1353     CHKNULL(l_pPersistenceManager);
1354
1355     l_pPersistenceManager->ResetPersistFlag();
1356
1357     // before sending shutdown ack, synchronize all the modified block buffers by NPPService for writing
1358     l_pnsnpp->Syncfs();
1359
1360     // Send shutdown ack response to requester
1361     FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Sending shutdown complete message to requestor  %s.",
1362            m_cShutdownRequestor.c_str());
1363     HANDLE hMq = FrameworkunifiedMcOpenSender(l_pHApp, m_cShutdownRequestor.c_str());
1364     if (NULL != hMq) {   // LCOV_EXCL_BR_LINE 4: NSFW error case.
1365       if (eFrameworkunifiedStatusOK != FrameworkunifiedSendMsg(hMq, NPS_NPP_STOP_ACK, 0, NULL)) {  // LCOV_EXCL_BR_LINE 4: NSFW error case
1366         // LCOV_EXCL_START 4: NSFW error case
1367         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1368         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error sending shutdown complete message to requestor  %s.",
1369                m_cShutdownRequestor.c_str());
1370         // LCOV_EXCL_STOP
1371       }
1372       FrameworkunifiedMcClose(hMq);
1373     } else {
1374       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1375       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error in OpenSender for requestor %s.", m_cShutdownRequestor.c_str());  // LCOV_EXCL_LINE 4: NSFW error case.  // NOLINT[whitespace/line_length]
1376     }
1377   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
1378     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1379     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
1380     // LCOV_EXCL_STOP
1381   }
1382   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
1383   return eFrameworkunifiedStatusOK;
1384 }
1385
1386 ////////////////////////////////////////////////////////////////////////////////////////////////////
1387 /// NotificationpersistentserviceOnRegisterPersistentFile
1388 /// The state machine executes this transition when event for registering persistent file tag is
1389 /// received.
1390 ////////////////////////////////////////////////////////////////////////////////////////////////////
1391 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnRegisterPersistentFile) {
1392   try {
1393     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
1394     CHKNULL(f_pSourceState);
1395     NC_RegisterPersistentFileMsg l_tMsg = {};
1396
1397     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
1398     CHKNULL(l_pHApp);
1399     PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
1400
1401     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
1402     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
1403
1404     CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
1405
1406
1407     if (NULL != l_pPersistenceManager && NULL != l_cMsgSource) {  // LCOV_EXCL_BR_LINE 6: l_pPersistenceManager and l_cMsgSource can't be NULL  // NOLINT[whitespace/line_length]
1408       if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(l_pHApp, static_cast<PVOID>(&l_tMsg), sizeof(l_tMsg), eSMRRelease)) {  // LCOV_EXCL_BR_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
1409         std::string l_cName;
1410         l_cName = l_tMsg.cFileTag;
1411
1412         if (eFrameworkunifiedStatusOK != l_pPersistenceManager->NotificationpersistentserviceRegister(l_cMsgSource,  // LCOV_EXCL_BR_LINE 6: always return ok
1413                                                                l_tMsg.cFileTag,
1414                                                                ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE,
1415                                                                // l_tMsg.eRegisterType,
1416                                                                l_tMsg.bIsUserFile)) {
1417           AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1418           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error in Registering Persitence File :: %s", l_tMsg.cFileTag);  // LCOV_EXCL_LINE 6: always return ok  // NOLINT[whitespace/line_length]
1419         }
1420
1421         FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Registered File %s as TO BE PERSISTED for %s",
1422                l_tMsg.cFileTag, l_cMsgSource);
1423       } else {
1424         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1425         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't register persistent file. Invalid message size received.");  // LCOV_EXCL_LINE 6: l_pPersistenceManager and l_cMsgSource can't be NULL  // NOLINT[whitespace/line_length]
1426       }
1427     } else {
1428       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1429       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't register persistent file. l_pPersistenceManager is NULL");  // LCOV_EXCL_LINE 6: l_pPersistenceManager and l_cMsgSource can't be NULL  // NOLINT[whitespace/line_length]
1430     }
1431   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
1432     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1433     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
1434     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1435     return NULL;
1436     // LCOV_EXCL_STOP
1437   }
1438   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1439   return f_pSourceState;
1440 }
1441
1442 ////////////////////////////////////////////////////////////////////////////////////////////////////
1443 /// NotificationpersistentserviceOnReleasePersistentFile
1444 /// The state machine executes this transition when event for releasing persistent file tag is
1445 /// received.
1446 ////////////////////////////////////////////////////////////////////////////////////////////////////
1447 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnReleasePersistentFile) {
1448   try {
1449     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
1450
1451     // Check if  persistence has been disabled than return immediately
1452     if (TRUE == CPersistenceManager::m_bPersistenceDisabled) {  // LCOV_EXCL_BR_LINE 6: custom command line options
1453       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1454       return f_pSourceState;  // LCOV_EXCL_LINE 6: custom command line options
1455     }
1456
1457     CHKNULL(f_pSourceState);
1458     NC_ReleasePersistentFileMsg l_tMsg = {};
1459
1460     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
1461     CHKNULL(l_pHApp);
1462     PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
1463
1464     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
1465     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
1466
1467     // get the instance of persistence manager
1468     CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
1469     // get the instance of persistence manager
1470     CnotificationpersistentservicePersonalizationManager *l_pNotificationpersistentservicePersonalizationManager = l_pnsnpp->m_pPersonalizationManager;
1471
1472     if (NULL != l_pPersistenceManager && NULL != l_cMsgSource && NULL != l_pNotificationpersistentservicePersonalizationManager) {  // LCOV_EXCL_BR_LINE 6: l_pPersistenceManager,  l_cMsgSource and l_pNotificationpersistentservicePersonalizationManager can't be NULL  // NOLINT[whitespace/line_length]
1473       if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(l_pHApp, static_cast<PVOID>(&l_tMsg), sizeof(l_tMsg), eSMRRelease)) {  // LCOV_EXCL_BR_LINE 4: NSFW error case.  // NOLINT[whitespace/line_length]
1474         // Check if the filetag is registered as user specific persistence
1475         if (TRUE == l_pPersistenceManager->IsUserPersistence(l_tMsg.cFileTag, ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE)) {
1476           if (!l_pNotificationpersistentservicePersonalizationManager->NotificationpersistentserviceIsValidPersonality(l_tMsg.cUsername)) {
1477             FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1478             return f_pSourceState;
1479           }
1480         }
1481
1482         if (eFrameworkunifiedStatusOK != l_pPersistenceManager->NotificationpersistentserviceRelease(l_cMsgSource,
1483                                                               l_tMsg.cFileTag,
1484                                                               l_tMsg.cFilePath,
1485                                                               l_tMsg.eFrameworkunifiedReleaseType, // NOLINT (readability/naming)
1486                                                               ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE,
1487                                                               l_tMsg.cUsername)) {
1488           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error in releasing persitence file :: %s", l_tMsg.cFileTag);
1489         }
1490
1491         FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Release file %s to tag %s for source %s",
1492                l_tMsg.cFilePath, l_tMsg.cFileTag, l_cMsgSource);
1493       } else {
1494         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1495         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't release persistent file. Invalid message size received");  // LCOV_EXCL_LINE 4: NSFW error case.  // NOLINT[whitespace/line_length]
1496       }
1497     } else {
1498       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1499       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't release persistent file. l_pPersistenceManager is NULL");  // LCOV_EXCL_LINE 6: l_pPersistenceManager,  l_cMsgSource and l_pNotificationpersistentservicePersonalizationManager can't be NULL  // NOLINT[whitespace/line_length]
1500     }
1501   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
1502     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1503     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
1504     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1505     return NULL;
1506     // LCOV_EXCL_STOP
1507   }
1508   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1509   return f_pSourceState;
1510 }
1511
1512 ////////////////////////////////////////////////////////////////////////////////////////////////////
1513 /// NotificationpersistentserviceOnLoadPersistentFile
1514 /// The state machine executes this transition when event for loading persistent file is received.
1515 ////////////////////////////////////////////////////////////////////////////////////////////////////
1516 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnLoadPersistentFile) {
1517   try {
1518     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
1519     CHKNULL(f_pSourceState);
1520     NC_LoadPersistedFileMsg l_tMsg = {};
1521
1522     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
1523     CHKNULL(l_pHApp);
1524     PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
1525
1526     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
1527     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
1528
1529     CnotificationpersistentservicePersonalizationManager *l_pNotificationpersistentservicePersonalizationManager = l_pnsnpp->m_pPersonalizationManager;
1530     // get the instance of persistence manager
1531     CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
1532
1533     if (NULL != l_pPersistenceManager && NULL != l_cMsgSource && NULL != l_pNotificationpersistentservicePersonalizationManager) {  // LCOV_EXCL_BR_LINE 6: l_pPersistenceManager,  l_cMsgSource and l_pNotificationpersistentservicePersonalizationManager can't be NULL  // NOLINT[whitespace/line_length]
1534       if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(l_pHApp, static_cast<PVOID>(&l_tMsg), sizeof(l_tMsg), eSMRRelease)) {  // LCOV_EXCL_BR_LINE 4: NSFW error case.  // NOLINT[whitespace/line_length]
1535         FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Load file %s that was PERSISTED by %s with tag %s",
1536                l_tMsg.cFilePath, l_cMsgSource, l_tMsg.cFileTag);
1537
1538         // Check if the filetag is registered as user specific persistence
1539         if (TRUE == l_pPersistenceManager->IsUserPersistence(l_tMsg.cFileTag, ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE)) {
1540           if (!l_pNotificationpersistentservicePersonalizationManager->NotificationpersistentserviceIsValidPersonality(l_tMsg.cUsername)) {
1541             FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1542             return f_pSourceState;
1543           }
1544         }
1545
1546         EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
1547         NC_LoadPersistedAck l_tMsgAck = {};
1548
1549         HANDLE l_hMq = FrameworkunifiedMcOpenSender(l_pHApp, l_cMsgSource);
1550
1551         if (NULL != l_hMq) {  // LCOV_EXCL_BR_LINE 4: NSFW error case
1552           //// Check if  persistence has been disabled than send positive acknowledgement to the application
1553           if (TRUE == CPersistenceManager::m_bPersistenceDisabled) {  // LCOV_EXCL_BR_LINE 6: custom command line options  // NOLINT[whitespace/line_length]
1554             // LCOV_EXCL_START 6: custom command line options
1555             AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1556             l_tMsgAck.eStatus = eFrameworkunifiedStatusOK;
1557 #ifdef AGL_PosixBasedOS001LEGACY_USED
1558             strlcpy(l_tMsgAck.cTag, l_tMsg.cFileTag, sizeof(l_tMsgAck.cTag));
1559 #endif
1560
1561             // send ack to requester
1562             if (eFrameworkunifiedStatusOK != (l_estatus = FrameworkunifiedSendMsg(l_hMq, NPS_GET_PERS_FILE_ACK, sizeof(l_tMsgAck), &l_tMsgAck))) {
1563               FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedSendMsg returned l_estatus=%d", l_estatus);
1564             }
1565             // LCOV_EXCL_STOP
1566           } else {
1567             if (eFrameworkunifiedStatusOK != (l_estatus = l_pPersistenceManager->NotificationpersistentserviceLoad(l_cMsgSource,
1568                                                                             l_tMsg.cFileTag,
1569                                                                             l_tMsg.cFilePath,
1570                                                                             ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE,
1571                                                                             l_tMsg.cUsername))) {
1572               if (eFrameworkunifiedStatusFileLoadSuccess == l_estatus) {  // LCOV_EXCL_BR_LINE 6: l_estatus can't be eFrameworkunifiedStatusFileLoadSuccess  // NOLINT[whitespace/line_length]
1573                 AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1574                 l_tMsgAck.eStatus = eFrameworkunifiedStatusOK;  // LCOV_EXCL_LINE 6: l_estatus can't be eFrameworkunifiedStatusFileLoadSuccess
1575               } else {
1576                 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error in Loading Persitence File :: %s", l_tMsg.cFileTag);
1577
1578                 // return error to requester
1579                 l_tMsgAck.eStatus = l_estatus;
1580               }
1581
1582               std::strncpy(l_tMsgAck.cTag, l_tMsg.cFileTag, (MAX_PATH_LENGTH - 1));
1583
1584               // send ack to requester
1585               if (eFrameworkunifiedStatusOK != (l_estatus = FrameworkunifiedSendMsg(l_hMq, NPS_GET_PERS_FILE_ACK, sizeof(l_tMsgAck), &l_tMsgAck))) {  // LCOV_EXCL_BR_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
1586                 AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1587                 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedSendMsg returned l_estatus=%d", l_estatus);  // LCOV_EXCL_LINE 4: NSFW error case.  // NOLINT[whitespace/line_length]
1588               }
1589               FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "NPS_GET_PERS_FILE_ACK is sent to %s. File load status: %d, "
1590                      "message sent status: %d ", l_cMsgSource, l_tMsgAck.eStatus, l_estatus);
1591             }
1592           }
1593
1594           FrameworkunifiedMcClose(l_hMq);
1595         } else {
1596           // LCOV_EXCL_START 4: NSFW error case
1597           AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1598           // catastrophic failure!
1599           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "McOpenSender failed for %s", l_cMsgSource);
1600           // LCOV_EXCL_STOP
1601         }
1602       } else {
1603         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1604         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't load persistent file. Invalid message size received.");  // LCOV_EXCL_LINE 4: NSFW error case.  // NOLINT[whitespace/line_length]
1605       }
1606     } else {
1607       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1608       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't load persistent file. l_pNotificationManager is NULL");  // LCOV_EXCL_LINE 6: l_pPersistenceManager, l_cMsgSource and l_pNotificationpersistentservicePersonalizationManager can't be NULL  // NOLINT[whitespace/line_length]
1609     }
1610   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
1611     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1612     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
1613     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1614     return NULL;
1615     // LCOV_EXCL_STOP
1616   }
1617   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1618   return f_pSourceState;
1619 }
1620
1621 ////////////////////////////////////////////////////////////////////////////////////////////////////
1622 /// NotificationpersistentserviceOnRegisterPersistentFolder
1623 /// The state machine executes this transition when event for registering persistent folder tag is
1624 /// received.
1625 ////////////////////////////////////////////////////////////////////////////////////////////////////
1626 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnRegisterPersistentFolder) {
1627   try {
1628     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
1629     CHKNULL(f_pSourceState);
1630     NC_RegisterPersistentFolderMsg l_tMsg = {};
1631
1632     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
1633     CHKNULL(l_pHApp);
1634     PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
1635
1636     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
1637     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
1638
1639     CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
1640
1641     if (NULL != l_pPersistenceManager && NULL != l_cMsgSource) {  // LCOV_EXCL_BR_LINE 6: l_pPersistenceManager and l_cMsgSource can't be NULL  // NOLINT[whitespace/line_length]
1642       if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(l_pHApp,  // LCOV_EXCL_BR_LINE 4: NSFW error case
1643                                               static_cast<PVOID>(&l_tMsg),
1644                                               sizeof(l_tMsg),
1645                                               eSMRRelease)) {
1646         std::string l_cName;
1647         l_cName = l_tMsg.cFolderTag;
1648
1649         if (eFrameworkunifiedStatusOK != l_pPersistenceManager->NotificationpersistentserviceRegister(l_cMsgSource,  // LCOV_EXCL_BR_LINE 6: always return ok
1650                                                                l_tMsg.cFolderTag,
1651                                                                ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER,
1652                                                                // l_tMsg.eRegisterType,
1653                                                                l_tMsg.bIsUserFolder)) {
1654           AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1655           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error in Registering Persitence Folder :: %s", l_tMsg.cFolderTag);  // LCOV_EXCL_LINE 6: always return ok  // NOLINT[whitespace/line_length]
1656         }
1657
1658         FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Registered Folder %s as TO BE PERSISTED for %s",
1659                l_tMsg.cFolderTag, l_cMsgSource);
1660       } else {
1661         // LCOV_EXCL_START 4: NSFW error case
1662         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1663         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't register persistent folder. Invalid message size received.");
1664         // LCOV_EXCL_STOP
1665       }
1666     } else {
1667       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1668       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't register persistent folder.. l_pPersistenceManager is NULL");  // LCOV_EXCL_LINE 6: l_pPersistenceManager and l_cMsgSource can't be NULL  // NOLINT[whitespace/line_length]
1669     }
1670   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
1671     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1672     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
1673     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1674     return NULL;
1675     // LCOV_EXCL_STOP
1676   }
1677   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1678   return f_pSourceState;
1679 }
1680
1681 ////////////////////////////////////////////////////////////////////////////////////////////////////
1682 /// NotificationpersistentserviceOnLoadPersistentFolder
1683 /// The state machine executes this transition when event for loading persistent folder is received.
1684 ////////////////////////////////////////////////////////////////////////////////////////////////////
1685 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnLoadPersistentFolder) {
1686   try {
1687     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
1688     CHKNULL(f_pSourceState);
1689     NC_LoadPersistedFolderMsg l_tMsg = {};
1690
1691     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
1692     CHKNULL(l_pHApp);
1693     PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
1694
1695     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
1696     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
1697
1698     CnotificationpersistentservicePersonalizationManager *l_pNotificationpersistentservicePersonalizationManager = l_pnsnpp->m_pPersonalizationManager;
1699
1700     // get the instance of persistence manager
1701     CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
1702
1703     if (NULL != l_pPersistenceManager && NULL != l_cMsgSource && NULL != l_pNotificationpersistentservicePersonalizationManager) {  // LCOV_EXCL_BR_LINE 6: l_pPersistenceManager,  l_cMsgSource and l_pNotificationpersistentservicePersonalizationManager can't be NULL  // NOLINT[whitespace/line_length]
1704       if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(l_pHApp, static_cast<PVOID>(&l_tMsg), sizeof(l_tMsg), eSMRRelease)) {  // LCOV_EXCL_BR_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
1705         FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Load folder %s that was PERSISTED by %s with tag %s",
1706                l_tMsg.cFolderPath, l_cMsgSource, l_tMsg.cFolderTag);
1707
1708         // Check if the foldertag is registered as user specific persistence
1709         if (TRUE == l_pPersistenceManager->IsUserPersistence(l_tMsg.cFolderTag, ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER)) {
1710           if (!l_pNotificationpersistentservicePersonalizationManager->NotificationpersistentserviceIsValidPersonality(l_tMsg.cUsername)) {
1711             FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1712             return f_pSourceState;
1713           }
1714         }
1715
1716         EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
1717         NC_LoadPersistedAck l_tMsgAck = {};
1718         HANDLE l_hMq = NULL;
1719         l_hMq = FrameworkunifiedMcOpenSender(l_pHApp, l_cMsgSource);
1720
1721         if (NULL != l_hMq) {  // LCOV_EXCL_BR_LINE 4: NSFW error case
1722           //// Check if  persistence has been disabled than  send positive acknowledgement to the application
1723           if (TRUE == CPersistenceManager::m_bPersistenceDisabled) {  // LCOV_EXCL_BR_LINE 6: custom command line options  // NOLINT[whitespace/line_length]
1724             // LCOV_EXCL_START 6: custom command line options
1725             AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1726             l_tMsgAck.eStatus = eFrameworkunifiedStatusOK;
1727 #ifdef AGL_PosixBasedOS001LEGACY_USED
1728             strlcpy(l_tMsgAck.cTag, l_tMsg.cFolderTag, sizeof(l_tMsgAck.cTag));
1729 #endif
1730
1731             // send ack to requester
1732             if (eFrameworkunifiedStatusOK != (l_estatus = FrameworkunifiedSendMsg(l_hMq,
1733                                                         NPS_GET_PERS_FOLDER_ACK,
1734                                                         sizeof(l_tMsgAck), &l_tMsgAck))) {
1735               FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedSendMsg returned l_estatus=%d", l_estatus);
1736             }
1737             // LCOV_EXCL_STOP
1738           } else {
1739             if (eFrameworkunifiedStatusOK != (l_estatus = l_pPersistenceManager->NotificationpersistentserviceLoad(l_cMsgSource,
1740                                                                             l_tMsg.cFolderTag,
1741                                                                             l_tMsg.cFolderPath,
1742                                                                             ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER,
1743                                                                             l_tMsg.cUsername))) {
1744               FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error in Loading Persitence Folder :: %s", l_tMsg.cFolderTag);
1745
1746               // return error to requester
1747               l_tMsgAck.eStatus = l_estatus;
1748               std::strncpy(l_tMsgAck.cTag, l_tMsg.cFolderTag, (MAX_PATH_LENGTH - 1));
1749
1750               // send ack to requester
1751               if (eFrameworkunifiedStatusOK != (l_estatus = FrameworkunifiedSendMsg(l_hMq,  // LCOV_EXCL_BR_LINE 4: NSFW error case
1752                                                           NPS_GET_PERS_FOLDER_ACK,
1753                                                           sizeof(l_tMsgAck), &l_tMsgAck))) {
1754                 // LCOV_EXCL_START 4: NSFW error case
1755                 AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1756                 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: FrameworkunifiedSendMsg returned l_estatus=%d", l_estatus);
1757                 // LCOV_EXCL_STOP
1758               }
1759             }
1760           }
1761           FrameworkunifiedMcClose(l_hMq);
1762         } else {
1763           // LCOV_EXCL_START 4: NSFW error case
1764           AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1765           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1766                  "Can't send ack NPS_GET_PERS_FOLDER_ACK. McOpenSender failed for %s ", l_cMsgSource);
1767           // LCOV_EXCL_STOP
1768         }
1769       } else {
1770         // LCOV_EXCL_START 4: NSFW error case
1771         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1772         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't load persistent folder. Invalid message size received.");
1773         // LCOV_EXCL_STOP
1774       }
1775     } else {
1776       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1777       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't load persistent folder. l_pNotificationManager is NULL");  // LCOV_EXCL_LINE 6: l_pPersistenceManager,  l_cMsgSource and l_pNotificationpersistentservicePersonalizationManager can't be NULL  // NOLINT[whitespace/line_length]
1778     }
1779   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
1780     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1781     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
1782     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1783     return NULL;
1784     // LCOV_EXCL_STOP
1785   }
1786   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1787   return f_pSourceState;
1788 }
1789
1790 ////////////////////////////////////////////////////////////////////////////////////////////////////
1791 /// NotificationpersistentserviceOnReleasePersistentFolder
1792 /// The state machine executes this transition when event for releasing persistent folder tag is
1793 /// received.
1794 ////////////////////////////////////////////////////////////////////////////////////////////////////
1795 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnReleasePersistentFolder) {
1796   try {
1797     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
1798     CHKNULL(f_pSourceState);
1799
1800     // Check if  persistence has been disabled than return immediately
1801     if (TRUE == CPersistenceManager::m_bPersistenceDisabled) {  // LCOV_EXCL_BR_LINE 6: custom command line options
1802       // LCOV_EXCL_START 6: custom command line options
1803       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1804       FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1805       return f_pSourceState;
1806       // LCOV_EXCL_STOP
1807     }
1808
1809     NC_ReleasePersistentFolderMsg l_tMsg = {};
1810
1811     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
1812     CHKNULL(l_pHApp);
1813     PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
1814
1815     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
1816     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
1817
1818     // get the instance of persistence manager
1819     CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
1820
1821     CnotificationpersistentservicePersonalizationManager *l_pNotificationpersistentservicePersonalizationManager = l_pnsnpp->m_pPersonalizationManager;
1822
1823     if (NULL != l_pPersistenceManager && NULL != l_cMsgSource && NULL != l_pNotificationpersistentservicePersonalizationManager) {  // LCOV_EXCL_BR_LINE 6: l_pPersistenceManager,  l_cMsgSource and l_pNotificationpersistentservicePersonalizationManager can't be NULL  // NOLINT[whitespace/line_length]
1824       if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(l_pHApp, static_cast<PVOID>(&l_tMsg), sizeof(l_tMsg), eSMRRelease)) {  // LCOV_EXCL_BR_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
1825         // Check if the foldertag is registered as user specific persistence
1826         if (TRUE == l_pPersistenceManager->IsUserPersistence(l_tMsg.cFolderTag, ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER)) {
1827           if (!l_pNotificationpersistentservicePersonalizationManager->NotificationpersistentserviceIsValidPersonality(l_tMsg.cUsername)) {
1828             FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1829             return f_pSourceState;
1830           }
1831         }
1832         if (eFrameworkunifiedStatusOK != l_pPersistenceManager->NotificationpersistentserviceRelease(l_cMsgSource,
1833                                                               l_tMsg.cFolderTag,
1834                                                               l_tMsg.cFolderPath,
1835                                                               l_tMsg.eFrameworkunifiedReleaseType, // NOLINT (readability/naming)
1836                                                               ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER,
1837                                                               l_tMsg.cUsername)) {
1838           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error in releasing persitence folder :: %s", l_tMsg.cFolderTag);
1839         }
1840
1841         FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Release Folder %s to tag %s for source %s",
1842                l_tMsg.cFolderPath, l_tMsg.cFolderTag, l_cMsgSource);
1843       } else {
1844         // LCOV_EXCL_START 4: NSFW error case
1845         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1846         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't release persistent folder. Invalid message size received.");
1847         // LCOV_EXCL_STOP
1848       }
1849     } else {
1850       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1851       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't release persistent folder. l_pPersistenceManager is NULL");  // LCOV_EXCL_LINE 6: l_pPersistenceManager,  l_cMsgSource and l_pNotificationpersistentservicePersonalizationManager can't be NULL  // NOLINT[whitespace/line_length]
1852     }
1853   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
1854     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1855     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
1856     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1857     return NULL;
1858     // LCOV_EXCL_STOP
1859   }
1860   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1861   return f_pSourceState;
1862 }
1863
1864 ////////////////////////////////////////////////////////////////////////////////////////////////////
1865 /// NotificationpersistentserviceOnNPGetReadyStatus
1866 ///
1867 ////////////////////////////////////////////////////////////////////////////////////////////////////
1868 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPGetReadyStatus) {
1869   try {
1870     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
1871
1872     CHKNULL(f_pSourceState);
1873
1874     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
1875     CHKNULL(l_pHApp);
1876
1877     PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
1878     CHKNULL(l_cMsgSource);
1879
1880     HANDLE l_hMq = FrameworkunifiedMcOpenSender(l_pHApp, l_cMsgSource);
1881     if (NULL != l_hMq) {  // LCOV_EXCL_BR_LINE 4: NSFW error case
1882       EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
1883
1884       // send ack to requester
1885       if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedSendMsg(l_hMq, NPS_GET_READYSTATUS_ACK, 0, NULL))) {  // LCOV_EXCL_BR_LINE 4: NSFW error case.  // NOLINT[whitespace/line_length]
1886         FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __PRETTY_FUNCTION__, "NPP ready status sent to %s.", l_cMsgSource);
1887       } else {
1888         // LCOV_EXCL_START 4: NSFW error case.
1889         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1890         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "Error sending NPS_GET_READYSTATUS_ACK to %s, status: %d", l_cMsgSource,
1891                l_estatus);
1892         // LCOV_EXCL_STOP
1893       }
1894
1895       FrameworkunifiedMcClose(l_hMq);
1896       l_hMq = NULL;
1897     } else {
1898       // LCOV_EXCL_START 4: NSFW error case
1899       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1900       // catastrophic failure!
1901       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "McOpenSender failed for %s ", l_cMsgSource);
1902       // LCOV_EXCL_STOP
1903     }
1904   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
1905     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1906     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
1907     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1908     return NULL;
1909     // LCOV_EXCL_STOP
1910   }
1911   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
1912   return f_pSourceState;
1913 }
1914
1915 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPRegisterImmediateNotifications) {
1916   try {
1917     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
1918     EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
1919
1920     CHKNULL(f_pSourceState);
1921     NC_register_multiple_immediate_notif_msg *l_pMsg = NULL;
1922
1923     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
1924     CHKNULL(l_pHApp);
1925
1926     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
1927     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
1928
1929     // get app name of message source
1930     PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
1931     CHKNULL(l_cMsgSource);
1932
1933     // get instance of notification manager
1934     CNotificationManager *l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
1935
1936     if (NULL != l_pNotificationManager) {  // LCOV_EXCL_BR_LINE 6: l_pNotificationManager can't be NULL
1937       UI_32 l_uiMsgLength = FrameworkunifiedGetMsgLength(l_pHApp);
1938
1939       if (l_uiMsgLength <= 0) {  // LCOV_EXCL_BR_LINE 6: l_uiMsgLength must be greater than 0
1940         // LCOV_EXCL_START 6: l_uiMsgLength must be greater than 0
1941         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1942         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1943                "Can't register immediate persistence notification from source %s. Invalid message length.",
1944                l_cMsgSource);
1945         // LCOV_EXCL_STOP
1946       } else {
1947         std::vector<CHAR> l_vData = std::vector<CHAR>(l_uiMsgLength);
1948
1949         // get the received data
1950         if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(l_pHApp, &l_vData[0], static_cast<UI_32>(l_vData.size()), eSMRRelease))) {  // LCOV_EXCL_BR_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
1951           l_pMsg = reinterpret_cast<NC_register_multiple_immediate_notif_msg *>(&l_vData[0]);
1952
1953           if (NULL != l_pMsg) {  // LCOV_EXCL_BR_LINE 5: reinterpret_cast's error case.
1954             NC_register_immediate_notif_msg *l_pEventInfo = NULL;
1955             UI_32 l_uiCount;
1956             // register all the notifications
1957             for (l_uiCount = 0 ; l_uiCount < l_pMsg->numNotifications; ++l_uiCount) {
1958               l_pEventInfo = &l_pMsg->notifierList[l_uiCount];
1959
1960               if (NULL != l_pEventInfo) {  // LCOV_EXCL_BR_LINE 6: l_pEventInfo can't be NULL
1961                 FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Register immediate persistence notification: "
1962                        "NotificationName[%d] = %s, data length = %d ",
1963                        l_uiCount, l_pEventInfo->notificationName, l_pEventInfo->maxLength);
1964
1965                 if (eFrameworkunifiedStatusOK != l_pNotificationManager->NotificationpersistentserviceServiceOnRegisterEvents(l_cMsgSource,
1966                                                                                        l_pEventInfo->notificationName,
1967                                                                                        l_pEventInfo->maxLength,
1968                                                                                        l_pEventInfo->persType,
1969                                                                                        l_pEventInfo->delay)) {
1970                   FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1971                          "Error in NotificationpersistentserviceServiceOnRegisterEvents :: %s", l_pEventInfo->notificationName);
1972                 }
1973               } else {
1974                 // LCOV_EXCL_START 6: l_pEventInfo can't be NULL
1975                 AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1976                 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1977                        "Can't register immediate persistence notification from source %s. l_pEventInfo is NULL",
1978                        l_cMsgSource);
1979                 // LCOV_EXCL_STOP
1980               }
1981             }
1982           } else {
1983             // LCOV_EXCL_START 5: reinterpret_cast's error case.
1984             AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1985             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1986                    "Can't register immediate persistence notification from source %s. Invalid src mq",
1987                    l_cMsgSource);
1988             // LCOV_EXCL_STOP
1989           }
1990         } else {
1991           // LCOV_EXCL_START 4: NSFW error case.
1992           AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
1993           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
1994                  "Can't register immediate persistence notification from source %s, "
1995                  "Error getting message data, status: 0x%x",
1996                  l_cMsgSource, l_estatus);
1997           // LCOV_EXCL_STOP
1998         }
1999       }
2000     } else {
2001       // LCOV_EXCL_START 6: l_pNotificationManager can't be NULL
2002       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
2003       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2004              "Can't register immediate persistence notification from source %s. "
2005              "l_pNotificationManager is NULL", l_cMsgSource);
2006       // LCOV_EXCL_STOP
2007     }
2008   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
2009     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
2010     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
2011     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
2012     return NULL;
2013     // LCOV_EXCL_STOP
2014   }
2015   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
2016   return f_pSourceState;
2017 }
2018
2019 ////////////////////////////////////////////////////////////////////////////////////////////////////
2020 /// NotificationpersistentserviceOnNPClearPersistedData
2021 /// Deletes NPS Persistent Data and sends the ack back to requester
2022 ////////////////////////////////////////////////////////////////////////////////////////////////////
2023 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPClearPersistedData) {
2024   EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusFail;
2025
2026   // requeter MsgQ handle for sending Ack
2027   HANDLE hRequesterAck = NULL;
2028
2029   // Application Handle
2030   HANDLE l_pHApp = NULL;
2031
2032   // Received request data
2033   NC_ClearPersistedDataReq l_tMsg = {};
2034
2035   // Ack structure
2036   NC_ClearPersisteDatadAck l_tMsgAck = {};
2037
2038   // requester name
2039   PCSTR pRequester = NULL;
2040
2041   try {
2042     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
2043
2044     l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
2045     CHKNULL(l_pHApp);
2046
2047     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
2048     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
2049     CHKNULL(l_pnsnpp);
2050
2051     pRequester = FrameworkunifiedGetMsgSrc(l_pHApp);
2052     CHKNULL(pRequester);
2053
2054     if (sizeof(NC_ClearPersistedDataReq) == FrameworkunifiedGetMsgLength(l_pHApp)) {  // LCOV_EXCL_BR_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
2055       if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(l_pHApp, (PVOID)(&l_tMsg), sizeof(NC_ClearPersistedDataReq), eSMRRelease))) {  // LCOV_EXCL_BR_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
2056         FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Request for deleting the persistent data of type %d received from %s",
2057                l_tMsg.ePersistenceData, pRequester);
2058
2059         CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
2060         CHKNULL(l_pPersistenceManager);
2061
2062         l_estatus = l_pPersistenceManager->ClearPersistenceData(l_tMsg.ePersistenceData);
2063       } else {
2064         // LCOV_EXCL_START 4: NSFW error case
2065         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
2066         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "FrameworkunifiedGetMsgDataOfSize Error");
2067         // LCOV_EXCL_STOP
2068       }
2069     } else {
2070       // LCOV_EXCL_START 4: NSFW error case
2071       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
2072       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't delete persistent data. Invalid message size received.");
2073       // LCOV_EXCL_STOP
2074     }
2075   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
2076     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
2077     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
2078     f_pSourceState = NULL;
2079     l_estatus = eFrameworkunifiedStatusNullPointer;
2080     // LCOV_EXCL_STOP
2081   }
2082
2083   // sending acknowledgement to the requester
2084
2085   // create the requestor handle to send the ack
2086   hRequesterAck = FrameworkunifiedMcOpenSender(l_pHApp,
2087                                   pRequester);
2088
2089   if (NULL != hRequesterAck) {  // LCOV_EXCL_BR_LINE 4: NSFW error case
2090     // set the status
2091     l_tMsgAck.eStatus = l_estatus;
2092
2093     // send NC_ClearPersisteDatadAck to the requester
2094     if (eFrameworkunifiedStatusOK != FrameworkunifiedSendMsg(hRequesterAck,  // LCOV_EXCL_BR_LINE 4: NSFW error case
2095                                    NPS_DELETE_PERSISTED_DATA_ACK,
2096                                    sizeof(l_tMsgAck),
2097                                    &l_tMsgAck)) {
2098       // LCOV_EXCL_START 4: NSFW error case
2099       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
2100       FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error sending NPS_GET_PERS_FILE_ACK message to %s", pRequester);
2101       // LCOV_EXCL_STOP
2102     }
2103
2104     // close handle
2105     FrameworkunifiedMcClose(hRequesterAck);
2106   } else {
2107     // LCOV_EXCL_START 4: NSFW error case
2108     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
2109     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedMcOpenSender failed for %s ", pRequester);
2110     // LCOV_EXCL_STOP
2111   }
2112   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
2113   return f_pSourceState;
2114 }
2115
2116 ////////////////////////////////////////////////////////////////////////////////////////////////////
2117 /// NotificationpersistentserviceOnNPSetDefaultPersistentData
2118 /// Sets the default value of the persistent notification
2119 ////////////////////////////////////////////////////////////////////////////////////////////////////
2120 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPSetDefaultPersistentData) {
2121   try {
2122     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
2123     EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
2124
2125     CHKNULL(f_pSourceState);
2126
2127     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
2128     CHKNULL(l_pHApp);
2129
2130     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
2131     CHKNULL(l_pNotificationpersistentserviceHSM);
2132
2133     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
2134     CHKNULL(l_pnsnpp);
2135
2136     PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
2137     CHKNULL(l_cMsgSource);
2138
2139     // get instance of notification manager
2140     CNotificationManager *l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
2141
2142     if (NULL != l_pNotificationManager) {  // LCOV_EXCL_BR_LINE 6: l_pNotificationManager can't be NULL
2143       UI_32 l_uiMsgLength = FrameworkunifiedGetMsgLength(l_pHApp);
2144
2145       CHAR l_cNotificationName[MAX_SYS_INFO_SIZE] = {};
2146
2147       // retrieve notification name
2148       FrameworkunifiedGetSystemInfo(l_pHApp, l_cNotificationName);
2149
2150       if (0 != std::strlen(l_cNotificationName)) {  // LCOV_EXCL_BR_LINE 6: double check, l_cNotificationName can't be empty  // NOLINT[whitespace/line_length]
2151         FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__,
2152                "Set default value request for Notification:: %s from :: %s", l_cNotificationName,
2153                l_cMsgSource);
2154
2155         if (0 != l_uiMsgLength) {
2156           std::vector<CHAR> pMsgData = std::vector<CHAR>(l_uiMsgLength);
2157
2158           // get the received data
2159           if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(l_pHApp, &pMsgData[0], static_cast<UI_32>(pMsgData.size()), eSMRRelease))) {  // LCOV_EXCL_BR_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
2160             // set the default notification data
2161             if (eFrameworkunifiedStatusOK != l_pNotificationManager->NotificationpersistentserviceSetDefaultPersistentNotificationData(l_cNotificationName,
2162                                                                                                 (PVOID)&pMsgData[0],
2163                                                                                                 l_uiMsgLength)) {
2164               FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2165                      "Error in NotificationpersistentserviceSetDefaultPersistentNotificationData :: %s", l_cNotificationName);
2166             }
2167           } else {
2168             // LCOV_EXCL_START 4: NSFW error case
2169             AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
2170             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2171                    "Unable to set default persistent notification data for %s, "
2172                    "Error retrieving data from message, status: 0x%x",
2173                    l_cNotificationName, l_estatus);
2174             // LCOV_EXCL_STOP
2175           }
2176         } else {
2177           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2178                  "Not setting default persistent notification data for %s, Data length received is %d",
2179                  l_cNotificationName, l_uiMsgLength);
2180         }
2181       } else {
2182         // LCOV_EXCL_START 6: double check, l_cNotificationName can't be empty
2183         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
2184         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2185                "Unable to Set DefaultPersistentNotificationData from source %s, Notification name is blank",
2186                l_cMsgSource);
2187         // LCOV_EXCL_STOP
2188       }
2189     } else {
2190       // LCOV_EXCL_START 6: l_pNotificationManager can't be NULL
2191       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
2192       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2193              "Can't set default value for notification from source %s, l_pNotificationManager is NULL", l_cMsgSource);
2194       // LCOV_EXCL_STOP
2195     }
2196   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
2197     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
2198     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
2199     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
2200     return NULL;
2201     // LCOV_EXCL_STOP
2202   }
2203   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
2204   return f_pSourceState;
2205 }
2206
2207 ////////////////////////////////////////////////////////////////////////////////////////////////////
2208 /// NotificationpersistentserviceOnNPSetNotfnPersistentType
2209 /// Sets the persist type of notification
2210 ////////////////////////////////////////////////////////////////////////////////////////////////////
2211 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPSetNotfnPersistentType) {
2212   try {
2213     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
2214     CHKNULL(f_pSourceState);
2215
2216     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
2217     CHKNULL(l_pHApp);
2218
2219     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
2220     CHKNULL(l_pNotificationpersistentserviceHSM);
2221
2222     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
2223     CHKNULL(l_pnsnpp);
2224
2225     EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
2226
2227     CHAR l_cNotificationName[MAX_SYS_INFO_SIZE] = {};
2228
2229     // retrieve notification name
2230     FrameworkunifiedGetSystemInfo(l_pHApp,
2231                      l_cNotificationName);
2232
2233     // get instance of notification manager
2234     CNotificationManager *l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
2235
2236     if (NULL != l_pNotificationManager && 0 != std::strlen(l_cNotificationName)) {  // LCOV_EXCL_BR_LINE 6: l_pNotificationManager can't be NULL, l_cNotificationName can't be empty  // NOLINT[whitespace/line_length]
2237       FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Set persist type request for Notification:: %s", l_cNotificationName);
2238
2239       EFrameworkunifiedPersistCategory ePersistCategory = eFrameworkunifiedUserData;
2240
2241       // get the received data
2242       if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedGetMsgDataOfSize(l_pHApp, &ePersistCategory, sizeof(EFrameworkunifiedPersistCategory), eSMRRelease))) {  // LCOV_EXCL_BR_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
2243         // set the notification persist type
2244         if (eFrameworkunifiedStatusOK != (l_estatus = l_pNotificationManager->NotificationpersistentserviceSetPersistentCategory(l_cNotificationName,  // LCOV_EXCL_BR_LINE 6: always return ok  // NOLINT[whitespace/line_length]
2245                                                                                           ePersistCategory))) {
2246           // LCOV_EXCL_START 6: always return ok
2247           AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
2248           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error in Setting PersistentType for notification :: %s, Status: 0x%x",
2249                  l_cNotificationName, l_estatus);
2250           // LCOV_EXCL_STOP
2251         }
2252       } else {
2253         // LCOV_EXCL_START 4: NSFW error case
2254         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
2255         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2256                "Error in getting the PersistentType message data for notification :: %s, Status: 0x%x",
2257                l_cNotificationName, l_estatus);
2258         // LCOV_EXCL_STOP
2259       }
2260     } else {
2261       // LCOV_EXCL_START 6: l_pNotificationManager can't be NULL, l_cNotificationName can't be empty
2262       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
2263       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't set persist type for notification :: %s", l_cNotificationName);
2264       // LCOV_EXCL_STOP
2265     }
2266   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
2267     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
2268     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
2269     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
2270     return NULL;
2271     // LCOV_EXCL_STOP
2272   }
2273
2274   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
2275   return f_pSourceState;
2276 }
2277
2278 ////////////////////////////////////////////////////////////////////////////////////////////////////
2279 /// NotificationpersistentserviceOnNPSetFilePersistentType
2280 /// Sets the persist type of file
2281 ////////////////////////////////////////////////////////////////////////////////////////////////////
2282 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPSetFilePersistentType) {
2283   try {
2284     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
2285     CHKNULL(f_pSourceState);
2286
2287     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
2288     CHKNULL(l_pHApp);
2289
2290     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
2291     CHKNULL(l_pNotificationpersistentserviceHSM);
2292
2293     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
2294     CHKNULL(l_pnsnpp);
2295
2296     PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
2297     CHKNULL(l_cMsgSource);
2298
2299     // get instance of persistence manager
2300     CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
2301
2302     if (NULL != l_pPersistenceManager) {  // LCOV_EXCL_BR_LINE 6: l_pPersistenceManager can't be NULL
2303       NC_SetFilePersistType l_tMsg = {};
2304
2305       // get the received data
2306       if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(l_pHApp, static_cast<PVOID>(&l_tMsg), sizeof(l_tMsg), eSMRRelease)) {  // LCOV_EXCL_BR_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
2307         if (0 != std::strlen(l_tMsg.cTag)) {  // LCOV_EXCL_BR_LINE 6: double check, l_tMsg.cTag can't be empty
2308           FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__,
2309                  "Set persist type request for file tag:: %s from %s", l_tMsg.cTag, l_cMsgSource);
2310
2311           // set the file persist type
2312           if (eFrameworkunifiedStatusOK != l_pPersistenceManager->NotificationpersistentserviceSetPersistentCategory(l_cMsgSource,
2313                                                                               l_tMsg.cTag,
2314                                                                               l_tMsg.ePersistType,
2315                                                                               ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE)) {
2316             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2317                    "Error in Setting FilePersistentType for tag:: %s for request from:: %s", l_tMsg.cTag,
2318                    l_cMsgSource);
2319           }
2320         } else {
2321           // LCOV_EXCL_START 6: double check, l_tMsg.cTag can't be empty
2322           AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
2323           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2324                  "set file persistent type request for NULL file tag from source:: %s", l_cMsgSource);
2325           // LCOV_EXCL_STOP
2326         }
2327       }
2328     } else {
2329       // LCOV_EXCL_START 6: l_pPersistenceManager can't be NULL
2330       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
2331       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2332              "Can't process request for setting persist type for file from source: %s, l_pPersistenceManager is NULL",
2333              l_cMsgSource);
2334       // LCOV_EXCL_STOP
2335     }
2336   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
2337     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
2338     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
2339     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
2340     return NULL;
2341     // LCOV_EXCL_STOP
2342   }
2343   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
2344   return f_pSourceState;
2345 }
2346
2347 ////////////////////////////////////////////////////////////////////////////////////////////////////
2348 /// NotificationpersistentserviceOnNPSetFolderPersistentType
2349 /// Sets the persist type of folder
2350 ////////////////////////////////////////////////////////////////////////////////////////////////////
2351 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPSetFolderPersistentType) {
2352   try {
2353     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
2354     CHKNULL(f_pSourceState);
2355
2356     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
2357     CHKNULL(l_pHApp);
2358
2359     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
2360     CHKNULL(l_pNotificationpersistentserviceHSM);
2361
2362     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
2363     CHKNULL(l_pnsnpp);
2364
2365     PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
2366     CHKNULL(l_cMsgSource);
2367
2368     // get instance of persistence manager
2369     CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
2370
2371     if (NULL != l_pPersistenceManager) {  // LCOV_EXCL_BR_LINE 6: l_pPersistenceManager can't be NULL
2372       NC_SetFolderPersistType l_tMsg = {};
2373
2374       // get the received data
2375       if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(l_pHApp, static_cast<PVOID>(&l_tMsg), sizeof(l_tMsg), eSMRRelease)) {  // LCOV_EXCL_BR_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
2376         if (0 != std::strlen(l_tMsg.cTag)) {  // LCOV_EXCL_BR_LINE 6: double check, l_tMsg.cTag can't be empty
2377           FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Set persist type request for folder tag:: %s", l_tMsg.cTag);
2378
2379           // set the file persist type
2380           if (eFrameworkunifiedStatusOK != l_pPersistenceManager->NotificationpersistentserviceSetPersistentCategory(l_cMsgSource,
2381                                                                               l_tMsg.cTag,
2382                                                                               l_tMsg.ePersistType,
2383                                                                               ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER)) {
2384             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2385                    "Error in Setting FolderPersistentType for tag:: %s for request from:: %s", l_tMsg.cTag,
2386                    l_cMsgSource);
2387           }
2388         } else {
2389           // LCOV_EXCL_START 6: double check, l_tMsg.cTag can't be empty
2390           AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
2391           FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2392                  "set file persistent type request for NULL folder tag from source:: %s", l_cMsgSource);
2393           // LCOV_EXCL_STOP
2394         }
2395       }
2396     } else {
2397       // LCOV_EXCL_START 6: l_pPersistenceManager can't be NULL
2398       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
2399       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
2400              "Can't process request for setting persist type for folder from source: %s, l_pPersistenceManager is NULL",
2401              l_cMsgSource);
2402       // LCOV_EXCL_STOP
2403     }
2404   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
2405     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
2406     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
2407     FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
2408     return NULL;
2409     // LCOV_EXCL_STOP
2410   }
2411   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
2412   return f_pSourceState;
2413 }
2414
2415 ////////////////////////////////////////////////////////////////////////////////////////////////////
2416 /// NotificationpersistentserviceOnNPShutdown
2417 /// Internal transition when NPP receives shutdown message
2418 ////////////////////////////////////////////////////////////////////////////////////////////////////
2419 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPShutdown) {
2420   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
2421   try {
2422     CHKNULL(f_pSourceState);
2423
2424     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
2425     CHKNULL(l_pHApp);
2426
2427     NC_StopMsgData l_tStopMsgData = {};
2428
2429     PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
2430     CHKNULL(l_cMsgSource);
2431
2432     if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(l_pHApp, static_cast<PVOID>(&l_tStopMsgData), sizeof(l_tStopMsgData), eSMRRelease)) {  // LCOV_EXCL_BR_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
2433       // make a transition to sNotificationpersistentserviceShutdownDataSave state and pass the message data through event
2434       CShutDownMsgData *l_pMsgData = new(std::nothrow) CShutDownMsgData(EVENT(evNPShutdownDataSave),
2435                                                                         l_tStopMsgData.eShutdownType,
2436                                                                         l_tStopMsgData.uiStopMsgData);
2437       CHKNULL(l_pMsgData);
2438
2439       CEventDataPtr l_pData(l_pMsgData);
2440       f_pSourceState->FrameworkunifiedPostEvent(l_pData);
2441
2442       FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "Shutdown Message received from %s with data: %d", l_cMsgSource,
2443              l_tStopMsgData.uiStopMsgData);
2444     } else {
2445       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
2446       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Can't process shutdown request from:: %s, Invalid message data", l_cMsgSource);  // LCOV_EXCL_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
2447     }
2448   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
2449     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
2450     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
2451     f_pSourceState = NULL;
2452     // LCOV_EXCL_STOP
2453   }
2454   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
2455   return f_pSourceState;
2456 }
2457
2458 ////////////////////////////////////////////////////////////////////////////////////////////////////
2459 /// NotificationpersistentserviceOnNPNorDataSaveAck
2460 /// Internal transition when NPP receives shutdown ack message nor worker thread
2461 ////////////////////////////////////////////////////////////////////////////////////////////////////
2462 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPNorDataSaveAck) {
2463   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
2464   try {
2465     // data received with ack
2466     UI_32 l_uiPersistCategoryFlag = 0;
2467
2468     CHKNULL(f_pSourceState);
2469
2470     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
2471     CHKNULL(l_pHApp);
2472
2473     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
2474     CHKNULL(l_pNotificationpersistentserviceHSM);
2475
2476     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
2477     CHKNULL(l_pnsnpp);
2478
2479     PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
2480     CHKNULL(l_cMsgSource);
2481
2482     // get instance of persistence manager
2483     CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
2484     CHKNULL(l_pPersistenceManager);
2485
2486     l_pPersistenceManager->SetImmediateDataPersistedStatus(TRUE);
2487
2488     if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(l_pHApp, static_cast<PVOID>(&l_uiPersistCategoryFlag), sizeof(l_uiPersistCategoryFlag), eSMRRelease)) {  // LCOV_EXCL_BR_LINE 4: NSFW error case  // NOLINT[whitespace/line_length]
2489       FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __FUNCTION__, "ShutdownAck received from %s with data: %d", l_cMsgSource,
2490              l_uiPersistCategoryFlag);
2491     }
2492
2493     // depending on the flag delete the persisted data from persistent memory
2494     // which are not to be persisted during shutdown
2495     l_pnsnpp->DeletePersistedDataFolder(l_uiPersistCategoryFlag);
2496
2497     if (TRUE == l_pPersistenceManager->HaveAllReleaseRequestsPersisted()) {  // LCOV_EXCL_BR_LINE 6: always return ok
2498       FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "All release requests are processed.");
2499       f_pSourceState->FrameworkunifiedPostEvent(EVENT(evIdle));
2500     }
2501   } catch (std::exception &e) {  // LCOV_EXCL_START 5: exception error
2502     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
2503     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
2504     f_pSourceState = NULL;
2505     // LCOV_EXCL_STOP
2506   }
2507   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
2508   return f_pSourceState;
2509 }
2510
2511 CsNotificationpersistentservicePersistenceReady::CsNotificationpersistentservicePersistenceReady(std::string f_strName): CFrameworkunifiedLeafState(f_strName) {
2512   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
2513   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
2514 }
2515
2516 CsNotificationpersistentservicePersistenceReady::~CsNotificationpersistentservicePersistenceReady() {  // LCOV_EXCL_START 200: cannot test code
2517   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
2518   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
2519   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
2520 }
2521 // LCOV_EXCL_STOP
2522
2523 EFrameworkunifiedStatus CsNotificationpersistentservicePersistenceReady::FrameworkunifiedOnEntry(CEventDataPtr f_peventdata) {
2524   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
2525
2526   HANDLE l_pHApp = FrameworkunifiedGetAppHandle();
2527
2528   if (NULL != l_pHApp) {  // LCOV_EXCL_BR_LINE 4: NSFW error case.
2529     HANDLE l_hMq = FrameworkunifiedMcOpenSender(l_pHApp, g_csendreadyackto);
2530
2531     if (NULL != l_hMq) {  // LCOV_EXCL_BR_LINE 4: NSFW error case.
2532       EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
2533
2534       // send ack to requester
2535       if (eFrameworkunifiedStatusOK == (l_estatus = FrameworkunifiedSendMsg(l_hMq, NPS_NPP_READY_EVENT, 0, NULL))) {  // LCOV_EXCL_BR_LINE 4: NSFW error case.  // NOLINT[whitespace/line_length]
2536         FRAMEWORKUNIFIEDLOG(ZONE_PRD_INFO2, __PRETTY_FUNCTION__, "NPP ready status sent to %s.", g_csendreadyackto);
2537       } else {
2538         // LCOV_EXCL_START 4: NSFW error case.
2539         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
2540         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "Error sending NPS_NPP_READY_EVENT to %s, status: %d", g_csendreadyackto,
2541                l_estatus);
2542         // LCOV_EXCL_STOP
2543       }
2544       FrameworkunifiedMcClose(l_hMq);
2545       l_hMq = NULL;
2546     } else {
2547       // catastrophic failure!
2548       AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
2549       FRAMEWORKUNIFIEDLOG(ZONE_ERR, __PRETTY_FUNCTION__, "McOpenSender failed for %s ", g_csendreadyackto);  // LCOV_EXCL_LINE 4: NSFW error case.  // NOLINT[whitespace/line_length]
2550     }
2551   }
2552
2553   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
2554   return eFrameworkunifiedStatusOK;
2555 }
2556
2557 EFrameworkunifiedStatus CsNotificationpersistentservicePersistenceReady::FrameworkunifiedOnExit(CEventDataPtr f_peventdata) {  // LCOV_EXCL_START 200: cannot test code
2558   AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
2559   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
2560   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
2561   return eFrameworkunifiedStatusOK;
2562   // LCOV_EXCL_STOP
2563 }
2564
2565 #ifdef NPP_PROFILEINFO_ENABLE
2566
2567 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPProfileNotifications) {
2568   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
2569   try {
2570     CHKNULL(f_pSourceState);
2571
2572     // get the application handle
2573     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
2574     CHKNULL(l_pHApp);
2575
2576     // get the statemachine pointer of application
2577     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
2578     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
2579     CHKNULL(l_pnsnpp);
2580
2581     // get the message source name
2582     PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
2583     CHKNULL(l_cMsgSource);
2584
2585     // get the message queue handle for sending the response
2586     HANDLE hSrcMqHandle = FrameworkunifiedMcOpenSender(l_pHApp, l_cMsgSource);
2587     CHKNULL(hSrcMqHandle);
2588
2589     // get instance of notification manager
2590     CNotificationManager *l_pNotificationManager = l_pnsnpp->m_pNotificationManager;
2591     CHKNULL(l_pNotificationManager);
2592
2593     std::string l_cNotificationProfileInfo = "";
2594
2595     // get the data from notification manager
2596     if (eFrameworkunifiedStatusOK == l_pNotificationManager->GetNotificationProfilingData(l_cNotificationProfileInfo)) {
2597       UI_32 l_uiLength = l_cNotificationProfileInfo.size();
2598
2599       FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "FrameworkunifiedSendMsg NPS_PROFILE_NOTIFICATION_RESP Msg Length: %d", l_uiLength);
2600
2601       PCHAR l_pData =  new CHAR[l_uiLength];
2602       std::memset(l_pData, '0', l_uiLength);
2603
2604       std::strncpy(l_pData, l_cNotificationProfileInfo.c_str(), l_cNotificationProfileInfo.size());
2605
2606       if (eFrameworkunifiedStatusOK != FrameworkunifiedSendMsg(hSrcMqHandle,
2607                                      NPS_PROFILE_NOTIFICATION_RESP,
2608                                      l_uiLength,
2609                                      l_pData)) {
2610         FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__,
2611                "FrameworkunifiedSendMsg NPS_PROFILE_NOTIFICATION_RESP for Notification Profiling failed.");
2612       }
2613
2614       delete[] l_pData;
2615     } else {
2616       FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Failed to get Notification profiling data from NSNPP.");
2617     }
2618   } catch (std::exception &e) {
2619     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
2620     f_pSourceState = NULL;
2621   }
2622
2623   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
2624   return f_pSourceState;
2625 }
2626
2627 IMPLEMENT_INTERNALTRANSITION(NotificationpersistentserviceOnNPProfilePersistence) {
2628   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "+");
2629   try {
2630     CHKNULL(f_pSourceState);
2631
2632     // get the application handle
2633     HANDLE l_pHApp = f_pSourceState->FrameworkunifiedGetAppHandle();
2634     CHKNULL(l_pHApp);
2635
2636     // get the statemachine pointer of application
2637     CFrameworkunifiedHSM *l_pNotificationpersistentserviceHSM = FrameworkunifiedGetStateMachine(l_pHApp);
2638     CNSNPP *l_pnsnpp = static_cast<CNSNPP *>(l_pNotificationpersistentserviceHSM);
2639     CHKNULL(l_pnsnpp);
2640
2641     // get the message source name
2642     PCSTR l_cMsgSource = FrameworkunifiedGetMsgSrc(l_pHApp);
2643     CHKNULL(l_cMsgSource);
2644
2645     // get the message queue handle for sending the response
2646     HANDLE hSrcMqHandle = FrameworkunifiedMcOpenSender(l_pHApp, l_cMsgSource);
2647     CHKNULL(hSrcMqHandle);
2648
2649     // get instance of persistence manager
2650     CPersistenceManager *l_pPersistenceManager = l_pnsnpp->m_pPersistenceManager;
2651
2652     CHKNULL(l_pPersistenceManager);
2653
2654     std::string l_cPersistenceProfileInfo = "";
2655
2656     if (eFrameworkunifiedStatusOK == l_pPersistenceManager->GetPersistenceProfilingData(l_cPersistenceProfileInfo)) {
2657       UI_32 l_uiLength = l_cPersistenceProfileInfo.size();
2658
2659       FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "FrameworkunifiedSendMsg NPS_PROFILE_PERSISTENCE_RESP Msg Length: %d", l_uiLength);
2660
2661       PCHAR l_pData =  new CHAR[l_uiLength];
2662       std::memset(l_pData, '0', l_uiLength);
2663
2664       std::strncpy(l_pData, l_cPersistenceProfileInfo.c_str(), l_cPersistenceProfileInfo.size());
2665
2666       if (eFrameworkunifiedStatusOK != FrameworkunifiedSendMsg(hSrcMqHandle,
2667                                      NPS_PROFILE_PERSISTENCE_RESP,
2668                                      l_uiLength,
2669                                      l_pData)) {
2670         FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "FrameworkunifiedSendMsg NPS_PROFILE_PERSISTENCE_RESP for Persistence Profiling failed.");
2671       }
2672
2673       delete[] l_pData;
2674     }
2675   } catch (std::exception &e) {
2676     FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Exception %s", e.what());
2677     f_pSourceState = NULL;
2678   }
2679
2680   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __PRETTY_FUNCTION__, "-");
2681   return f_pSourceState;
2682 }
2683
2684 #endif