From a8919451b9d9a39732a5bedec3b0f7ed155325f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B5=E5=97=A3=E9=92=8A?= Date: Thu, 21 Nov 2024 11:52:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DcontenUri=E5=88=86=E4=BA=AB?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 段嗣钊 Change-Id: Idc2a2ef81fbb3395a05c87681b043c09855caf13 --- services/abilitymgr/src/ability_record.cpp | 10 ++++------ .../src/uri_permission_manager_stub_impl.cpp | 8 ++------ .../uri_permission_impl_test.cpp | 2 +- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/services/abilitymgr/src/ability_record.cpp b/services/abilitymgr/src/ability_record.cpp index 6885481a09..6e8d855fbe 100644 --- a/services/abilitymgr/src/ability_record.cpp +++ b/services/abilitymgr/src/ability_record.cpp @@ -3372,12 +3372,10 @@ bool AbilityRecord::GrantPermissionToShell(const std::vector &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; } diff --git a/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp b/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp index cac6b6f3fe..b576a00ea5 100644 --- a/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp +++ b/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp @@ -808,21 +808,17 @@ std::vector UriPermissionManagerStubImpl::CheckUriPermission(TokenIdPermis std::vector result(uriVec.size(), false); std::vector mediaUris; std::vector 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()) { diff --git a/test/unittest/uri_permission_impl_test/uri_permission_impl_test.cpp b/test/unittest/uri_permission_impl_test/uri_permission_impl_test.cpp index 8494426b0e..6d500d83b0 100755 --- a/test/unittest/uri_permission_impl_test/uri_permission_impl_test.cpp +++ b/test/unittest/uri_permission_impl_test/uri_permission_impl_test.cpp @@ -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;