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 "common/step/pkgmgr/step_recover_application.h"
7 #include <boost/filesystem.hpp>
9 #include "common/paths.h"
10 #include "common/pkgmgr_registration.h"
12 namespace bf = boost::filesystem;
14 namespace common_installer {
17 Step::Status StepRecoverApplication::RecoveryNew() {
20 if (context_->manifest_data.get())
21 UnregisterAppInPkgmgr(context_->manifest_data.get(),
22 context_->pkgid.get(),
24 context_->request_mode.get());
26 UnregisterAppInPkgmgrForPkgId(context_->pkgid.get(),
28 context_->request_mode.get());
32 Step::Status StepRecoverApplication::RecoveryUpdate() {
34 LOG(ERROR) << "Some parameters are lacking";
37 UnregisterAppInPkgmgr(context_->manifest_data.get(),
38 context_->pkgid.get(),
40 context_->request_mode.get());
41 if (!RegisterAppInPkgmgr(context_->manifest_data.get(),
42 context_->pkgid.get(),
43 context_->certificate_info.get(),
45 context_->storage.get(),
46 context_->request_mode.get(),
47 context_->tep_path.get())) {
48 LOG(ERROR) << "Unsuccessful app registration";
49 return Status::RECOVERY_ERROR;
54 Step::Status StepRecoverApplication::RecoveryReadonlyUpdateInstall() {
55 // Hmm... this is just-work solution...
56 manifest_x* manifest_data = context_->manifest_data.get();
57 free(manifest_data->system);
58 manifest_data->system = strdup("true");
59 free(manifest_data->preload);
60 manifest_data->preload = strdup("true");
61 free(manifest_data->readonly);
62 manifest_data->readonly = strdup("true");
63 free(manifest_data->removable);
64 manifest_data->removable = strdup("false");
65 return RecoveryUpdate();
68 bool StepRecoverApplication::SetXmlPaths() {
69 if (context_->pkgid.get().empty())
72 bf::path(getUserManifestPath(context_->uid.get(),
73 context_->is_readonly_package.get()))
74 / context_->pkgid.get();
76 context_->xml_path.set(xml_path);
77 context_->backup_xml_path.set(GetBackupPathForManifestFile(xml_path));
82 } // namespace common_installer