!11658 修复contenUri分享问题

Merge pull request !11658 from 段嗣钊/master1118
This commit is contained in:
openharmony_ci 2024-11-22 07:59:26 +00:00 committed by Gitee
commit e80c069a4f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 7 additions and 13 deletions

View File

@ -3380,12 +3380,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;