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 "wgt/wgt_installer.h"
7 #include <common/pkgmgr_interface.h>
9 #include <common/step/backup/step_backup_icons.h>
10 #include <common/step/backup/step_backup_manifest.h>
11 #include <common/step/backup/step_copy_backup.h>
12 #include <common/step/configuration/step_block_cross_update.h>
13 #include <common/step/configuration/step_configure.h>
14 #include <common/step/configuration/step_fail.h>
15 #include <common/step/configuration/step_parse_manifest.h>
16 #include <common/step/filesystem/step_acquire_external_storage.h>
17 #include <common/step/filesystem/step_clear_data.h>
18 #include <common/step/filesystem/step_copy.h>
19 #include <common/step/filesystem/step_copy_storage_directories.h>
20 #include <common/step/filesystem/step_copy_tep.h>
21 #include <common/step/filesystem/step_create_icons.h>
22 #include <common/step/filesystem/step_create_per_user_storage_directories.h>
23 #include <common/step/filesystem/step_create_storage_directories.h>
24 #include <common/step/filesystem/step_delta_patch.h>
25 #include <common/step/filesystem/step_recover_files.h>
26 #include <common/step/filesystem/step_recover_icons.h>
27 #include <common/step/filesystem/step_recover_manifest.h>
28 #include <common/step/filesystem/step_recover_external_storage.h>
29 #include <common/step/filesystem/step_recover_storage_directories.h>
30 #include <common/step/filesystem/step_remove_files.h>
31 #include <common/step/filesystem/step_remove_icons.h>
32 #include <common/step/filesystem/step_remove_per_user_storage_directories.h>
33 #include <common/step/filesystem/step_remove_temporary_directory.h>
34 #include <common/step/filesystem/step_remove_zip_image.h>
35 #include <common/step/filesystem/step_unzip.h>
36 #include <common/step/mount/step_mount_install.h>
37 #include <common/step/mount/step_mount_unpacked.h>
38 #include <common/step/mount/step_mount_update.h>
39 #include <common/step/pkgmgr/step_check_removable.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_old_certificate.h>
50 #include <common/step/security/step_check_signature.h>
51 #include <common/step/security/step_privilege_compatibility.h>
52 #include <common/step/security/step_recover_security.h>
53 #include <common/step/security/step_register_security.h>
54 #include <common/step/security/step_revoke_security.h>
55 #include <common/step/security/step_rollback_deinstallation_security.h>
56 #include <common/step/security/step_rollback_installation_security.h>
57 #include <common/step/security/step_update_security.h>
59 #include <wgt_manifest_handlers/widget_config_parser.h>
60 #include <common/step/rds/step_rds_modify.h>
61 #include <common/step/rds/step_rds_parse.h>
63 #include "wgt/step/configuration/step_parse.h"
64 #include "wgt/step/encryption/step_encrypt_resources.h"
65 #include "wgt/step/encryption/step_remove_encryption_data.h"
66 #include "wgt/step/filesystem/step_copy_preview_icons.h"
67 #include "wgt/step/filesystem/step_create_symbolic_link.h"
68 #include "wgt/step/filesystem/step_wgt_patch_icons.h"
69 #include "wgt/step/filesystem/step_wgt_patch_storage_directories.h"
70 #include "wgt/step/filesystem/step_wgt_prepare_package_directory.h"
71 #include "wgt/step/filesystem/step_wgt_resource_directory.h"
72 #include "wgt/step/filesystem/step_wgt_update_package_directory.h"
73 #include "wgt/step/pkgmgr/step_generate_xml.h"
74 #include "wgt/step/rds/step_wgt_rds_modify.h"
75 #include "wgt/step/security/step_add_default_privileges.h"
76 #include "wgt/step/security/step_check_settings_level.h"
77 #include "wgt/step/security/step_check_wgt_background_category.h"
78 #include "wgt/step/security/step_check_wgt_notification_category.h"
79 #include "wgt/step/security/step_check_wgt_ime_privilege.h"
80 #include "wgt/step/security/step_direct_manifest_check_signature.h"
82 namespace ci = common_installer;
86 WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
87 : AppInstaller("wgt", pkgrmgr) {
88 context_->backend_data.set(new WgtBackendData());
90 /* treat the request */
91 switch (pkgmgr_->GetRequestType()) {
92 case ci::RequestType::Install : {
93 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
94 AddStep<ci::filesystem::StepUnzip>();
95 AddStep<wgt::configuration::StepParse>(
96 wgt::configuration::StepParse::ConfigLocation::PACKAGE, true);
97 AddStep<ci::security::StepCheckSignature>();
98 AddStep<ci::security::StepPrivilegeCompatibility>();
99 AddStep<wgt::security::StepCheckSettingsLevel>();
100 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
101 AddStep<wgt::security::StepCheckWgtNotificationCategory>();
102 AddStep<wgt::security::StepCheckWgtImePrivilege>();
103 AddStep<wgt::encryption::StepEncryptResources>();
104 AddStep<wgt::filesystem::StepWgtResourceDirectory>();
105 AddStep<ci::security::StepRollbackInstallationSecurity>();
106 AddStep<ci::filesystem::StepAcquireExternalStorage>();
107 AddStep<ci::filesystem::StepCopy>();
108 AddStep<ci::filesystem::StepCopyTep>();
109 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
110 AddStep<ci::filesystem::StepCreateStorageDirectories>();
111 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
112 AddStep<wgt::filesystem::StepWgtPatchIcons>();
113 AddStep<ci::filesystem::StepCreateIcons>();
114 AddStep<wgt::filesystem::StepCopyPreviewIcons>();
115 AddStep<wgt::pkgmgr::StepGenerateXml>();
116 AddStep<ci::pkgmgr::StepRegisterApplication>();
117 AddStep<ci::pkgmgr::StepRunParserPlugin>(
118 ci::Plugin::ActionType::Install);
119 AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>();
120 AddStep<ci::security::StepRegisterSecurity>();
123 case ci::RequestType::Update: {
124 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
125 AddStep<ci::filesystem::StepUnzip>();
126 AddStep<wgt::configuration::StepParse>(
127 wgt::configuration::StepParse::ConfigLocation::PACKAGE, true);
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<ci::security::StepCheckOldCertificate>();
135 AddStep<wgt::encryption::StepEncryptResources>();
136 AddStep<wgt::filesystem::StepWgtResourceDirectory>();
137 AddStep<ci::configuration::StepParseManifest>(
138 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
139 ci::configuration::StepParseManifest::StoreLocation::BACKUP);
140 AddStep<ci::configuration::StepBlockCrossUpdate>();
141 AddStep<ci::pkgmgr::StepKillApps>();
142 AddStep<ci::backup::StepBackupManifest>();
143 AddStep<ci::backup::StepBackupIcons>();
144 AddStep<ci::filesystem::StepAcquireExternalStorage>();
145 AddStep<ci::backup::StepCopyBackup>();
146 AddStep<ci::filesystem::StepCopyTep>();
147 AddStep<ci::pkgmgr::StepUpdateTep>();
148 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
149 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
150 AddStep<wgt::filesystem::StepWgtPatchIcons>();
151 AddStep<ci::filesystem::StepCreateIcons>();
152 AddStep<wgt::filesystem::StepCopyPreviewIcons>();
153 AddStep<ci::filesystem::StepCopyStorageDirectories>();
154 AddStep<ci::security::StepUpdateSecurity>();
155 AddStep<wgt::pkgmgr::StepGenerateXml>();
156 AddStep<ci::pkgmgr::StepRunParserPlugin>(
157 ci::Plugin::ActionType::Upgrade);
158 AddStep<ci::pkgmgr::StepUpdateApplication>();
161 case ci::RequestType::Uninstall: {
162 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
163 AddStep<ci::pkgmgr::StepCheckRemovable>();
164 AddStep<ci::configuration::StepParseManifest>(
165 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
166 ci::configuration::StepParseManifest::StoreLocation::NORMAL);
167 AddStep<ci::pkgmgr::StepKillApps>();
168 AddStep<ci::filesystem::StepAcquireExternalStorage>();
169 AddStep<ci::pkgmgr::StepRunParserPlugin>(
170 ci::Plugin::ActionType::Uninstall);
171 AddStep<ci::filesystem::StepRemovePerUserStorageDirectories>();
172 AddStep<ci::pkgmgr::StepUnregisterApplication>();
173 AddStep<ci::security::StepRollbackDeinstallationSecurity>();
174 AddStep<ci::filesystem::StepRemoveFiles>();
175 AddStep<ci::filesystem::StepRemoveZipImage>();
176 AddStep<ci::filesystem::StepRemoveIcons>();
177 AddStep<wgt::encryption::StepRemoveEncryptionData>();
178 AddStep<ci::security::StepRevokeSecurity>();
179 AddStep<ci::pkgmgr::StepRemoveManifest>();
182 case ci::RequestType::Reinstall: {
183 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
184 AddStep<wgt::configuration::StepParse>(
185 wgt::configuration::StepParse::ConfigLocation::PACKAGE, false);
186 AddStep<ci::pkgmgr::StepKillApps>();
187 AddStep<ci::configuration::StepParseManifest>(
188 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
189 ci::configuration::StepParseManifest::StoreLocation::BACKUP);
190 AddStep<ci::configuration::StepBlockCrossUpdate>();
191 AddStep<ci::filesystem::StepAcquireExternalStorage>();
192 AddStep<ci::rds::StepRDSParse>();
193 AddStep<wgt::rds::StepWgtRDSModify>();
194 AddStep<ci::security::StepUpdateSecurity>();
197 case ci::RequestType::Delta: {
198 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
199 AddStep<ci::filesystem::StepUnzip>();
200 // TODO(t.iwanek): manifest is parsed twice...
201 AddStep<wgt::configuration::StepParse>(
202 wgt::configuration::StepParse::ConfigLocation::PACKAGE, false);
203 // start file may not have changed
204 AddStep<ci::configuration::StepParseManifest>(
205 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
206 ci::configuration::StepParseManifest::StoreLocation::BACKUP);
207 AddStep<ci::filesystem::StepDeltaPatch>("res/wgt/");
208 AddStep<wgt::configuration::StepParse>(
209 wgt::configuration::StepParse::ConfigLocation::PACKAGE, true);
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<ci::security::StepCheckOldCertificate>();
217 AddStep<wgt::encryption::StepEncryptResources>();
218 AddStep<wgt::filesystem::StepWgtResourceDirectory>();
219 AddStep<ci::configuration::StepBlockCrossUpdate>();
220 AddStep<ci::pkgmgr::StepKillApps>();
221 AddStep<ci::backup::StepBackupManifest>();
222 AddStep<ci::backup::StepBackupIcons>();
223 AddStep<ci::filesystem::StepAcquireExternalStorage>();
224 AddStep<ci::backup::StepCopyBackup>();
225 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
226 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
227 AddStep<wgt::filesystem::StepWgtPatchIcons>();
228 AddStep<ci::filesystem::StepCreateIcons>();
229 AddStep<wgt::filesystem::StepCopyPreviewIcons>();
230 AddStep<ci::filesystem::StepCopyStorageDirectories>();
231 AddStep<ci::security::StepUpdateSecurity>();
232 AddStep<wgt::pkgmgr::StepGenerateXml>();
233 AddStep<ci::pkgmgr::StepRunParserPlugin>(
234 ci::Plugin::ActionType::Upgrade);
235 AddStep<ci::pkgmgr::StepUpdateApplication>();
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>();
254 case ci::RequestType::Clear: {
255 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
256 AddStep<ci::configuration::StepParseManifest>(
257 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
258 ci::configuration::StepParseManifest::StoreLocation::NORMAL);
259 AddStep<ci::filesystem::StepClearData>();
262 case ci::RequestType::MountInstall: {
263 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
264 AddStep<ci::mount::StepMountUnpacked>();
265 AddStep<wgt::configuration::StepParse>(
266 wgt::configuration::StepParse::ConfigLocation::PACKAGE, true);
267 AddStep<ci::security::StepCheckSignature>();
268 AddStep<ci::security::StepPrivilegeCompatibility>();
269 AddStep<wgt::security::StepCheckSettingsLevel>();
270 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
271 AddStep<wgt::security::StepCheckWgtNotificationCategory>();
272 AddStep<wgt::security::StepCheckWgtImePrivilege>();
273 AddStep<wgt::encryption::StepEncryptResources>();
274 AddStep<ci::security::StepRollbackInstallationSecurity>();
275 AddStep<ci::mount::StepMountInstall>();
276 AddStep<wgt::filesystem::StepWgtPreparePackageDirectory>();
277 AddStep<ci::filesystem::StepCopyTep>();
278 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
279 AddStep<ci::filesystem::StepCreateStorageDirectories>();
280 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
281 AddStep<wgt::filesystem::StepWgtPatchIcons>();
282 AddStep<ci::filesystem::StepCreateIcons>();
283 AddStep<wgt::filesystem::StepCopyPreviewIcons>();
284 AddStep<wgt::pkgmgr::StepGenerateXml>();
285 AddStep<ci::pkgmgr::StepRegisterApplication>();
286 AddStep<ci::pkgmgr::StepRunParserPlugin>(
287 ci::Plugin::ActionType::Install);
288 AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>();
289 AddStep<ci::security::StepRegisterSecurity>();
292 case ci::RequestType::MountUpdate: {
293 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
294 AddStep<ci::mount::StepMountUnpacked>();
295 AddStep<wgt::configuration::StepParse>(
296 wgt::configuration::StepParse::ConfigLocation::PACKAGE, true);
297 AddStep<ci::security::StepCheckSignature>();
298 AddStep<ci::security::StepPrivilegeCompatibility>();
299 AddStep<wgt::security::StepCheckSettingsLevel>();
300 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
301 AddStep<wgt::security::StepCheckWgtNotificationCategory>();
302 AddStep<wgt::security::StepCheckWgtImePrivilege>();
303 AddStep<ci::security::StepCheckOldCertificate>();
304 AddStep<ci::configuration::StepParseManifest>(
305 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
306 ci::configuration::StepParseManifest::StoreLocation::BACKUP);
307 AddStep<ci::configuration::StepBlockCrossUpdate>();
308 AddStep<ci::pkgmgr::StepKillApps>();
309 AddStep<ci::backup::StepBackupManifest>();
310 AddStep<ci::backup::StepBackupIcons>();
311 AddStep<ci::mount::StepMountUpdate>();
312 AddStep<wgt::filesystem::StepWgtUpdatePackageDirectory>();
313 AddStep<ci::filesystem::StepCopyTep>();
314 AddStep<ci::pkgmgr::StepUpdateTep>();
315 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
316 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
317 AddStep<wgt::filesystem::StepWgtPatchIcons>();
318 AddStep<ci::filesystem::StepCreateIcons>();
319 AddStep<wgt::filesystem::StepCopyPreviewIcons>();
320 AddStep<ci::security::StepUpdateSecurity>();
321 AddStep<wgt::pkgmgr::StepGenerateXml>();
322 AddStep<ci::pkgmgr::StepRunParserPlugin>(
323 ci::Plugin::ActionType::Upgrade);
324 AddStep<ci::pkgmgr::StepUpdateApplication>();
327 case ci::RequestType::ManifestDirectInstall: {
328 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
329 AddStep<wgt::configuration::StepParse>(
330 wgt::configuration::StepParse::ConfigLocation::INSTALLED, true);
331 AddStep<wgt::security::StepDirectManifestCheckSignature>();
332 AddStep<ci::security::StepPrivilegeCompatibility>();
333 AddStep<wgt::security::StepCheckWgtNotificationCategory>();
334 AddStep<wgt::security::StepCheckWgtImePrivilege>();
335 AddStep<wgt::security::StepCheckSettingsLevel>();
336 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
337 AddStep<ci::security::StepRollbackInstallationSecurity>();
338 AddStep<wgt::pkgmgr::StepGenerateXml>();
339 AddStep<ci::pkgmgr::StepRegisterApplication>();
340 AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Install);
341 AddStep<ci::security::StepRegisterSecurity>();
344 case ci::RequestType::ManifestDirectUpdate: {
345 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
346 AddStep<wgt::configuration::StepParse>(
347 wgt::configuration::StepParse::ConfigLocation::INSTALLED, true);
348 AddStep<wgt::security::StepDirectManifestCheckSignature>();
349 AddStep<ci::security::StepPrivilegeCompatibility>();
350 AddStep<wgt::security::StepCheckWgtNotificationCategory>();
351 AddStep<wgt::security::StepCheckWgtImePrivilege>();
352 AddStep<wgt::security::StepCheckSettingsLevel>();
353 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
354 AddStep<ci::configuration::StepParseManifest>(
355 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
356 ci::configuration::StepParseManifest::StoreLocation::BACKUP);
357 AddStep<ci::pkgmgr::StepKillApps>();
358 AddStep<ci::filesystem::StepCopyTep>();
359 AddStep<ci::security::StepUpdateSecurity>();
360 AddStep<wgt::pkgmgr::StepGenerateXml>();
361 AddStep<ci::pkgmgr::StepRunParserPlugin>(
362 ci::Plugin::ActionType::Upgrade);
363 AddStep<ci::pkgmgr::StepUpdateApplication>();
367 AddStep<ci::configuration::StepFail>();