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"
80 namespace ci = common_installer;
84 WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
85 : AppInstaller("wgt", pkgrmgr) {
86 context_->backend_data.set(new WgtBackendData());
88 /* treat the request */
89 switch (pkgmgr_->GetRequestType()) {
90 case ci::RequestType::Install : {
91 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
92 AddStep<ci::filesystem::StepUnzip>();
93 AddStep<wgt::configuration::StepParse>(true);
94 AddStep<ci::pkgmgr::StepCheckBlacklist>();
95 AddStep<ci::security::StepCheckSignature>();
96 AddStep<ci::security::StepPrivilegeCompatibility>();
97 AddStep<wgt::security::StepCheckSettingsLevel>();
98 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
99 AddStep<wgt::security::StepCheckWgtNotificationCategory>();
100 AddStep<wgt::security::StepCheckWgtImePrivilege>();
101 AddStep<wgt::encryption::StepEncryptResources>();
102 AddStep<wgt::filesystem::StepWgtResourceDirectory>();
103 AddStep<ci::security::StepRollbackInstallationSecurity>();
104 AddStep<ci::filesystem::StepCopy>();
105 AddStep<ci::filesystem::StepCopyTep>();
106 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
107 AddStep<ci::filesystem::StepCreateStorageDirectories>();
108 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
109 AddStep<wgt::filesystem::StepWgtPatchIcons>();
110 AddStep<ci::filesystem::StepCreateIcons>();
111 AddStep<wgt::pkgmgr::StepGenerateXml>();
112 AddStep<ci::pkgmgr::StepRegisterApplication>();
113 AddStep<ci::pkgmgr::StepRunParserPlugin>(
114 ci::Plugin::ActionType::Install);
115 AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>();
116 AddStep<ci::security::StepRegisterSecurity>();
119 case ci::RequestType::Update: {
120 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
121 AddStep<ci::filesystem::StepUnzip>();
122 AddStep<wgt::configuration::StepParse>(true);
123 AddStep<ci::pkgmgr::StepCheckBlacklist>();
124 AddStep<ci::security::StepCheckSignature>();
125 AddStep<ci::security::StepPrivilegeCompatibility>();
126 AddStep<wgt::security::StepCheckSettingsLevel>();
127 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
128 AddStep<wgt::security::StepCheckWgtNotificationCategory>();
129 AddStep<wgt::security::StepCheckWgtImePrivilege>();
130 AddStep<ci::security::StepCheckOldCertificate>();
131 AddStep<wgt::filesystem::StepWgtResourceDirectory>();
132 AddStep<ci::configuration::StepParseManifest>(
133 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
134 ci::configuration::StepParseManifest::StoreLocation::BACKUP);
135 AddStep<ci::configuration::StepBlockCrossUpdate>();
136 AddStep<ci::pkgmgr::StepKillApps>();
137 AddStep<ci::backup::StepBackupManifest>();
138 AddStep<ci::backup::StepBackupIcons>();
139 AddStep<ci::backup::StepCopyBackup>();
140 AddStep<ci::filesystem::StepCopyTep>();
141 AddStep<ci::pkgmgr::StepUpdateTep>();
142 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
143 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
144 AddStep<wgt::filesystem::StepWgtPatchIcons>();
145 AddStep<ci::filesystem::StepCreateIcons>();
146 AddStep<ci::filesystem::StepCopyStorageDirectories>();
147 AddStep<ci::security::StepUpdateSecurity>();
148 AddStep<wgt::pkgmgr::StepGenerateXml>();
149 AddStep<ci::pkgmgr::StepRunParserPlugin>(
150 ci::Plugin::ActionType::Upgrade);
151 AddStep<ci::pkgmgr::StepUpdateApplication>();
154 case ci::RequestType::Uninstall: {
155 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
156 AddStep<ci::pkgmgr::StepCheckRemovable>();
157 AddStep<ci::configuration::StepParseManifest>(
158 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
159 ci::configuration::StepParseManifest::StoreLocation::NORMAL);
160 AddStep<ci::pkgmgr::StepKillApps>();
161 AddStep<ci::pkgmgr::StepRunParserPlugin>(
162 ci::Plugin::ActionType::Uninstall);
163 AddStep<ci::filesystem::StepRemovePerUserStorageDirectories>();
164 AddStep<ci::pkgmgr::StepUnregisterApplication>();
165 AddStep<ci::security::StepRollbackDeinstallationSecurity>();
166 AddStep<ci::filesystem::StepRemoveFiles>();
167 AddStep<ci::filesystem::StepRemoveZipImage>();
168 AddStep<ci::filesystem::StepRemoveIcons>();
169 AddStep<wgt::encryption::StepRemoveEncryptionData>();
170 AddStep<ci::security::StepRevokeSecurity>();
171 AddStep<ci::pkgmgr::StepRemoveManifest>();
174 case ci::RequestType::Reinstall: {
175 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
176 AddStep<wgt::configuration::StepParse>(false);
177 AddStep<ci::pkgmgr::StepKillApps>();
178 AddStep<ci::configuration::StepParseManifest>(
179 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
180 ci::configuration::StepParseManifest::StoreLocation::BACKUP);
181 AddStep<ci::configuration::StepBlockCrossUpdate>();
182 AddStep<ci::pkgmgr::StepCheckBlacklist>();
183 AddStep<ci::rds::StepRDSParse>();
184 AddStep<wgt::rds::StepWgtRDSModify>();
185 AddStep<ci::security::StepUpdateSecurity>();
188 case ci::RequestType::Delta: {
189 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
190 AddStep<ci::filesystem::StepUnzip>();
191 // TODO(t.iwanek): manifest is parsed twice...
192 AddStep<wgt::configuration::StepParse>(false);
193 // start file may not have changed
194 AddStep<ci::filesystem::StepDeltaPatch>("res/wgt/");
195 AddStep<wgt::configuration::StepParse>(true);
196 AddStep<ci::pkgmgr::StepCheckBlacklist>();
197 AddStep<ci::security::StepCheckSignature>();
198 AddStep<ci::security::StepPrivilegeCompatibility>();
199 AddStep<wgt::security::StepCheckSettingsLevel>();
200 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
201 AddStep<wgt::security::StepCheckWgtNotificationCategory>();
202 AddStep<wgt::security::StepCheckWgtImePrivilege>();
203 AddStep<ci::security::StepCheckOldCertificate>();
204 AddStep<wgt::filesystem::StepWgtResourceDirectory>();
205 AddStep<ci::configuration::StepParseManifest>(
206 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
207 ci::configuration::StepParseManifest::StoreLocation::BACKUP);
208 AddStep<ci::configuration::StepBlockCrossUpdate>();
209 AddStep<ci::pkgmgr::StepKillApps>();
210 AddStep<ci::backup::StepBackupManifest>();
211 AddStep<ci::backup::StepBackupIcons>();
212 AddStep<ci::backup::StepCopyBackup>();
213 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
214 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
215 AddStep<wgt::filesystem::StepWgtPatchIcons>();
216 AddStep<ci::filesystem::StepCreateIcons>();
217 AddStep<ci::filesystem::StepCopyStorageDirectories>();
218 AddStep<ci::security::StepUpdateSecurity>();
219 AddStep<wgt::pkgmgr::StepGenerateXml>();
220 AddStep<ci::pkgmgr::StepRunParserPlugin>(
221 ci::Plugin::ActionType::Upgrade);
222 AddStep<ci::pkgmgr::StepUpdateApplication>();
225 case ci::RequestType::Recovery: {
226 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
227 AddStep<ci::recovery::StepOpenRecoveryFile>();
228 AddStep<wgt::configuration::StepParseRecovery>();
229 AddStep<ci::pkgmgr::StepRecoverApplication>();
230 AddStep<ci::filesystem::StepRemoveTemporaryDirectory>();
231 AddStep<ci::filesystem::StepRecoverIcons>();
232 AddStep<ci::filesystem::StepRecoverManifest>();
233 AddStep<ci::filesystem::StepRecoverStorageDirectories>();
234 AddStep<ci::filesystem::StepRecoverFiles>();
235 AddStep<ci::security::StepRecoverSecurity>();
238 case ci::RequestType::Clear: {
239 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
240 AddStep<ci::filesystem::StepClearData>();
243 case ci::RequestType::MountInstall: {
244 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
245 AddStep<ci::mount::StepMountUnpacked>();
246 AddStep<wgt::configuration::StepParse>(true);
247 AddStep<ci::pkgmgr::StepCheckBlacklist>();
248 AddStep<ci::security::StepCheckSignature>();
249 AddStep<ci::security::StepPrivilegeCompatibility>();
250 AddStep<wgt::security::StepCheckSettingsLevel>();
251 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
252 AddStep<wgt::security::StepCheckWgtNotificationCategory>();
253 AddStep<wgt::security::StepCheckWgtImePrivilege>();
254 AddStep<wgt::encryption::StepEncryptResources>();
255 AddStep<ci::security::StepRollbackInstallationSecurity>();
256 AddStep<ci::mount::StepMountInstall>();
257 AddStep<wgt::filesystem::StepWgtPreparePackageDirectory>();
258 AddStep<ci::filesystem::StepCopyTep>();
259 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
260 AddStep<ci::filesystem::StepCreateStorageDirectories>();
261 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
262 AddStep<wgt::filesystem::StepWgtPatchIcons>();
263 AddStep<ci::filesystem::StepCreateIcons>();
264 AddStep<wgt::pkgmgr::StepGenerateXml>();
265 AddStep<ci::pkgmgr::StepRegisterApplication>();
266 AddStep<ci::pkgmgr::StepRunParserPlugin>(
267 ci::Plugin::ActionType::Install);
268 AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>();
269 AddStep<ci::security::StepRegisterSecurity>();
272 case ci::RequestType::MountUpdate: {
273 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
274 AddStep<ci::mount::StepMountUnpacked>();
275 AddStep<wgt::configuration::StepParse>(true);
276 AddStep<ci::pkgmgr::StepCheckBlacklist>();
277 AddStep<ci::security::StepCheckSignature>();
278 AddStep<ci::security::StepPrivilegeCompatibility>();
279 AddStep<wgt::security::StepCheckSettingsLevel>();
280 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
281 AddStep<wgt::security::StepCheckWgtNotificationCategory>();
282 AddStep<wgt::security::StepCheckWgtImePrivilege>();
283 AddStep<ci::security::StepCheckOldCertificate>();
284 AddStep<ci::configuration::StepParseManifest>(
285 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
286 ci::configuration::StepParseManifest::StoreLocation::BACKUP);
287 AddStep<ci::configuration::StepBlockCrossUpdate>();
288 AddStep<ci::pkgmgr::StepKillApps>();
289 AddStep<ci::backup::StepBackupManifest>();
290 AddStep<ci::backup::StepBackupIcons>();
291 AddStep<ci::mount::StepMountUpdate>();
292 AddStep<wgt::filesystem::StepWgtUpdatePackageDirectory>();
293 AddStep<ci::filesystem::StepCopyTep>();
294 AddStep<ci::pkgmgr::StepUpdateTep>();
295 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
296 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
297 AddStep<wgt::filesystem::StepWgtPatchIcons>();
298 AddStep<ci::filesystem::StepCreateIcons>();
299 AddStep<ci::security::StepUpdateSecurity>();
300 AddStep<wgt::pkgmgr::StepGenerateXml>();
301 AddStep<ci::pkgmgr::StepRunParserPlugin>(
302 ci::Plugin::ActionType::Upgrade);
303 AddStep<ci::pkgmgr::StepUpdateApplication>();
307 AddStep<ci::configuration::StepFail>();