1 // Copyright (c) 2016 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/external_mount.h"
7 #include <app2ext_interface.h>
8 #include <manifest_parser/utils/logging.h>
12 #include "common/utils/pkgmgr_query.h"
13 #include "common/utils/paths.h"
15 namespace fs = std::filesystem;
17 namespace common_installer {
19 const char kInstalledExternally[] = "installed_external";
21 ExternalMount::ExternalMount(const std::string& pkgid, uid_t uid)
27 ExternalMount::~ExternalMount() {
29 if (service.DisableExternalPkgForUsr(pkgid_.c_str(), uid_)) {
30 LOG(ERROR) << "app2ext_usr_disable_external_pkg failed";
35 bool ExternalMount::IsAvailable() const {
36 fs::path storage_path = GetExternalCardPath();
37 if (!fs::exists(storage_path)) {
38 LOG(WARNING) << "External storage (SD Card) is not mounted.";
41 PkgQueryInterface pkg_query(pkgid_, uid_);
42 std::string storage = pkg_query.StorageForPkgId();
43 if (storage != kInstalledExternally)
49 bool ExternalMount::Mount() {
52 if (service.EnableExternalPkgForUsr(pkgid_.c_str(), uid_)) {
53 LOG(ERROR) << "app2ext_usr_enable_external_pkg failed";
60 bool ExternalMount::Umount() {
63 if (service.DisableExternalPkgForUsr(pkgid_.c_str(), uid_)) {
64 LOG(ERROR) << "app2ext_usr_disable_external_pkg failed";
71 } // namespace common_installer