summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHwankyu Jhun <h.jhun@samsung.com>2024-02-05 12:07:39 +0900
committerHwankyu Jhun <h.jhun@samsung.com>2024-02-05 13:10:29 +0900
commit9b8d8fd108240e8eb5ce92d54b43ab8eb5f9d454 (patch)
tree1af545a3f2388d4b50ac18edd7e7e6a17c0cd42c
parente342ffcb9b43878d5c2c6c47b660288c84733e1f (diff)
downloadaul-1-9b8d8fd108240e8eb5ce92d54b43ab8eb5f9d454.tar.gz
aul-1-9b8d8fd108240e8eb5ce92d54b43ab8eb5f9d454.tar.bz2
aul-1-9b8d8fd108240e8eb5ce92d54b43ab8eb5f9d454.zip
Remove storage library dependency
To remove loading capi-system-info library, this patch removes a libstorage dependency. Change-Id: Iae64e8373001b8638dde362f4c8739f370a3618c Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r--CMakeLists.txt1
-rw-r--r--packaging/aul.spec3
-rw-r--r--src/aul/CMakeLists.txt1
-rw-r--r--src/aul/app_info/external_directory_info.cc57
-rw-r--r--test/unit_tests/CMakeLists.txt1
5 files changed, 44 insertions, 19 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 73d81941..9da7ab42 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -58,7 +58,6 @@ PKG_CHECK_MODULES(PARCEL_DEPS REQUIRED parcel)
PKG_CHECK_MODULES(PKGMGR_INFO_DEPS REQUIRED pkgmgr-info)
PKG_CHECK_MODULES(PKGMGR_INSTALLER_DEPS REQUIRED pkgmgr-installer)
PKG_CHECK_MODULES(SQLITE3_DEPS REQUIRED sqlite3)
-PKG_CHECK_MODULES(STORAGE_DEPS REQUIRED storage)
PKG_CHECK_MODULES(TTRACE_DEPS REQUIRED ttrace)
PKG_CHECK_MODULES(UUID_DEPS REQUIRED uuid)
PKG_CHECK_MODULES(VCONF_DEPS REQUIRED vconf)
diff --git a/packaging/aul.spec b/packaging/aul.spec
index 00f1d4ba..8303c93b 100644
--- a/packaging/aul.spec
+++ b/packaging/aul.spec
@@ -33,12 +33,13 @@ BuildRequires: pkgconfig(parcel)
BuildRequires: pkgconfig(pkgmgr-info)
BuildRequires: pkgconfig(pkgmgr-installer)
BuildRequires: pkgconfig(sqlite3)
-BuildRequires: pkgconfig(storage)
BuildRequires: pkgconfig(ttrace)
BuildRequires: pkgconfig(uuid)
BuildRequires: pkgconfig(vconf)
BuildRequires: xdgmime-devel, pkgconfig(xdgmime)
+Requires: storage
+
%if 0%{?gcov:1}
BuildRequires: lcov
%endif
diff --git a/src/aul/CMakeLists.txt b/src/aul/CMakeLists.txt
index c4e8f07b..2d9de984 100644
--- a/src/aul/CMakeLists.txt
+++ b/src/aul/CMakeLists.txt
@@ -47,7 +47,6 @@ APPLY_PKG_CONFIG(${TARGET_AUL} PUBLIC
LIBTZPLATFORM_CONFIG_DEPS
PARCEL_DEPS
PKGMGR_INFO_DEPS
- STORAGE_DEPS
TTRACE_DEPS
UUID_DEPS
VCONF_DEPS
diff --git a/src/aul/app_info/external_directory_info.cc b/src/aul/app_info/external_directory_info.cc
index eb1fef95..8ed7c5b0 100644
--- a/src/aul/app_info/external_directory_info.cc
+++ b/src/aul/app_info/external_directory_info.cc
@@ -15,7 +15,7 @@
*
*/
-#include <storage-internal.h>
+#include <dlfcn.h>
#include <sys/types.h>
#include <tzplatform_config.h>
#include <unistd.h>
@@ -31,27 +31,54 @@
namespace aul {
namespace {
+constexpr const char kPathLibStorage[] = "/usr/lib/libstorage.so.0.1";
constexpr const char kDefaultExternalStorage[] = "/opt/media/sdcard";
constexpr const char kDataDir[] = "data/";
constexpr const char kCacheDir[] = "cache/";
constexpr const char kSharedDataDir[] = "shared/data/";
-std::string GetSdCardPath() {
- int storage_id = 0;
- char* path = nullptr;
- int ret = storage_get_primary_sdcard(&storage_id, &path);
- if (ret != STORAGE_ERROR_NONE)
- _W("Failed to get primary sdcard. error(%d)", ret);
-
- auto ptr = std::unique_ptr<char, decltype(std::free)*>(path, std::free);
- if (path)
- return std::string(path);
-
- return std::string(kDefaultExternalStorage);
-}
+class Storage {
+ public:
+ Storage() {
+ handle_ = dlopen(kPathLibStorage, RTLD_LAZY | RTLD_LOCAL);
+ if (handle_ == nullptr)
+ _E("dlopen() is failed. error(%s)", dlerror());
+ }
+
+ ~Storage() {
+ if (handle_) dlclose(handle_);
+ }
+
+ std::string GetPrimarySdcard() {
+ if (handle_ == nullptr) return {};
+
+ int (*storage_get_primary_sdcard_func)(int*, char**) =
+ reinterpret_cast<int (*)(int*, char**)>(
+ dlsym(handle_, "storage_get_primary_sdcard"));
+ if (storage_get_primary_sdcard_func == nullptr) {
+ _E("dlsym() is failed");
+ return {};
+ }
+
+ int storage_id = 0;
+ char* path = nullptr;
+ int ret = storage_get_primary_sdcard_func(&storage_id, &path);
+ if (ret != 0)
+ _E("storage_get_primary_sdcard() is failed. error(%d)", ret);
+
+ auto path_auto = std::unique_ptr<char, decltype(std::free)*>(path, free);
+ if (path) return std::string(path);
+
+ return std::string(kDefaultExternalStorage);
+ }
+
+ private:
+ void* handle_;
+};
std::string GetExternalPath(const std::string& pkg_id, uid_t uid) {
- std::string sdcard_path = GetSdCardPath();
+ Storage storage;
+ std::string sdcard_path = storage.GetPrimarySdcard();
tzplatform_set_user(uid);
std::string path = sdcard_path + "/apps/" +
std::string(tzplatform_getenv(TZ_USER_NAME)) + "/apps_rw/" +
diff --git a/test/unit_tests/CMakeLists.txt b/test/unit_tests/CMakeLists.txt
index 5c15dfd5..4b370b1a 100644
--- a/test/unit_tests/CMakeLists.txt
+++ b/test/unit_tests/CMakeLists.txt
@@ -26,7 +26,6 @@ APPLY_PKG_CONFIG(${TARGET_AUL_UNIT_TESTS} PUBLIC
LIBXML_DEPS
PARCEL_DEPS
PKGMGR_INFO_DEPS
- STORAGE_DEPS
TTRACE_DEPS
UUID_DEPS
VCONF_DEPS