From cf573f56ea713c0974928a22faf3f444a792b63f Mon Sep 17 00:00:00 2001 From: dengjun Date: Fri, 24 Nov 2023 15:47:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dengjun --- interfaces/innerkits/native/BUILD.gn | 2 + .../native/file_uri/src/file_uri.cpp | 37 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/interfaces/innerkits/native/BUILD.gn b/interfaces/innerkits/native/BUILD.gn index 67c3c077e..840439d9d 100644 --- a/interfaces/innerkits/native/BUILD.gn +++ b/interfaces/innerkits/native/BUILD.gn @@ -72,6 +72,8 @@ ohos_shared_library("fileuri_native") { "hilog:libhilog", "ipc:ipc_core", "samgr:samgr_proxy", + "init:libbegetutil", + "file_api:remote_uri_native", ] part_name = "app_file_service" diff --git a/interfaces/innerkits/native/file_uri/src/file_uri.cpp b/interfaces/innerkits/native/file_uri/src/file_uri.cpp index f027c842c..18cc9b5bd 100644 --- a/interfaces/innerkits/native/file_uri/src/file_uri.cpp +++ b/interfaces/innerkits/native/file_uri/src/file_uri.cpp @@ -24,6 +24,8 @@ #include "common_func.h" #include "log.h" #include "sandbox_helper.h" +#include "parameter.h" +#include "remote_uri.h" using namespace std; namespace OHOS { @@ -36,6 +38,23 @@ const std::string FILE_SCHEME_PREFIX = "file://"; const std::string FILE_MANAGER_AUTHORITY = "docs"; const std::string MEDIA_AUTHORITY = "media"; const std::string NETWORK_PARA = "?networkid="; +const int32_t FULL_MOUT_ENABLE_SIZE = 6; +const char* g_filemanagerFullMoutEnableParameter = "const.filemanager.full_mout.enable"; + +namespace { + bool CheckFilemanagerFullMoutEnable() + { + char value[FULL_MOUT_ENABLE_SIZE] = "false"; + int retSystem = GetParameter(g_filemanagerFullMoutEnableParameter, "false", value, FULL_MOUT_ENABLE_SIZE); + if (retSystem > 0 && !std::strcmp(value, "true")) { + LOGD("this is a pc"); + return true; + } + LOGD("this is not a pc"); + return false; + } +} + string FileUri::GetName() { string sandboxPath = SandboxHelper::Decode(uri_.GetPath()); @@ -69,6 +88,24 @@ string FileUri::GetRealPath() string realPath = sandboxPath; string bundleName = uri_.GetAuthority(); LOGD("GetRealPath decode path is %{private}s", sandboxPath.c_str()); + + if (!CheckFilemanagerFullMoutEnable()) { + LOGD("Device is not PC"); + return ""; + } + + if (OHOS::DistributedFS::ModuleRemoteUri::RemoteUri::IsMediaUri(realPath)) { + LOGD("Is Media Uri"); + return ""; + } + LOGD("Is not Media Uri"); + int fd = -1; + if (OHOS::DistributedFS::ModuleRemoteUri::RemoteUri::IsRemoteUri(realPath,fd)) { + LOGD("Is Remote Uri"); + return ""; + } + LOGD("Is not Remote Uri"); + if (bundleName == FILE_MANAGER_AUTHORITY && uri_.ToString().find(NETWORK_PARA) == string::npos && access(realPath.c_str(), F_OK) == 0) { -- Gitee