From 1b06a48d05ddf7e41f10c87434eebc52e004780a Mon Sep 17 00:00:00 2001 From: zhangkaixiang Date: Thu, 29 Jun 2023 22:24:39 +0800 Subject: [PATCH] adapt to sandbox app share file Signed-off-by: zhangkaixiang Change-Id: I7132fb1fbc63ded09401ed6cc94c89eab90cb8e3 --- .../native/file_share/src/file_share.cpp | 27 ++++--------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/interfaces/innerkits/native/file_share/src/file_share.cpp b/interfaces/innerkits/native/file_share/src/file_share.cpp index 3ca42a513..f7cb9ba01 100644 --- a/interfaces/innerkits/native/file_share/src/file_share.cpp +++ b/interfaces/innerkits/native/file_share/src/file_share.cpp @@ -41,27 +41,6 @@ struct FileShareInfo { SHARE_FILE_TYPE type_; }; -static void UpdateBundleNameForDlp(const string &providerPath, string &bundleName, const string &providerBundleName) -{ - if (providerBundleName == DLP_MANAGER_BUNDLE_NAME) { - size_t lastPos = providerPath.find_last_of("/"); - if (lastPos == string::npos) { - return; - } - string subStr = providerPath.substr(lastPos); - size_t firstPos = subStr.find_first_of("_"); - if (firstPos == string::npos) { - return; - } - subStr = subStr.substr(firstPos + 1); - size_t secondPos = subStr.find_first_of("_"); - if (secondPos == string::npos) { - return; - } - bundleName += "_" + subStr.substr(0, secondPos); - } -} - static int32_t GetTargetInfo(uint32_t tokenId, string &bundleName, string ¤tUid) { Security::AccessToken::HapTokenInfo hapInfo; @@ -72,6 +51,11 @@ static int32_t GetTargetInfo(uint32_t tokenId, string &bundleName, string &curre } bundleName = hapInfo.bundleName; currentUid = to_string(hapInfo.userID); + + int index = hapInfo.instIndex; + if (index != 0) { + bundleName += "_" + to_string(index); + } return 0; } @@ -124,7 +108,6 @@ static int32_t GetProviderPath(const string &uriStr, FileShareInfo &info) { Uri uri(uriStr); string pathInProvider = uri.GetPath(); - UpdateBundleNameForDlp(pathInProvider, info.targetBundleName_, info.providerBundleName_); size_t num = SANDBOX_PATH.size(); string lowerPathTail = "", lowerPathHead = ""; -- Gitee