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