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