From c2a6b80d998cf8791943631e9dc81712a474f19d Mon Sep 17 00:00:00 2001 From: oh_ci Date: Thu, 7 Aug 2025 06:35:48 +0000 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!3245=20?= =?UTF-8?q?:=20ACL=E6=9D=83=E9=99=90=E6=9C=80=E5=B0=8F=E5=8C=96'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/common/BUILD.gn | 1 - .../service/common/bundle_utils.cpp | 43 ---------------- .../service/common/bundle_utils.h | 41 --------------- .../data_share/common/bundle_mgr_proxy.cpp | 25 --------- .../data_share/common/bundle_mgr_proxy.h | 1 - .../data_share/data_share_service_impl.cpp | 7 --- .../service/rdb/rdb_service_impl.cpp | 11 ---- .../service/test/BUILD.gn | 2 - .../test/data_share_service_impl_test.cpp | 51 +------------------ .../datashareserviceimpl_fuzzer/BUILD.gn | 1 - .../datashareservicestub_fuzzer/BUILD.gn | 1 - .../datasharesubscriber_fuzzer/BUILD.gn | 1 - 12 files changed, 2 insertions(+), 183 deletions(-) delete mode 100644 services/distributeddataservice/service/common/bundle_utils.cpp delete mode 100644 services/distributeddataservice/service/common/bundle_utils.h diff --git a/services/distributeddataservice/service/common/BUILD.gn b/services/distributeddataservice/service/common/BUILD.gn index 98a8c1c55..50a08c56e 100644 --- a/services/distributeddataservice/service/common/BUILD.gn +++ b/services/distributeddataservice/service/common/BUILD.gn @@ -23,7 +23,6 @@ ohos_source_set("distributeddata_common") { ubsan = true } sources = [ - "bundle_utils.cpp", "common_types_utils.cpp", "value_proxy.cpp", "xcollie.cpp", diff --git a/services/distributeddataservice/service/common/bundle_utils.cpp b/services/distributeddataservice/service/common/bundle_utils.cpp deleted file mode 100644 index f722d9d85..000000000 --- a/services/distributeddataservice/service/common/bundle_utils.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* -* Copyright (c) 2025 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "bundle_utils.h" - -namespace OHOS::DistributedData { -BundleUtils &BundleUtils::GetInstance() -{ - static BundleUtils instance; - return instance; -} - -void BundleUtils::SetBundleInfoCallback(Callback callback) -{ - std::lock_guard lock(lock_); - bundleInfoCallback_ = std::move(callback); -} - -std::pair BundleUtils::CheckSilentConfig(const std::string &bundleName, int32_t userId) -{ - Callback callback; - { - std::lock_guard lock(lock_); - callback = bundleInfoCallback_; - } - if (callback == nullptr) { - return std::make_pair(-1, false); - } - return callback(bundleName, userId); -} -} \ No newline at end of file diff --git a/services/distributeddataservice/service/common/bundle_utils.h b/services/distributeddataservice/service/common/bundle_utils.h deleted file mode 100644 index 98dad60ea..000000000 --- a/services/distributeddataservice/service/common/bundle_utils.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -* Copyright (c) 2025 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#ifndef OHOS_DISTRIBUTED_DATA_DATAMGR_SERVICE_BUNDLEINFO_UTILS_H -#define OHOS_DISTRIBUTED_DATA_DATAMGR_SERVICE_BUNDLEINFO_UTILS_H - -#include -#include -#include -#include -#include - -namespace OHOS::DistributedData { -using Callback = std::function(const std::string &bundleName, int32_t userId)>; -class BundleUtils { -public: - BundleUtils() = default; - static BundleUtils &GetInstance(); - - std::pair CheckSilentConfig(const std::string &bundleName, int32_t userId); - - void SetBundleInfoCallback(Callback callback); - -private: - std::mutex lock_; - Callback bundleInfoCallback_; -}; -} -#endif // OHOS_DISTRIBUTED_DATA_DATAMGR_SERVICE_BUNDLEINFO_UTILS_H \ No newline at end of file diff --git a/services/distributeddataservice/service/data_share/common/bundle_mgr_proxy.cpp b/services/distributeddataservice/service/data_share/common/bundle_mgr_proxy.cpp index 843b53d15..267a66c32 100644 --- a/services/distributeddataservice/service/data_share/common/bundle_mgr_proxy.cpp +++ b/services/distributeddataservice/service/data_share/common/bundle_mgr_proxy.cpp @@ -290,29 +290,4 @@ std::pair> BundleMgrProxy::ConvertHapModuleInfo( } return std::make_pair(E_OK, hapModuleInfos); } - -std::pair BundleMgrProxy::CheckSilentConfig(const std::string &bundleName, int32_t userId) -{ - AppExecFwk::BundleInfo bundleInfo; - auto bmsClient = GetBundleMgrProxy(); - if (bmsClient == nullptr) { - ZLOGE( - "GetBundleMgrProxy is nullptr! bundleName is %{public}s, userId is %{public}d", bundleName.c_str(), userId); - return std::make_pair(E_BMS_NOT_READY, false); - } - - auto ret = bmsClient->GetBundleInfo(bundleName, - static_cast(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE), bundleInfo, userId); - if (!ret) { - ZLOGE("Get bundleInfo failed! ret: %{public}d", ret); - return std::make_pair(E_ERROR, false); - } - - for (auto &hapModuleInfo : bundleInfo.hapModuleInfos) { - if (!hapModuleInfo.proxyDatas.empty()) { - return std::make_pair(E_OK, true); - } - } - return std::make_pair(E_SILENT_PROXY_DISABLE, false); -} } // namespace OHOS::DataShare \ No newline at end of file diff --git a/services/distributeddataservice/service/data_share/common/bundle_mgr_proxy.h b/services/distributeddataservice/service/data_share/common/bundle_mgr_proxy.h index 6f6ca58c4..7198715f1 100644 --- a/services/distributeddataservice/service/data_share/common/bundle_mgr_proxy.h +++ b/services/distributeddataservice/service/data_share/common/bundle_mgr_proxy.h @@ -85,7 +85,6 @@ public: BundleConfig &bundleConfig, int32_t appIndex = 0); int GetBundleInfoFromBMSWithCheck(const std::string &bundleName, int32_t userId, BundleConfig &bundleConfig, int32_t appIndex = 0); - std::pair CheckSilentConfig(const std::string &bundleName, int32_t userId); void Delete(const std::string &bundleName, int32_t userId, int32_t appIndex); sptr CheckBMS(); std::pair GetCallerAppIdentifier(const std::string &bundleName, int32_t userId); diff --git a/services/distributeddataservice/service/data_share/data_share_service_impl.cpp b/services/distributeddataservice/service/data_share/data_share_service_impl.cpp index c9a1b00f7..b6c6ef150 100644 --- a/services/distributeddataservice/service/data_share/data_share_service_impl.cpp +++ b/services/distributeddataservice/service/data_share/data_share_service_impl.cpp @@ -22,8 +22,6 @@ #include "account/account_delegate.h" #include "app_connect_manager.h" -#include "bundle_mgr_proxy.h" -#include "bundle_utils.h" #include "block_data.h" #include "common_event_manager.h" #include "common_event_support.h" @@ -669,11 +667,6 @@ int32_t DataShareServiceImpl::OnBind(const BindInfo &binderInfo) SubscribeConcurrentTask(); SubscribeTimeChanged(); SubscribeChange(); - - auto task = [](const std::string &bundleName, int32_t userId) { - return BundleMgrProxy::GetInstance()->CheckSilentConfig(bundleName, userId); - }; - BundleUtils::GetInstance().SetBundleInfoCallback(task); ZLOGI("end"); return E_OK; } diff --git a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp index 228d33ab1..3f2341dee 100644 --- a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp +++ b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp @@ -19,7 +19,6 @@ #include "accesstoken_kit.h" #include "account/account_delegate.h" #include "bootstrap.h" -#include "bundle_utils.h" #include "changeevent/remote_change_event.h" #include "checker/checker_manager.h" #include "cloud/change_event.h" @@ -881,16 +880,6 @@ int32_t RdbServiceImpl::BeforeOpen(RdbSyncerParam ¶m) return RDB_NO_META; } SetReturnParam(meta, param); - // there is no need to set acl, path is has acl - if (param.isNeedSetAcl_) { - return RDB_OK; - } - if (param.isSearchable_) { - param.isNeedSetAcl_ = true; - return RDB_OK; - } - auto [err, flag] = BundleUtils::GetInstance().CheckSilentConfig(meta.bundleName, std::atoi(meta.user.c_str())); - param.isNeedSetAcl_ = flag; return RDB_OK; } diff --git a/services/distributeddataservice/service/test/BUILD.gn b/services/distributeddataservice/service/test/BUILD.gn index 2f050490c..da148cd83 100644 --- a/services/distributeddataservice/service/test/BUILD.gn +++ b/services/distributeddataservice/service/test/BUILD.gn @@ -1187,7 +1187,6 @@ ohos_unittest("DataShareServiceImplTest") { ] sources = [ - "${data_service_path}/service/common/bundle_utils.cpp", "${data_service_path}/service/common/xcollie.cpp", "${data_service_path}/service/data_share/common/app_connect_manager.cpp", "${data_service_path}/service/data_share/common/bundle_mgr_proxy.cpp", @@ -1318,7 +1317,6 @@ ohos_unittest("DataShareServiceImplMockTest") { include_dirs = [ "${data_service_path}/service/config/include" ] sources = [ - "${data_service_path}/service/common/bundle_utils.cpp", "${data_service_path}/service/common/xcollie.cpp", "${data_service_path}/service/config/src/model/app_access_check_config.cpp", "${data_service_path}/service/config/src/model/app_id_mapping_config.cpp", diff --git a/services/distributeddataservice/service/test/data_share_service_impl_test.cpp b/services/distributeddataservice/service/test/data_share_service_impl_test.cpp index 076ec4bb3..cd59ac22f 100644 --- a/services/distributeddataservice/service/test/data_share_service_impl_test.cpp +++ b/services/distributeddataservice/service/test/data_share_service_impl_test.cpp @@ -21,8 +21,6 @@ #include "accesstoken_kit.h" #include "account_delegate_mock.h" -#include "bundle_mgr_proxy.h" -#include "bundle_utils.h" #include "data_share_service_stub.h" #include "device_manager_adapter.h" #include "dump/dump_manager.h" @@ -136,8 +134,8 @@ HWTEST_F(DataShareServiceImplTest, DataShareServiceImpl001, TestSize.Level1) predicates.EqualTo("", ""); std::vector columns; - DataShareOption option; - auto [errVal, resQuery] = dataShareServiceImpl.Query(uri, "", predicates, columns, option); + DataShareOption option; + auto [errVal, resQuery] = dataShareServiceImpl.Query(uri, "", predicates, columns, option); int resultSet = 0; if (resQuery != nullptr) { resQuery->GetRowCount(resultSet); @@ -565,49 +563,4 @@ HWTEST_F(DataShareServiceImplTest, UpdateLaunchInfo001, TestSize.Level1) EXPECT_EQ(storeMetaData.size(), 0); ZLOGI("DataShareServiceImplTest UpdateLaunchInfo001 end"); } - -/** -* @tc.name: BundleMgrProxyTest001 -* @tc.desc: Test the CheckSilentConfig method of BundleMgrProxy -* @tc.type: FUNC -* @tc.require: -*/ -HWTEST_F(DataShareServiceImplTest, BundleMgrProxyTest001, TestSize.Level1) -{ - ZLOGI("DataShareServiceImplTest BundleMgrProxyTest001 start"); - int32_t user = static_cast(USER_TEST); - auto bundleMgr = BundleMgrProxy::GetInstance(); - ASSERT_NE(bundleMgr, nullptr); - auto [err, ret] = bundleMgr->CheckSilentConfig(BUNDLE_NAME, user); - EXPECT_EQ(err, OHOS::DataShare::E_SILENT_PROXY_DISABLE); - EXPECT_EQ(ret, false); - auto [err2, ret2] = bundleMgr->CheckSilentConfig("", user); - EXPECT_NE(err2, OHOS::DataShare::E_OK); - EXPECT_EQ(ret2, false); - ZLOGI("DataShareServiceImplTest BundleMgrProxyTest001 end"); -} - -/** -* @tc.name: BundleUtilsTest001 -* @tc.desc: Test the SetBundleInfoCallback and CheckSilentConfig methods of BundleUtils -* @tc.type: FUNC -* @tc.require: -*/ -HWTEST_F(DataShareServiceImplTest, BundleUtilsTest001, TestSize.Level1) -{ - ZLOGI("DataShareServiceImplTest BundleUtilsTest001 start"); - - auto [err, ret] = BundleUtils::GetInstance().CheckSilentConfig("", 0); - EXPECT_EQ(err, -1); - EXPECT_EQ(ret, false); - - auto task = [](const std::string &bundleName, int32_t userId) { - return std::make_pair(0, true); - }; - BundleUtils::GetInstance().SetBundleInfoCallback(task); - auto [err2, ret2] = BundleUtils::GetInstance().CheckSilentConfig("", 0); - EXPECT_EQ(err2, 0); - EXPECT_EQ(ret2, true); - ZLOGI("DataShareServiceImplTest BundleUtilsTest001 end"); -} } // namespace OHOS::Test \ No newline at end of file diff --git a/services/distributeddataservice/service/test/fuzztest/datashareserviceimpl_fuzzer/BUILD.gn b/services/distributeddataservice/service/test/fuzztest/datashareserviceimpl_fuzzer/BUILD.gn index a9fa1ed93..17ca41e7e 100644 --- a/services/distributeddataservice/service/test/fuzztest/datashareserviceimpl_fuzzer/BUILD.gn +++ b/services/distributeddataservice/service/test/fuzztest/datashareserviceimpl_fuzzer/BUILD.gn @@ -50,7 +50,6 @@ ohos_fuzztest("DataShareServiceImplFuzzTest") { ] sources = [ - "${data_service_path}/service/common/bundle_utils.cpp", "${data_service_path}/service/common/xcollie.cpp", "${data_service_path}/service/data_share/common/app_connect_manager.cpp", "${data_service_path}/service/data_share/common/bundle_mgr_proxy.cpp", diff --git a/services/distributeddataservice/service/test/fuzztest/datashareservicestub_fuzzer/BUILD.gn b/services/distributeddataservice/service/test/fuzztest/datashareservicestub_fuzzer/BUILD.gn index 122e80ed1..8f2dc9fbb 100644 --- a/services/distributeddataservice/service/test/fuzztest/datashareservicestub_fuzzer/BUILD.gn +++ b/services/distributeddataservice/service/test/fuzztest/datashareservicestub_fuzzer/BUILD.gn @@ -48,7 +48,6 @@ ohos_fuzztest("DataShareServiceStubFuzzTest") { ] sources = [ - "${data_service_path}/service/common/bundle_utils.cpp", "${data_service_path}/service/common/xcollie.cpp", "${data_service_path}/service/data_share/common/app_connect_manager.cpp", "${data_service_path}/service/data_share/common/bundle_mgr_proxy.cpp", diff --git a/services/distributeddataservice/service/test/fuzztest/datasharesubscriber_fuzzer/BUILD.gn b/services/distributeddataservice/service/test/fuzztest/datasharesubscriber_fuzzer/BUILD.gn index 59d6a23d9..42efc4c2c 100644 --- a/services/distributeddataservice/service/test/fuzztest/datasharesubscriber_fuzzer/BUILD.gn +++ b/services/distributeddataservice/service/test/fuzztest/datasharesubscriber_fuzzer/BUILD.gn @@ -50,7 +50,6 @@ ohos_fuzztest("DataShareSubscriberFuzzTest") { ] sources = [ - "${data_service_path}/service/common/bundle_utils.cpp", "${data_service_path}/service/common/xcollie.cpp", "${data_service_path}/service/data_share/common/app_connect_manager.cpp", "${data_service_path}/service/data_share/common/bundle_mgr_proxy.cpp", -- Gitee