diff --git a/interfaces/common/src/common_func.cpp b/interfaces/common/src/common_func.cpp index 7288d16cda88b2eb7d3bda157e4cba77270359cf..adde788f73eb19417c2135da56b258dacb28e542 100644 --- a/interfaces/common/src/common_func.cpp +++ b/interfaces/common/src/common_func.cpp @@ -33,6 +33,8 @@ using namespace OHOS::AppExecFwk; namespace { const std::string FILE_SCHEME_PREFIX = "file://"; const char BACKFLASH = '/'; + const std::string FILE_MANAGER_URI_HEAD = "/storage/"; + const std::string FILE_MANAGER_AUTHORITY = "docs"; } static sptr GetBundleMgrProxy() { @@ -89,7 +91,7 @@ string CommonFunc::GetUriFromPath(const string &path) string realPath = path; NormalizePath(realPath); - string packageName = GetSelfBundleName(); + string packageName = (path.find(FILE_MANAGER_URI_HEAD) == 0) ? FILE_MANAGER_AUTHORITY : GetSelfBundleName(); realPath = FILE_SCHEME_PREFIX + packageName + realPath; return SandboxHelper::Encode(realPath); }