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_revoke_security.h>
36 #include <common/step/step_register_security.h>
37 #include <common/step/step_rollback_deinstallation_security.h>
38 #include <common/step/step_rollback_installation_security.h>
39 #include <common/step/step_run_parser_plugins.h>
40 #include <common/step/step_check_signature.h>
41 #include <common/step/step_unregister_app.h>
42 #include <common/step/step_unzip.h>
43 #include <common/step/step_update_app.h>
44 #include <common/step/step_update_security.h>
45 #include <common/step/step_check_old_certificate.h>
46 #include <common/step/step_remove_manifest.h>
48 #include <wgt_manifest_handlers/widget_config_parser.h>
49 #include "wgt/step/step_add_default_privileges.h"
50 #include "wgt/step/step_check_settings_level.h"
51 #include "wgt/step/step_check_wgt_background_category.h"
52 #include "wgt/step/step_create_symbolic_link.h"
53 #include "wgt/step/step_encrypt_resources.h"
54 #include "wgt/step/step_generate_xml.h"
55 #include "wgt/step/step_parse.h"
56 #include "wgt/step/step_parse_recovery.h"
57 #include "wgt/step/step_rds_modify.h"
58 #include "wgt/step/step_rds_parse.h"
59 #include "wgt/step/step_remove_encryption_data.h"
60 #include "wgt/step/step_wgt_patch_icons.h"
61 #include "wgt/step/step_wgt_patch_storage_directories.h"
62 #include "wgt/step/step_wgt_resource_directory.h"
64 namespace ci = common_installer;
68 WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
69 : AppInstaller("wgt", pkgrmgr) {
70 context_->backend_data.set(new WgtBackendData());
72 /* treat the request */
73 switch (pkgmgr_->GetRequestType()) {
74 case ci::RequestType::Install : {
75 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
76 AddStep<ci::filesystem::StepUnzip>();
77 AddStep<wgt::parse::StepParse>(true);
78 AddStep<ci::blacklist::StepCheckBlacklist>();
79 AddStep<ci::security::StepCheckSignature>();
80 AddStep<ci::security::StepPrivilegeCompatibility>();
81 AddStep<wgt::security::StepCheckSettingsLevel>();
82 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
83 AddStep<wgt::encrypt::StepEncryptResources>();
84 AddStep<wgt::filesystem::StepWgtResourceDirectory>();
85 AddStep<ci::security::StepRollbackInstallationSecurity>();
86 AddStep<ci::filesystem::StepCopy>();
87 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
88 AddStep<ci::filesystem::StepCreateStorageDirectories>();
89 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
90 AddStep<wgt::filesystem::StepWgtPatchIcons>();
91 AddStep<ci::filesystem::StepCreateIcons>();
92 AddStep<wgt::pkgmgr::StepGenerateXml>();
93 AddStep<ci::pkgmgr::StepRegisterApplication>();
94 AddStep<ci::pkgmgr::StepRunParserPlugin>(
95 ci::PluginsLauncher::ActionType::Install);
96 AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>();
97 AddStep<ci::security::StepRegisterSecurity>();
100 case ci::RequestType::Update: {
101 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
102 AddStep<ci::filesystem::StepUnzip>();
103 AddStep<wgt::parse::StepParse>(true);
104 AddStep<ci::blacklist::StepCheckBlacklist>();
105 AddStep<ci::security::StepCheckSignature>();
106 AddStep<ci::security::StepPrivilegeCompatibility>();
107 AddStep<wgt::security::StepCheckSettingsLevel>();
108 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
109 AddStep<ci::security::StepCheckOldCertificate>();
110 AddStep<wgt::filesystem::StepWgtResourceDirectory>();
111 AddStep<ci::parse::StepParseManifest>(
112 ci::parse::StepParseManifest::ManifestLocation::INSTALLED,
113 ci::parse::StepParseManifest::StoreLocation::BACKUP);
114 AddStep<ci::pkgmgr::StepKillApps>();
115 AddStep<ci::backup::StepBackupManifest>();
116 AddStep<ci::backup::StepBackupIcons>();
117 AddStep<ci::backup::StepCopyBackup>();
118 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
119 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
120 AddStep<wgt::filesystem::StepWgtPatchIcons>();
121 AddStep<ci::filesystem::StepCreateIcons>();
122 AddStep<ci::filesystem::StepCopyStorageDirectories>();
123 AddStep<ci::security::StepUpdateSecurity>();
124 AddStep<wgt::pkgmgr::StepGenerateXml>();
125 AddStep<ci::pkgmgr::StepRunParserPlugin>(
126 ci::PluginsLauncher::ActionType::Upgrade);
127 AddStep<ci::pkgmgr::StepUpdateApplication>();
130 case ci::RequestType::Uninstall: {
131 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
132 AddStep<ci::parse::StepParseManifest>(
133 ci::parse::StepParseManifest::ManifestLocation::INSTALLED,
134 ci::parse::StepParseManifest::StoreLocation::NORMAL);
135 AddStep<ci::pkgmgr::StepKillApps>();
136 AddStep<ci::pkgmgr::StepRunParserPlugin>(
137 ci::PluginsLauncher::ActionType::Uninstall);
138 AddStep<ci::pkgmgr::StepUnregisterApplication>();
139 AddStep<ci::security::StepRollbackDeinstallationSecurity>();
140 AddStep<ci::filesystem::StepRemoveFiles>();
141 AddStep<ci::filesystem::StepRemoveIcons>();
142 AddStep<wgt::encrypt::StepRemoveEncryptionData>();
143 AddStep<ci::security::StepRevokeSecurity>();
144 AddStep<ci::pkgmgr::StepRemoveManifest>();
147 case ci::RequestType::Reinstall: {
148 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
149 AddStep<wgt::parse::StepParse>(false);
150 AddStep<ci::pkgmgr::StepKillApps>();
151 AddStep<ci::parse::StepParseManifest>(
152 ci::parse::StepParseManifest::ManifestLocation::INSTALLED,
153 ci::parse::StepParseManifest::StoreLocation::BACKUP);
154 AddStep<ci::blacklist::StepCheckBlacklist>();
155 AddStep<wgt::rds::StepRDSParse>();
156 AddStep<wgt::rds::StepRDSModify>();
157 AddStep<ci::security::StepUpdateSecurity>();
160 case ci::RequestType::Delta: {
161 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
162 AddStep<ci::filesystem::StepUnzip>();
163 // TODO(t.iwanek): manifest is parsed twice...
164 AddStep<wgt::parse::StepParse>(false); // start file may not have changed
165 AddStep<ci::filesystem::StepDeltaPatch>("res/wgt/");
166 AddStep<wgt::parse::StepParse>(true);
167 AddStep<ci::blacklist::StepCheckBlacklist>();
168 AddStep<ci::security::StepCheckSignature>();
169 AddStep<ci::security::StepPrivilegeCompatibility>();
170 AddStep<wgt::security::StepCheckSettingsLevel>();
171 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
172 AddStep<ci::security::StepCheckOldCertificate>();
173 AddStep<wgt::filesystem::StepWgtResourceDirectory>();
174 AddStep<ci::parse::StepParseManifest>(
175 ci::parse::StepParseManifest::ManifestLocation::INSTALLED,
176 ci::parse::StepParseManifest::StoreLocation::BACKUP);
177 AddStep<ci::pkgmgr::StepKillApps>();
178 AddStep<ci::backup::StepBackupManifest>();
179 AddStep<ci::backup::StepBackupIcons>();
180 AddStep<ci::backup::StepCopyBackup>();
181 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
182 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
183 AddStep<wgt::filesystem::StepWgtPatchIcons>();
184 AddStep<ci::filesystem::StepCreateIcons>();
185 AddStep<ci::filesystem::StepCopyStorageDirectories>();
186 AddStep<ci::security::StepUpdateSecurity>();
187 AddStep<wgt::pkgmgr::StepGenerateXml>();
188 AddStep<ci::pkgmgr::StepRunParserPlugin>(
189 ci::PluginsLauncher::ActionType::Upgrade);
190 AddStep<ci::pkgmgr::StepUpdateApplication>();
193 case ci::RequestType::Recovery: {
194 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
195 AddStep<ci::recovery::StepOpenRecoveryFile>();
196 AddStep<wgt::parse::StepParseRecovery>();
197 AddStep<ci::pkgmgr::StepRecoverApplication>();
198 AddStep<ci::filesystem::StepRemoveTemporaryDirectory>();
199 AddStep<ci::filesystem::StepRecoverIcons>();
200 AddStep<ci::filesystem::StepRecoverManifest>();
201 AddStep<ci::filesystem::StepRecoverStorageDirectories>();
202 AddStep<ci::filesystem::StepRecoverFiles>();
203 AddStep<ci::security::StepRecoverSecurity>();
206 case ci::RequestType::Clear: {
207 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
208 AddStep<ci::filesystem::StepClearData>();
212 AddStep<ci::configuration::StepFail>();