From 466aa832b17201f4e4976f79f2559ff68616a349 Mon Sep 17 00:00:00 2001 From: wangsen1994 Date: Tue, 8 Jul 2025 22:06:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E5=8A=A8=E5=90=8C=E6=AD=A5=E5=AE=9E?= =?UTF-8?q?=E5=86=B5=E6=97=B6=EF=BC=8C=E6=9C=AA=E6=A0=A1=E9=AA=8C=E5=AE=9E?= =?UTF-8?q?=E5=86=B5=E5=8D=8F=E5=90=8C=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangsen1994 --- .../include/soft_bus/distributed_service.h | 1 + .../distributed_publish_service_v2.cpp | 27 ++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/services/distributed/include/soft_bus/distributed_service.h b/services/distributed/include/soft_bus/distributed_service.h index 1b17aa3a1..c2fd686a8 100644 --- a/services/distributed/include/soft_bus/distributed_service.h +++ b/services/distributed/include/soft_bus/distributed_service.h @@ -59,6 +59,7 @@ public: #endif std::string GetNotificationKey(const std::shared_ptr& notification); constexpr static const char* WEARABLE_DEVICE_TYPE = "wearable"; + constexpr static const char* LITEWEARABLE_DEVICE_TYPE = "liteWearable"; constexpr static const char* PAD_DEVICE_TYPE = "pad"; constexpr static const char* PC_DEVICE_TYPE = "pc"; constexpr static const char* PHONE_DEVICE_TYPE = "phone"; diff --git a/services/distributed/src/soft_bus/distributed_publish_service_v2.cpp b/services/distributed/src/soft_bus/distributed_publish_service_v2.cpp index 0da71ee42..15c1c661f 100644 --- a/services/distributed/src/soft_bus/distributed_publish_service_v2.cpp +++ b/services/distributed/src/soft_bus/distributed_publish_service_v2.cpp @@ -39,6 +39,7 @@ #include "distributed_subscribe_service.h" #include "remove_all_distributed_box.h" #include "bundle_resource_helper.h" +#include "distributed_service.h" namespace OHOS { namespace Notification { @@ -322,8 +323,26 @@ void DistributedPublishService::SyncLiveViewNotification(const DistributedDevice return; } + DistributedDeviceInfo device; + if (!DistributedDeviceService::GetInstance().GetDeviceInfo(peerDevice.deviceId_, device)) { + return; + } + // wearable switch set by litewearable + std::string deviceType = DistributedDeviceService::DeviceTypeToTypeString(device.deviceType_); + if (deviceType == DistributedService::WEARABLE_DEVICE_TYPE) { + deviceType = DistributedService::LITEWEARABLE_DEVICE_TYPE; + } + + bool enable = false; + auto result = NotificationHelper::IsDistributedEnabledBySlot(NotificationConstant::SlotType::LIVE_VIEW, + deviceType, enable); + if (result != ERR_OK || !enable) { + ANS_LOGW("Dans get switch %{public}s failed %{public}d.", deviceType.c_str(), result); + return; + } + std::vector> notifications; - auto result = NotificationHelper::GetAllNotificationsBySlotType(notifications, + result = NotificationHelper::GetAllNotificationsBySlotType(notifications, NotificationConstant::SlotType::LIVE_VIEW); if (result != ERR_OK) { ANS_LOGI("Dans get all active %{public}d.", result); @@ -339,7 +358,7 @@ void DistributedPublishService::SyncLiveViewNotification(const DistributedDevice } notificationList.push_back(notification->GetKey()); } - SyncNotifictionList(peerDevice, notificationList); + SyncNotifictionList(device, notificationList); for (auto& notification : notifications) { if (notification == nullptr || notification->GetNotificationRequestPoint() == nullptr || @@ -348,9 +367,9 @@ void DistributedPublishService::SyncLiveViewNotification(const DistributedDevice continue; } std::shared_ptr sharedNotification = std::make_shared(*notification); - SendNotifictionRequest(sharedNotification, peerDevice, true); + SendNotifictionRequest(sharedNotification, device, true); } - DistributedDeviceService::GetInstance().SetDeviceSyncData(peerDevice.deviceId_, + DistributedDeviceService::GetInstance().SetDeviceSyncData(device.deviceId_, DistributedDeviceService::SYNC_LIVE_VIEW, true); } -- Gitee