Revert "Remove storage library dependency" 21/306121/1
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 16 Feb 2024 08:17:27 +0000 (17:17 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Fri, 16 Feb 2024 08:17:32 +0000 (17:17 +0900)
This reverts commit a30ee8d64b840d490d1caf5256da1765d5d8762e.

Change-Id: I6d9f1f536431342eef9c8a9047cfbb6396fe1aad

CMakeLists.txt
packaging/aul.spec
src/aul/CMakeLists.txt
src/aul/app_info/external_directory_info.cc
test/unit_tests/CMakeLists.txt

index 9da7ab4..73d8194 100644 (file)
@@ -58,6 +58,7 @@ 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)
index a6ac120..b946e71 100644 (file)
@@ -33,13 +33,12 @@ 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
index 2d9de98..c4e8f07 100644 (file)
@@ -47,6 +47,7 @@ APPLY_PKG_CONFIG(${TARGET_AUL} PUBLIC
   LIBTZPLATFORM_CONFIG_DEPS
   PARCEL_DEPS
   PKGMGR_INFO_DEPS
+  STORAGE_DEPS
   TTRACE_DEPS
   UUID_DEPS
   VCONF_DEPS
index 8ed7c5b..eb1fef9 100644 (file)
@@ -15,7 +15,7 @@
  *
  */
 
-#include <dlfcn.h>
+#include <storage-internal.h>
 #include <sys/types.h>
 #include <tzplatform_config.h>
 #include <unistd.h>
 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/";
 
-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 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);
+}
 
 std::string GetExternalPath(const std::string& pkg_id, uid_t uid) {
-  Storage storage;
-  std::string sdcard_path = storage.GetPrimarySdcard();
+  std::string sdcard_path = GetSdCardPath();
   tzplatform_set_user(uid);
   std::string path = sdcard_path + "/apps/" +
       std::string(tzplatform_getenv(TZ_USER_NAME)) + "/apps_rw/" +
index 4b370b1..5c15dfd 100644 (file)
@@ -26,6 +26,7 @@ APPLY_PKG_CONFIG(${TARGET_AUL_UNIT_TESTS} PUBLIC
   LIBXML_DEPS
   PARCEL_DEPS
   PKGMGR_INFO_DEPS
+  STORAGE_DEPS
   TTRACE_DEPS
   UUID_DEPS
   VCONF_DEPS