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_parse.h"
62 #include "hybrid/step/configuration/step_stash_tpk_config.h"
63 #include "hybrid/step/encryption/step_encrypt_resources.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<hybrid::configuration::StepParse>(true);
92 AddStep<hybrid::configuration::StepMergeTpkConfig>();
93 AddStep<ci::security::StepCheckSignature>();
94 AddStep<ci::security::StepPrivilegeCompatibility>();
95 AddStep<wgt::security::StepCheckSettingsLevel>();
96 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
97 AddStep<wgt::security::StepCheckWgtNotificationCategory>();
98 AddStep<wgt::security::StepCheckWgtImePrivilege>();
99 AddStep<hybrid::encryption::StepEncryptResources>();
100 AddStep<ci::security::StepRollbackInstallationSecurity>();
101 AddStep<ci::filesystem::StepCopy>();
102 AddStep<ci::filesystem::StepCopyTep>();
103 AddStep<tpk::filesystem::StepTpkPatchIcons>();
104 AddStep<wgt::filesystem::StepWgtPatchIcons>();
105 AddStep<ci::filesystem::StepCreateIcons>();
106 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
107 AddStep<ci::filesystem::StepCreateStorageDirectories>();
108 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
109 AddStep<tpk::filesystem::StepCreateSymbolicLink>();
110 AddStep<wgt::pkgmgr::StepGenerateXml>();
111 AddStep<ci::pkgmgr::StepRunParserPlugin>(
112 ci::Plugin::ActionType::Install);
113 AddStep<ci::pkgmgr::StepRegisterApplication>();
114 AddStep<ci::security::StepRegisterSecurity>();
115 AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>();
117 case ci::RequestType::Update:
118 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
119 AddStep<ci::filesystem::StepUnzip>();
120 AddStep<ci::configuration::StepParseManifest>(
121 ci::configuration::StepParseManifest::ManifestLocation::PACKAGE,
122 ci::configuration::StepParseManifest::StoreLocation::NORMAL);
123 AddStep<hybrid::configuration::StepStashTpkConfig>();
124 AddStep<hybrid::configuration::StepParse>(true);
125 AddStep<hybrid::configuration::StepMergeTpkConfig>();
126 AddStep<ci::security::StepCheckSignature>();
127 AddStep<ci::security::StepPrivilegeCompatibility>();
128 AddStep<wgt::security::StepCheckSettingsLevel>();
129 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
130 AddStep<wgt::security::StepCheckWgtNotificationCategory>();
131 AddStep<wgt::security::StepCheckWgtImePrivilege>();
132 AddStep<hybrid::encryption::StepEncryptResources>();
133 AddStep<ci::security::StepRollbackInstallationSecurity>();
134 AddStep<ci::configuration::StepParseManifest>(
135 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
136 ci::configuration::StepParseManifest::StoreLocation::BACKUP);
137 AddStep<ci::configuration::StepBlockCrossUpdate>();
138 AddStep<ci::pkgmgr::StepKillApps>();
139 AddStep<ci::backup::StepBackupManifest>();
140 AddStep<ci::backup::StepBackupIcons>();
141 AddStep<ci::backup::StepCopyBackup>();
142 AddStep<ci::filesystem::StepCopyTep>();
143 AddStep<ci::pkgmgr::StepUpdateTep>();
144 AddStep<tpk::filesystem::StepTpkPatchIcons>();
145 AddStep<wgt::filesystem::StepWgtPatchIcons>();
146 AddStep<ci::filesystem::StepCreateIcons>();
147 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
148 AddStep<ci::filesystem::StepCopyStorageDirectories>();
149 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
150 AddStep<tpk::filesystem::StepCreateSymbolicLink>();
151 AddStep<ci::security::StepUpdateSecurity>();
152 AddStep<wgt::pkgmgr::StepGenerateXml>();
153 AddStep<ci::pkgmgr::StepUpdateApplication>();
154 AddStep<ci::pkgmgr::StepRunParserPlugin>(
155 ci::Plugin::ActionType::Upgrade);
157 case ci::RequestType::Uninstall:
158 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
159 AddStep<ci::pkgmgr::StepCheckRemovable>();
160 AddStep<ci::configuration::StepParseManifest>(
161 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
162 ci::configuration::StepParseManifest::StoreLocation::NORMAL);
163 AddStep<ci::pkgmgr::StepRunParserPlugin>(
164 ci::Plugin::ActionType::Uninstall);
165 AddStep<ci::pkgmgr::StepKillApps>();
166 AddStep<ci::filesystem::StepRemovePerUserStorageDirectories>();
167 AddStep<ci::pkgmgr::StepUnregisterApplication>();
168 AddStep<ci::security::StepRollbackDeinstallationSecurity>();
169 AddStep<ci::filesystem::StepRemoveFiles>();
170 AddStep<ci::filesystem::StepRemoveZipImage>();
171 AddStep<ci::filesystem::StepRemoveIcons>();
172 AddStep<wgt::encryption::StepRemoveEncryptionData>();
173 AddStep<ci::security::StepRevokeSecurity>();
174 AddStep<ci::pkgmgr::StepRemoveManifest>();
176 case ci::RequestType::Reinstall:
177 // RDS is not supported for hybrid apps
178 AddStep<ci::configuration::StepFail>();
180 case ci::RequestType::Delta:
181 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
182 AddStep<ci::filesystem::StepUnzip>();
183 AddStep<ci::configuration::StepParseManifest>(
184 ci::configuration::StepParseManifest::ManifestLocation::PACKAGE,
185 ci::configuration::StepParseManifest::StoreLocation::NORMAL);
186 AddStep<ci::filesystem::StepDeltaPatch>();
187 AddStep<hybrid::configuration::StepStashTpkConfig>();
188 AddStep<hybrid::configuration::StepParse>(true);
189 AddStep<hybrid::configuration::StepMergeTpkConfig>();
190 AddStep<ci::security::StepCheckSignature>();
191 AddStep<ci::security::StepPrivilegeCompatibility>();
192 AddStep<wgt::security::StepCheckSettingsLevel>();
193 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
194 AddStep<wgt::security::StepCheckWgtNotificationCategory>();
195 AddStep<wgt::security::StepCheckWgtImePrivilege>();
196 AddStep<hybrid::encryption::StepEncryptResources>();
197 AddStep<ci::security::StepRollbackInstallationSecurity>();
198 AddStep<ci::configuration::StepParseManifest>(
199 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
200 ci::configuration::StepParseManifest::StoreLocation::BACKUP);
201 AddStep<ci::configuration::StepBlockCrossUpdate>();
202 AddStep<ci::pkgmgr::StepKillApps>();
203 AddStep<ci::backup::StepBackupManifest>();
204 AddStep<ci::backup::StepBackupIcons>();
205 AddStep<ci::backup::StepCopyBackup>();
206 AddStep<tpk::filesystem::StepTpkPatchIcons>();
207 AddStep<wgt::filesystem::StepWgtPatchIcons>();
208 AddStep<ci::filesystem::StepCreateIcons>();
209 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
210 AddStep<ci::filesystem::StepCopyStorageDirectories>();
211 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
212 AddStep<tpk::filesystem::StepCreateSymbolicLink>();
213 AddStep<ci::security::StepUpdateSecurity>();
214 AddStep<wgt::pkgmgr::StepGenerateXml>();
215 AddStep<ci::pkgmgr::StepUpdateApplication>();
216 AddStep<ci::pkgmgr::StepRunParserPlugin>(
217 ci::Plugin::ActionType::Upgrade);
219 case ci::RequestType::Recovery:
220 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
221 AddStep<ci::recovery::StepOpenRecoveryFile>();
222 AddStep<ci::configuration::StepParseManifest>(
223 ci::configuration::StepParseManifest::ManifestLocation::RECOVERY,
224 ci::configuration::StepParseManifest::StoreLocation::NORMAL);
225 AddStep<hybrid::configuration::StepStashTpkConfig>();
226 AddStep<wgt::configuration::StepParseRecovery>();
227 AddStep<hybrid::configuration::StepMergeTpkConfig>();
228 AddStep<ci::pkgmgr::StepRecoverApplication>();
229 AddStep<ci::filesystem::StepRemoveTemporaryDirectory>();
230 AddStep<ci::filesystem::StepRecoverIcons>();
231 AddStep<ci::filesystem::StepRecoverManifest>();
232 AddStep<ci::filesystem::StepRecoverStorageDirectories>();
233 AddStep<ci::filesystem::StepRecoverFiles>();
234 AddStep<ci::security::StepRecoverSecurity>();
236 case ci::RequestType::Clear:
237 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
238 AddStep<ci::filesystem::StepClearData>();
240 case ci::RequestType::MountInstall:
241 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
242 AddStep<ci::mount::StepMountUnpacked>();
243 AddStep<ci::configuration::StepParseManifest>(
244 ci::configuration::StepParseManifest::ManifestLocation::PACKAGE,
245 ci::configuration::StepParseManifest::StoreLocation::NORMAL);
246 AddStep<hybrid::configuration::StepStashTpkConfig>();
247 AddStep<hybrid::configuration::StepParse>(true);
248 AddStep<hybrid::configuration::StepMergeTpkConfig>();
249 AddStep<ci::security::StepCheckSignature>();
250 AddStep<ci::security::StepPrivilegeCompatibility>();
251 AddStep<wgt::security::StepCheckSettingsLevel>();
252 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
253 AddStep<wgt::security::StepCheckWgtNotificationCategory>();
254 AddStep<wgt::security::StepCheckWgtImePrivilege>();
255 AddStep<hybrid::encryption::StepEncryptResources>();
256 AddStep<ci::security::StepRollbackInstallationSecurity>();
257 AddStep<ci::mount::StepMountInstall>();
258 AddStep<tpk::filesystem::StepTpkPreparePackageDirectory>();
259 AddStep<ci::filesystem::StepCopyTep>();
260 AddStep<tpk::filesystem::StepTpkPatchIcons>();
261 AddStep<wgt::filesystem::StepWgtPatchIcons>();
262 AddStep<ci::filesystem::StepCreateIcons>();
263 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
264 AddStep<ci::filesystem::StepCreateStorageDirectories>();
265 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
266 AddStep<tpk::filesystem::StepCreateSymbolicLink>();
267 AddStep<wgt::pkgmgr::StepGenerateXml>();
268 AddStep<ci::pkgmgr::StepRunParserPlugin>(
269 ci::Plugin::ActionType::Install);
270 AddStep<ci::pkgmgr::StepRegisterApplication>();
271 AddStep<ci::security::StepRegisterSecurity>();
272 AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>();
274 case ci::RequestType::MountUpdate:
275 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
276 AddStep<ci::mount::StepMountUnpacked>();
277 AddStep<ci::configuration::StepParseManifest>(
278 ci::configuration::StepParseManifest::ManifestLocation::PACKAGE,
279 ci::configuration::StepParseManifest::StoreLocation::NORMAL);
280 AddStep<hybrid::configuration::StepStashTpkConfig>();
281 AddStep<hybrid::configuration::StepParse>(true);
282 AddStep<hybrid::configuration::StepMergeTpkConfig>();
283 AddStep<ci::security::StepCheckSignature>();
284 AddStep<ci::security::StepPrivilegeCompatibility>();
285 AddStep<wgt::security::StepCheckSettingsLevel>();
286 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
287 AddStep<wgt::security::StepCheckWgtNotificationCategory>();
288 AddStep<wgt::security::StepCheckWgtImePrivilege>();
289 AddStep<hybrid::encryption::StepEncryptResources>();
290 AddStep<ci::security::StepRollbackInstallationSecurity>();
291 AddStep<ci::configuration::StepParseManifest>(
292 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
293 ci::configuration::StepParseManifest::StoreLocation::BACKUP);
294 AddStep<ci::configuration::StepBlockCrossUpdate>();
295 AddStep<ci::pkgmgr::StepKillApps>();
296 AddStep<ci::backup::StepBackupManifest>();
297 AddStep<ci::backup::StepBackupIcons>();
298 AddStep<ci::mount::StepMountUpdate>();
299 AddStep<tpk::filesystem::StepTpkUpdatePackageDirectory>();
300 AddStep<ci::filesystem::StepCopyTep>();
301 AddStep<ci::pkgmgr::StepUpdateTep>();
302 AddStep<tpk::filesystem::StepTpkPatchIcons>();
303 AddStep<wgt::filesystem::StepWgtPatchIcons>();
304 AddStep<ci::filesystem::StepCreateIcons>();
305 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
306 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
307 AddStep<tpk::filesystem::StepCreateSymbolicLink>();
308 AddStep<ci::security::StepUpdateSecurity>();
309 AddStep<wgt::pkgmgr::StepGenerateXml>();
310 AddStep<ci::pkgmgr::StepUpdateApplication>();
311 AddStep<ci::pkgmgr::StepRunParserPlugin>(
312 ci::Plugin::ActionType::Upgrade);
315 AddStep<ci::configuration::StepFail>();
320 } // namespace hybrid