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_copy.h>
15 #include <common/step/step_copy_backup.h>
16 #include <common/step/step_copy_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_open_recovery_file.h>
21 #include <common/step/step_parse_manifest.h>
22 #include <common/step/step_privilege_compatibility.h>
23 #include <common/step/step_register_app.h>
24 #include <common/step/step_recover_application.h>
25 #include <common/step/step_recover_files.h>
26 #include <common/step/step_recover_icons.h>
27 #include <common/step/step_recover_manifest.h>
28 #include <common/step/step_recover_security.h>
29 #include <common/step/step_recover_storage_directories.h>
30 #include <common/step/step_remove_icons.h>
31 #include <common/step/step_remove_files.h>
32 #include <common/step/step_remove_temporary_directory.h>
33 #include <common/step/step_revoke_security.h>
34 #include <common/step/step_register_security.h>
35 #include <common/step/step_rollback_deinstallation_security.h>
36 #include <common/step/step_rollback_installation_security.h>
37 #include <common/step/step_check_signature.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_check_old_certificate.h>
44 #include <wgt_manifest_handlers/widget_config_parser.h>
46 #include "wgt/step/step_add_default_privileges.h"
47 #include "wgt/step/step_check_settings_level.h"
48 #include "wgt/step/step_check_wgt_background_category.h"
49 #include "wgt/step/step_create_symbolic_link.h"
50 #include "wgt/step/step_encrypt_resources.h"
51 #include "wgt/step/step_generate_xml.h"
52 #include "wgt/step/step_parse.h"
53 #include "wgt/step/step_parse_recovery.h"
54 #include "wgt/step/step_rds_modify.h"
55 #include "wgt/step/step_rds_parse.h"
56 #include "wgt/step/step_remove_encryption_data.h"
57 #include "wgt/step/step_wgt_patch_icons.h"
58 #include "wgt/step/step_wgt_patch_storage_directories.h"
59 #include "wgt/step/step_wgt_resource_directory.h"
61 namespace ci = common_installer;
65 WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
66 : AppInstaller("wgt", pkgrmgr) {
67 context_->backend_data.set(new WgtBackendData());
69 /* treat the request */
70 switch (pkgmgr_->GetRequestType()) {
71 case ci::RequestType::Install : {
72 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
73 AddStep<ci::filesystem::StepUnzip>();
74 AddStep<wgt::parse::StepParse>(true);
75 AddStep<ci::blacklist::StepCheckBlacklist>();
76 AddStep<ci::security::StepCheckSignature>();
77 AddStep<ci::security::StepPrivilegeCompatibility>();
78 AddStep<wgt::security::StepCheckSettingsLevel>();
79 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
80 AddStep<wgt::encrypt::StepEncryptResources>();
81 AddStep<wgt::filesystem::StepWgtResourceDirectory>();
82 AddStep<ci::security::StepRollbackInstallationSecurity>();
83 AddStep<ci::filesystem::StepCopy>();
84 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
85 AddStep<ci::filesystem::StepCreateStorageDirectories>();
86 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
87 AddStep<wgt::filesystem::StepWgtPatchIcons>();
88 AddStep<ci::filesystem::StepCreateIcons>();
89 AddStep<wgt::pkgmgr::StepGenerateXml>();
90 AddStep<ci::pkgmgr::StepRegisterApplication>();
91 AddStep<ci::security::StepRegisterSecurity>();
94 case ci::RequestType::Update: {
95 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
96 AddStep<ci::filesystem::StepUnzip>();
97 AddStep<wgt::parse::StepParse>(true);
98 AddStep<ci::blacklist::StepCheckBlacklist>();
99 AddStep<ci::security::StepCheckSignature>();
100 AddStep<ci::security::StepPrivilegeCompatibility>();
101 AddStep<wgt::security::StepCheckSettingsLevel>();
102 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
103 AddStep<ci::security::StepCheckOldCertificate>();
104 AddStep<wgt::filesystem::StepWgtResourceDirectory>();
105 AddStep<ci::parse::StepParseManifest>(
106 ci::parse::StepParseManifest::ManifestLocation::INSTALLED,
107 ci::parse::StepParseManifest::StoreLocation::BACKUP);
108 AddStep<ci::pkgmgr::StepKillApps>();
109 AddStep<ci::backup::StepBackupManifest>();
110 AddStep<ci::backup::StepBackupIcons>();
111 AddStep<ci::backup::StepCopyBackup>();
112 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
113 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
114 AddStep<wgt::filesystem::StepWgtPatchIcons>();
115 AddStep<ci::filesystem::StepCreateIcons>();
116 AddStep<ci::filesystem::StepCopyStorageDirectories>();
117 AddStep<ci::security::StepUpdateSecurity>();
118 AddStep<wgt::pkgmgr::StepGenerateXml>();
119 AddStep<ci::pkgmgr::StepUpdateApplication>();
122 case ci::RequestType::Uninstall: {
123 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
124 AddStep<ci::parse::StepParseManifest>(
125 ci::parse::StepParseManifest::ManifestLocation::INSTALLED,
126 ci::parse::StepParseManifest::StoreLocation::NORMAL);
127 AddStep<ci::pkgmgr::StepKillApps>();
128 AddStep<ci::backup::StepBackupManifest>();
129 AddStep<ci::pkgmgr::StepUnregisterApplication>();
130 AddStep<ci::security::StepRollbackDeinstallationSecurity>();
131 AddStep<ci::filesystem::StepRemoveFiles>();
132 AddStep<ci::filesystem::StepRemoveIcons>();
133 AddStep<wgt::encrypt::StepRemoveEncryptionData>();
134 AddStep<ci::security::StepRevokeSecurity>();
137 case ci::RequestType::Reinstall: {
138 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
139 AddStep<wgt::parse::StepParse>(false);
140 AddStep<ci::pkgmgr::StepKillApps>();
141 AddStep<ci::parse::StepParseManifest>(
142 ci::parse::StepParseManifest::ManifestLocation::INSTALLED,
143 ci::parse::StepParseManifest::StoreLocation::BACKUP);
144 AddStep<ci::blacklist::StepCheckBlacklist>();
145 AddStep<wgt::rds::StepRDSParse>();
146 AddStep<wgt::rds::StepRDSModify>();
147 AddStep<ci::security::StepUpdateSecurity>();
150 case ci::RequestType::Delta: {
151 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
152 AddStep<ci::filesystem::StepUnzip>();
153 // TODO(t.iwanek): manifest is parsed twice...
154 AddStep<wgt::parse::StepParse>(false); // start file may not have changed
155 AddStep<ci::filesystem::StepDeltaPatch>("res/wgt/");
156 AddStep<wgt::parse::StepParse>(true);
157 AddStep<ci::blacklist::StepCheckBlacklist>();
158 AddStep<ci::security::StepCheckSignature>();
159 AddStep<ci::security::StepPrivilegeCompatibility>();
160 AddStep<wgt::security::StepCheckSettingsLevel>();
161 AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
162 AddStep<ci::security::StepCheckOldCertificate>();
163 AddStep<wgt::filesystem::StepWgtResourceDirectory>();
164 AddStep<ci::parse::StepParseManifest>(
165 ci::parse::StepParseManifest::ManifestLocation::INSTALLED,
166 ci::parse::StepParseManifest::StoreLocation::BACKUP);
167 AddStep<ci::pkgmgr::StepKillApps>();
168 AddStep<ci::backup::StepBackupManifest>();
169 AddStep<ci::backup::StepBackupIcons>();
170 AddStep<ci::backup::StepCopyBackup>();
171 AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
172 AddStep<wgt::filesystem::StepCreateSymbolicLink>();
173 AddStep<wgt::filesystem::StepWgtPatchIcons>();
174 AddStep<ci::filesystem::StepCreateIcons>();
175 AddStep<ci::filesystem::StepCopyStorageDirectories>();
176 AddStep<ci::security::StepUpdateSecurity>();
177 AddStep<wgt::pkgmgr::StepGenerateXml>();
178 AddStep<ci::pkgmgr::StepUpdateApplication>();
181 case ci::RequestType::Recovery: {
182 AddStep<ci::configuration::StepConfigure>(pkgmgr_);
183 AddStep<ci::recovery::StepOpenRecoveryFile>();
184 AddStep<wgt::parse::StepParseRecovery>();
185 AddStep<ci::pkgmgr::StepRecoverApplication>();
186 AddStep<ci::filesystem::StepRemoveTemporaryDirectory>();
187 AddStep<ci::filesystem::StepRecoverIcons>();
188 AddStep<ci::filesystem::StepRecoverManifest>();
189 AddStep<ci::filesystem::StepRecoverStorageDirectories>();
190 AddStep<ci::filesystem::StepRecoverFiles>();
191 AddStep<ci::security::StepRecoverSecurity>();
195 AddStep<ci::configuration::StepFail>();