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_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_clear_data.h>
16 #include <common/step/filesystem/step_copy.h>
17 #include <common/step/filesystem/step_copy_storage_directories.h>
18 #include <common/step/filesystem/step_copy_tep.h>
19 #include <common/step/filesystem/step_create_icons.h>
20 #include <common/step/filesystem/step_create_per_user_storage_directories.h>
21 #include <common/step/filesystem/step_create_storage_directories.h>
22 #include <common/step/filesystem/step_delta_patch.h>
23 #include <common/step/filesystem/step_recover_files.h>
24 #include <common/step/filesystem/step_recover_icons.h>
25 #include <common/step/filesystem/step_recover_manifest.h>
26 #include <common/step/filesystem/step_recover_storage_directories.h>
27 #include <common/step/filesystem/step_remove_files.h>
28 #include <common/step/filesystem/step_remove_icons.h>
29 #include <common/step/filesystem/step_remove_per_user_storage_directories.h>
30 #include <common/step/filesystem/step_remove_temporary_directory.h>
31 #include <common/step/filesystem/step_unzip.h>
32 #include <common/step/pkgmgr/step_check_blacklist.h>
33 #include <common/step/pkgmgr/step_check_removable.h>
34 #include <common/step/pkgmgr/step_kill_apps.h>
35 #include <common/step/pkgmgr/step_recover_application.h>
36 #include <common/step/pkgmgr/step_register_app.h>
37 #include <common/step/pkgmgr/step_remove_manifest.h>
38 #include <common/step/pkgmgr/step_run_parser_plugins.h>
39 #include <common/step/pkgmgr/step_unregister_app.h>
40 #include <common/step/pkgmgr/step_update_app.h>
41 #include <common/step/pkgmgr/step_update_tep.h>
42 #include <common/step/recovery/step_open_recovery_file.h>
43 #include <common/step/security/step_check_old_certificate.h>
44 #include <common/step/security/step_check_signature.h>
45 #include <common/step/security/step_privilege_compatibility.h>
46 #include <common/step/security/step_recover_security.h>
47 #include <common/step/security/step_register_security.h>
48 #include <common/step/security/step_revoke_security.h>
49 #include <common/step/security/step_rollback_deinstallation_security.h>
50 #include <common/step/security/step_rollback_installation_security.h>
51 #include <common/step/security/step_update_security.h>
53 #include <wgt_manifest_handlers/widget_config_parser.h>
54 #include <common/step/rds/step_rds_modify.h>
55 #include <common/step/rds/step_rds_parse.h>
57 #include "wgt/step/configuration/step_parse.h"
58 #include "wgt/step/configuration/step_parse_recovery.h"
59 #include "wgt/step/encryption/step_encrypt_resources.h"
60 #include "wgt/step/encryption/step_remove_encryption_data.h"
61 #include "wgt/step/filesystem/step_create_symbolic_link.h"
62 #include "wgt/step/filesystem/step_wgt_patch_icons.h"
63 #include "wgt/step/filesystem/step_wgt_patch_storage_directories.h"
64 #include "wgt/step/filesystem/step_wgt_resource_directory.h"
65 #include "wgt/step/pkgmgr/step_generate_xml.h"
66 #include "wgt/step/rds/step_wgt_rds_modify.h"
67 #include "wgt/step/security/step_add_default_privileges.h"
68 #include "wgt/step/security/step_check_settings_level.h"
69 #include "wgt/step/security/step_check_wgt_background_category.h"
71 namespace ci = common_installer;
75 WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
76 : AppInstaller("wgt", pkgrmgr) {
77 context_->backend_data.set(new WgtBackendData());
79 /* treat the request */
80 switch (pkgmgr_->GetRequestType()) {
81 case ci::RequestType::Install : {
82 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
83 AddStep<ci::filesystem::StepUnzip>();
84 AddStep<wgt::configuration::StepParse>(true);
85 AddStep<ci::pkgmgr::StepCheckBlacklist>();
86 AddStep<ci::security::StepCheckSignature>();
87 AddStep<ci::security::StepPrivilegeCompatibility>();
88 AddStep<wgt::security::StepCheckSettingsLevel>();
89 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
90 AddStep<wgt::encryption::StepEncryptResources>();
91 AddStep<wgt::filesystem::StepWgtResourceDirectory>();
92 AddStep<ci::security::StepRollbackInstallationSecurity>();
93 AddStep<ci::filesystem::StepCopy>();
94 AddStep<ci::filesystem::StepCopyTep>();
95 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
96 AddStep<ci::filesystem::StepCreateStorageDirectories>();
97 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
98 AddStep<wgt::filesystem::StepWgtPatchIcons>();
99 AddStep<ci::filesystem::StepCreateIcons>();
100 AddStep<wgt::pkgmgr::StepGenerateXml>();
101 AddStep<ci::pkgmgr::StepRegisterApplication>();
102 AddStep<ci::pkgmgr::StepRunParserPlugin>(
103 ci::Plugin::ActionType::Install);
104 AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>();
105 AddStep<ci::security::StepRegisterSecurity>();
108 case ci::RequestType::Update: {
109 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
110 AddStep<ci::filesystem::StepUnzip>();
111 AddStep<wgt::configuration::StepParse>(true);
112 AddStep<ci::pkgmgr::StepCheckBlacklist>();
113 AddStep<ci::security::StepCheckSignature>();
114 AddStep<ci::security::StepPrivilegeCompatibility>();
115 AddStep<wgt::security::StepCheckSettingsLevel>();
116 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
117 AddStep<ci::security::StepCheckOldCertificate>();
118 AddStep<wgt::filesystem::StepWgtResourceDirectory>();
119 AddStep<ci::configuration::StepParseManifest>(
120 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
121 ci::configuration::StepParseManifest::StoreLocation::BACKUP);
122 AddStep<ci::pkgmgr::StepKillApps>();
123 AddStep<ci::backup::StepBackupManifest>();
124 AddStep<ci::backup::StepBackupIcons>();
125 AddStep<ci::backup::StepCopyBackup>();
126 AddStep<ci::filesystem::StepCopyTep>();
127 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
128 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
129 AddStep<wgt::filesystem::StepWgtPatchIcons>();
130 AddStep<ci::filesystem::StepCreateIcons>();
131 AddStep<ci::filesystem::StepCopyStorageDirectories>();
132 AddStep<ci::security::StepUpdateSecurity>();
133 AddStep<wgt::pkgmgr::StepGenerateXml>();
134 AddStep<ci::pkgmgr::StepRunParserPlugin>(
135 ci::Plugin::ActionType::Upgrade);
136 AddStep<ci::pkgmgr::StepUpdateApplication>();
137 // TODO(t.iwanek): this step is supposed to be removed as it is quickfix
138 AddStep<ci::pkgmgr::StepUpdateTep>();
141 case ci::RequestType::Uninstall: {
142 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
143 AddStep<ci::pkgmgr::StepCheckRemovable>();
144 AddStep<ci::configuration::StepParseManifest>(
145 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
146 ci::configuration::StepParseManifest::StoreLocation::NORMAL);
147 AddStep<ci::pkgmgr::StepKillApps>();
148 AddStep<ci::pkgmgr::StepRunParserPlugin>(
149 ci::Plugin::ActionType::Uninstall);
150 AddStep<ci::filesystem::StepRemovePerUserStorageDirectories>();
151 AddStep<ci::pkgmgr::StepUnregisterApplication>();
152 AddStep<ci::security::StepRollbackDeinstallationSecurity>();
153 AddStep<ci::filesystem::StepRemoveFiles>();
154 AddStep<ci::filesystem::StepRemoveIcons>();
155 AddStep<wgt::encryption::StepRemoveEncryptionData>();
156 AddStep<ci::security::StepRevokeSecurity>();
157 AddStep<ci::pkgmgr::StepRemoveManifest>();
160 case ci::RequestType::Reinstall: {
161 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
162 AddStep<wgt::configuration::StepParse>(false);
163 AddStep<ci::pkgmgr::StepKillApps>();
164 AddStep<ci::configuration::StepParseManifest>(
165 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
166 ci::configuration::StepParseManifest::StoreLocation::BACKUP);
167 AddStep<ci::pkgmgr::StepCheckBlacklist>();
168 AddStep<ci::rds::StepRDSParse>();
169 AddStep<wgt::rds::StepWgtRDSModify>();
170 AddStep<ci::security::StepUpdateSecurity>();
173 case ci::RequestType::Delta: {
174 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
175 AddStep<ci::filesystem::StepUnzip>();
176 // TODO(t.iwanek): manifest is parsed twice...
177 AddStep<wgt::configuration::StepParse>(false);
178 // start file may not have changed
179 AddStep<ci::filesystem::StepDeltaPatch>("res/wgt/");
180 AddStep<wgt::configuration::StepParse>(true);
181 AddStep<ci::pkgmgr::StepCheckBlacklist>();
182 AddStep<ci::security::StepCheckSignature>();
183 AddStep<ci::security::StepPrivilegeCompatibility>();
184 AddStep<wgt::security::StepCheckSettingsLevel>();
185 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
186 AddStep<ci::security::StepCheckOldCertificate>();
187 AddStep<wgt::filesystem::StepWgtResourceDirectory>();
188 AddStep<ci::configuration::StepParseManifest>(
189 ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
190 ci::configuration::StepParseManifest::StoreLocation::BACKUP);
191 AddStep<ci::pkgmgr::StepKillApps>();
192 AddStep<ci::backup::StepBackupManifest>();
193 AddStep<ci::backup::StepBackupIcons>();
194 AddStep<ci::backup::StepCopyBackup>();
195 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
196 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
197 AddStep<wgt::filesystem::StepWgtPatchIcons>();
198 AddStep<ci::filesystem::StepCreateIcons>();
199 AddStep<ci::filesystem::StepCopyStorageDirectories>();
200 AddStep<ci::security::StepUpdateSecurity>();
201 AddStep<wgt::pkgmgr::StepGenerateXml>();
202 AddStep<ci::pkgmgr::StepRunParserPlugin>(
203 ci::Plugin::ActionType::Upgrade);
204 AddStep<ci::pkgmgr::StepUpdateApplication>();
207 case ci::RequestType::Recovery: {
208 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
209 AddStep<ci::recovery::StepOpenRecoveryFile>();
210 AddStep<wgt::configuration::StepParseRecovery>();
211 AddStep<ci::pkgmgr::StepRecoverApplication>();
212 AddStep<ci::filesystem::StepRemoveTemporaryDirectory>();
213 AddStep<ci::filesystem::StepRecoverIcons>();
214 AddStep<ci::filesystem::StepRecoverManifest>();
215 AddStep<ci::filesystem::StepRecoverStorageDirectories>();
216 AddStep<ci::filesystem::StepRecoverFiles>();
217 AddStep<ci::security::StepRecoverSecurity>();
220 case ci::RequestType::Clear: {
221 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
222 AddStep<ci::filesystem::StepClearData>();
226 AddStep<ci::configuration::StepFail>();