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_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_storage_directories.h>
28 #include <common/step/filesystem/step_remove_files.h>
29 #include <common/step/filesystem/step_remove_icons.h>
30 #include <common/step/filesystem/step_remove_per_user_storage_directories.h>
31 #include <common/step/filesystem/step_remove_temporary_directory.h>
32 #include <common/step/filesystem/step_remove_zip_image.h>
33 #include <common/step/filesystem/step_unzip.h>
34 #include <common/step/mount/step_mount_install.h>
35 #include <common/step/mount/step_mount_unpacked.h>
36 #include <common/step/mount/step_mount_update.h>
37 #include <common/step/pkgmgr/step_check_blacklist.h>
38 #include <common/step/pkgmgr/step_check_removable.h>
39 #include <common/step/pkgmgr/step_kill_apps.h>
40 #include <common/step/pkgmgr/step_recover_application.h>
41 #include <common/step/pkgmgr/step_register_app.h>
42 #include <common/step/pkgmgr/step_remove_manifest.h>
43 #include <common/step/pkgmgr/step_run_parser_plugins.h>
44 #include <common/step/pkgmgr/step_unregister_app.h>
45 #include <common/step/pkgmgr/step_update_app.h>
46 #include <common/step/pkgmgr/step_update_tep.h>
47 #include <common/step/recovery/step_open_recovery_file.h>
48 #include <common/step/security/step_check_old_certificate.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 <wgt_manifest_handlers/widget_config_parser.h>
59 #include <common/step/rds/step_rds_modify.h>
60 #include <common/step/rds/step_rds_parse.h>
62 #include "wgt/step/configuration/step_parse.h"
63 #include "wgt/step/configuration/step_parse_recovery.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_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/filesystem/step_wgt_prepare_package_directory.h"
70 #include "wgt/step/filesystem/step_wgt_resource_directory.h"
71 #include "wgt/step/filesystem/step_wgt_update_package_directory.h"
72 #include "wgt/step/pkgmgr/step_generate_xml.h"
73 #include "wgt/step/rds/step_wgt_rds_modify.h"
74 #include "wgt/step/security/step_add_default_privileges.h"
75 #include "wgt/step/security/step_check_settings_level.h"
76 #include "wgt/step/security/step_check_wgt_background_category.h"
77 #include "wgt/step/security/step_check_wgt_notification_category.h"
78 #include "wgt/step/security/step_check_wgt_ime_privilege.h"
79 #include "wgt/step/security/step_direct_manifest_check_signature.h"
81 namespace ci = common_installer;
85 WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
86 : AppInstaller("wgt", pkgrmgr) {
87 context_->backend_data.set(new WgtBackendData());
89 /* treat the request */
90 switch (pkgmgr_->GetRequestType()) {
91 case ci::RequestType::Install : {
92 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
93 AddStep<ci::filesystem::StepUnzip>();
94 AddStep<wgt::configuration::StepParse>(
95 wgt::configuration::StepParse::ConfigLocation::PACKAGE, true);
96 AddStep<ci::pkgmgr::StepCheckBlacklist>();
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::StepCopy>();
107 AddStep<ci::filesystem::StepCopyTep>();
108 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
109 AddStep<ci::filesystem::StepCreateStorageDirectories>();
110 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
111 AddStep<wgt::filesystem::StepWgtPatchIcons>();
112 AddStep<ci::filesystem::StepCreateIcons>();
113 AddStep<wgt::pkgmgr::StepGenerateXml>();
114 AddStep<ci::pkgmgr::StepRegisterApplication>();
115 AddStep<ci::pkgmgr::StepRunParserPlugin>(
116 ci::Plugin::ActionType::Install);
117 AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>();
118 AddStep<ci::security::StepRegisterSecurity>();
121 case ci::RequestType::Update: {
122 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
123 AddStep<ci::filesystem::StepUnzip>();
124 AddStep<wgt::configuration::StepParse>(
125 wgt::configuration::StepParse::ConfigLocation::PACKAGE, true);
126 AddStep<ci::pkgmgr::StepCheckBlacklist>();
127 AddStep<ci::security::StepCheckSignature>();
128 AddStep<ci::security::StepPrivilegeCompatibility>();
129 AddStep<wgt::security::StepCheckSettingsLevel>();
130 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
131 AddStep<wgt::security::StepCheckWgtNotificationCategory>();
132 AddStep<wgt::security::StepCheckWgtImePrivilege>();
133 AddStep<ci::security::StepCheckOldCertificate>();
134 AddStep<wgt::filesystem::StepWgtResourceDirectory>();
135 AddStep<ci::configuration::StepParseManifest>(
136 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
137 ci::configuration::StepParseManifest::StoreLocation::BACKUP);
138 AddStep<ci::configuration::StepBlockCrossUpdate>();
139 AddStep<ci::pkgmgr::StepKillApps>();
140 AddStep<ci::backup::StepBackupManifest>();
141 AddStep<ci::backup::StepBackupIcons>();
142 AddStep<ci::backup::StepCopyBackup>();
143 AddStep<ci::filesystem::StepCopyTep>();
144 AddStep<ci::pkgmgr::StepUpdateTep>();
145 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
146 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
147 AddStep<wgt::filesystem::StepWgtPatchIcons>();
148 AddStep<ci::filesystem::StepCreateIcons>();
149 AddStep<ci::filesystem::StepCopyStorageDirectories>();
150 AddStep<ci::security::StepUpdateSecurity>();
151 AddStep<wgt::pkgmgr::StepGenerateXml>();
152 AddStep<ci::pkgmgr::StepRunParserPlugin>(
153 ci::Plugin::ActionType::Upgrade);
154 AddStep<ci::pkgmgr::StepUpdateApplication>();
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::StepKillApps>();
164 AddStep<ci::pkgmgr::StepRunParserPlugin>(
165 ci::Plugin::ActionType::Uninstall);
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>();
177 case ci::RequestType::Reinstall: {
178 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
179 AddStep<wgt::configuration::StepParse>(
180 wgt::configuration::StepParse::ConfigLocation::PACKAGE, false);
181 AddStep<ci::pkgmgr::StepKillApps>();
182 AddStep<ci::configuration::StepParseManifest>(
183 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
184 ci::configuration::StepParseManifest::StoreLocation::BACKUP);
185 AddStep<ci::configuration::StepBlockCrossUpdate>();
186 AddStep<ci::pkgmgr::StepCheckBlacklist>();
187 AddStep<ci::rds::StepRDSParse>();
188 AddStep<wgt::rds::StepWgtRDSModify>();
189 AddStep<ci::security::StepUpdateSecurity>();
192 case ci::RequestType::Delta: {
193 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
194 AddStep<ci::filesystem::StepUnzip>();
195 // TODO(t.iwanek): manifest is parsed twice...
196 AddStep<wgt::configuration::StepParse>(
197 wgt::configuration::StepParse::ConfigLocation::PACKAGE, false);
198 // start file may not have changed
199 AddStep<ci::configuration::StepParseManifest>(
200 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
201 ci::configuration::StepParseManifest::StoreLocation::BACKUP);
202 AddStep<ci::filesystem::StepDeltaPatch>("res/wgt/");
203 AddStep<wgt::configuration::StepParse>(
204 wgt::configuration::StepParse::ConfigLocation::PACKAGE, true);
205 AddStep<ci::pkgmgr::StepCheckBlacklist>();
206 AddStep<ci::security::StepCheckSignature>();
207 AddStep<ci::security::StepPrivilegeCompatibility>();
208 AddStep<wgt::security::StepCheckSettingsLevel>();
209 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
210 AddStep<wgt::security::StepCheckWgtNotificationCategory>();
211 AddStep<wgt::security::StepCheckWgtImePrivilege>();
212 AddStep<ci::security::StepCheckOldCertificate>();
213 AddStep<wgt::filesystem::StepWgtResourceDirectory>();
214 AddStep<ci::configuration::StepBlockCrossUpdate>();
215 AddStep<ci::pkgmgr::StepKillApps>();
216 AddStep<ci::backup::StepBackupManifest>();
217 AddStep<ci::backup::StepBackupIcons>();
218 AddStep<ci::backup::StepCopyBackup>();
219 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
220 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
221 AddStep<wgt::filesystem::StepWgtPatchIcons>();
222 AddStep<ci::filesystem::StepCreateIcons>();
223 AddStep<ci::filesystem::StepCopyStorageDirectories>();
224 AddStep<ci::security::StepUpdateSecurity>();
225 AddStep<wgt::pkgmgr::StepGenerateXml>();
226 AddStep<ci::pkgmgr::StepRunParserPlugin>(
227 ci::Plugin::ActionType::Upgrade);
228 AddStep<ci::pkgmgr::StepUpdateApplication>();
231 case ci::RequestType::Recovery: {
232 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
233 AddStep<ci::recovery::StepOpenRecoveryFile>();
234 AddStep<wgt::configuration::StepParseRecovery>();
235 AddStep<ci::pkgmgr::StepRecoverApplication>();
236 AddStep<ci::filesystem::StepRemoveTemporaryDirectory>();
237 AddStep<ci::filesystem::StepRecoverIcons>();
238 AddStep<ci::filesystem::StepRecoverManifest>();
239 AddStep<ci::filesystem::StepRecoverStorageDirectories>();
240 AddStep<ci::filesystem::StepRecoverFiles>();
241 AddStep<ci::security::StepRecoverSecurity>();
244 case ci::RequestType::Clear: {
245 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
246 AddStep<ci::filesystem::StepClearData>();
249 case ci::RequestType::MountInstall: {
250 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
251 AddStep<ci::mount::StepMountUnpacked>();
252 AddStep<wgt::configuration::StepParse>(
253 wgt::configuration::StepParse::ConfigLocation::PACKAGE, true);
254 AddStep<ci::pkgmgr::StepCheckBlacklist>();
255 AddStep<ci::security::StepCheckSignature>();
256 AddStep<ci::security::StepPrivilegeCompatibility>();
257 AddStep<wgt::security::StepCheckSettingsLevel>();
258 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
259 AddStep<wgt::security::StepCheckWgtNotificationCategory>();
260 AddStep<wgt::security::StepCheckWgtImePrivilege>();
261 AddStep<wgt::encryption::StepEncryptResources>();
262 AddStep<ci::security::StepRollbackInstallationSecurity>();
263 AddStep<ci::mount::StepMountInstall>();
264 AddStep<wgt::filesystem::StepWgtPreparePackageDirectory>();
265 AddStep<ci::filesystem::StepCopyTep>();
266 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
267 AddStep<ci::filesystem::StepCreateStorageDirectories>();
268 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
269 AddStep<wgt::filesystem::StepWgtPatchIcons>();
270 AddStep<ci::filesystem::StepCreateIcons>();
271 AddStep<wgt::pkgmgr::StepGenerateXml>();
272 AddStep<ci::pkgmgr::StepRegisterApplication>();
273 AddStep<ci::pkgmgr::StepRunParserPlugin>(
274 ci::Plugin::ActionType::Install);
275 AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>();
276 AddStep<ci::security::StepRegisterSecurity>();
279 case ci::RequestType::MountUpdate: {
280 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
281 AddStep<ci::mount::StepMountUnpacked>();
282 AddStep<wgt::configuration::StepParse>(
283 wgt::configuration::StepParse::ConfigLocation::PACKAGE, true);
284 AddStep<ci::pkgmgr::StepCheckBlacklist>();
285 AddStep<ci::security::StepCheckSignature>();
286 AddStep<ci::security::StepPrivilegeCompatibility>();
287 AddStep<wgt::security::StepCheckSettingsLevel>();
288 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
289 AddStep<wgt::security::StepCheckWgtNotificationCategory>();
290 AddStep<wgt::security::StepCheckWgtImePrivilege>();
291 AddStep<ci::security::StepCheckOldCertificate>();
292 AddStep<ci::configuration::StepParseManifest>(
293 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
294 ci::configuration::StepParseManifest::StoreLocation::BACKUP);
295 AddStep<ci::configuration::StepBlockCrossUpdate>();
296 AddStep<ci::pkgmgr::StepKillApps>();
297 AddStep<ci::backup::StepBackupManifest>();
298 AddStep<ci::backup::StepBackupIcons>();
299 AddStep<ci::mount::StepMountUpdate>();
300 AddStep<wgt::filesystem::StepWgtUpdatePackageDirectory>();
301 AddStep<ci::filesystem::StepCopyTep>();
302 AddStep<ci::pkgmgr::StepUpdateTep>();
303 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
304 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
305 AddStep<wgt::filesystem::StepWgtPatchIcons>();
306 AddStep<ci::filesystem::StepCreateIcons>();
307 AddStep<ci::security::StepUpdateSecurity>();
308 AddStep<wgt::pkgmgr::StepGenerateXml>();
309 AddStep<ci::pkgmgr::StepRunParserPlugin>(
310 ci::Plugin::ActionType::Upgrade);
311 AddStep<ci::pkgmgr::StepUpdateApplication>();
314 case ci::RequestType::ManifestDirectInstall: {
315 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
316 AddStep<wgt::configuration::StepParse>(
317 wgt::configuration::StepParse::ConfigLocation::INSTALLED, true);
318 AddStep<ci::pkgmgr::StepCheckBlacklist>();
319 AddStep<wgt::security::StepDirectManifestCheckSignature>();
320 AddStep<ci::security::StepPrivilegeCompatibility>();
321 AddStep<wgt::security::StepCheckWgtNotificationCategory>();
322 AddStep<wgt::security::StepCheckWgtImePrivilege>();
323 AddStep<wgt::security::StepCheckSettingsLevel>();
324 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
325 AddStep<ci::security::StepRollbackInstallationSecurity>();
326 AddStep<wgt::pkgmgr::StepGenerateXml>();
327 AddStep<ci::pkgmgr::StepRegisterApplication>();
328 AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Install);
329 AddStep<ci::security::StepRegisterSecurity>();
332 case ci::RequestType::ManifestDirectUpdate: {
333 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
334 AddStep<wgt::configuration::StepParse>(
335 wgt::configuration::StepParse::ConfigLocation::INSTALLED, true);
336 AddStep<ci::pkgmgr::StepCheckBlacklist>();
337 AddStep<wgt::security::StepDirectManifestCheckSignature>();
338 AddStep<ci::security::StepPrivilegeCompatibility>();
339 AddStep<wgt::security::StepCheckWgtNotificationCategory>();
340 AddStep<wgt::security::StepCheckWgtImePrivilege>();
341 AddStep<wgt::security::StepCheckSettingsLevel>();
342 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
343 AddStep<ci::configuration::StepParseManifest>(
344 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
345 ci::configuration::StepParseManifest::StoreLocation::BACKUP);
346 AddStep<ci::pkgmgr::StepKillApps>();
347 AddStep<ci::filesystem::StepCopyTep>();
348 AddStep<ci::security::StepUpdateSecurity>();
349 AddStep<wgt::pkgmgr::StepGenerateXml>();
350 AddStep<ci::pkgmgr::StepRunParserPlugin>(
351 ci::Plugin::ActionType::Upgrade);
352 AddStep<ci::pkgmgr::StepUpdateApplication>();
356 AddStep<ci::configuration::StepFail>();