From 9c19c89aede8db6a859ff45c95bfbd55b8b5426b Mon Sep 17 00:00:00 2001 From: wwx1138977 Date: Sun, 8 Oct 2023 11:01:07 +0800 Subject: [PATCH] =?UTF-8?q?data=5Fshare=E7=BC=96=E8=AF=91=E5=AE=8F?= =?UTF-8?q?=E9=9A=94=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wwx1138977 --- interfaces/kits/js/BUILD.gn | 9 +++++++-- .../kits/js/file_share/grant_uri_permission.cpp | 13 +++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/js/BUILD.gn b/interfaces/kits/js/BUILD.gn index 47ecdfc16..4e4d40084 100644 --- a/interfaces/kits/js/BUILD.gn +++ b/interfaces/kits/js/BUILD.gn @@ -60,8 +60,6 @@ ohos_shared_library("fileshare") { "access_token:libtokenid_sdk", "c_utils:utils", "common_event_service:cesfwk_innerkits", - "data_share:datashare_common", - "data_share:datashare_consumer", "file_api:filemgmt_libhilog", "file_api:filemgmt_libn", "file_api:remote_uri_native", @@ -70,6 +68,13 @@ ohos_shared_library("fileshare") { "napi:ace_napi", ] + if (defined(global_parts_info) && + defined(global_parts_info.distributeddatamgr_data_share)) { + defines = [ "DATA_SHARE" ] + external_deps += [ "data_share:datashare_common" ] + external_deps += [ "data_share:datashare_consumer" ] + } + relative_install_dir = "module" part_name = "app_file_service" diff --git a/interfaces/kits/js/file_share/grant_uri_permission.cpp b/interfaces/kits/js/file_share/grant_uri_permission.cpp index 9b464f2ca..b14322ce8 100644 --- a/interfaces/kits/js/file_share/grant_uri_permission.cpp +++ b/interfaces/kits/js/file_share/grant_uri_permission.cpp @@ -15,8 +15,10 @@ #include "grant_uri_permission.h" #include "ability.h" +#ifdef DATA_SHARE #include "datashare_helper.h" #include "datashare_values_bucket.h" +#endif #include "ipc_skeleton.h" #include "log.h" #include "remote_uri.h" @@ -24,7 +26,9 @@ #include "uri_permission_manager_client.h" #include "want.h" +#ifdef DATA_SHARE using namespace OHOS::DataShare; +#endif using namespace OHOS::FileManagement::LibN; using namespace OHOS::DistributedFS::ModuleRemoteUri; @@ -50,6 +54,7 @@ namespace ModuleFileShare { return Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(fullTokenId); } +#ifdef DATA_SHARE static int32_t GetIdFromUri(string uri) { std::replace(uri.begin(), uri.end(), '/', ' '); @@ -59,6 +64,7 @@ namespace ModuleFileShare { ss >> tmp >> tmp >> tmp >> fileId; return fileId; } +#endif static string GetModeFromFlag(unsigned int flag) { @@ -81,6 +87,7 @@ namespace ModuleFileShare { return flag; } +#ifdef DATA_SHARE static int32_t GetMediaTypeAndApiFromUri(const std::string &uri, bool &isApi10) { if (uri.find(MEDIA_FILE_URI_PHOTO_PREFEX) == 0) { @@ -146,9 +153,11 @@ namespace ModuleFileShare { valuesBucket.Put(PERMISSION_TABLE_TYPE, filesType); return 0; } +#endif static int GrantInMediaLibrary(const UriPermissionInfo &uriPermInfo, Uri &uri) { + #ifdef DATA_SHARE bool isApi10 = false; DataShareValuesBucket valuesBucket; int ret = InitValuesBucket(uriPermInfo, uri, isApi10, valuesBucket); @@ -160,6 +169,10 @@ namespace ModuleFileShare { if (ret < 0) { return ret; } + #else + LOGE("FileShare::InitValuesBucket data_share not found!"); + return -EINVAL; + #endif return 0; } -- Gitee