From e9135a52b30049b6257138ec42c7f1ff28935da6 Mon Sep 17 00:00:00 2001 From: jiangminsen Date: Wed, 7 Aug 2024 19:36:38 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E7=BB=9D=E5=AF=B9=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E5=BC=95=E7=94=A8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jiangminsen --- services/dbms/src/distributed_data_storage.cpp | 7 ++----- .../dbms/test/unittest/distributed_bms_host_test/BUILD.gn | 8 +++----- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/services/dbms/src/distributed_data_storage.cpp b/services/dbms/src/distributed_data_storage.cpp index bbb411f..a371416 100644 --- a/services/dbms/src/distributed_data_storage.cpp +++ b/services/dbms/src/distributed_data_storage.cpp @@ -308,7 +308,7 @@ bool DistributedDataStorage::SyncAndCompleted(const std::string &udid, const std APP_LOGE("can not get uuid by networkId error:%{public}d", ret); return false; } - if (udid.size() == 0) { + if (uuid.size() == 0) { APP_LOGE("get uuid is Empty"); return false; } @@ -481,7 +481,7 @@ std::map DistributedDataStorage::GetAllOldDi APP_LOGE("GetLocalUdid failed"); return oldDistributedBundleInfos; } - Key allEntryKeyPrefix(""); + Key allEntryKeyPrefix(udid); std::vector allEntries; Status status = kvStorePtr_->GetEntries(allEntryKeyPrefix, allEntries); if (status != Status::SUCCESS) { @@ -490,9 +490,6 @@ std::map DistributedDataStorage::GetAllOldDi } for (const auto &entry : allEntries) { std::string key = entry.key.ToString(); - if (key.find(udid) == std::string::npos) { - continue; - } std::string value = entry.value.ToString(); DistributedBundleInfo distributedBundleInfo; if (distributedBundleInfo.FromJsonString(value)) { diff --git a/services/dbms/test/unittest/distributed_bms_host_test/BUILD.gn b/services/dbms/test/unittest/distributed_bms_host_test/BUILD.gn index b11a501..8ae72e9 100644 --- a/services/dbms/test/unittest/distributed_bms_host_test/BUILD.gn +++ b/services/dbms/test/unittest/distributed_bms_host_test/BUILD.gn @@ -31,11 +31,7 @@ ohos_unittest("DistributedBmsHostTest") { "mock_distributed_bms_interface.cpp", ] - deps = [ - "${dbms_inner_api_path}:dbms_fwk", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] + deps = [ "${dbms_inner_api_path}:dbms_fwk" ] external_deps = [ "ability_base:want", @@ -47,6 +43,8 @@ ohos_unittest("DistributedBmsHostTest") { "c_utils:utils", "common_event_service:cesfwk_innerkits", "device_manager:devicemanagersdk", + "googletest:gmock_main", + "googletest:gtest_main", "hicollie:libhicollie", "hilog:libhilog", "i18n:intl_util", -- Gitee From f258929acf8bdc53a1c5710a062a1787e166f455 Mon Sep 17 00:00:00 2001 From: jiangminsen Date: Wed, 4 Sep 2024 09:14:46 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E7=AB=9E=E4=BA=89?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jiangminsen --- services/dbms/include/distributed_bms.h | 1 + services/dbms/src/distributed_bms.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/services/dbms/include/distributed_bms.h b/services/dbms/include/distributed_bms.h index 145c18c..d4e4309 100644 --- a/services/dbms/include/distributed_bms.h +++ b/services/dbms/include/distributed_bms.h @@ -144,6 +144,7 @@ private: std::shared_ptr dbmsDeviceManager_; std::shared_ptr distributedSub_; std::mutex bundleMgrMutex_; + std::mutex dbmsDeviceManagerMutex_; void Init(); void InitDeviceManager(); diff --git a/services/dbms/src/distributed_bms.cpp b/services/dbms/src/distributed_bms.cpp index 1b11085..1bde3d4 100644 --- a/services/dbms/src/distributed_bms.cpp +++ b/services/dbms/src/distributed_bms.cpp @@ -168,8 +168,11 @@ void DistributedBms::Init() void DistributedBms::InitDeviceManager() { if (dbmsDeviceManager_ == nullptr) { - APP_LOGI("Create device manager"); - dbmsDeviceManager_ = std::make_shared(); + std::lock_guard lock(dbmsDeviceManagerMutex_); + if (dbmsDeviceManager_ == nullptr) { + APP_LOGI("Create device manager"); + dbmsDeviceManager_ = std::make_shared(); + } } } -- Gitee From 5e0d8ee7b3445b1e47c2f947c974338b68a63a1e Mon Sep 17 00:00:00 2001 From: jiangminsen Date: Wed, 9 Oct 2024 16:47:35 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=AE=89=E5=85=A8=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jiangminsen --- services/dbms/src/image_compress.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/dbms/src/image_compress.cpp b/services/dbms/src/image_compress.cpp index 894bc16..6365e81 100644 --- a/services/dbms/src/image_compress.cpp +++ b/services/dbms/src/image_compress.cpp @@ -151,12 +151,16 @@ bool ImageCompress::CompressImageByContent(const std::unique_ptr &fil Media::SourceOptions options; std::unique_ptr imageSourcePtr = Media::ImageSource::CreateImageSource(fileData.get(), fileSize, options, errorCode); + if (imageSourcePtr == nullptr) { + APP_LOGE("imageSourcePtr nullptr"); + return false; + } // do compress Media::DecodeOptions decodeOptions; uint32_t pixMapError = 0; std::unique_ptr pixMap = imageSourcePtr->CreatePixelMap(decodeOptions, pixMapError); if (pixMap == nullptr || pixMapError != Media::SUCCESS) { - APP_LOGE("CreatePixelMap failed!"); + APP_LOGE("CreatePixelMap failed"); return false; } double ratio = CalculateRatio(fileSize, imageType); -- Gitee