diff --git a/common/utils/include/dhardware_ipc_interface_code.h b/common/utils/include/dhardware_ipc_interface_code.h index 4027e585aa1bfb3b1daa027b95a726ebd561fc74..f5e49b605df039c268001d4c099a6adb75a1b970 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 c919ae238d565f495d3bb521be2d012f8184d5a5..98337d3ffbd62b8379f1116bea735a39fb3be9e1 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/common/utils/include/ipublisher_listener.h b/common/utils/include/ipublisher_listener.h index 5a4938ecd66b8da2d8cb420792890a706250b7aa..efc2ae958e6699435937e6f4155edab1b4e676bc 100644 --- a/common/utils/include/ipublisher_listener.h +++ b/common/utils/include/ipublisher_listener.h @@ -36,8 +36,10 @@ enum class DHTopic : uint32_t { TOPIC_DEV_OFFLINE = 4, // publish low latency message TOPIC_LOW_LATENCY = 5, + // Topic car cabin is ready + TOPIC_CAR_CABIN_READY = 6, // Topic max border, not use for real topic - TOPIC_MAX = 6 + TOPIC_MAX = 7 }; class IPublisherListener : public IRemoteBroker { diff --git a/interfaces/inner_kits/include/ipc/distributed_hardware_proxy.h b/interfaces/inner_kits/include/ipc/distributed_hardware_proxy.h index 14c50bcd3e64487edd8de64155c40e06611df624..557548b49990afb9766c41add849e355035d44ee 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 f3b7847f924f66672543351da3a1a24db4c63a1f..584e996215908ec5946bd95732e3a15741a7c1a7 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 260aaebf5ab31c4b6ad6b33674f88424bfbe38ad..5a7c74cf2a092348eff3f4f8d3e526c4b747669c 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 79d8a95b13f463cd2e796ba261fe32eb309d1804..2ac1585eb8582a787769da305010af3f5a5f8746 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 24cb7a2e33204745cfa2acc49290cf02a8a4394b..7310339510692b49b5fbdb574eb4e1d565c29694 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 6a268097f5821843f2817bc6e8415ae15b9e55c4..132ceda406fd2d07fe7bb1dda7f540fb95ca19b5 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) { diff --git a/services/distributedhardwarefwkservice/src/publisher/publisher.cpp b/services/distributedhardwarefwkservice/src/publisher/publisher.cpp index 199637b75bfd46fe45b4476bf3ed71789a72f823..2ba20c842479d8a79c7c63f871e5bac14f6dbf35 100644 --- a/services/distributedhardwarefwkservice/src/publisher/publisher.cpp +++ b/services/distributedhardwarefwkservice/src/publisher/publisher.cpp @@ -25,6 +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_CABIN_READY, std::make_shared(DHTopic::TOPIC_CAR_CABIN_READY) }, }) { }