diff --git a/services/distributeddataservice/service/common/BUILD.gn b/services/distributeddataservice/service/common/BUILD.gn index 98a8c1c55a479c8b1aa7f7a37e936f5af2327261..50a08c56e6e2ee8ef72a754ae62274ca1a5c89fd 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 f722d9d851e4cf511d822af0e8b1e38b62cac1ab..0000000000000000000000000000000000000000 --- 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 98dad60ea3dabdc55481d61b83e3230c9093a085..0000000000000000000000000000000000000000 --- 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 843b53d1517ccbe98031942f072db7f962c7e9fe..267a66c32ffa41bc3041f5ce9b2e10b251ae02cf 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 6f6ca58c43cf209507865c4738ff92c643fd751d..7198715f13ab791ed66c14ba7dfca73b089f6d95 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 c9a1b00f740f088abb6c637eda37e4aca0ff619f..b6c6ef15013fe3c35d45862a6ec5596d74d9f572 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 228d33ab1c1549a859ed8ec426f3e903ea13c4a0..3f2341deee1ea01f3f530b26f7b4e97a24ba5f95 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 2f050490c0e2e16943098b1ecc9ef10444a1cba2..da148cd8366a0b381aec63560027bef3bc4ee271 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 076ec4bb30496342d23cb744dd267cb0eea4f3df..cd59ac22f7b6c16be11c9a171dc7e1327600e8d6 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 a9fa1ed938b695ddd21df83d8bc0ce4b3f071443..17ca41e7ea604699c00f5b3795e897e9942db54f 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 122e80ed1abe3beb48bb493e18f05163f05f89f5..8f2dc9fbb4b701f19ee5edffcc26f5b392953b44 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 59d6a23d90c2af2074a2315dad3bb6ba0f671a68..42efc4c2cd66b7e94b1dabd35e920ce2c72739b5 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",