1 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache-2.0 license that can be
3 // found in the LICENSE file.
5 #include "hybrid/hybrid_installer.h"
7 #include <common/step/backup/step_backup_icons.h>
8 #include <common/step/backup/step_backup_manifest.h>
9 #include <common/step/backup/step_copy_backup.h>
10 #include <common/step/configuration/step_block_cross_update.h>
11 #include <common/step/configuration/step_configure.h>
12 #include <common/step/configuration/step_fail.h>
13 #include <common/step/configuration/step_parse_manifest.h>
14 #include <common/step/filesystem/step_clear_data.h>
15 #include <common/step/filesystem/step_copy.h>
16 #include <common/step/filesystem/step_copy_storage_directories.h>
17 #include <common/step/filesystem/step_copy_tep.h>
18 #include <common/step/filesystem/step_create_icons.h>
19 #include <common/step/filesystem/step_create_per_user_storage_directories.h>
20 #include <common/step/filesystem/step_create_storage_directories.h>
21 #include <common/step/filesystem/step_delta_patch.h>
22 #include <common/step/filesystem/step_recover_files.h>
23 #include <common/step/filesystem/step_recover_icons.h>
24 #include <common/step/filesystem/step_recover_manifest.h>
25 #include <common/step/filesystem/step_recover_storage_directories.h>
26 #include <common/step/filesystem/step_remove_files.h>
27 #include <common/step/filesystem/step_remove_icons.h>
28 #include <common/step/filesystem/step_remove_per_user_storage_directories.h>
29 #include <common/step/filesystem/step_remove_temporary_directory.h>
30 #include <common/step/filesystem/step_remove_zip_image.h>
31 #include <common/step/filesystem/step_unzip.h>
32 #include <common/step/mount/step_mount_install.h>
33 #include <common/step/mount/step_mount_unpacked.h>
34 #include <common/step/mount/step_mount_update.h>
35 #include <common/step/pkgmgr/step_check_removable.h>
36 #include <common/step/pkgmgr/step_kill_apps.h>
37 #include <common/step/pkgmgr/step_recover_application.h>
38 #include <common/step/pkgmgr/step_register_app.h>
39 #include <common/step/pkgmgr/step_remove_manifest.h>
40 #include <common/step/pkgmgr/step_run_parser_plugins.h>
41 #include <common/step/pkgmgr/step_unregister_app.h>
42 #include <common/step/pkgmgr/step_update_app.h>
43 #include <common/step/pkgmgr/step_update_tep.h>
44 #include <common/step/recovery/step_open_recovery_file.h>
45 #include <common/step/security/step_check_signature.h>
46 #include <common/step/security/step_privilege_compatibility.h>
47 #include <common/step/security/step_recover_security.h>
48 #include <common/step/security/step_register_security.h>
49 #include <common/step/security/step_revoke_security.h>
50 #include <common/step/security/step_rollback_deinstallation_security.h>
51 #include <common/step/security/step_rollback_installation_security.h>
52 #include <common/step/security/step_update_security.h>
54 #include <tpk/step/filesystem/step_create_symbolic_link.h>
55 #include <tpk/step/filesystem/step_tpk_patch_icons.h>
56 #include <tpk/step/filesystem/step_tpk_prepare_package_directory.h>
57 #include <tpk/step/filesystem/step_tpk_update_package_directory.h>
59 #include "hybrid/hybrid_backend_data.h"
60 #include "hybrid/step/configuration/step_merge_tpk_config.h"
61 #include "hybrid/step/configuration/step_stash_tpk_config.h"
62 #include "hybrid/step/encryption/step_encrypt_resources.h"
63 #include "wgt/step/configuration/step_parse.h"
64 #include "wgt/step/configuration/step_parse_recovery.h"
65 #include "wgt/step/encryption/step_remove_encryption_data.h"
66 #include "wgt/step/filesystem/step_create_symbolic_link.h"
67 #include "wgt/step/filesystem/step_wgt_patch_icons.h"
68 #include "wgt/step/filesystem/step_wgt_patch_storage_directories.h"
69 #include "wgt/step/pkgmgr/step_generate_xml.h"
70 #include "wgt/step/security/step_check_settings_level.h"
71 #include "wgt/step/security/step_check_wgt_background_category.h"
72 #include "wgt/step/security/step_check_wgt_notification_category.h"
73 #include "wgt/step/security/step_check_wgt_ime_privilege.h"
75 namespace ci = common_installer;
79 HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
80 : AppInstaller("wgt", pkgmgr) {
81 context_->backend_data.set(new HybridBackendData());
83 switch (pkgmgr_->GetRequestType()) {
84 case ci::RequestType::Install:
85 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
86 AddStep<ci::filesystem::StepUnzip>();
87 AddStep<ci::configuration::StepParseManifest>(
88 ci::configuration::StepParseManifest::ManifestLocation::PACKAGE,
89 ci::configuration::StepParseManifest::StoreLocation::NORMAL);
90 AddStep<hybrid::configuration::StepStashTpkConfig>();
91 AddStep<wgt::configuration::StepParse>(
92 wgt::configuration::StepParse::ConfigLocation::RESOURCE_WGT, true);
93 AddStep<hybrid::configuration::StepMergeTpkConfig>();
94 AddStep<ci::security::StepCheckSignature>();
95 AddStep<ci::security::StepPrivilegeCompatibility>();
96 AddStep<wgt::security::StepCheckSettingsLevel>();
97 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
98 AddStep<wgt::security::StepCheckWgtNotificationCategory>();
99 AddStep<wgt::security::StepCheckWgtImePrivilege>();
100 AddStep<hybrid::encryption::StepEncryptResources>();
101 AddStep<ci::security::StepRollbackInstallationSecurity>();
102 AddStep<ci::filesystem::StepCopy>();
103 AddStep<ci::filesystem::StepCopyTep>();
104 AddStep<tpk::filesystem::StepTpkPatchIcons>();
105 AddStep<wgt::filesystem::StepWgtPatchIcons>();
106 AddStep<ci::filesystem::StepCreateIcons>();
107 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
108 AddStep<ci::filesystem::StepCreateStorageDirectories>();
109 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
110 AddStep<tpk::filesystem::StepCreateSymbolicLink>();
111 AddStep<wgt::pkgmgr::StepGenerateXml>();
112 AddStep<ci::pkgmgr::StepRunParserPlugin>(
113 ci::Plugin::ActionType::Install);
114 AddStep<ci::pkgmgr::StepRegisterApplication>();
115 AddStep<ci::security::StepRegisterSecurity>();
116 AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>();
118 case ci::RequestType::Update:
119 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
120 AddStep<ci::filesystem::StepUnzip>();
121 AddStep<ci::configuration::StepParseManifest>(
122 ci::configuration::StepParseManifest::ManifestLocation::PACKAGE,
123 ci::configuration::StepParseManifest::StoreLocation::NORMAL);
124 AddStep<hybrid::configuration::StepStashTpkConfig>();
125 AddStep<wgt::configuration::StepParse>(
126 wgt::configuration::StepParse::ConfigLocation::RESOURCE_WGT, true);
127 AddStep<hybrid::configuration::StepMergeTpkConfig>();
128 AddStep<ci::security::StepCheckSignature>();
129 AddStep<ci::security::StepPrivilegeCompatibility>();
130 AddStep<wgt::security::StepCheckSettingsLevel>();
131 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
132 AddStep<wgt::security::StepCheckWgtNotificationCategory>();
133 AddStep<wgt::security::StepCheckWgtImePrivilege>();
134 AddStep<hybrid::encryption::StepEncryptResources>();
135 AddStep<ci::security::StepRollbackInstallationSecurity>();
136 AddStep<ci::configuration::StepParseManifest>(
137 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
138 ci::configuration::StepParseManifest::StoreLocation::BACKUP);
139 AddStep<ci::configuration::StepBlockCrossUpdate>();
140 AddStep<ci::pkgmgr::StepKillApps>();
141 AddStep<ci::backup::StepBackupManifest>();
142 AddStep<ci::backup::StepBackupIcons>();
143 AddStep<ci::backup::StepCopyBackup>();
144 AddStep<ci::filesystem::StepCopyTep>();
145 AddStep<ci::pkgmgr::StepUpdateTep>();
146 AddStep<tpk::filesystem::StepTpkPatchIcons>();
147 AddStep<wgt::filesystem::StepWgtPatchIcons>();
148 AddStep<ci::filesystem::StepCreateIcons>();
149 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
150 AddStep<ci::filesystem::StepCopyStorageDirectories>();
151 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
152 AddStep<tpk::filesystem::StepCreateSymbolicLink>();
153 AddStep<ci::security::StepUpdateSecurity>();
154 AddStep<wgt::pkgmgr::StepGenerateXml>();
155 AddStep<ci::pkgmgr::StepUpdateApplication>();
156 AddStep<ci::pkgmgr::StepRunParserPlugin>(
157 ci::Plugin::ActionType::Upgrade);
159 case ci::RequestType::Uninstall:
160 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
161 AddStep<ci::pkgmgr::StepCheckRemovable>();
162 AddStep<ci::configuration::StepParseManifest>(
163 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
164 ci::configuration::StepParseManifest::StoreLocation::NORMAL);
165 AddStep<ci::pkgmgr::StepRunParserPlugin>(
166 ci::Plugin::ActionType::Uninstall);
167 AddStep<ci::pkgmgr::StepKillApps>();
168 AddStep<ci::filesystem::StepRemovePerUserStorageDirectories>();
169 AddStep<ci::pkgmgr::StepUnregisterApplication>();
170 AddStep<ci::security::StepRollbackDeinstallationSecurity>();
171 AddStep<ci::filesystem::StepRemoveFiles>();
172 AddStep<ci::filesystem::StepRemoveZipImage>();
173 AddStep<ci::filesystem::StepRemoveIcons>();
174 AddStep<wgt::encryption::StepRemoveEncryptionData>();
175 AddStep<ci::security::StepRevokeSecurity>();
176 AddStep<ci::pkgmgr::StepRemoveManifest>();
178 case ci::RequestType::Reinstall:
179 // RDS is not supported for hybrid apps
180 AddStep<ci::configuration::StepFail>();
182 case ci::RequestType::Delta:
183 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
184 AddStep<ci::filesystem::StepUnzip>();
185 AddStep<ci::configuration::StepParseManifest>(
186 ci::configuration::StepParseManifest::ManifestLocation::PACKAGE,
187 ci::configuration::StepParseManifest::StoreLocation::NORMAL);
188 AddStep<hybrid::configuration::StepStashTpkConfig>();
189 AddStep<ci::configuration::StepParseManifest>(
190 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
191 ci::configuration::StepParseManifest::StoreLocation::BACKUP);
192 AddStep<ci::filesystem::StepDeltaPatch>();
193 AddStep<wgt::configuration::StepParse>(
194 wgt::configuration::StepParse::ConfigLocation::RESOURCE_WGT, true);
195 AddStep<hybrid::configuration::StepMergeTpkConfig>();
196 AddStep<ci::security::StepCheckSignature>();
197 AddStep<ci::security::StepPrivilegeCompatibility>();
198 AddStep<wgt::security::StepCheckSettingsLevel>();
199 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
200 AddStep<wgt::security::StepCheckWgtNotificationCategory>();
201 AddStep<wgt::security::StepCheckWgtImePrivilege>();
202 AddStep<hybrid::encryption::StepEncryptResources>();
203 AddStep<ci::security::StepRollbackInstallationSecurity>();
204 AddStep<ci::configuration::StepBlockCrossUpdate>();
205 AddStep<ci::pkgmgr::StepKillApps>();
206 AddStep<ci::backup::StepBackupManifest>();
207 AddStep<ci::backup::StepBackupIcons>();
208 AddStep<ci::backup::StepCopyBackup>();
209 AddStep<tpk::filesystem::StepTpkPatchIcons>();
210 AddStep<wgt::filesystem::StepWgtPatchIcons>();
211 AddStep<ci::filesystem::StepCreateIcons>();
212 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
213 AddStep<ci::filesystem::StepCopyStorageDirectories>();
214 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
215 AddStep<tpk::filesystem::StepCreateSymbolicLink>();
216 AddStep<ci::security::StepUpdateSecurity>();
217 AddStep<wgt::pkgmgr::StepGenerateXml>();
218 AddStep<ci::pkgmgr::StepUpdateApplication>();
219 AddStep<ci::pkgmgr::StepRunParserPlugin>(
220 ci::Plugin::ActionType::Upgrade);
222 case ci::RequestType::Recovery:
223 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
224 AddStep<ci::recovery::StepOpenRecoveryFile>();
225 AddStep<ci::configuration::StepParseManifest>(
226 ci::configuration::StepParseManifest::ManifestLocation::RECOVERY,
227 ci::configuration::StepParseManifest::StoreLocation::NORMAL);
228 AddStep<hybrid::configuration::StepStashTpkConfig>();
229 AddStep<wgt::configuration::StepParseRecovery>();
230 AddStep<hybrid::configuration::StepMergeTpkConfig>();
231 AddStep<ci::pkgmgr::StepRecoverApplication>();
232 AddStep<ci::filesystem::StepRemoveTemporaryDirectory>();
233 AddStep<ci::filesystem::StepRecoverIcons>();
234 AddStep<ci::filesystem::StepRecoverManifest>();
235 AddStep<ci::filesystem::StepRecoverStorageDirectories>();
236 AddStep<ci::filesystem::StepRecoverFiles>();
237 AddStep<ci::security::StepRecoverSecurity>();
239 case ci::RequestType::Clear:
240 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
241 AddStep<ci::filesystem::StepClearData>();
243 case ci::RequestType::MountInstall:
244 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
245 AddStep<ci::mount::StepMountUnpacked>();
246 AddStep<ci::configuration::StepParseManifest>(
247 ci::configuration::StepParseManifest::ManifestLocation::PACKAGE,
248 ci::configuration::StepParseManifest::StoreLocation::NORMAL);
249 AddStep<hybrid::configuration::StepStashTpkConfig>();
250 AddStep<wgt::configuration::StepParse>(
251 wgt::configuration::StepParse::ConfigLocation::RESOURCE_WGT, true);
252 AddStep<hybrid::configuration::StepMergeTpkConfig>();
253 AddStep<ci::security::StepCheckSignature>();
254 AddStep<ci::security::StepPrivilegeCompatibility>();
255 AddStep<wgt::security::StepCheckSettingsLevel>();
256 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
257 AddStep<wgt::security::StepCheckWgtNotificationCategory>();
258 AddStep<wgt::security::StepCheckWgtImePrivilege>();
259 AddStep<hybrid::encryption::StepEncryptResources>();
260 AddStep<ci::security::StepRollbackInstallationSecurity>();
261 AddStep<ci::mount::StepMountInstall>();
262 AddStep<tpk::filesystem::StepTpkPreparePackageDirectory>();
263 AddStep<ci::filesystem::StepCopyTep>();
264 AddStep<tpk::filesystem::StepTpkPatchIcons>();
265 AddStep<wgt::filesystem::StepWgtPatchIcons>();
266 AddStep<ci::filesystem::StepCreateIcons>();
267 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
268 AddStep<ci::filesystem::StepCreateStorageDirectories>();
269 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
270 AddStep<tpk::filesystem::StepCreateSymbolicLink>();
271 AddStep<wgt::pkgmgr::StepGenerateXml>();
272 AddStep<ci::pkgmgr::StepRunParserPlugin>(
273 ci::Plugin::ActionType::Install);
274 AddStep<ci::pkgmgr::StepRegisterApplication>();
275 AddStep<ci::security::StepRegisterSecurity>();
276 AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>();
278 case ci::RequestType::MountUpdate:
279 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
280 AddStep<ci::mount::StepMountUnpacked>();
281 AddStep<ci::configuration::StepParseManifest>(
282 ci::configuration::StepParseManifest::ManifestLocation::PACKAGE,
283 ci::configuration::StepParseManifest::StoreLocation::NORMAL);
284 AddStep<hybrid::configuration::StepStashTpkConfig>();
285 AddStep<wgt::configuration::StepParse>(
286 wgt::configuration::StepParse::ConfigLocation::RESOURCE_WGT, true);
287 AddStep<hybrid::configuration::StepMergeTpkConfig>();
288 AddStep<ci::security::StepCheckSignature>();
289 AddStep<ci::security::StepPrivilegeCompatibility>();
290 AddStep<wgt::security::StepCheckSettingsLevel>();
291 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
292 AddStep<wgt::security::StepCheckWgtNotificationCategory>();
293 AddStep<wgt::security::StepCheckWgtImePrivilege>();
294 AddStep<hybrid::encryption::StepEncryptResources>();
295 AddStep<ci::security::StepRollbackInstallationSecurity>();
296 AddStep<ci::configuration::StepParseManifest>(
297 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
298 ci::configuration::StepParseManifest::StoreLocation::BACKUP);
299 AddStep<ci::configuration::StepBlockCrossUpdate>();
300 AddStep<ci::pkgmgr::StepKillApps>();
301 AddStep<ci::backup::StepBackupManifest>();
302 AddStep<ci::backup::StepBackupIcons>();
303 AddStep<ci::mount::StepMountUpdate>();
304 AddStep<tpk::filesystem::StepTpkUpdatePackageDirectory>();
305 AddStep<ci::filesystem::StepCopyTep>();
306 AddStep<ci::pkgmgr::StepUpdateTep>();
307 AddStep<tpk::filesystem::StepTpkPatchIcons>();
308 AddStep<wgt::filesystem::StepWgtPatchIcons>();
309 AddStep<ci::filesystem::StepCreateIcons>();
310 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
311 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
312 AddStep<tpk::filesystem::StepCreateSymbolicLink>();
313 AddStep<ci::security::StepUpdateSecurity>();
314 AddStep<wgt::pkgmgr::StepGenerateXml>();
315 AddStep<ci::pkgmgr::StepUpdateApplication>();
316 AddStep<ci::pkgmgr::StepRunParserPlugin>(
317 ci::Plugin::ActionType::Upgrade);
319 case ci::RequestType::ManifestDirectInstall:
320 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
321 AddStep<ci::configuration::StepParseManifest>(
322 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
323 ci::configuration::StepParseManifest::StoreLocation::NORMAL);
324 AddStep<hybrid::configuration::StepStashTpkConfig>();
325 AddStep<wgt::configuration::StepParse>(
326 wgt::configuration::StepParse::ConfigLocation::INSTALLED, true);
327 AddStep<hybrid::configuration::StepMergeTpkConfig>();
328 AddStep<ci::security::StepCheckSignature>();
329 AddStep<ci::security::StepPrivilegeCompatibility>();
330 AddStep<wgt::security::StepCheckSettingsLevel>();
331 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
332 AddStep<ci::security::StepRollbackInstallationSecurity>();
333 AddStep<wgt::pkgmgr::StepGenerateXml>();
334 AddStep<ci::pkgmgr::StepRunParserPlugin>(
335 ci::Plugin::ActionType::Install);
336 AddStep<ci::pkgmgr::StepRegisterApplication>();
337 AddStep<ci::security::StepRegisterSecurity>();
338 AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>();
340 case ci::RequestType::ManifestDirectUpdate:
341 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
342 AddStep<ci::filesystem::StepUnzip>();
343 AddStep<ci::configuration::StepParseManifest>(
344 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
345 ci::configuration::StepParseManifest::StoreLocation::NORMAL);
346 AddStep<hybrid::configuration::StepStashTpkConfig>();
347 AddStep<wgt::configuration::StepParse>(
348 wgt::configuration::StepParse::ConfigLocation::INSTALLED, true);
349 AddStep<hybrid::configuration::StepMergeTpkConfig>();
350 AddStep<ci::security::StepCheckSignature>();
351 AddStep<ci::security::StepPrivilegeCompatibility>();
352 AddStep<wgt::security::StepCheckSettingsLevel>();
353 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
354 AddStep<ci::security::StepRollbackInstallationSecurity>();
355 AddStep<ci::configuration::StepParseManifest>(
356 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
357 ci::configuration::StepParseManifest::StoreLocation::BACKUP);
358 AddStep<ci::pkgmgr::StepKillApps>();
359 AddStep<ci::security::StepUpdateSecurity>();
360 AddStep<wgt::pkgmgr::StepGenerateXml>();
361 AddStep<ci::pkgmgr::StepUpdateApplication>();
362 AddStep<ci::pkgmgr::StepRunParserPlugin>(
363 ci::Plugin::ActionType::Upgrade);
366 AddStep<ci::configuration::StepFail>();
371 } // namespace hybrid