From fe88c2034f404c7262b453d5c324c5cc99b079a5 Mon Sep 17 00:00:00 2001 From: "yaoruozi1@huawei.com" Date: Tue, 24 Oct 2023 17:32:15 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E5=BA=A7=E8=88=B1=E7=BB=93=E6=9E=9C=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yaoruozi1@huawei.com --- common/utils/include/ipublisher_listener.h | 6 +++++- .../src/publisher/publisher.cpp | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/common/utils/include/ipublisher_listener.h b/common/utils/include/ipublisher_listener.h index 5a4938ec..2288643e 100644 --- a/common/utils/include/ipublisher_listener.h +++ b/common/utils/include/ipublisher_listener.h @@ -37,7 +37,11 @@ enum class DHTopic : uint32_t { // publish low latency message TOPIC_LOW_LATENCY = 5, // Topic max border, not use for real topic - TOPIC_MAX = 6 + TOPIC_MAX = 6, + // Topic connect car cabin success + TOPIC_CONNECT_SUCCESS = 7, + // Topic disconnect car cabin success + TOPIC_DISCONNECT_SUCCESS = 8 }; class IPublisherListener : public IRemoteBroker { diff --git a/services/distributedhardwarefwkservice/src/publisher/publisher.cpp b/services/distributedhardwarefwkservice/src/publisher/publisher.cpp index 199637b7..f312ede2 100644 --- a/services/distributedhardwarefwkservice/src/publisher/publisher.cpp +++ b/services/distributedhardwarefwkservice/src/publisher/publisher.cpp @@ -25,6 +25,8 @@ Publisher::Publisher() : publisherItems_({ { DHTopic::TOPIC_STOP_DSCREEN, std::make_shared(DHTopic::TOPIC_STOP_DSCREEN) }, { DHTopic::TOPIC_DEV_OFFLINE, std::make_shared(DHTopic::TOPIC_DEV_OFFLINE) }, { DHTopic::TOPIC_LOW_LATENCY, std::make_shared(DHTopic::TOPIC_LOW_LATENCY) }, + { DHTopic::TOPIC_CONNECT_SUCCESS, std::make_shared(DHTopic::TOPIC_CONNECT_SUCCESS) }, + { DHTopic::TOPIC_DISCONNECT_SUCCESS, std::make_shared(DHTopic::TOPIC_DISCONNECT_SUCCESS) }, }) { } -- Gitee From 465748d1b560031b062cefc8815c53c87df7f6e9 Mon Sep 17 00:00:00 2001 From: "yaoruozi1@huawei.com" Date: Wed, 25 Oct 2023 15:27:17 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BA=A7=E8=88=B1?= =?UTF-8?q?=E5=87=86=E5=A4=87=E6=88=90=E5=8A=9FTopic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yaoruozi1@huawei.com --- common/utils/include/ipublisher_listener.h | 6 ++---- .../src/publisher/publisher.cpp | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/common/utils/include/ipublisher_listener.h b/common/utils/include/ipublisher_listener.h index 2288643e..2ff77b83 100644 --- a/common/utils/include/ipublisher_listener.h +++ b/common/utils/include/ipublisher_listener.h @@ -38,10 +38,8 @@ enum class DHTopic : uint32_t { TOPIC_LOW_LATENCY = 5, // Topic max border, not use for real topic TOPIC_MAX = 6, - // Topic connect car cabin success - TOPIC_CONNECT_SUCCESS = 7, - // Topic disconnect car cabin success - TOPIC_DISCONNECT_SUCCESS = 8 + // Topic car cabin is ready + TOPIC_CAR_CARBIN_READY = 7 }; class IPublisherListener : public IRemoteBroker { diff --git a/services/distributedhardwarefwkservice/src/publisher/publisher.cpp b/services/distributedhardwarefwkservice/src/publisher/publisher.cpp index f312ede2..38adb40a 100644 --- a/services/distributedhardwarefwkservice/src/publisher/publisher.cpp +++ b/services/distributedhardwarefwkservice/src/publisher/publisher.cpp @@ -25,8 +25,7 @@ Publisher::Publisher() : publisherItems_({ { DHTopic::TOPIC_STOP_DSCREEN, std::make_shared(DHTopic::TOPIC_STOP_DSCREEN) }, { DHTopic::TOPIC_DEV_OFFLINE, std::make_shared(DHTopic::TOPIC_DEV_OFFLINE) }, { DHTopic::TOPIC_LOW_LATENCY, std::make_shared(DHTopic::TOPIC_LOW_LATENCY) }, - { DHTopic::TOPIC_CONNECT_SUCCESS, std::make_shared(DHTopic::TOPIC_CONNECT_SUCCESS) }, - { DHTopic::TOPIC_DISCONNECT_SUCCESS, std::make_shared(DHTopic::TOPIC_DISCONNECT_SUCCESS) }, + { DHTopic::TOPIC_CAR_CARBIN_READY, std::make_shared(DHTopic::TOPIC_CAR_CARBIN_READY) }, }) { } -- Gitee From d4329930893100e3972116fa15ac378f0bc46194 Mon Sep 17 00:00:00 2001 From: "yaoruozi1@huawei.com" Date: Fri, 3 Nov 2023 14:14:00 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9Topic=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yaoruozi1@huawei.com --- common/utils/include/ipublisher_listener.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/utils/include/ipublisher_listener.h b/common/utils/include/ipublisher_listener.h index 2ff77b83..21051e1b 100644 --- a/common/utils/include/ipublisher_listener.h +++ b/common/utils/include/ipublisher_listener.h @@ -36,10 +36,10 @@ enum class DHTopic : uint32_t { TOPIC_DEV_OFFLINE = 4, // publish low latency message TOPIC_LOW_LATENCY = 5, - // Topic max border, not use for real topic - TOPIC_MAX = 6, // Topic car cabin is ready - TOPIC_CAR_CARBIN_READY = 7 + TOPIC_CAR_CARBIN_READY = 6, + // Topic max border, not use for real topic + TOPIC_MAX = 7 }; class IPublisherListener : public IRemoteBroker { -- Gitee From 3e9ec9bad41dee5e522aed65cfedace20700111b Mon Sep 17 00:00:00 2001 From: "yaoruozi1@huawei.com" Date: Fri, 3 Nov 2023 14:18:56 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9Topic=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yaoruozi1@huawei.com --- common/utils/include/ipublisher_listener.h | 2 +- .../distributedhardwarefwkservice/src/publisher/publisher.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/utils/include/ipublisher_listener.h b/common/utils/include/ipublisher_listener.h index 21051e1b..efc2ae95 100644 --- a/common/utils/include/ipublisher_listener.h +++ b/common/utils/include/ipublisher_listener.h @@ -37,7 +37,7 @@ enum class DHTopic : uint32_t { // publish low latency message TOPIC_LOW_LATENCY = 5, // Topic car cabin is ready - TOPIC_CAR_CARBIN_READY = 6, + TOPIC_CAR_CABIN_READY = 6, // Topic max border, not use for real topic TOPIC_MAX = 7 }; diff --git a/services/distributedhardwarefwkservice/src/publisher/publisher.cpp b/services/distributedhardwarefwkservice/src/publisher/publisher.cpp index 38adb40a..2ba20c84 100644 --- a/services/distributedhardwarefwkservice/src/publisher/publisher.cpp +++ b/services/distributedhardwarefwkservice/src/publisher/publisher.cpp @@ -25,7 +25,7 @@ Publisher::Publisher() : publisherItems_({ { DHTopic::TOPIC_STOP_DSCREEN, std::make_shared(DHTopic::TOPIC_STOP_DSCREEN) }, { DHTopic::TOPIC_DEV_OFFLINE, std::make_shared(DHTopic::TOPIC_DEV_OFFLINE) }, { DHTopic::TOPIC_LOW_LATENCY, std::make_shared(DHTopic::TOPIC_LOW_LATENCY) }, - { DHTopic::TOPIC_CAR_CARBIN_READY, std::make_shared(DHTopic::TOPIC_CAR_CARBIN_READY) }, + { DHTopic::TOPIC_CAR_CABIN_READY, std::make_shared(DHTopic::TOPIC_CAR_CABIN_READY) }, }) { } -- Gitee From ffffc921d08cc8b32baa4bbb86fafea84252ea11 Mon Sep 17 00:00:00 2001 From: "yaoruozi1@huawei.com" Date: Sat, 18 Nov 2023 11:23:41 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=BA=A7=E8=88=B1=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yaoruozi1@huawei.com --- .../include/dhardware_ipc_interface_code.h | 19 +++++++------- common/utils/include/idistributed_hardware.h | 3 ++- .../include/ipc/distributed_hardware_proxy.h | 1 + .../src/ipc/distributed_hardware_proxy.cpp | 25 ++++++++++++++++++- .../include/distributed_hardware_service.h | 1 + .../include/distributed_hardware_stub.h | 1 + .../src/distributed_hardware_service.cpp | 10 ++++++++ .../src/distributed_hardware_stub.cpp | 16 ++++++++++++ 8 files changed, 65 insertions(+), 11 deletions(-) diff --git a/common/utils/include/dhardware_ipc_interface_code.h b/common/utils/include/dhardware_ipc_interface_code.h index 4027e585..f5e49b60 100644 --- a/common/utils/include/dhardware_ipc_interface_code.h +++ b/common/utils/include/dhardware_ipc_interface_code.h @@ -22,15 +22,16 @@ namespace OHOS { namespace DistributedHardware { enum class DHMsgInterfaceCode : uint32_t { - REG_PUBLISHER_LISTNER = 1, - UNREG_PUBLISHER_LISTENER = 2, - PUBLISH_MESSAGE = 3, - INIT_CTL_CEN = 4, - RELEASE_CTL_CEN = 5, - CREATE_CTL_CEN_CHANNEL = 6, - NOTIFY_AV_EVENT = 7, - REGISTER_CTL_CEN_CALLBACK = 8, - QUERY_LOCAL_SYS_SPEC = 9, + REG_PUBLISHER_LISTNER = 48001, + UNREG_PUBLISHER_LISTENER = 48002, + PUBLISH_MESSAGE = 48003, + INIT_CTL_CEN = 48004, + RELEASE_CTL_CEN = 48005, + CREATE_CTL_CEN_CHANNEL = 48006, + NOTIFY_AV_EVENT = 48007, + REGISTER_CTL_CEN_CALLBACK = 48008, + QUERY_LOCAL_SYS_SPEC = 48009, + NOTIFY_SOURCE_DEVICE_REMOTE_DMSDP_STARTED = 1, }; } // namespace DistributedHardware } // namespace OHOS diff --git a/common/utils/include/idistributed_hardware.h b/common/utils/include/idistributed_hardware.h index c919ae23..98337d3f 100644 --- a/common/utils/include/idistributed_hardware.h +++ b/common/utils/include/idistributed_hardware.h @@ -31,7 +31,7 @@ namespace OHOS { namespace DistributedHardware { class IDistributedHardware : public OHOS::IRemoteBroker { public: - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.distributedhardware.distributedhardwarefwk"); + DECLARE_INTERFACE_DESCRIPTOR(u"ohos.distributedhardware.accessToken"); IDistributedHardware() = default; virtual ~IDistributedHardware() = default; virtual int32_t RegisterPublisherListener(const DHTopic topic, const sptr &listener) = 0; @@ -45,6 +45,7 @@ public: virtual int32_t NotifyAVCenter(int32_t engineId, const AVTransEvent &event) = 0; virtual int32_t RegisterCtlCenterCallback(int32_t engineId, const sptr &callback) = 0; + virtual int32_t NotifySourceRemoteSinkStarted(std::string &deviceId) = 0; }; } // namespace DistributedHardware } // namespace OHOS diff --git a/interfaces/inner_kits/include/ipc/distributed_hardware_proxy.h b/interfaces/inner_kits/include/ipc/distributed_hardware_proxy.h index 14c50bcd..557548b4 100644 --- a/interfaces/inner_kits/include/ipc/distributed_hardware_proxy.h +++ b/interfaces/inner_kits/include/ipc/distributed_hardware_proxy.h @@ -43,6 +43,7 @@ public: int32_t CreateControlChannel(int32_t engineId, const std::string &peerDevId) override; int32_t NotifyAVCenter(int32_t engineId, const AVTransEvent &event) override; int32_t RegisterCtlCenterCallback(int32_t engineId, const sptr &callback) override; + int32_t NotifySourceRemoteSinkStarted(std::string &deviceId) override; private: static inline BrokerDelegator delegator_; diff --git a/interfaces/inner_kits/src/ipc/distributed_hardware_proxy.cpp b/interfaces/inner_kits/src/ipc/distributed_hardware_proxy.cpp index f3b7847f..584e9962 100644 --- a/interfaces/inner_kits/src/ipc/distributed_hardware_proxy.cpp +++ b/interfaces/inner_kits/src/ipc/distributed_hardware_proxy.cpp @@ -364,7 +364,6 @@ int32_t DistributedHardwareProxy::RegisterCtlCenterCallback(int32_t engineId, MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { DHLOGE("WriteInterfaceToken fail!"); return ERR_DH_AVT_SERVICE_WRITE_TOKEN_FAIL; @@ -386,5 +385,29 @@ int32_t DistributedHardwareProxy::RegisterCtlCenterCallback(int32_t engineId, return reply.ReadInt32(); } + +int32_t DistributedHardwareProxy::NotifySourceRemoteSinkStarted(std::string &deviceId) +{ + DHLOGI("DistributedHardwareProxy NotifySourceRemoteSinkStarted Started"); + sptr remote = Remote(); + if (remote == nullptr) { + DHLOGE("NotifySourceRemoteSinkStarted error, remote info is null"); + return ERR_DH_AVT_SERVICE_REMOTE_IS_NULL; + } + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + DHLOGE("WriteInterfaceToken fail!"); + return ERR_DH_FWK_SERVICE_WRITE_TOKEN_FAIL; + } + if (!data.WriteString(deviceId)) { + DHLOGE("Write deviceId error."); + return ERR_DH_FWK_SERVICE_WRITE_INFO_FAIL; + } + int32_t ret = remote->SendRequest(static_cast(DHMsgInterfaceCode::NOTIFY_SOURCE_DEVICE_REMOTE_DMSDP_STARTED), data, reply, option); + DHLOGI("DistributedHardwareProxy NotifySourceRemoteSinkStarted End"); + return ret; +} } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file diff --git a/services/distributedhardwarefwkservice/include/distributed_hardware_service.h b/services/distributedhardwarefwkservice/include/distributed_hardware_service.h index 260aaebf..5a7c74cf 100644 --- a/services/distributedhardwarefwkservice/include/distributed_hardware_service.h +++ b/services/distributedhardwarefwkservice/include/distributed_hardware_service.h @@ -47,6 +47,7 @@ public: int32_t CreateControlChannel(int32_t engineId, const std::string &peerDevId) override; int32_t NotifyAVCenter(int32_t engineId, const AVTransEvent &event) override; int32_t RegisterCtlCenterCallback(int32_t engineId, const sptr &callback) override; + int32_t NotifySourceRemoteSinkStarted(std::string &deviceId) override; protected: void OnStart() override; diff --git a/services/distributedhardwarefwkservice/include/distributed_hardware_stub.h b/services/distributedhardwarefwkservice/include/distributed_hardware_stub.h index 79d8a95b..2ac1585e 100644 --- a/services/distributedhardwarefwkservice/include/distributed_hardware_stub.h +++ b/services/distributedhardwarefwkservice/include/distributed_hardware_stub.h @@ -37,6 +37,7 @@ private: int32_t CreateControlChannelInner(MessageParcel &data, MessageParcel &reply); int32_t NotifyAVCenterInner(MessageParcel &data, MessageParcel &reply); int32_t RegisterControlCenterCallbackInner(MessageParcel &data, MessageParcel &reply); + int32_t HandleNotifySourceRemoteSinkStarted(MessageParcel &data, MessageParcel &reply); bool ValidTopic(uint32_t topic); bool ValidQueryLocalSpec(uint32_t spec); diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp index 24cb7a2e..73103395 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp @@ -17,9 +17,11 @@ #include +#include "constants.h" #include "if_system_ability_manager.h" #include "ipc_skeleton.h" #include "ipc_types.h" +#include "ipublisher_listener.h" #include "iservice_registry.h" #include "nlohmann/json.hpp" #include "string_ex.h" @@ -208,6 +210,14 @@ int32_t DistributedHardwareService::RegisterCtlCenterCallback(int32_t engineId, return AVTransControlCenter::GetInstance().RegisterCtlCenterCallback(engineId, callback); } +int32_t DistributedHardwareService::NotifySourceRemoteSinkStarted(std::string &deviceId) +{ + DHLOGI("DistributedHardwareService NotifySourceRemoteSinkStarted Cabin Ready Start."); + Publisher::GetInstance().PublishMessage(DHTopic::TOPIC_CAR_CABIN_READY, deviceId); + DHLOGI("DistributedHardwareService NotifySourceRemoteSinkStarted Cabin Ready End."); + return DH_FWK_SUCCESS; +} + int DistributedHardwareService::Dump(int32_t fd, const std::vector& args) { DHLOGI("DistributedHardwareService Dump."); diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_stub.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_stub.cpp index 6a268097..132ceda4 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_stub.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_stub.cpp @@ -63,6 +63,9 @@ int32_t DistributedHardwareStub::OnRemoteRequest(uint32_t code, MessageParcel &d case static_cast(DHMsgInterfaceCode::QUERY_LOCAL_SYS_SPEC): { return QueryLocalSysSpecInner(data, reply); } + case static_cast(DHMsgInterfaceCode::NOTIFY_SOURCE_DEVICE_REMOTE_DMSDP_STARTED): { + return HandleNotifySourceRemoteSinkStarted(data, reply); + } default: return IPCObjectStub::OnRemoteRequest(code, data, reply, option); } @@ -217,6 +220,19 @@ int32_t DistributedHardwareStub::RegisterControlCenterCallbackInner(MessageParce return DH_FWK_SUCCESS; } +int32_t OHOS::DistributedHardware::DistributedHardwareStub::HandleNotifySourceRemoteSinkStarted(MessageParcel &data, MessageParcel &reply) +{ + DHLOGI("DistributedHardwareStub HandleNotifySourceRemoteSinkStarted Start."); + std::string deviceId = data.ReadString(); + int32_t ret = NotifySourceRemoteSinkStarted(deviceId); + if(!reply.WriteInt32(ret)) { + DHLOGE("write ret failed."); + return ERR_DH_FWK_SERVICE_WRITE_INFO_FAIL; + } + DHLOGI("DistributedHardwareStub HandleNotifySourceRemoteSinkStarted End."); + return DH_FWK_SUCCESS; +} + bool DistributedHardwareStub::ValidTopic(uint32_t topic) { if (topic <= (uint32_t)DHTopic::TOPIC_MIN || topic >= (uint32_t)DHTopic::TOPIC_MAX) { -- Gitee