修复contenUri分享问题

Signed-off-by: 段嗣钊 <duansizhao@huawei.com>
Change-Id: Idc2a2ef81fbb3395a05c87681b043c09855caf13
This commit is contained in:
段嗣钊 2024-11-21 11:52:13 +08:00
parent 8ec347d055
commit a8919451b9
3 changed files with 7 additions and 13 deletions

View File

@ -3372,12 +3372,10 @@ bool AbilityRecord::GrantPermissionToShell(const std::vector<std::string> &strUr
}
uint32_t initiatorTokenId = IPCSkeleton::GetCallingTokenID();
for (auto&& uri : uriVec) {
auto ret = IN_PROCESS_CALL(UriPermissionManagerClient::GetInstance().GrantUriPermission(uri, flag, targetPkg,
appIndex_, initiatorTokenId, recordId_));
if (ret == ERR_OK) {
isGrantedUriPermission_ = true;
}
auto ret = IN_PROCESS_CALL(UriPermissionManagerClient::GetInstance().GrantUriPermissionPrivileged(uriVec,
flag, targetPkg, appIndex_, initiatorTokenId, recordId_));
if (ret == ERR_OK) {
isGrantedUriPermission_ = true;
}
return true;
}

View File

@ -808,21 +808,17 @@ std::vector<bool> UriPermissionManagerStubImpl::CheckUriPermission(TokenIdPermis
std::vector<bool> result(uriVec.size(), false);
std::vector<Uri> mediaUris;
std::vector<int32_t> mediaUriIndexs;
bool isFoundationCall = UPMSUtils::IsFoundationCall();
std::string callerAlterableBundleName;
UPMSUtils::GetAlterableBundleNameByTokenId(tokenId, callerAlterableBundleName);
for (size_t i = 0; i < uriVec.size(); i++) {
auto uri = uriVec[i];
auto &&scheme = uri.GetScheme();
if (scheme != "content" && scheme != "file") {
// checkUriPermission not support content uri
if (scheme != "file") {
TAG_LOGW(AAFwkTag::URIPERMMGR, "invalid uri:%{private}s", uri.ToString().c_str());
result[i] = false;
continue;
}
if (scheme == "content") {
result[i] = isFoundationCall;
continue;
}
auto &&authority = uri.GetAuthority();
TAG_LOGD(AAFwkTag::URIPERMMGR, "UriAuth:%{public}s", authority.c_str());
if (authority == "docs" && tokenIdPermission.VerifyFileAccessManagerPermission()) {

View File

@ -643,7 +643,7 @@ HWTEST_F(UriPermissionImplTest, Upms_CheckUriPermission_005, TestSize.Level1)
MyFlag::tokenInfos[callerTokenId1] = TokenInfo(callerTokenId1, MyATokenTypeEnum::TOKEN_NATIVE, "foundation");
TokenIdPermission tokenIdPermission1(callerTokenId1);
auto ret = upms->CheckUriPermission(tokenIdPermission1, uri, flagRead)[0];
ASSERT_EQ(ret, true);
ASSERT_EQ(ret, false);
uint32_t callerTokenId2 = 1002;
IPCSkeleton::callerTokenId = callerTokenId2;