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