2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 ////////////////////////////////////////////////////////////////////////////////////////////////////
18 /// \defgroup <<Group Tag>> <<Group Name>>
19 /// \ingroup tag_NS_NPPService
21 ////////////////////////////////////////////////////////////////////////////////////////////////////
23 ////////////////////////////////////////////////////////////////////////////////////////////////////
24 /// \ingroup tag_NS_NPPService
29 ////////////////////////////////////////////////////////////////////////////////////////////////////
31 #ifndef NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_H_
32 #define NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_H_
34 #include <native_service/frameworkunified_sm_framework_types.h>
35 #include <native_service/frameworkunified_sm_hsm.h>
36 #include <native_service/frameworkunified_types.h>
40 class CPersistenceManager;
41 class CNotificationManager;
42 class CnotificationpersistentservicePersonalizationManager;
45 * This class act as a controller class which holds the instance of notification, personalization
46 * and persistence manager respectively.
48 class CNSNPP: public CFrameworkunifiedHSM {
50 ////////////////////////////////////////////////////////////////////////////////////////////////
52 /// Constructor of CNSNPP class
55 /// PVOID - application handle
59 ////////////////////////////////////////////////////////////////////////////////////////////////
60 explicit CNSNPP(PVOID f_happ);
62 ////////////////////////////////////////////////////////////////////////////////////////////////
64 /// Destructor of CNSNPP class
70 ////////////////////////////////////////////////////////////////////////////////////////////////
73 ///////////////////////////////////////////////////////////////////////////////////////////
75 /// This function is used to allocate dynamic memory for member variables of this class after
76 /// creation of object.
79 /// HANDLE - Application handle
81 /// \return EFrameworkunifiedStatus
82 /// EFrameworkunifiedStatus - Returns status of operation
84 ///////////////////////////////////////////////////////////////////////////////////////////
85 EFrameworkunifiedStatus Init(HANDLE f_happ);
87 ///////////////////////////////////////////////////////////////////////////////////////////
89 /// This function is used to deinitialize the NPP object.
92 /// HANDLE - Application handle
95 /// VOID - Returns status of operation
97 ///////////////////////////////////////////////////////////////////////////////////////////
98 VOID DeInit(HANDLE f_happ);
100 ////////////////////////////////////////////////////////////////////////////////////////////////
101 /// FrameworkunifiedCreate
102 /// This function is pure virtual function of parent class.
103 /// In this function, states and events of StateMachine are created and connected.
105 /// \param [in] f_peventdata
106 /// PVOID - Event data
108 /// \return EFrameworkunifiedStatus
109 /// EFrameworkunifiedStatus - Returns status of operation
111 ////////////////////////////////////////////////////////////////////////////////////////////////
112 virtual EFrameworkunifiedStatus FrameworkunifiedCreate(PVOID f_peventdata = NULL);
114 ////////////////////////////////////////////////////////////////////////////////////////////////
115 /// NotificationpersistentservicePersistAll
116 /// Persist all persistent state, user persistent state notification data;
117 /// and all global and user related files to permenant storage
119 /// \param [in] f_eshutdowntype
120 /// EFrameworkunifiedShutdownType - shutdown type i.e. normal shutdown, quick, data reset
122 /// \param [in] f_uinotificationpersistentservicepersistcategoryflag
123 /// UI_32 - Hex value from enum EFrameworkunifiedPersistCategory, representing data to persist
124 /// 0 - persist orignal data and
125 /// 1 - persist default data
127 /// \return EFrameworkunifiedStatus
128 /// EFrameworkunifiedStatus - Returns status of operation
130 ////////////////////////////////////////////////////////////////////////////////////////////////
131 EFrameworkunifiedStatus NotificationpersistentservicePersistAll(EFrameworkunifiedShutdownType f_eshutdowntype, UI_32 f_uinotificationpersistentservicepersistcategoryflag);
133 ////////////////////////////////////////////////////////////////////////////////////////////////
134 /// NotificationpersistentserviceSaveNotificationPersistentData
135 /// In this function, all the data related to persistent notification is retrieved from
136 /// notification manager and stored in persistent file by persistent manager.
138 /// \param [in] f_epersistenttype
139 /// EFrameworkunifiedPersistentVarType - Type of persistent notification
140 /// \param [in] f_uinotificationpersistentservicepersistcategoryflag
141 /// UI_32 - Hex value from enum EFrameworkunifiedPersistCategory, representing data to persist
142 /// 0 - persist orignal data and
143 /// 1 - persist default data
145 /// \return EFrameworkunifiedStatus
146 /// EFrameworkunifiedStatus - Returns status of operation
148 ////////////////////////////////////////////////////////////////////////////////////////////////
149 EFrameworkunifiedStatus NotificationpersistentserviceSaveNotificationPersistentData(EFrameworkunifiedNotificationType f_epersistenttype,
150 UI_32 f_uinotificationpersistentservicepersistcategoryflag = 0x0);
152 ////////////////////////////////////////////////////////////////////////////////////////////////
153 /// NotificationpersistentserviceLoadPersistentNotificationData
154 /// In this transition, persistent file is loaded by persistent manager and
155 /// persistent notifications and its data is loaded to notification manager.
157 /// \param [in] f_epersistenttype
158 /// EFrameworkunifiedPersistentVarType - Type of persistent notification
160 /// \return EFrameworkunifiedStatus
161 /// EFrameworkunifiedStatus - Returns status of operation
163 ////////////////////////////////////////////////////////////////////////////////////////////////
164 EFrameworkunifiedStatus NotificationpersistentserviceLoadPersistentNotificationData(EFrameworkunifiedNotificationType f_epersistenttype);
166 ///////////////////////////////////////////////////////////////////////////////////////////
167 /// DeletePersistedDataFolder
168 /// This function does not deletes the data instead just rename the folder which needs to
169 /// be deleted. And this data will gets deleted during next startup.
171 /// \param f_uipersistcategoryflag
172 /// UI_32 - Rename the persisted data folder depending on enum EFrameworkunifiedPersistCategory value
174 /// \return EFrameworkunifiedStatus
175 /// EFrameworkunifiedStatus - Returns status of operation
177 ///////////////////////////////////////////////////////////////////////////////////////////
178 EFrameworkunifiedStatus DeletePersistedDataFolder(UI_32 f_uipersistcategoryflag);
180 ///////////////////////////////////////////////////////////////////////////////////////////
182 /// Syncfs is carried out.
186 /// \return EFrameworkunifiedStatus
187 /// EFrameworkunifiedStatus - Returns status of operation
189 ///////////////////////////////////////////////////////////////////////////////////////////
190 EFrameworkunifiedStatus Syncfs();
192 ////////////////////////////////////////////////////////////////////////////////////////////////
193 /// Singleton instance of NotificationManager
194 ////////////////////////////////////////////////////////////////////////////////////////////////
195 CNotificationManager *m_pNotificationManager; ///< Instance of Notification Manager
197 ////////////////////////////////////////////////////////////////////////////////////////////////
198 /// Singleton instance of PersonalizationManager
199 ////////////////////////////////////////////////////////////////////////////////////////////////
200 CnotificationpersistentservicePersonalizationManager *m_pPersonalizationManager; ///< Instance of Personalization Manager
202 ////////////////////////////////////////////////////////////////////////////////////////////////
203 /// Singleton instance of PersistenceManager
204 ////////////////////////////////////////////////////////////////////////////////////////////////
205 CPersistenceManager *m_pPersistenceManager;
206 // scheduling priority of read thread
207 static SI_32 m_siReadThreadPrio; // NOLINT (readability/naming)
208 // scheduling priority of write thread
209 static SI_32 m_siWriteThreadPrio; // NOLINT (readability/naming)
210 // scheduling priority of immediate persistence thread
211 static SI_32 m_siImmediatePersistenceThreadPrio; // NOLINT (readability/naming)
212 // number of times CRC check is required. (CRC check will be done more than once only on failure)
214 m_siCRCCheckCount; // NOLINT (readability/naming)
217 ///< name of reader thread
218 const std::string m_cReadThreadName; // NOLINT (readability/naming)
219 ///< name of writer thread
220 const std::string m_cWriteThreadName; // NOLINT (readability/naming)
221 ///< name of immediate persistence thread
222 const std::string m_cImmediatePersistenceThreadName; // NOLINT (readability/naming)
224 ///////////////////////////////////////////////////////////////////////////////////////////
225 /// CreateAndStartChildThreads
226 /// This function creates and start all child threads.
229 /// HANDLE - Application handle
231 /// \return EFrameworkunifiedStatus
232 /// EFrameworkunifiedStatus - Returns status of operation
234 ///////////////////////////////////////////////////////////////////////////////////////////
235 EFrameworkunifiedStatus CreateAndStartChildThreads(HANDLE f_happ);
237 ///////////////////////////////////////////////////////////////////////////////////////////
238 /// SwitchToFileStructureVersion1
239 /// Copy all the data from old persistent path to new persistent path
241 /// \param [IN] f_uinppversion
242 /// UI_32 - New version of NPPService
244 /// \return EFrameworkunifiedStatus
245 /// EFrameworkunifiedStatus - Returns status of operation
247 ///////////////////////////////////////////////////////////////////////////////////////////
248 EFrameworkunifiedStatus SwitchToFileStructureVersion1(const UI_32 f_uinppversion);
250 ///////////////////////////////////////////////////////////////////////////////////////////
251 /// SwitchToFileStructureVersion2
252 /// Move immediate notification data files from IMMEDIATE_PERSISTENCE_STORAGE_V1 to
253 /// IMMEDIATE_PERSISTENCE_STORAGE_V2/AllUserAppData/UserData
255 /// \param [IN] f_uinppversion
256 /// UI_32 - New version of NPPService
258 /// \return EFrameworkunifiedStatus
259 /// EFrameworkunifiedStatus - Returns status of operation
261 ///////////////////////////////////////////////////////////////////////////////////////////
262 EFrameworkunifiedStatus SwitchToFileStructureVersion2(const UI_32 f_uinppversion);
264 ///////////////////////////////////////////////////////////////////////////////////////////
266 /// Get the version of NSNPP from version.txt
271 /// UI_8 - version number
273 ///////////////////////////////////////////////////////////////////////////////////////////
274 UI_32 GetNSNPPVersion();
276 ///////////////////////////////////////////////////////////////////////////////////////////
278 /// Set the version of NSNPP in version.txt
280 /// \param [IN] f_uiversion
281 /// UI_32 - version number
283 /// \return EFrameworkunifiedStatus
284 /// EFrameworkunifiedStatus - Returns status of operation
286 ///////////////////////////////////////////////////////////////////////////////////////////
287 EFrameworkunifiedStatus SetNSNPPVersion(UI_8 f_uiversion);
289 HANDLE m_hNSReadThread; ///< Reader thread handle
291 HANDLE m_hNSWriteThread; ///< Writer thread handle
293 HANDLE m_hNSImmediatePersistenceThread; ///< immediate persistence thread handle
296 #endif // NOTIFICATION_PERSISTENT_SERVICE_SERVER_INCLUDE_NS_NPP_H_