diff --git a/services/distributed/include/soft_bus/distributed_service.h b/services/distributed/include/soft_bus/distributed_service.h index 1b17aa3a1929de02e59364b91a890e8d9db323e2..c2fd686a84842df9605e06eb70b1b64b68e423e1 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 0da71ee42c050d5af7f552137382acac8e376907..15c1c661f1ae9f926868640dccc0394c13ca74b6 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); }