diff --git a/services/storage_daemon/BUILD.gn b/services/storage_daemon/BUILD.gn index 994300e82aec8a015f1ab5b00e5758256fea43ce..3b9a54e56a0a072d210170c59628a6570d548547 100644 --- a/services/storage_daemon/BUILD.gn +++ b/services/storage_daemon/BUILD.gn @@ -102,8 +102,6 @@ ohos_executable("storage_daemon") { "ability_base:base", "ability_base:want", "ability_base:zuri", - "access_token:libaccesstoken_sdk", - "app_file_service:fileshare_native", "c_utils:utils", "dfs_service:cloud_daemon_kit_inner", "hiviewdfx_hilog_native:libhilog", diff --git a/services/storage_daemon/ipc/src/storage_daemon.cpp b/services/storage_daemon/ipc/src/storage_daemon.cpp index 67c1d2bb74b7be8584fa6183caf57e24a2269406..ba535838f21b6b7a59b3bc8842d8793f9571737f 100644 --- a/services/storage_daemon/ipc/src/storage_daemon.cpp +++ b/services/storage_daemon/ipc/src/storage_daemon.cpp @@ -15,6 +15,8 @@ #include "ipc/storage_daemon.h" +#include + #ifdef USER_CRYPTO_MANAGER #include "crypto/key_manager.h" #endif @@ -22,7 +24,6 @@ #include "disk/disk_manager.h" #include "volume/volume_manager.h" #endif -#include "file_share.h" #include "file_sharing/file_sharing.h" #include "quota/quota_manager.h" #include "storage_service_constant.h" @@ -37,6 +38,9 @@ namespace OHOS { namespace StorageDaemon { using namespace OHOS::FileManagement::CloudFile; + +typedef int32_t (*CreateShareFileFunc)(std::string, uint32_t, uint32_t); +typedef int32_t (*DeleteShareFileFunc)(uint32_t, std::vector); int32_t StorageDaemon::Shutdown() { return E_OK; @@ -106,7 +110,7 @@ int32_t StorageDaemon::PrepareUserDirs(int32_t userId, uint32_t flags) { #ifdef USER_CRYPTO_MANAGER int32_t ret = KeyManager::GetInstance()->GenerateUserKeys(userId, flags); - if (ret != 0) { + if (ret != E_OK) { LOGE("Generate user %{public}d key error", userId); return ret; } @@ -118,7 +122,7 @@ int32_t StorageDaemon::PrepareUserDirs(int32_t userId, uint32_t flags) int32_t StorageDaemon::DestroyUserDirs(int32_t userId, uint32_t flags) { int32_t ret = UserManager::GetInstance()->DestroyUserDirs(userId, flags); - if (ret != 0) { + if (ret != E_OK) { LOGW("Destroy user %{public}d dirs failed, please check", userId); } @@ -230,12 +234,40 @@ int32_t StorageDaemon::UpdateKeyContext(uint32_t userId) int32_t StorageDaemon::CreateShareFile(std::string uri, uint32_t tokenId, uint32_t flag) { - return AppFileService::FileShare::CreateShareFile(uri, tokenId, flag); + void *dlhandler = dlopen("libfileshare_native.z.so", RTLD_LAZY); + if (dlhandler == NULL) { + LOGE("CreateShareFile cannot open so, errno = %{public}s", dlerror()); + return E_ERR; + } + CreateShareFileFunc createShareFile = nullptr; + createShareFile = reinterpret_cast(dlsym(dlhandler, "CreateShareFile")); + if (createShareFile == nullptr) { + LOGE("CreateShareFile dlsym failed, errno = %{public}s", dlerror()); + dlclose(dlhandler); + return E_ERR; + } + int ret = createShareFile(uri, tokenId, flag); + dlclose(dlhandler); + return ret; } int32_t StorageDaemon::DeleteShareFile(uint32_t tokenId, std::vectorsharePathList) { - return AppFileService::FileShare::DeleteShareFile(tokenId, sharePathList); + void *dlhandler = dlopen("libfileshare_native.z.so", RTLD_LAZY); + if (dlhandler == NULL) { + LOGE("DeleteShareFile cannot open so, errno = %{public}s", dlerror()); + return E_ERR; + } + DeleteShareFileFunc deleteShareFile = nullptr; + deleteShareFile = reinterpret_cast(dlsym(dlhandler, "DeleteShareFile")); + if (deleteShareFile == nullptr) { + LOGE("DeleteShareFile dlsym failed, errno = %{public}s", dlerror()); + dlclose(dlhandler); + return E_ERR; + } + int32_t ret = deleteShareFile(tokenId, sharePathList); + dlclose(dlhandler); + return ret; } int32_t StorageDaemon::SetBundleQuota(const std::string &bundleName, int32_t uid,