mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 22:21:36 -04:00
@@ -62,7 +62,7 @@ public:
|
||||
void SelectPermissionedUri(std::vector<Uri> &uris, std::vector<int32_t> &indexs, std::vector<std::string> &uriVec);
|
||||
|
||||
int32_t GetUriToGrantByPolicy(std::vector<PolicyInfo> &docsPolicyInfoVec,
|
||||
std::vector<PolicyInfo> &bundlePolicyInfoVec, bool isRemoveDfsDocsUri);
|
||||
std::vector<PolicyInfo> &bundlePolicyInfoVec);
|
||||
|
||||
bool GetUriToGrantByPolicy(std::vector<PolicyInfo> &policyVec);
|
||||
|
||||
@@ -86,9 +86,6 @@ public:
|
||||
|
||||
// content uri
|
||||
std::vector<std::string> contentUris;
|
||||
// distribute docs uri
|
||||
std::vector<std::string> dfsDocsUris;
|
||||
std::vector<bool> isDfsDocsUriVec;
|
||||
|
||||
// caller's uri
|
||||
std::vector<PolicyInfo> selfBundlePolicyInfos;
|
||||
|
||||
@@ -34,7 +34,6 @@ int32_t BatchUri::Init(const std::vector<std::string> &uriVec, uint32_t mode,
|
||||
validUriCount = 0;
|
||||
checkResult = std::vector<bool>(totalUriCount, false);
|
||||
isDocsUriVec = std::vector<bool>(totalUriCount, false);
|
||||
isDfsDocsUriVec = std::vector<bool>(totalUriCount, false);
|
||||
isTargetBundleUri = std::vector<bool>(totalUriCount, false);
|
||||
for (size_t index = 0; index < uriVec.size(); index++) {
|
||||
Uri uriInner = Uri(uriVec[index]);
|
||||
@@ -73,11 +72,6 @@ void BatchUri::InitFileUriInfo(Uri &uriInner, uint32_t index, const uint32_t mod
|
||||
}
|
||||
// docs uri
|
||||
if (authority == FUDConstants::DOCS_AUTHORITY) {
|
||||
// distribute docs uri
|
||||
if (FUDUtils::IsDocsCloudUri(uriInner)) {
|
||||
dfsDocsUris.emplace_back(uriInner.ToString());
|
||||
isDfsDocsUriVec[index] = true;
|
||||
}
|
||||
isDocsUriVec[index] = true;
|
||||
// need to check uri permission
|
||||
otherUris.emplace_back(uriInner);
|
||||
@@ -181,7 +175,7 @@ void BatchUri::SelectPermissionedUri(std::vector<Uri> &uris, std::vector<int32_t
|
||||
}
|
||||
|
||||
int32_t BatchUri::GetUriToGrantByPolicy(std::vector<PolicyInfo> &docsPolicyInfoVec,
|
||||
std::vector<PolicyInfo> &bundlePolicyInfoVec, bool isRemoveDfsDocsUri)
|
||||
std::vector<PolicyInfo> &bundlePolicyInfoVec)
|
||||
{
|
||||
// bundleName + docs
|
||||
int32_t count = 0;
|
||||
@@ -200,7 +194,7 @@ int32_t BatchUri::GetUriToGrantByPolicy(std::vector<PolicyInfo> &docsPolicyInfoV
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::URIPERMMGR, "Add policy: path is %{private}s, mode is %{public}u.",
|
||||
otherPolicyInfos[i].path.c_str(), static_cast<uint32_t>(otherPolicyInfos[i].mode));
|
||||
if (isDocsUriVec[index] && (!isRemoveDfsDocsUri || !isDfsDocsUriVec[index])) {
|
||||
if (isDocsUriVec[index]) {
|
||||
docsPolicyInfoVec.emplace_back(otherPolicyInfos[i]);
|
||||
} else {
|
||||
bundlePolicyInfoVec.emplace_back(otherPolicyInfos[i]);
|
||||
|
||||
@@ -36,6 +36,7 @@ constexpr int32_t API_VERSION_MOD = 100;
|
||||
constexpr int32_t FOUNDATION_UID = 5523;
|
||||
constexpr int32_t UDMF_UID = 3012;
|
||||
constexpr int32_t PASTEBOARD_UID = 3816;
|
||||
constexpr int32_t BROKER_PASTEBOARD_UID = 5557;
|
||||
constexpr const char* NET_WORK_ID_MARK = "?networkid=";
|
||||
}
|
||||
|
||||
@@ -332,7 +333,7 @@ bool FUDUtils::IsDocsCloudUri(Uri &uri)
|
||||
bool FUDUtils::IsUdmfOrPasteboardCall()
|
||||
{
|
||||
auto uid = IPCSkeleton::GetCallingUid();
|
||||
return uid == UDMF_UID || uid == PASTEBOARD_UID;
|
||||
return uid == UDMF_UID || uid == PASTEBOARD_UID || uid == BROKER_PASTEBOARD_UID;
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -132,17 +132,12 @@ HWTEST_F(BatchUriTest, Init_0500, TestSize.Level2)
|
||||
ASSERT_NE(batchUri, nullptr);
|
||||
std::vector<std::string> uriVec;
|
||||
uriVec.push_back("content://temp.txt");
|
||||
uriVec.push_back("file://docs/temp.txt?networkid=1001");
|
||||
uint32_t mode = 0;
|
||||
std::string callerAlterBundleName = "callerBundleName";
|
||||
std::string targetAlterBundleName = "targetBundleName";
|
||||
MyFlag::isDocsCloudUri_ = true;
|
||||
auto ret = batchUri->Init(uriVec, mode, callerAlterBundleName, targetAlterBundleName, false);
|
||||
EXPECT_EQ(ret, 2);
|
||||
EXPECT_EQ(ret, 1);
|
||||
EXPECT_EQ(batchUri->contentUris.size(), 1);
|
||||
EXPECT_EQ(batchUri->dfsDocsUris.size(), 1);
|
||||
EXPECT_EQ(batchUri->isDfsDocsUriVec[1], true);
|
||||
EXPECT_EQ(batchUri->isDocsUriVec[1], true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -210,47 +205,6 @@ HWTEST_F(BatchUriTest, GetUriToGrantByPolicy_0300, TestSize.Level2)
|
||||
EXPECT_TRUE(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetUriToGrantByPolicy_0400
|
||||
* @tc.name: GetUriToGrantByPolicy
|
||||
* @tc.desc: Test GetUriToGrantByPolicy.
|
||||
*/
|
||||
HWTEST_F(BatchUriTest, GetUriToGrantByPolicy_0400, TestSize.Level2)
|
||||
{
|
||||
auto batchUri = std::make_shared<BatchUri>();
|
||||
ASSERT_NE(batchUri, nullptr);
|
||||
std::vector<std::string> uriVec;
|
||||
MyFlag::isDocsCloudUri_ = true;
|
||||
uriVec.emplace_back("file://docs/temp.txt?networkid=1001");
|
||||
uint32_t mode = 0;
|
||||
std::string callerAlterBundleName = "callerBundleName";
|
||||
std::string targetAlterBundleName = "targetBundleName";
|
||||
auto ret = batchUri->Init(uriVec, mode, callerAlterBundleName, targetAlterBundleName, false);
|
||||
EXPECT_EQ(ret, 1);
|
||||
batchUri->otherPolicyInfos = { PolicyInfo() };
|
||||
|
||||
std::vector<PolicyInfo> docsPolicyInfoVec;
|
||||
std::vector<PolicyInfo> bundlePolicyInfoVec;
|
||||
bool isRemoveDfsDocsUri = false;
|
||||
batchUri->checkResult = { false };
|
||||
auto count = batchUri->GetUriToGrantByPolicy(docsPolicyInfoVec, bundlePolicyInfoVec, isRemoveDfsDocsUri);
|
||||
EXPECT_EQ(count, 0);
|
||||
|
||||
isRemoveDfsDocsUri = false;
|
||||
docsPolicyInfoVec.clear();
|
||||
batchUri->checkResult = { true };
|
||||
count = batchUri->GetUriToGrantByPolicy(docsPolicyInfoVec, bundlePolicyInfoVec, isRemoveDfsDocsUri);
|
||||
EXPECT_EQ(count, 1);
|
||||
EXPECT_EQ(docsPolicyInfoVec.size(), 1);
|
||||
|
||||
isRemoveDfsDocsUri = true;
|
||||
docsPolicyInfoVec.clear();
|
||||
batchUri->checkResult = { true };
|
||||
count = batchUri->GetUriToGrantByPolicy(docsPolicyInfoVec, bundlePolicyInfoVec, isRemoveDfsDocsUri);
|
||||
EXPECT_EQ(count, 1);
|
||||
EXPECT_EQ(docsPolicyInfoVec.size(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetUriToGrantByPolicy_0500
|
||||
* @tc.name: GetUriToGrantByPolicy
|
||||
@@ -274,16 +228,7 @@ HWTEST_F(BatchUriTest, GetUriToGrantByPolicy_0500, TestSize.Level2)
|
||||
std::vector<PolicyInfo> docsPolicyInfoVec;
|
||||
std::vector<PolicyInfo> bundlePolicyInfoVec;
|
||||
batchUri->checkResult = { true, true };
|
||||
bool isRemoveDfsDocsUri = true;
|
||||
auto count = batchUri->GetUriToGrantByPolicy(docsPolicyInfoVec, bundlePolicyInfoVec, isRemoveDfsDocsUri);
|
||||
EXPECT_EQ(count, 2);
|
||||
EXPECT_EQ(docsPolicyInfoVec.size(), 1);
|
||||
EXPECT_EQ(bundlePolicyInfoVec.size(), 1);
|
||||
|
||||
isRemoveDfsDocsUri = false;
|
||||
docsPolicyInfoVec.clear();
|
||||
bundlePolicyInfoVec.clear();
|
||||
count = batchUri->GetUriToGrantByPolicy(docsPolicyInfoVec, bundlePolicyInfoVec, isRemoveDfsDocsUri);
|
||||
auto count = batchUri->GetUriToGrantByPolicy(docsPolicyInfoVec, bundlePolicyInfoVec);
|
||||
EXPECT_EQ(count, 2);
|
||||
EXPECT_EQ(docsPolicyInfoVec.size(), 1);
|
||||
EXPECT_EQ(bundlePolicyInfoVec.size(), 1);
|
||||
|
||||
@@ -50,7 +50,7 @@ std::string MyFlag::upmsUtilsBundleName_ = "";
|
||||
bool MyFlag::upmsUtilsGetBundleNameByTokenIdRet_ = false;
|
||||
std::string MyFlag::upmsUtilsAppId_ = "";
|
||||
int32_t MyFlag::upmsUtilsGetAppIdByBundleNameRet_ = 0;
|
||||
bool MyFlag::upmsUtilsIsFoundationCallRet_;
|
||||
bool MyFlag::upmsUtilsIsFoundationCallRet_ = false;
|
||||
uint32_t MyFlag::upmsUtilsTokenId_ = 0;
|
||||
bool MyFlag::fudUtilsGenerateFUDAppInfoRet_ = true;
|
||||
std::string MyFlag::bundleName_ = "";
|
||||
|
||||
Reference in New Issue
Block a user