From 96d2e71c6bd87eca58c81ea874d4ff18f8becd46 Mon Sep 17 00:00:00 2001 From: oh_ci Date: Thu, 17 Jul 2025 07:34:49 +0000 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!997=20:?= =?UTF-8?q?=20=E5=88=86=E5=B8=83=E5=BC=8F=E7=A1=AC=E4=BB=B6=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=A1=86=E6=9E=B6IDL=E5=8C=96'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../av_trans_control_center_callback.h | 10 +- .../av_trans_control_center_callback_stub.h | 40 +++++ .../src/av_trans_control_center_callback.cpp | 24 ++- .../av_trans_control_center_callback_stub.cpp | 94 ++++++++++++ .../include/av_trans_control_center.h | 6 +- .../av_trans_control_center_callback_proxy.h | 44 ++++++ .../services/src/av_trans_control_center.cpp | 9 +- ...av_trans_control_center_callback_proxy.cpp | 141 ++++++++++++++++++ .../test/fuzztest/BUILD.gn | 3 +- .../avtranscallbacknotify_fuzzer/BUILD.gn | 8 +- .../avtranscallbacknotify_fuzzer.cpp | 5 +- .../BUILD.gn | 8 +- .../avtranscallbacksetparameter_fuzzer.cpp | 4 +- .../BUILD.gn | 9 +- .../avtranscallbacksetsharedmemory_fuzzer.cpp | 5 +- .../BUILD.gn | 65 ++++++++ .../avtransstubonremoterequest_fuzzer.cpp | 85 +++++++++++ .../avtransstubonremoterequest_fuzzer.h | 44 +++--- .../corpus/init | 16 ++ .../project.xml | 25 ++++ .../test/unittest/BUILD.gn | 3 +- ...rans_control_center_callback_stub_test.cpp | 110 ++++++++++++++ ..._trans_control_center_callback_stub_test.h | 42 ++++++ .../av_trans_control_center_callback_test.cpp | 12 +- .../av_trans_control_center_callback_test.h | 3 +- .../services/av_trans_control_center_test.h | 13 +- .../av_trans_engine/av_receiver/BUILD.gn | 1 - .../test/unittest/av_receiver_engine/BUILD.gn | 2 - .../av_receiver_engine_provider/BUILD.gn | 2 - .../av_trans_engine/av_sender/BUILD.gn | 1 - .../test/unittest/av_sender_engine/BUILD.gn | 2 - .../av_sender_engine_provider/BUILD.gn | 2 - .../test/unittest/common/BUILD.gn | 3 +- av_transport/common/include/av_sync_utils.h | 58 ------- av_transport/common/include/av_trans_types.h | 46 +----- av_transport/common/test/unittest/BUILD.gn | 1 - bundle.json | 1 + .../iav_trans_control_center_callback.h | 43 ++++++ common/utils/include/idistributed_hardware.h | 2 +- interfaces/inner_kits/BUILD.gn | 72 +-------- .../include/distributed_hardware_fwk_kit.h | 5 +- .../inner_kits/include/ipc/dhfwk_sa_manager.h | 6 +- .../include/ipc/distributed_hardware_proxy.h | 2 +- .../src/distributed_hardware_fwk_kit.cpp | 2 +- .../inner_kits/src/ipc/dhfwk_sa_manager.cpp | 2 +- .../src/ipc/distributed_hardware_proxy.cpp | 2 +- .../distributedhardwarefwkkit_fuzzer/BUILD.gn | 3 - .../distributedhardwarefwkkit_fuzzer.cpp | 8 +- .../distributedhardwarefwkkit_fuzzer.h | 8 +- .../BUILD.gn | 3 - .../common/distributedhardwarefwkkit/BUILD.gn | 2 - .../distributed_hardware_fwk_kit_test.h | 1 - .../src/distributed_hardware_fwk_kit_test.cpp | 2 +- .../common/ipc/dhfwk_sa_manager/BUILD.gn | 1 - .../include/dhfwk_sa_manager_test.h | 2 +- .../include/distributed_hardware_proxy_test.h | 3 +- .../src/distributed_hardware_proxy_test.cpp | 5 +- .../hardware_status_listener_stub/BUILD.gn | 1 - .../ipc/publisher_listener_stub/BUILD.gn | 1 - interfaces/kits/napi/BUILD.gn | 2 - .../distributedhardwarefwkservice/BUILD.gn | 8 +- .../include/distributed_hardware_service.h | 2 +- .../src/distributed_hardware_service.cpp | 2 +- .../src/distributed_hardware_stub.cpp | 3 +- .../component_privacy/BUILD.gn | 1 - .../common/distributedhardwarestub/BUILD.gn | 1 - .../include/distributed_hardware_stub_test.h | 2 +- .../hidumphelper/enabledcompsdump/BUILD.gn | 1 - .../test/unittest/common/ipc/BUILD.gn | 1 - .../hardware_status_listener_proxy/BUILD.gn | 1 - .../common/lowlatency/lowlatency/BUILD.gn | 1 - .../lowlatency/lowlatencylistener/BUILD.gn | 1 - .../test/unittest/common/publisher/BUILD.gn | 1 - .../unittest/common/versionmanager/BUILD.gn | 1 - utils/BUILD.gn | 5 +- .../common/histreamer_ability_parser/BUILD.gn | 1 - utils/test/unittest/common/utilstool/BUILD.gn | 1 - 77 files changed, 809 insertions(+), 349 deletions(-) create mode 100644 av_transport/av_trans_control_center/inner_kits/include/av_trans_control_center_callback_stub.h create mode 100644 av_transport/av_trans_control_center/inner_kits/src/av_trans_control_center_callback_stub.cpp create mode 100644 av_transport/av_trans_control_center/services/include/ipc/av_trans_control_center_callback_proxy.h create mode 100644 av_transport/av_trans_control_center/services/src/ipc/av_trans_control_center_callback_proxy.cpp create mode 100644 av_transport/av_trans_control_center/test/fuzztest/avtransstubonremoterequest_fuzzer/BUILD.gn create mode 100644 av_transport/av_trans_control_center/test/fuzztest/avtransstubonremoterequest_fuzzer/avtransstubonremoterequest_fuzzer.cpp rename interfaces/inner_kits/IAvTransControlCenterCallback.idl => av_transport/av_trans_control_center/test/fuzztest/avtransstubonremoterequest_fuzzer/avtransstubonremoterequest_fuzzer.h (51%) create mode 100644 av_transport/av_trans_control_center/test/fuzztest/avtransstubonremoterequest_fuzzer/corpus/init create mode 100644 av_transport/av_trans_control_center/test/fuzztest/avtransstubonremoterequest_fuzzer/project.xml create mode 100644 av_transport/av_trans_control_center/test/unittest/inner_kits/av_trans_control_center_callback_stub_test.cpp create mode 100644 av_transport/av_trans_control_center/test/unittest/inner_kits/av_trans_control_center_callback_stub_test.h create mode 100644 common/utils/include/iav_trans_control_center_callback.h diff --git a/av_transport/av_trans_control_center/inner_kits/include/av_trans_control_center_callback.h b/av_transport/av_trans_control_center/inner_kits/include/av_trans_control_center_callback.h index 521da97b..8ec6257c 100644 --- a/av_transport/av_trans_control_center/inner_kits/include/av_trans_control_center_callback.h +++ b/av_transport/av_trans_control_center/inner_kits/include/av_trans_control_center_callback.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -23,14 +23,14 @@ namespace OHOS { namespace DistributedHardware { -class AVTransControlCenterCallback : public AvTransControlCenterCallbackStub { +class AVTransControlCenterCallback : public AVTransControlCenterCallbackStub { public: AVTransControlCenterCallback() = default; ~AVTransControlCenterCallback() override = default; - int32_t SetParameter(uint32_t tag, const std::string &value) override; - int32_t SetSharedMemory(const AVTransSharedMemoryExt& memory) override; - int32_t Notify(const AVTransEventExt& event) override; + int32_t SetParameter(AVTransTag tag, const std::string &value) override; + int32_t SetSharedMemory(const AVTransSharedMemory &memory) override; + int32_t Notify(const AVTransEvent &event) override; void SetSenderEngine(const std::shared_ptr &sender); void SetReceiverEngine(const std::shared_ptr &receiver); diff --git a/av_transport/av_trans_control_center/inner_kits/include/av_trans_control_center_callback_stub.h b/av_transport/av_trans_control_center/inner_kits/include/av_trans_control_center_callback_stub.h new file mode 100644 index 00000000..57327328 --- /dev/null +++ b/av_transport/av_trans_control_center/inner_kits/include/av_trans_control_center_callback_stub.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_AV_TRANS_CONTROL_CENTER_CALLBACK_STUB_H +#define OHOS_AV_TRANS_CONTROL_CENTER_CALLBACK_STUB_H + +#include "iremote_stub.h" +#include "iav_trans_control_center_callback.h" + +namespace OHOS { +namespace DistributedHardware { +class AVTransControlCenterCallbackStub : public IRemoteStub { +public: + AVTransControlCenterCallbackStub(); + virtual ~AVTransControlCenterCallbackStub() override; + int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; + +private: + int32_t SetParameterInner(MessageParcel &data, MessageParcel &reply); + int32_t SetSharedMemoryInner(MessageParcel &data, MessageParcel &reply); + int32_t NotifyInner(MessageParcel &data, MessageParcel &reply); + +private: + DISALLOW_COPY_AND_MOVE(AVTransControlCenterCallbackStub); +}; +} // namespace DistributedHardware +} // namespace OHOS +#endif // OHOS_AV_TRANS_CONTROL_CENTER_CALLBACK_STUB_H diff --git a/av_transport/av_trans_control_center/inner_kits/src/av_trans_control_center_callback.cpp b/av_transport/av_trans_control_center/inner_kits/src/av_trans_control_center_callback.cpp index 7fb896fe..832d0079 100644 --- a/av_transport/av_trans_control_center/inner_kits/src/av_trans_control_center_callback.cpp +++ b/av_transport/av_trans_control_center/inner_kits/src/av_trans_control_center_callback.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -20,42 +20,36 @@ namespace OHOS { namespace DistributedHardware { -int32_t AVTransControlCenterCallback::SetParameter(uint32_t tag, const std::string &value) +int32_t AVTransControlCenterCallback::SetParameter(AVTransTag tag, const std::string &value) { - if ((static_cast(tag) == AVTransTag::START_AV_SYNC) || - (static_cast(tag) == AVTransTag::STOP_AV_SYNC) || - (static_cast(tag) == AVTransTag::TIME_SYNC_RESULT)) { + if ((tag == AVTransTag::START_AV_SYNC) || (tag == AVTransTag::STOP_AV_SYNC) || + (tag == AVTransTag::TIME_SYNC_RESULT)) { std::shared_ptr rcvEngine = receiverEngine_.lock(); if (rcvEngine != nullptr) { - rcvEngine->SetParameter(static_cast(tag), value); + rcvEngine->SetParameter(tag, value); } } return DH_AVT_SUCCESS; } -int32_t AVTransControlCenterCallback::SetSharedMemory(const AVTransSharedMemoryExt &memory) +int32_t AVTransControlCenterCallback::SetSharedMemory(const AVTransSharedMemory &memory) { DHLOGW("AVTransControlCenterCallback::SetSharedMemory enter."); - AVTransSharedMemory memoryTrans; - memoryTrans.size = memory.size; - memoryTrans.fd = memory.fd; - memoryTrans.name = memory.name; - std::shared_ptr sendEngine = senderEngine_.lock(); if (sendEngine != nullptr) { - sendEngine->SetParameter(AVTransTag::SHARED_MEMORY_FD, MarshalSharedMemory(memoryTrans)); + sendEngine->SetParameter(AVTransTag::SHARED_MEMORY_FD, MarshalSharedMemory(memory)); } std::shared_ptr rcvEngine = receiverEngine_.lock(); if (rcvEngine != nullptr) { - rcvEngine->SetParameter(AVTransTag::SHARED_MEMORY_FD, MarshalSharedMemory(memoryTrans)); + rcvEngine->SetParameter(AVTransTag::SHARED_MEMORY_FD, MarshalSharedMemory(memory)); } return DH_AVT_SUCCESS; } -int32_t AVTransControlCenterCallback::Notify(const AVTransEventExt& event) +int32_t AVTransControlCenterCallback::Notify(const AVTransEvent& event) { DHLOGW("AVTransControlCenterCallback::Notify enter."); return DH_AVT_SUCCESS; diff --git a/av_transport/av_trans_control_center/inner_kits/src/av_trans_control_center_callback_stub.cpp b/av_transport/av_trans_control_center/inner_kits/src/av_trans_control_center_callback_stub.cpp new file mode 100644 index 00000000..696bfb12 --- /dev/null +++ b/av_transport/av_trans_control_center/inner_kits/src/av_trans_control_center_callback_stub.cpp @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "av_trans_control_center_callback_stub.h" + +#include "av_trans_errno.h" +#include "distributed_hardware_log.h" + +namespace OHOS { +namespace DistributedHardware { +AVTransControlCenterCallbackStub::AVTransControlCenterCallbackStub() +{ +} + +AVTransControlCenterCallbackStub::~AVTransControlCenterCallbackStub() +{ +} + +int32_t AVTransControlCenterCallbackStub::OnRemoteRequest(uint32_t code, + MessageParcel &data, MessageParcel &reply, MessageOption &option) +{ + (void)option; + if (data.ReadInterfaceToken() != GetDescriptor()) { + DHLOGE("Read valid token failed"); + return ERR_INVALID_DATA; + } + switch (code) { + case (uint32_t)IAVTransControlCenterCallback::Message::SET_PARAMETER: { + return SetParameterInner(data, reply); + } + case (uint32_t)IAVTransControlCenterCallback::Message::SET_SHARED_MEMORY: { + return SetSharedMemoryInner(data, reply); + } + case (uint32_t)IAVTransControlCenterCallback::Message::NOTIFY_AV_EVENT: { + return NotifyInner(data, reply); + } + default: + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); + } + + return NO_ERROR; +} + +int32_t AVTransControlCenterCallbackStub::SetParameterInner(MessageParcel &data, MessageParcel &reply) +{ + uint32_t transTag = data.ReadUint32(); + std::string tagValue = data.ReadString(); + int32_t ret = SetParameter((AVTransTag)transTag, tagValue); + if (!reply.WriteInt32(ret)) { + DHLOGE("Write ret code failed"); + return ERR_DH_AVT_SERVICE_WRITE_INFO_FAIL; + } + return NO_ERROR; +} + +int32_t AVTransControlCenterCallbackStub::SetSharedMemoryInner(MessageParcel &data, MessageParcel &reply) +{ + int32_t fd = data.ReadFileDescriptor(); + int32_t size = data.ReadInt32(); + std::string name = data.ReadString(); + int32_t ret = SetSharedMemory(AVTransSharedMemory{ fd, size, name }); + if (!reply.WriteInt32(ret)) { + DHLOGE("Write ret code failed"); + return ERR_DH_AVT_SERVICE_WRITE_INFO_FAIL; + } + return NO_ERROR; +} + +int32_t AVTransControlCenterCallbackStub::NotifyInner(MessageParcel &data, MessageParcel &reply) +{ + uint32_t type = data.ReadUint32(); + std::string content = data.ReadString(); + std::string peerDevId = data.ReadString(); + int32_t ret = Notify(AVTransEvent{(EventType)type, content, peerDevId}); + if (!reply.WriteInt32(ret)) { + DHLOGE("Write ret code failed"); + return ERR_DH_AVT_SERVICE_WRITE_INFO_FAIL; + } + return NO_ERROR; +} +} // namespace DistributedHardware +} // namespace OHOS \ No newline at end of file diff --git a/av_transport/av_trans_control_center/services/include/av_trans_control_center.h b/av_transport/av_trans_control_center/services/include/av_trans_control_center.h index 8d31239e..4f97415c 100644 --- a/av_transport/av_trans_control_center/services/include/av_trans_control_center.h +++ b/av_transport/av_trans_control_center/services/include/av_trans_control_center.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2025 Huawei Device Co., Ltd. + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -35,7 +35,7 @@ public: int32_t ReleaseAVCenter(int32_t engineId); int32_t CreateControlChannel(int32_t engineId, const std::string &peerDevId); int32_t NotifyAVCenter(int32_t engineId, const AVTransEvent &event); - int32_t RegisterCtlCenterCallback(int32_t engineId, const sptr &callback); + int32_t RegisterCtlCenterCallback(int32_t engineId, const sptr &callback); // interfaces from ISoftbusChannelListener void OnChannelEvent(const AVTransEvent &event) override; @@ -64,7 +64,7 @@ private: std::vector connectedDevIds_; std::map engine2DevIdMap_; - std::map> callbackMap_; + std::map> callbackMap_; }; } } diff --git a/av_transport/av_trans_control_center/services/include/ipc/av_trans_control_center_callback_proxy.h b/av_transport/av_trans_control_center/services/include/ipc/av_trans_control_center_callback_proxy.h new file mode 100644 index 00000000..9b657f4b --- /dev/null +++ b/av_transport/av_trans_control_center/services/include/ipc/av_trans_control_center_callback_proxy.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_AV_TRANS_CONTROL_CENTER_CALLBACK_PROXY_H +#define OHOS_AV_TRANS_CONTROL_CENTER_CALLBACK_PROXY_H + +#include + +#include "iremote_proxy.h" +#include "refbase.h" +#include "iav_trans_control_center_callback.h" + +namespace OHOS { +namespace DistributedHardware { +class AVTransControlCenterCallbackProxy : public IRemoteProxy { +public: + explicit AVTransControlCenterCallbackProxy(const sptr &impl) + : IRemoteProxy(impl) + { + } + virtual ~AVTransControlCenterCallbackProxy() {} + + int32_t SetParameter(AVTransTag tag, const std::string &value) override; + int32_t SetSharedMemory(const AVTransSharedMemory &memory) override; + int32_t Notify(const AVTransEvent &event) override; + +private: + static inline BrokerDelegator delegator_; +}; +} // namespace DistributedHardware +} // namespace OHOS +#endif // OHOS_AV_TRANS_CONTROL_CENTER_CALLBACK_PROXY_H diff --git a/av_transport/av_trans_control_center/services/src/av_trans_control_center.cpp b/av_transport/av_trans_control_center/services/src/av_trans_control_center.cpp index 5a888269..525791ad 100644 --- a/av_transport/av_trans_control_center/services/src/av_trans_control_center.cpp +++ b/av_transport/av_trans_control_center/services/src/av_trans_control_center.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2025 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -17,7 +17,6 @@ #include "anonymous_string.h" #include "av_trans_log.h" -#include "av_trans_errno.h" namespace OHOS { namespace DistributedHardware { @@ -203,7 +202,7 @@ int32_t AVTransControlCenter::NotifyAVCenter(int32_t engineId, const AVTransEven } int32_t AVTransControlCenter::RegisterCtlCenterCallback(int32_t engineId, - const sptr &callback) + const sptr &callback) { TRUE_RETURN_V_MSG_E(IsInvalidEngineId(engineId), ERR_DH_AVT_INVALID_PARAM_VALUE, "Invalid input engine id = %{public}d", engineId); @@ -233,7 +232,7 @@ void AVTransControlCenter::SetParam2Engines(AVTransTag tag, const std::string &v std::lock_guard lock(callbackMutex_); for (auto iter = callbackMap_.begin(); iter != callbackMap_.end(); iter++) { if (iter->second != nullptr) { - iter->second->SetParameter(static_cast(tag), value); + iter->second->SetParameter(tag, value); } } } @@ -243,7 +242,7 @@ void AVTransControlCenter::SetParam2Engines(const AVTransSharedMemory &memory) std::lock_guard lock(callbackMutex_); for (auto iter = callbackMap_.begin(); iter != callbackMap_.end(); iter++) { if (iter->second != nullptr) { - iter->second->SetSharedMemory(AVTransSharedMemoryExt(memory)); + iter->second->SetSharedMemory(memory); } } } diff --git a/av_transport/av_trans_control_center/services/src/ipc/av_trans_control_center_callback_proxy.cpp b/av_transport/av_trans_control_center/services/src/ipc/av_trans_control_center_callback_proxy.cpp new file mode 100644 index 00000000..7a6268f7 --- /dev/null +++ b/av_transport/av_trans_control_center/services/src/ipc/av_trans_control_center_callback_proxy.cpp @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "av_trans_control_center_callback_proxy.h" + +#include +#include "parcel.h" + +#include "av_trans_constants.h" +#include "av_trans_errno.h" +#include "av_trans_log.h" +#include "av_trans_types.h" + +namespace OHOS { +namespace DistributedHardware { +#undef DH_LOG_TAG +#define DH_LOG_TAG "AVTransControlCenterCallbackProxy" + +int32_t AVTransControlCenterCallbackProxy::SetParameter(AVTransTag tag, const std::string& value) +{ + sptr remote = Remote(); + if (remote == nullptr) { + AVTRANS_LOGE("remote service is null"); + return ERR_DH_AVT_SERVICE_REMOTE_IS_NULL; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(GetDescriptor())) { + AVTRANS_LOGE("WriteInterfaceToken fail!"); + return ERR_DH_AVT_SERVICE_WRITE_TOKEN_FAIL; + } + if (!data.WriteUint32((uint32_t)tag)) { + AVTRANS_LOGE("Write tag failed"); + return ERR_DH_AVT_SERVICE_WRITE_INFO_FAIL; + } + if (!data.WriteString(value)) { + AVTRANS_LOGE("Write value failed"); + return ERR_DH_AVT_SERVICE_WRITE_INFO_FAIL; + } + int32_t ret = remote->SendRequest((uint32_t)IAVTransControlCenterCallback::Message::SET_PARAMETER, + data, reply, option); + if (ret != NO_ERROR) { + AVTRANS_LOGE("Send Request failed, ret: %{public}d", ret); + return ERR_DH_AVT_SERVICE_IPC_SEND_REQUEST_FAIL; + } + + return reply.ReadInt32(); +} + +int32_t AVTransControlCenterCallbackProxy::SetSharedMemory(const AVTransSharedMemory &memory) +{ + sptr remote = Remote(); + if (remote == nullptr) { + AVTRANS_LOGE("remote service is null"); + return ERR_DH_AVT_SERVICE_REMOTE_IS_NULL; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(GetDescriptor())) { + AVTRANS_LOGE("WriteInterfaceToken fail!"); + return ERR_DH_AVT_SERVICE_WRITE_TOKEN_FAIL; + } + if (!data.WriteFileDescriptor(memory.fd)) { + AVTRANS_LOGE("Write memory fd failed"); + return ERR_DH_AVT_SERVICE_WRITE_INFO_FAIL; + } + if (!data.WriteInt32(memory.size)) { + AVTRANS_LOGE("Write memory size failed"); + return ERR_DH_AVT_SERVICE_WRITE_INFO_FAIL; + } + if (!data.WriteString(memory.name)) { + AVTRANS_LOGE("Write memory name failed"); + return ERR_DH_AVT_SERVICE_WRITE_INFO_FAIL; + } + int32_t ret = remote->SendRequest((uint32_t)IAVTransControlCenterCallback::Message::SET_SHARED_MEMORY, + data, reply, option); + if (ret != NO_ERROR) { + AVTRANS_LOGE("Send Request failed, ret: %{public}d", ret); + return ERR_DH_AVT_SERVICE_IPC_SEND_REQUEST_FAIL; + } + + return reply.ReadInt32(); +} + +int32_t AVTransControlCenterCallbackProxy::Notify(const AVTransEvent& event) +{ + sptr remote = Remote(); + if (remote == nullptr) { + AVTRANS_LOGE("remote service is null"); + return ERR_DH_AVT_SERVICE_REMOTE_IS_NULL; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(GetDescriptor())) { + AVTRANS_LOGE("WriteInterfaceToken fail!"); + return ERR_DH_AVT_SERVICE_WRITE_TOKEN_FAIL; + } + if (!data.WriteUint32((uint32_t)event.type)) { + AVTRANS_LOGE("Write event type failed"); + return ERR_DH_AVT_SERVICE_WRITE_INFO_FAIL; + } + if (!data.WriteString(event.content)) { + AVTRANS_LOGE("Write event content failed"); + return ERR_DH_AVT_SERVICE_WRITE_INFO_FAIL; + } + if (!data.WriteString(event.peerDevId)) { + AVTRANS_LOGE("Write event peerDevId failed"); + return ERR_DH_AVT_SERVICE_WRITE_INFO_FAIL; + } + int32_t ret = remote->SendRequest((uint32_t)IAVTransControlCenterCallback::Message::NOTIFY_AV_EVENT, + data, reply, option); + if (ret != NO_ERROR) { + AVTRANS_LOGE("Send Request failed, ret: %{public}d", ret); + return ERR_DH_AVT_SERVICE_IPC_SEND_REQUEST_FAIL; + } + + return reply.ReadInt32(); +} +} // namespace DistributedHardware +} // namespace OHOS \ No newline at end of file diff --git a/av_transport/av_trans_control_center/test/fuzztest/BUILD.gn b/av_transport/av_trans_control_center/test/fuzztest/BUILD.gn index ee237584..19a3e19b 100644 --- a/av_transport/av_trans_control_center/test/fuzztest/BUILD.gn +++ b/av_transport/av_trans_control_center/test/fuzztest/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2025 Huawei Device Co., Ltd. +# Copyright (c) 2024 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -19,6 +19,7 @@ group("fuzztest") { "avtranscallbacksetparameter_fuzzer:fuzztest", "avtranscallbacksetsharedmemory_fuzzer:fuzztest", "avtransonsessionclosed_fuzzer:fuzztest", + "avtransstubonremoterequest_fuzzer:fuzztest", "onbytesreceived_fuzzer:fuzztest", "onsoftbustimesyncresult_fuzzer:fuzztest", "onstreamreceived_fuzzer:fuzztest", diff --git a/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacknotify_fuzzer/BUILD.gn b/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacknotify_fuzzer/BUILD.gn index 51edaa07..b9a4c6ab 100644 --- a/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacknotify_fuzzer/BUILD.gn +++ b/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacknotify_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2024-2025 Huawei Device Co., Ltd. +# Copyright (c) 2024 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -40,10 +40,7 @@ ohos_fuzztest("AVTransCallbackNotifyFuzzTest") { sources = [ "avtranscallbacknotify_fuzzer.cpp" ] - deps = [ - "${dh_fwk_sdk_path}:dhfwk_idl_hardware_head", - "${dh_fwk_sdk_path}:libdhfwk_sdk", - ] + deps = [ "${dh_fwk_sdk_path}:libdhfwk_sdk" ] defines = [ "HI_LOG_ENABLE", @@ -57,7 +54,6 @@ ohos_fuzztest("AVTransCallbackNotifyFuzzTest") { "ipc:ipc_core", "safwk:system_ability_fwk", "samgr:samgr_proxy", - "hilog:libhilog", ] } diff --git a/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacknotify_fuzzer/avtranscallbacknotify_fuzzer.cpp b/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacknotify_fuzzer/avtranscallbacknotify_fuzzer.cpp index 65131eee..50336f17 100644 --- a/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacknotify_fuzzer/avtranscallbacknotify_fuzzer.cpp +++ b/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacknotify_fuzzer/avtranscallbacknotify_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024-2025 Huawei Device Co., Ltd. + * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -30,12 +30,11 @@ void AVTransCallbackNotifyFuzzTest(const uint8_t *data, size_t size) std::string content(reinterpret_cast(data), size); std::string peerDevId(reinterpret_cast(data), size); AVTransEvent event = AVTransEvent{ type, content, peerDevId }; - AVTransEventExt eventExt = AVTransEventExt(event); sptr controlCenterCallback(new (std::nothrow) AVTransControlCenterCallback()); if (controlCenterCallback == nullptr) { return; } - controlCenterCallback->Notify(eventExt); + controlCenterCallback->Notify(event); } } // namespace DistributedHardware } // namespace OHOS diff --git a/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetparameter_fuzzer/BUILD.gn b/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetparameter_fuzzer/BUILD.gn index d3ba3dd9..63c488d7 100644 --- a/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetparameter_fuzzer/BUILD.gn +++ b/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetparameter_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2024-2025 Huawei Device Co., Ltd. +# Copyright (c) 2024 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -40,10 +40,7 @@ ohos_fuzztest("AVTransCallbackSetParameterFuzzTest") { sources = [ "avtranscallbacksetparameter_fuzzer.cpp" ] - deps = [ - "${dh_fwk_sdk_path}:dhfwk_idl_hardware_head", - "${dh_fwk_sdk_path}:libdhfwk_sdk", - ] + deps = [ "${dh_fwk_sdk_path}:libdhfwk_sdk" ] defines = [ "HI_LOG_ENABLE", @@ -57,7 +54,6 @@ ohos_fuzztest("AVTransCallbackSetParameterFuzzTest") { "ipc:ipc_core", "safwk:system_ability_fwk", "samgr:samgr_proxy", - "hilog:libhilog", ] } diff --git a/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetparameter_fuzzer/avtranscallbacksetparameter_fuzzer.cpp b/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetparameter_fuzzer/avtranscallbacksetparameter_fuzzer.cpp index 5d753f84..7ab4a3a9 100644 --- a/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetparameter_fuzzer/avtranscallbacksetparameter_fuzzer.cpp +++ b/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetparameter_fuzzer/avtranscallbacksetparameter_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024-2025 Huawei Device Co., Ltd. + * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -32,7 +32,7 @@ void AVTransCallbackSetParameterFuzzTest(const uint8_t *data, size_t size) if (controlCenterCallback == nullptr) { return; } - controlCenterCallback->SetParameter((uint32_t)tag, value); + controlCenterCallback->SetParameter(tag, value); } } // namespace DistributedHardware } // namespace OHOS diff --git a/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetsharedmemory_fuzzer/BUILD.gn b/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetsharedmemory_fuzzer/BUILD.gn index 92aa39a0..9f17b28c 100644 --- a/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetsharedmemory_fuzzer/BUILD.gn +++ b/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetsharedmemory_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2024-2025 Huawei Device Co., Ltd. +# Copyright (c) 2024 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -39,10 +39,8 @@ ohos_fuzztest("AVTransCallbackSetSharedMemoryFuzzTest") { sources = [ "avtranscallbacksetsharedmemory_fuzzer.cpp" ] - deps = [ - "${dh_fwk_sdk_path}:dhfwk_idl_hardware_head", - "${dh_fwk_sdk_path}:libdhfwk_sdk", - ] + deps = [ "${dh_fwk_sdk_path}:libdhfwk_sdk" ] + defines = [ "HI_LOG_ENABLE", "DH_LOG_TAG=\"AVTransCallbackSetSharedMemoryFuzzTest\"", @@ -55,7 +53,6 @@ ohos_fuzztest("AVTransCallbackSetSharedMemoryFuzzTest") { "ipc:ipc_core", "safwk:system_ability_fwk", "samgr:samgr_proxy", - "hilog:libhilog", ] } diff --git a/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetsharedmemory_fuzzer/avtranscallbacksetsharedmemory_fuzzer.cpp b/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetsharedmemory_fuzzer/avtranscallbacksetsharedmemory_fuzzer.cpp index d4cd7c42..66c5c5ef 100644 --- a/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetsharedmemory_fuzzer/avtranscallbacksetsharedmemory_fuzzer.cpp +++ b/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetsharedmemory_fuzzer/avtranscallbacksetsharedmemory_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024-2025 Huawei Device Co., Ltd. + * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -31,12 +31,11 @@ void AVTransCallbackSetSharedMemoryFuzzTest(const uint8_t *data, size_t size) int32_t len = fdp.ConsumeIntegral(); std::string name(reinterpret_cast(data), size); AVTransSharedMemory memory = AVTransSharedMemory{ fd, len, name }; - AVTransSharedMemoryExt memoryExt = AVTransSharedMemoryExt(memory); sptr controlCenterCallback(new (std::nothrow) AVTransControlCenterCallback()); if (controlCenterCallback == nullptr) { return; } - controlCenterCallback->SetSharedMemory(memoryExt); + controlCenterCallback->SetSharedMemory(memory); } } // namespace DistributedHardware } // namespace OHOS diff --git a/av_transport/av_trans_control_center/test/fuzztest/avtransstubonremoterequest_fuzzer/BUILD.gn b/av_transport/av_trans_control_center/test/fuzztest/avtransstubonremoterequest_fuzzer/BUILD.gn new file mode 100644 index 00000000..6ce4af8e --- /dev/null +++ b/av_transport/av_trans_control_center/test/fuzztest/avtransstubonremoterequest_fuzzer/BUILD.gn @@ -0,0 +1,65 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import("../../../../distributed_av_transport.gni") + +##############################fuzztest########################################## +ohos_fuzztest("AVTransStubOnRemoteRequestFuzzTest") { + module_out_path = fuzz_test_output_path + fuzz_config_file = + "${control_center_path}/test/fuzztest/avtransstubonremoterequest_fuzzer" + + include_dirs = [ + "include", + "${common_path}/include", + "${dh_fwk_utils_path}/include", + "${interface_path}", + "${control_center_path}/inner_kits/include", + "${control_center_path}/inner_kits/include/ipc", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "avtransstubonremoterequest_fuzzer.cpp" ] + + deps = [ "${dh_fwk_sdk_path}:libdhfwk_sdk" ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"AVTransStubOnRemoteRequestFuzzTest\"", + "LOG_DOMAIN=0xD004101", + ] + + external_deps = [ + "cJSON:cjson", + "c_utils:utils", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":AVTransStubOnRemoteRequestFuzzTest" ] +} +############################################################################### diff --git a/av_transport/av_trans_control_center/test/fuzztest/avtransstubonremoterequest_fuzzer/avtransstubonremoterequest_fuzzer.cpp b/av_transport/av_trans_control_center/test/fuzztest/avtransstubonremoterequest_fuzzer/avtransstubonremoterequest_fuzzer.cpp new file mode 100644 index 00000000..984fa7a6 --- /dev/null +++ b/av_transport/av_trans_control_center/test/fuzztest/avtransstubonremoterequest_fuzzer/avtransstubonremoterequest_fuzzer.cpp @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "avtransstubonremoterequest_fuzzer.h" + +#include +#include "av_trans_control_center_callback_stub.h" +#include "av_trans_control_center_callback.h" +#include "av_sync_utils.h" +#include "iremote_object.h" +#include "message_option.h" +#include "message_parcel.h" + +namespace OHOS { +namespace DistributedHardware { +const uint32_t DC_MESSAGE_SIZE = 4; + +std::string MarshalSharedMemory(const AVTransSharedMemory &memory) +{ + return ""; +} + +AVTransSharedMemory UnmarshalSharedMemory(const std::string &jsonStr) +{ + return AVTransSharedMemory{0, 0, ""}; +} + +void AVTransStubOnRemoteRequestFuzzTest(const uint8_t *data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + MessageParcel pdata; + MessageParcel reply; + MessageOption option; + pdata.WriteInterfaceToken(AVTransControlCenterCallback::GetDescriptor()); + uint32_t code = *(reinterpret_cast(data)) % DC_MESSAGE_SIZE; + if (code == (uint32_t)IAVTransControlCenterCallback::Message::SET_PARAMETER) { + uint32_t tag = *(reinterpret_cast(data)); + std::string value(reinterpret_cast(data), size); + pdata.WriteUint32(tag); + pdata.WriteString(value); + } else if (code == (uint32_t)IAVTransControlCenterCallback::Message::SET_SHARED_MEMORY) { + FuzzedDataProvider fdp(data, size); + int32_t len = fdp.ConsumeIntegral(); + std::string name(reinterpret_cast(data), size); + pdata.WriteInt32(len); + pdata.WriteString(name); + } else if (code == (uint32_t)IAVTransControlCenterCallback::Message::NOTIFY_AV_EVENT) { + uint32_t type = *(reinterpret_cast(data)); + std::string content(reinterpret_cast(data), size); + std::string devId(reinterpret_cast(data), size); + pdata.WriteUint32(type); + pdata.WriteString(content); + pdata.WriteString(devId); + } + + sptr controlCenterCallback(new (std::nothrow) AVTransControlCenterCallback()); + if (controlCenterCallback == nullptr) { + return; + } + controlCenterCallback->OnRemoteRequest(code, pdata, reply, option); +} +} // namespace DistributedHardware +} // namespace OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::AVTransStubOnRemoteRequestFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/interfaces/inner_kits/IAvTransControlCenterCallback.idl b/av_transport/av_trans_control_center/test/fuzztest/avtransstubonremoterequest_fuzzer/avtransstubonremoterequest_fuzzer.h similarity index 51% rename from interfaces/inner_kits/IAvTransControlCenterCallback.idl rename to av_transport/av_trans_control_center/test/fuzztest/avtransstubonremoterequest_fuzzer/avtransstubonremoterequest_fuzzer.h index 572afca1..29d2a14f 100644 --- a/interfaces/inner_kits/IAvTransControlCenterCallback.idl +++ b/av_transport/av_trans_control_center/test/fuzztest/avtransstubonremoterequest_fuzzer/avtransstubonremoterequest_fuzzer.h @@ -1,23 +1,21 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package OHOS.DistributedHardware; -sequenceable AvTransTypes..OHOS.DistributedHardware.AVTransEventExt; -sequenceable AvSyncUtils..OHOS.DistributedHardware.AVTransSharedMemoryExt; -interface OHOS.DistributedHardware.IAvTransControlCenterCallback { - [ipccode 1] void SetParameter([in] unsigned int tag, [in] String value); - [ipccode 2] void SetSharedMemory([in] AVTransSharedMemoryExt memory); - [ipccode 3] void Notify([in] AVTransEventExt event); -} \ No newline at end of file +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TEST_AVTRANSSTUBONREMOTEREQUEST_FUZZER_H +#define TEST_AVTRANSSTUBONREMOTEREQUEST_FUZZER_H + +#define FUZZ_PROJECT_NAME "avtransstubonremoterequest_fuzzer.cpp" + +#endif \ No newline at end of file diff --git a/av_transport/av_trans_control_center/test/fuzztest/avtransstubonremoterequest_fuzzer/corpus/init b/av_transport/av_trans_control_center/test/fuzztest/avtransstubonremoterequest_fuzzer/corpus/init new file mode 100644 index 00000000..6198079a --- /dev/null +++ b/av_transport/av_trans_control_center/test/fuzztest/avtransstubonremoterequest_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/av_transport/av_trans_control_center/test/fuzztest/avtransstubonremoterequest_fuzzer/project.xml b/av_transport/av_trans_control_center/test/fuzztest/avtransstubonremoterequest_fuzzer/project.xml new file mode 100644 index 00000000..7133b2b9 --- /dev/null +++ b/av_transport/av_trans_control_center/test/fuzztest/avtransstubonremoterequest_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/av_transport/av_trans_control_center/test/unittest/BUILD.gn b/av_transport/av_trans_control_center/test/unittest/BUILD.gn index 3111ed5c..42b720d8 100644 --- a/av_transport/av_trans_control_center/test/unittest/BUILD.gn +++ b/av_transport/av_trans_control_center/test/unittest/BUILD.gn @@ -40,6 +40,7 @@ ohos_unittest("AvTransControlCenterTest") { module_out_path = module_out_path sources = [ + "${control_center_path}/test/unittest/inner_kits/av_trans_control_center_callback_stub_test.cpp", "${control_center_path}/test/unittest/inner_kits/av_trans_control_center_callback_test.cpp", "${control_center_path}/test/unittest/services/av_sync_manager_test.cpp", "${control_center_path}/test/unittest/services/av_trans_control_center_test.cpp", @@ -47,7 +48,6 @@ ohos_unittest("AvTransControlCenterTest") { configs = [ ":module_private_config" ] deps = [ - "${dh_fwk_sdk_path}:dhfwk_idl_hardware_head", "${dh_fwk_sdk_path}:libdhfwk_sdk", "${dh_fwk_services_path}/distributedhardwarefwkservice:distributedhardwarefwksvr", ] @@ -67,7 +67,6 @@ ohos_unittest("AvTransControlCenterTest") { "c_utils:utils", "dsoftbus:softbus_client", "ipc:ipc_core", - "hilog:libhilog", ] cflags = [ diff --git a/av_transport/av_trans_control_center/test/unittest/inner_kits/av_trans_control_center_callback_stub_test.cpp b/av_transport/av_trans_control_center/test/unittest/inner_kits/av_trans_control_center_callback_stub_test.cpp new file mode 100644 index 00000000..9095fae3 --- /dev/null +++ b/av_transport/av_trans_control_center/test/unittest/inner_kits/av_trans_control_center_callback_stub_test.cpp @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "av_trans_control_center_callback_stub_test.h" +#include "av_trans_errno.h" +#include "av_trans_control_center_callback_proxy.h" + +using namespace testing::ext; +namespace OHOS { +namespace DistributedHardware { +void AVTransControlCenterCallbackStubTest::SetUpTestCase(void) +{ +} + +void AVTransControlCenterCallbackStubTest::TearDownTestCase(void) +{ +} + +void AVTransControlCenterCallbackStubTest::SetUp() +{ +} + +void AVTransControlCenterCallbackStubTest::TearDown() +{ +} + +int32_t AVTransControlCenterCallbackStubTest::TestControlCenterCallbackStub::SetParameter( + AVTransTag tag, const std::string &value) +{ + (void) tag; + (void) value; + return DH_AVT_SUCCESS; +} +int32_t AVTransControlCenterCallbackStubTest::TestControlCenterCallbackStub::SetSharedMemory( + const AVTransSharedMemory &memory) +{ + (void) memory; + return DH_AVT_SUCCESS; +} +int32_t AVTransControlCenterCallbackStubTest::TestControlCenterCallbackStub::Notify( + const AVTransEvent &event) +{ + (void) event; + return DH_AVT_SUCCESS; +} + +/** + * @tc.name: set_parameter_001 + * @tc.desc: set parameter function. + * @tc.type: FUNC + * @tc.require: AR000GHSK9 + */ +HWTEST_F(AVTransControlCenterCallbackStubTest, set_parameter_001, TestSize.Level0) +{ + sptr CallbackStubPtr(new TestControlCenterCallbackStub()); + AVTransControlCenterCallbackProxy callbackProxy(CallbackStubPtr); + + AVTransTag tag = AVTransTag::STOP_AV_SYNC; + std::string value = "value"; + int32_t ret = callbackProxy.SetParameter(tag, value); + EXPECT_EQ(NO_ERROR, ret); +} + +/** + * @tc.name: set_shared_memory_001 + * @tc.desc: set shared memory function. + * @tc.type: FUNC + * @tc.require: AR000GHSK9 + */ +HWTEST_F(AVTransControlCenterCallbackStubTest, set_shared_memory_001, TestSize.Level1) +{ + sptr CallbackStubPtr(new TestControlCenterCallbackStub()); + AVTransControlCenterCallbackProxy callbackProxy(CallbackStubPtr); + + AVTransSharedMemory memory; + memory.name = "AVTransSharedMemory"; + int32_t ret = callbackProxy.SetSharedMemory(memory); + EXPECT_EQ(NO_ERROR, ret); +} + +/** + * @tc.name: notify_001 + * @tc.desc: notify function. + * @tc.type: FUNC + * @tc.require: AR000GHSK9 + */ +HWTEST_F(AVTransControlCenterCallbackStubTest, notify_001, TestSize.Level0) +{ + sptr CallbackStubPtr(new TestControlCenterCallbackStub()); + AVTransControlCenterCallbackProxy callbackProxy(CallbackStubPtr); + + AVTransEvent event; + event.content = "content"; + int32_t ret = callbackProxy.Notify(event); + EXPECT_EQ(NO_ERROR, ret); +} +} // namespace DistributedHardware +} // namespace OHOS \ No newline at end of file diff --git a/av_transport/av_trans_control_center/test/unittest/inner_kits/av_trans_control_center_callback_stub_test.h b/av_transport/av_trans_control_center/test/unittest/inner_kits/av_trans_control_center_callback_stub_test.h new file mode 100644 index 00000000..7bbbaf0d --- /dev/null +++ b/av_transport/av_trans_control_center/test/unittest/inner_kits/av_trans_control_center_callback_stub_test.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_AV_TRANS_CONTROL_CENTER_CALLBACK_STUB_TEST_H +#define OHOS_AV_TRANS_CONTROL_CENTER_CALLBACK_STUB_TEST_H + +#include +#include "av_trans_control_center_callback_stub.h" + +namespace OHOS { +namespace DistributedHardware { +class AVTransControlCenterCallbackStubTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + + class TestControlCenterCallbackStub : public OHOS::DistributedHardware::AVTransControlCenterCallbackStub { + public: + TestControlCenterCallbackStub() = default; + virtual ~TestControlCenterCallbackStub() = default; + int32_t SetParameter(AVTransTag tag, const std::string &value) override; + int32_t SetSharedMemory(const AVTransSharedMemory &memory) override; + int32_t Notify(const AVTransEvent &event) override; + }; +}; +} // namespace DistributedHardware +} // namespace OHOS +#endif diff --git a/av_transport/av_trans_control_center/test/unittest/inner_kits/av_trans_control_center_callback_test.cpp b/av_transport/av_trans_control_center/test/unittest/inner_kits/av_trans_control_center_callback_test.cpp index d02eff92..3cf33725 100644 --- a/av_transport/av_trans_control_center/test/unittest/inner_kits/av_trans_control_center_callback_test.cpp +++ b/av_transport/av_trans_control_center/test/unittest/inner_kits/av_trans_control_center_callback_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2025 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -46,7 +46,7 @@ HWTEST_F(AVTransControlCenterCallbackTest, set_parameter_001, TestSize.Level0) callBack_->senderEngine_ = std::shared_ptr(); AVTransTag tag = AVTransTag::START_AV_SYNC; std::string value; - int32_t ret = callBack_->SetParameter((uint32_t)tag, value); + int32_t ret = callBack_->SetParameter(tag, value); EXPECT_EQ(DH_AVT_SUCCESS, ret); } @@ -63,7 +63,7 @@ HWTEST_F(AVTransControlCenterCallbackTest, set_parameter_002, TestSize.Level0) callBack_->senderEngine_ = std::shared_ptr(); AVTransTag tag = AVTransTag::STOP_AV_SYNC; std::string value; - int32_t ret = callBack_->SetParameter((uint32_t)tag, value); + int32_t ret = callBack_->SetParameter(tag, value); EXPECT_EQ(DH_AVT_SUCCESS, ret); } @@ -80,7 +80,7 @@ HWTEST_F(AVTransControlCenterCallbackTest, set_parameter_003, TestSize.Level0) callBack_->senderEngine_ = std::shared_ptr(); AVTransTag tag = AVTransTag::TIME_SYNC_RESULT; std::string value; - int32_t ret = callBack_->SetParameter((uint32_t)tag, value); + int32_t ret = callBack_->SetParameter(tag, value); EXPECT_EQ(DH_AVT_SUCCESS, ret); callBack_->receiverEngine_ = std::shared_ptr(); EXPECT_EQ(DH_AVT_SUCCESS, ret); @@ -97,7 +97,7 @@ HWTEST_F(AVTransControlCenterCallbackTest, set_shared_memory_001, TestSize.Level callBack_ = std::make_shared(); callBack_->receiverEngine_ = std::shared_ptr(); callBack_->senderEngine_ = std::shared_ptr(); - AVTransSharedMemoryExt memory; + AVTransSharedMemory memory; int32_t ret = callBack_->SetSharedMemory(memory); EXPECT_EQ(DH_AVT_SUCCESS, ret); callBack_->senderEngine_ = std::shared_ptr(); @@ -115,7 +115,7 @@ HWTEST_F(AVTransControlCenterCallbackTest, notify_001, TestSize.Level1) callBack_ = std::make_shared(); callBack_->receiverEngine_ = std::shared_ptr(); callBack_->senderEngine_ = std::shared_ptr(); - AVTransEventExt event; + AVTransEvent event; event.type = EventType::EVENT_ADD_STREAM; int32_t ret = callBack_->Notify(event); std::shared_ptr sender = std::shared_ptr(); diff --git a/av_transport/av_trans_control_center/test/unittest/inner_kits/av_trans_control_center_callback_test.h b/av_transport/av_trans_control_center/test/unittest/inner_kits/av_trans_control_center_callback_test.h index 32511d08..664f68e8 100644 --- a/av_transport/av_trans_control_center/test/unittest/inner_kits/av_trans_control_center_callback_test.h +++ b/av_transport/av_trans_control_center/test/unittest/inner_kits/av_trans_control_center_callback_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2025 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -29,7 +29,6 @@ #include "i_av_sender_engine_callback.h" #include "av_trans_message.h" #include "av_trans_buffer.h" -#include "av_trans_errno.h" namespace OHOS { namespace DistributedHardware { class AVTransControlCenterCallbackTest : public testing::Test { diff --git a/av_transport/av_trans_control_center/test/unittest/services/av_trans_control_center_test.h b/av_transport/av_trans_control_center/test/unittest/services/av_trans_control_center_test.h index 926d6bca..c0ab0744 100644 --- a/av_transport/av_trans_control_center/test/unittest/services/av_trans_control_center_test.h +++ b/av_transport/av_trans_control_center/test/unittest/services/av_trans_control_center_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2025 Huawei Device Co., Ltd. + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -24,7 +24,6 @@ #include "av_trans_control_center_callback_stub.h" #include "av_trans_types.h" #include "av_sync_utils.h" -#include "av_trans_errno.h" namespace OHOS { namespace DistributedHardware { @@ -36,26 +35,26 @@ public: void TearDown(); std::shared_ptr center_ = nullptr; }; -class CenterCallback : public AvTransControlCenterCallbackStub { +class CenterCallback : public AVTransControlCenterCallbackStub { public: CenterCallback() = default; ~CenterCallback() override = default; - int32_t SetParameter(uint32_t tag, const std::string &value) override + int32_t SetParameter(AVTransTag tag, const std::string &value) override { value_ = value; return DH_AVT_SUCCESS; } - int32_t SetSharedMemory(const AVTransSharedMemoryExt &memory) override + int32_t SetSharedMemory(const AVTransSharedMemory &memory) override { memory_ = memory; return DH_AVT_SUCCESS; } - int32_t Notify(const AVTransEventExt &event) override + int32_t Notify(const AVTransEvent &event) override { return DH_AVT_SUCCESS; } std::string value_; - AVTransSharedMemoryExt memory_; + AVTransSharedMemory memory_; }; } // namespace DistributedHardware } // namespace OHOS diff --git a/av_transport/av_trans_engine/av_receiver/BUILD.gn b/av_transport/av_trans_engine/av_receiver/BUILD.gn index 8f6514b8..de15b15b 100644 --- a/av_transport/av_trans_engine/av_receiver/BUILD.gn +++ b/av_transport/av_trans_engine/av_receiver/BUILD.gn @@ -71,7 +71,6 @@ ohos_shared_library("distributed_av_receiver") { ] deps = [ - "${dh_fwk_sdk_path}:dhfwk_idl_hardware_head", "${dh_fwk_sdk_path}:libdhfwk_sdk", "${distributed_av_transport_path}/framework:distributed_av_pipeline_fwk", "${filters_path}:avtrans_input_filter", diff --git a/av_transport/av_trans_engine/av_receiver/test/unittest/av_receiver_engine/BUILD.gn b/av_transport/av_trans_engine/av_receiver/test/unittest/av_receiver_engine/BUILD.gn index 0ed9f0c1..4e31909f 100644 --- a/av_transport/av_trans_engine/av_receiver/test/unittest/av_receiver_engine/BUILD.gn +++ b/av_transport/av_trans_engine/av_receiver/test/unittest/av_receiver_engine/BUILD.gn @@ -54,7 +54,6 @@ ohos_unittest("AvReceiverEngineTest") { cflags_cc = cflags deps = [ - "${dh_fwk_sdk_path}:dhfwk_idl_hardware_head", "${dh_fwk_sdk_path}:libdhfwk_sdk", "${engine_path}/av_receiver:distributed_av_receiver", "${filters_path}:avtrans_input_filter", @@ -134,7 +133,6 @@ ohos_unittest("AvAudioReceiverEngineTest") { cflags_cc = cflags deps = [ - "${dh_fwk_sdk_path}:dhfwk_idl_hardware_head", "${dh_fwk_sdk_path}:libdhfwk_sdk", "${distributed_av_transport_path}/framework:distributed_av_pipeline_fwk", "${engine_path}/av_receiver:distributed_av_receiver", diff --git a/av_transport/av_trans_engine/av_receiver/test/unittest/av_receiver_engine_provider/BUILD.gn b/av_transport/av_trans_engine/av_receiver/test/unittest/av_receiver_engine_provider/BUILD.gn index f2d09138..c93f8bd3 100644 --- a/av_transport/av_trans_engine/av_receiver/test/unittest/av_receiver_engine_provider/BUILD.gn +++ b/av_transport/av_trans_engine/av_receiver/test/unittest/av_receiver_engine_provider/BUILD.gn @@ -53,7 +53,6 @@ ohos_unittest("AvReceiverEngineProviderTest") { cflags_cc = cflags deps = [ - "${dh_fwk_sdk_path}:dhfwk_idl_hardware_head", "${dh_fwk_sdk_path}:libdhfwk_sdk", "${engine_path}/av_receiver:distributed_av_receiver", "${filters_path}:avtrans_input_filter", @@ -135,7 +134,6 @@ ohos_unittest("AvAudioReceiverEngineProviderTest") { cflags_cc = cflags deps = [ - "${dh_fwk_sdk_path}:dhfwk_idl_hardware_head", "${dh_fwk_sdk_path}:libdhfwk_sdk", "${engine_path}/av_receiver:distributed_av_receiver", "${filters_path}:avtrans_input_filter", diff --git a/av_transport/av_trans_engine/av_sender/BUILD.gn b/av_transport/av_trans_engine/av_sender/BUILD.gn index 3ca251c9..d17dafb4 100644 --- a/av_transport/av_trans_engine/av_sender/BUILD.gn +++ b/av_transport/av_trans_engine/av_sender/BUILD.gn @@ -66,7 +66,6 @@ ohos_shared_library("distributed_av_sender") { ] deps = [ - "${dh_fwk_sdk_path}:dhfwk_idl_hardware_head", "${dh_fwk_sdk_path}:libdhfwk_sdk", "${distributed_av_transport_path}/framework:distributed_av_pipeline_fwk", "${filters_path}:avtrans_input_filter", diff --git a/av_transport/av_trans_engine/av_sender/test/unittest/av_sender_engine/BUILD.gn b/av_transport/av_trans_engine/av_sender/test/unittest/av_sender_engine/BUILD.gn index b0c8e3a5..d44da2b5 100644 --- a/av_transport/av_trans_engine/av_sender/test/unittest/av_sender_engine/BUILD.gn +++ b/av_transport/av_trans_engine/av_sender/test/unittest/av_sender_engine/BUILD.gn @@ -53,7 +53,6 @@ ohos_unittest("AvSenderEngineTest") { cflags_cc = cflags deps = [ - "${dh_fwk_sdk_path}:dhfwk_idl_hardware_head", "${dh_fwk_sdk_path}:libdhfwk_sdk", "${engine_path}/av_sender:distributed_av_sender", "${filters_path}:avtrans_input_filter", @@ -134,7 +133,6 @@ ohos_unittest("AvAudioSenderEngineTest") { cflags_cc = cflags deps = [ - "${dh_fwk_sdk_path}:dhfwk_idl_hardware_head", "${dh_fwk_sdk_path}:libdhfwk_sdk", "${distributed_av_transport_path}/framework:distributed_av_pipeline_fwk", "${engine_path}/av_sender:distributed_av_sender", diff --git a/av_transport/av_trans_engine/av_sender/test/unittest/av_sender_engine_provider/BUILD.gn b/av_transport/av_trans_engine/av_sender/test/unittest/av_sender_engine_provider/BUILD.gn index 0f01c383..b2c42b5c 100644 --- a/av_transport/av_trans_engine/av_sender/test/unittest/av_sender_engine_provider/BUILD.gn +++ b/av_transport/av_trans_engine/av_sender/test/unittest/av_sender_engine_provider/BUILD.gn @@ -53,7 +53,6 @@ ohos_unittest("AvSenderEngineProviderTest") { cflags_cc = cflags deps = [ - "${dh_fwk_sdk_path}:dhfwk_idl_hardware_head", "${dh_fwk_sdk_path}:libdhfwk_sdk", "${engine_path}/av_sender:distributed_av_sender", "${filters_path}:avtrans_input_filter", @@ -137,7 +136,6 @@ ohos_unittest("AvAudioSenderEngineProviderTest") { cflags_cc = cflags deps = [ - "${dh_fwk_sdk_path}:dhfwk_idl_hardware_head", "${dh_fwk_sdk_path}:libdhfwk_sdk", "${engine_path}/av_sender:distributed_av_sender", "${filters_path}:avtrans_input_filter", diff --git a/av_transport/av_trans_handler/histreamer_ability_querier/test/unittest/common/BUILD.gn b/av_transport/av_trans_handler/histreamer_ability_querier/test/unittest/common/BUILD.gn index 41d15659..1b9fa37c 100644 --- a/av_transport/av_trans_handler/histreamer_ability_querier/test/unittest/common/BUILD.gn +++ b/av_transport/av_trans_handler/histreamer_ability_querier/test/unittest/common/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023-2025 Huawei Device Co., Ltd. +# Copyright (c) 2023-2024 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -54,7 +54,6 @@ ohos_unittest("HistreamerAbilityQuerierTest") { "bounds_checking_function:libsec_shared", "cJSON:cjson", "c_utils:utils", - "hilog:libhilog", ] defines = [ diff --git a/av_transport/common/include/av_sync_utils.h b/av_transport/common/include/av_sync_utils.h index 71a2cd3f..4d6ee1d6 100644 --- a/av_transport/common/include/av_sync_utils.h +++ b/av_transport/common/include/av_sync_utils.h @@ -18,9 +18,6 @@ #include #include -#include -#include "parcel.h" -#include "message_parcel.h" namespace OHOS { namespace DistributedHardware { @@ -38,61 +35,6 @@ struct AVTransSharedMemory { void* addr; }; -struct AVTransSharedMemoryExt : public AVTransSharedMemory, public Parcelable { - using AVTransSharedMemory::AVTransSharedMemory; - explicit AVTransSharedMemoryExt() {} - virtual ~AVTransSharedMemoryExt() - { - if (addr != nullptr) { - free(addr); - addr = nullptr; - } - } - explicit AVTransSharedMemoryExt(const AVTransSharedMemory& avTransSharedMemory) - { - fd = avTransSharedMemory.fd; - size = avTransSharedMemory.size; - name = avTransSharedMemory.name; - addr = (char*)malloc(size); - if (addr) { - auto ret = memcpy_s(addr, size, avTransSharedMemory.addr, size); - if (ret != EOK) { - free(addr); - addr = nullptr; - } - } else { - addr = nullptr; - } - } - virtual bool Marshalling(Parcel &parcel) const override - { - MessageParcel &messageParcel = static_cast(parcel); - if (!messageParcel.WriteFileDescriptor(fd)) { - return false; - } - if (!messageParcel.WriteInt32(size)) { - return false; - } - if (!messageParcel.WriteString(name)) { - return false; - } - return true; - } - - static AVTransSharedMemoryExt *Unmarshalling(Parcel &parcel) - { - MessageParcel &messageParcel = static_cast(parcel); - AVTransSharedMemoryExt *avTransSharedMemory = new (std::nothrow) AVTransSharedMemoryExt(); - if (avTransSharedMemory == nullptr) { - return nullptr; - } - avTransSharedMemory->fd = messageParcel.ReadFileDescriptor(); - avTransSharedMemory->size = messageParcel.ReadInt32(); - avTransSharedMemory->name = messageParcel.ReadString(); - return avTransSharedMemory; - } -}; - struct AVSyncClockUnit { uint32_t index; uint32_t frameNum; diff --git a/av_transport/common/include/av_trans_types.h b/av_transport/common/include/av_trans_types.h index 0c0a5c00..cb9ca677 100644 --- a/av_transport/common/include/av_trans_types.h +++ b/av_transport/common/include/av_trans_types.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2025 Huawei Device Co., Ltd. + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -18,8 +18,6 @@ #include #include -#include "parcel.h" -#include "message_parcel.h" namespace OHOS { namespace DistributedHardware { @@ -160,48 +158,6 @@ struct AVTransEvent { std::string peerDevId; }; -struct AVTransEventExt : public AVTransEvent, public Parcelable { - using AVTransEvent::AVTransEvent; - explicit AVTransEventExt() {} - virtual ~AVTransEventExt() = default; - explicit AVTransEventExt(const AVTransEvent& AVTransEvent) - { - type = AVTransEvent.type; - content = AVTransEvent.content; - peerDevId = AVTransEvent.peerDevId; - } - - virtual bool Marshalling(Parcel &parcel) const override - { - if (!parcel.WriteUint32((uint32_t)type)) { - return false; - } - if (!parcel.WriteString(content)) { - return false; - } - if (!parcel.WriteString(peerDevId)) { - return false; - } - return true; - } - - static AVTransEventExt *Unmarshalling(Parcel &parcel) - { - AVTransEventExt *avTransEvent = new (std::nothrow) AVTransEventExt(); - if (avTransEvent == nullptr) { - return nullptr; - } - uint32_t typeValue = parcel.ReadUint32(); - std::string contentValue = parcel.ReadString(); - std::string peerDevIdValue = parcel.ReadString(); - avTransEvent->type = static_cast(typeValue); - avTransEvent->content = contentValue; - avTransEvent->peerDevId = peerDevIdValue; - - return avTransEvent; - } -}; - struct AVStreamInfo { std::string sceneType; std::string peerDevId; diff --git a/av_transport/common/test/unittest/BUILD.gn b/av_transport/common/test/unittest/BUILD.gn index 3afb85ef..194df3d2 100644 --- a/av_transport/common/test/unittest/BUILD.gn +++ b/av_transport/common/test/unittest/BUILD.gn @@ -54,7 +54,6 @@ ohos_unittest("AvSyncUtilsTest") { "googletest:gmock", "googletest:gmock_main", "ipc:ipc_core", - "hilog:libhilog", ] cflags = [ diff --git a/bundle.json b/bundle.json index 21414068..4da51472 100644 --- a/bundle.json +++ b/bundle.json @@ -139,6 +139,7 @@ "dhardware_descriptor.h", "dhardware_ipc_interface_code.h", "distributed_hardware_errno.h", + "iav_trans_control_center_callback.h", "idistributed_hardware_manager.h", "idistributed_hardware_sink.h", "idistributed_hardware_source.h", diff --git a/common/utils/include/iav_trans_control_center_callback.h b/common/utils/include/iav_trans_control_center_callback.h new file mode 100644 index 00000000..bcbe6338 --- /dev/null +++ b/common/utils/include/iav_trans_control_center_callback.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_I_AV_TRANSPORT_CONTROL_CENTER_CALLBACK_H +#define OHOS_I_AV_TRANSPORT_CONTROL_CENTER_CALLBACK_H + +#include "iremote_broker.h" + +#include "av_sync_utils.h" +#include "av_trans_errno.h" +#include "av_trans_types.h" + +namespace OHOS { +namespace DistributedHardware { +class IAVTransControlCenterCallback : public IRemoteBroker { +public: + virtual int32_t SetParameter(AVTransTag tag, const std::string &value) = 0; + virtual int32_t SetSharedMemory(const AVTransSharedMemory &memory) = 0; + virtual int32_t Notify(const AVTransEvent &event) = 0; + + enum class Message : uint32_t { + SET_PARAMETER = 1, + SET_SHARED_MEMORY = 2, + NOTIFY_AV_EVENT = 3 + }; + + DECLARE_INTERFACE_DESCRIPTOR(u"ohos.distributedhardware.IAVTransControlCenterCallback"); +}; +} +} +#endif \ No newline at end of file diff --git a/common/utils/include/idistributed_hardware.h b/common/utils/include/idistributed_hardware.h index a0effd23..c46f6431 100644 --- a/common/utils/include/idistributed_hardware.h +++ b/common/utils/include/idistributed_hardware.h @@ -47,7 +47,7 @@ public: virtual int32_t CreateControlChannel(int32_t engineId, const std::string &peerDevId) = 0; virtual int32_t NotifyAVCenter(int32_t engineId, const AVTransEvent &event) = 0; virtual int32_t RegisterCtlCenterCallback(int32_t engineId, - const sptr callback) = 0; + const sptr callback) = 0; virtual int32_t NotifySourceRemoteSinkStarted(std::string &deviceId) = 0; virtual int32_t PauseDistributedHardware(DHType dhType, const std::string &networkId) = 0; virtual int32_t ResumeDistributedHardware(DHType dhType, const std::string &networkId) = 0; diff --git a/interfaces/inner_kits/BUILD.gn b/interfaces/inner_kits/BUILD.gn index a42e7ca0..0d6f0583 100644 --- a/interfaces/inner_kits/BUILD.gn +++ b/interfaces/inner_kits/BUILD.gn @@ -11,7 +11,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/config/components/idl_tool/idl.gni") import("//build/ohos.gni") import( "//foundation/distributedhardware/distributed_hardware_fwk/distributedhardwarefwk.gni") @@ -20,77 +19,9 @@ config("innerkits_external_config") { include_dirs = [ "${innerkits_path}/include", "${innerkits_path}/include/ipc", - "${target_gen_dir}", ] } -idl_gen_interface("dhfwk_idl_hardware") { - sources = [ - "IAvTransControlCenterCallback.idl", - ] - log_domainid = "0xD004100" - log_tag = "distributedhardware" -} - -config("dhfwk_idl_hardware_config") { - include_dirs = [ - "include", - "${av_trans_path}/common/include", - "${innerkits_path}/include", - ".", - "${target_gen_dir}", - "${common_path}/utils/include", - ] -} - -ohos_source_set("dhfwk_idl_hardware_source") { - sanitize = { - cfi = true - cfi_cross_dso = true - debug = false - } - public_configs = [ ":dhfwk_idl_hardware_config" ] - output_values = get_target_outputs(":dhfwk_idl_hardware") - sources = filter_include(output_values, [ "*.cpp" ]) - deps = [ ":dhfwk_idl_hardware" ] - - external_deps = [ - "c_utils:utils", - "hilog:libhilog", - "hitrace:hitrace_meter", - "ipc:ipc_core", - "safwk:system_ability_fwk", - "samgr:samgr_proxy", - ] - - subsystem_name = "distributedhardware" - - part_name = "distributed_hardware_fwk" -} - -ohos_source_set("dhfwk_idl_hardware_head") { - sanitize = { - cfi = true - cfi_cross_dso = true - debug = false - } - public_configs = [ ":dhfwk_idl_hardware_config" ] - deps = [ ":dhfwk_idl_hardware" ] - - external_deps = [ - "c_utils:utils", - "hilog:libhilog", - "hitrace:hitrace_meter", - "ipc:ipc_core", - "safwk:system_ability_fwk", - "samgr:samgr_proxy", - ] - - subsystem_name = "distributedhardware" - - part_name = "distributed_hardware_fwk" -} - ohos_shared_library("libdhfwk_sdk") { sanitize = { boundary_sanitize = true @@ -117,6 +48,7 @@ ohos_shared_library("libdhfwk_sdk") { sources = [ "${av_center_kits_path}/src/av_trans_control_center_callback.cpp", + "${av_center_kits_path}/src/av_trans_control_center_callback_stub.cpp", "${innerkits_path}/src/distributed_hardware_fwk_kit.cpp", "${innerkits_path}/src/ipc/dhfwk_sa_manager.cpp", "${innerkits_path}/src/ipc/distributed_hardware_proxy.cpp", @@ -126,7 +58,6 @@ ohos_shared_library("libdhfwk_sdk") { ] deps = [ - ":dhfwk_idl_hardware_source", "${services_path}/distributedhardwarefwkservice:distributedhardwarefwksvr", "${utils_path}:distributedhardwareutils", ] @@ -148,7 +79,6 @@ ohos_shared_library("libdhfwk_sdk") { "c_utils:utils", "hilog:libhilog", "hisysevent:libhisysevent", - "hitrace:hitrace_meter", "ipc:ipc_core", "safwk:system_ability_fwk", "samgr:samgr_proxy", diff --git a/interfaces/inner_kits/include/distributed_hardware_fwk_kit.h b/interfaces/inner_kits/include/distributed_hardware_fwk_kit.h index fc3d04fc..906561a2 100644 --- a/interfaces/inner_kits/include/distributed_hardware_fwk_kit.h +++ b/interfaces/inner_kits/include/distributed_hardware_fwk_kit.h @@ -29,9 +29,6 @@ #include "idistributed_hardware.h" #include "iget_dh_descriptors_callback.h" #include "ihardware_status_listener.h" -#include "device_type.h" -#include "av_trans_types.h" -#include "iav_trans_control_center_callback.h" #ifndef API_EXPORT #define API_EXPORT __attribute__((visibility("default"))) @@ -134,7 +131,7 @@ public: * @param callback av control center callback. * @return Returns 0 if success. */ - API_EXPORT int32_t RegisterCtlCenterCallback(int32_t engineId, const sptr callback); + API_EXPORT int32_t RegisterCtlCenterCallback(int32_t engineId, const sptr callback); /** * @brief Pause distributed hardware. diff --git a/interfaces/inner_kits/include/ipc/dhfwk_sa_manager.h b/interfaces/inner_kits/include/ipc/dhfwk_sa_manager.h index 0a7f1e59..831fafeb 100644 --- a/interfaces/inner_kits/include/ipc/dhfwk_sa_manager.h +++ b/interfaces/inner_kits/include/ipc/dhfwk_sa_manager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -42,7 +42,7 @@ public: int32_t AddPublisherListenerToCache(const DHTopic topic, sptr listener); void RemovePublisherListenerFromCache(const DHTopic topic, sptr listener); - void AddAVTransControlCenterCbToCache(int32_t engineId, const sptr callback); + void AddAVTransControlCenterCbToCache(int32_t engineId, const sptr callback); void RemoveAVTransControlCenterCbFromCache(int32_t engineId); public: @@ -66,7 +66,7 @@ private: std::mutex publisherListenersMutex_; std::unordered_map>> publisherListenersCache_; std::mutex avTransControlCenterCbMutex_; - std::unordered_map> avTransControlCenterCbCache_; + std::unordered_map> avTransControlCenterCbCache_; }; } // DistributedHardware } // OHOS diff --git a/interfaces/inner_kits/include/ipc/distributed_hardware_proxy.h b/interfaces/inner_kits/include/ipc/distributed_hardware_proxy.h index 7c8811af..211d4f67 100644 --- a/interfaces/inner_kits/include/ipc/distributed_hardware_proxy.h +++ b/interfaces/inner_kits/include/ipc/distributed_hardware_proxy.h @@ -51,7 +51,7 @@ public: int32_t ReleaseAVCenter(int32_t engineId) override; 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 RegisterCtlCenterCallback(int32_t engineId, const sptr callback) override; int32_t NotifySourceRemoteSinkStarted(std::string &deviceId) override; int32_t PauseDistributedHardware(DHType dhType, const std::string &networkId) override; int32_t ResumeDistributedHardware(DHType dhType, const std::string &networkId) override; diff --git a/interfaces/inner_kits/src/distributed_hardware_fwk_kit.cpp b/interfaces/inner_kits/src/distributed_hardware_fwk_kit.cpp index bf322121..3e2516c7 100644 --- a/interfaces/inner_kits/src/distributed_hardware_fwk_kit.cpp +++ b/interfaces/inner_kits/src/distributed_hardware_fwk_kit.cpp @@ -285,7 +285,7 @@ int32_t DistributedHardwareFwkKit::NotifyAVCenter(int32_t engineId, const AVTran } int32_t DistributedHardwareFwkKit::RegisterCtlCenterCallback(int32_t engineId, - const sptr callback) + const sptr callback) { DHLOGI("Register av control center callback. engineId: %{public}" PRId32, engineId); diff --git a/interfaces/inner_kits/src/ipc/dhfwk_sa_manager.cpp b/interfaces/inner_kits/src/ipc/dhfwk_sa_manager.cpp index 90ad5174..d8077a9f 100644 --- a/interfaces/inner_kits/src/ipc/dhfwk_sa_manager.cpp +++ b/interfaces/inner_kits/src/ipc/dhfwk_sa_manager.cpp @@ -203,7 +203,7 @@ void DHFWKSAManager::RemovePublisherListenerFromCache(const DHTopic topic, sptr< } void DHFWKSAManager::AddAVTransControlCenterCbToCache(int32_t engineId, - const sptr callback) + const sptr callback) { std::lock_guard avTransControlCenterCbLock(avTransControlCenterCbMutex_); avTransControlCenterCbCache_[engineId] = callback; diff --git a/interfaces/inner_kits/src/ipc/distributed_hardware_proxy.cpp b/interfaces/inner_kits/src/ipc/distributed_hardware_proxy.cpp index 5d6c9dbb..d4a2cbd8 100644 --- a/interfaces/inner_kits/src/ipc/distributed_hardware_proxy.cpp +++ b/interfaces/inner_kits/src/ipc/distributed_hardware_proxy.cpp @@ -352,7 +352,7 @@ int32_t DistributedHardwareProxy::NotifyAVCenter(int32_t engineId, const AVTrans } int32_t DistributedHardwareProxy::RegisterCtlCenterCallback(int32_t engineId, - const sptr callback) + const sptr callback) { sptr remote = Remote(); if (remote == nullptr) { diff --git a/interfaces/inner_kits/test/fuzztest/distributedhardwarefwkkit_fuzzer/BUILD.gn b/interfaces/inner_kits/test/fuzztest/distributedhardwarefwkkit_fuzzer/BUILD.gn index 3519afa0..ebbd5ab2 100644 --- a/interfaces/inner_kits/test/fuzztest/distributedhardwarefwkkit_fuzzer/BUILD.gn +++ b/interfaces/inner_kits/test/fuzztest/distributedhardwarefwkkit_fuzzer/BUILD.gn @@ -55,10 +55,7 @@ ohos_fuzztest("DistributedHardwareFwkKitFuzzTest") { "c_utils:utils", "ipc:ipc_core", "safwk:system_ability_fwk", - "hilog:libhilog", ] - - public_configs = [ "${innerkits_path}:dhfwk_idl_hardware_config" ] } ############################################################################### diff --git a/interfaces/inner_kits/test/fuzztest/distributedhardwarefwkkit_fuzzer/distributedhardwarefwkkit_fuzzer.cpp b/interfaces/inner_kits/test/fuzztest/distributedhardwarefwkkit_fuzzer/distributedhardwarefwkkit_fuzzer.cpp index ba099657..8dffe745 100644 --- a/interfaces/inner_kits/test/fuzztest/distributedhardwarefwkkit_fuzzer/distributedhardwarefwkkit_fuzzer.cpp +++ b/interfaces/inner_kits/test/fuzztest/distributedhardwarefwkkit_fuzzer/distributedhardwarefwkkit_fuzzer.cpp @@ -78,20 +78,20 @@ void TestGetDistributedHardwareCallback::OnError(const std::string &networkId, i (void)error; } -int32_t TestAVTransControlCenterCallback::SetParameter(uint32_t tag, const std::string &value) +int32_t TestAVTransControlCenterCallback::SetParameter(AVTransTag tag, const std::string &value) { (void)tag; (void)value; return DH_FWK_SUCCESS; } -int32_t TestAVTransControlCenterCallback::SetSharedMemory(const AVTransSharedMemoryExt &memory) +int32_t TestAVTransControlCenterCallback::SetSharedMemory(const AVTransSharedMemory &memory) { (void)memory; return DH_FWK_SUCCESS; } -int32_t TestAVTransControlCenterCallback::Notify(const AVTransEventExt &event) +int32_t TestAVTransControlCenterCallback::Notify(const AVTransEvent &event) { (void)event; return DH_FWK_SUCCESS; @@ -407,7 +407,7 @@ void RegisterCtlCenterCallbackFuzzTest(const uint8_t *data, size_t size) DistributedHardwareFwkKit dhfwkKit; int32_t engineId = *(reinterpret_cast(data)); - sptr listener(new TestAVTransControlCenterCallback()); + sptr listener(new TestAVTransControlCenterCallback()); dhfwkKit.RegisterCtlCenterCallback(engineId, listener); } } // namespace DistributedHardware diff --git a/interfaces/inner_kits/test/fuzztest/distributedhardwarefwkkit_fuzzer/distributedhardwarefwkkit_fuzzer.h b/interfaces/inner_kits/test/fuzztest/distributedhardwarefwkkit_fuzzer/distributedhardwarefwkkit_fuzzer.h index 1f4dfa41..ebdaf545 100644 --- a/interfaces/inner_kits/test/fuzztest/distributedhardwarefwkkit_fuzzer/distributedhardwarefwkkit_fuzzer.h +++ b/interfaces/inner_kits/test/fuzztest/distributedhardwarefwkkit_fuzzer/distributedhardwarefwkkit_fuzzer.h @@ -60,14 +60,14 @@ protected: EnableStep enableStep) override; void OnError(const std::string &networkId, int32_t error) override; }; -class TestAVTransControlCenterCallback : public IAvTransControlCenterCallback { +class TestAVTransControlCenterCallback : public IAVTransControlCenterCallback { public: TestAVTransControlCenterCallback() = default; virtual ~TestAVTransControlCenterCallback() = default; protected: - int32_t SetParameter(uint32_t tag, const std::string &value) override; - int32_t SetSharedMemory(const AVTransSharedMemoryExt& memory) override; - int32_t Notify(const AVTransEventExt& event) override; + int32_t SetParameter(AVTransTag tag, const std::string &value) override; + int32_t SetSharedMemory(const AVTransSharedMemory &memory) override; + int32_t Notify(const AVTransEvent &event) override; sptr AsObject() override { return nullptr; diff --git a/interfaces/inner_kits/test/fuzztest/distributedhardwarefwkstub_fuzzer/BUILD.gn b/interfaces/inner_kits/test/fuzztest/distributedhardwarefwkstub_fuzzer/BUILD.gn index 397d08d5..a344a08b 100644 --- a/interfaces/inner_kits/test/fuzztest/distributedhardwarefwkstub_fuzzer/BUILD.gn +++ b/interfaces/inner_kits/test/fuzztest/distributedhardwarefwkstub_fuzzer/BUILD.gn @@ -53,10 +53,7 @@ ohos_fuzztest("DistributedHardwareFwkStubFuzzTest") { "c_utils:utils", "ipc:ipc_core", "safwk:system_ability_fwk", - "hilog:libhilog", ] - - public_configs = [ "${innerkits_path}:dhfwk_idl_hardware_config" ] } ############################################################################### diff --git a/interfaces/inner_kits/test/unittest/common/distributedhardwarefwkkit/BUILD.gn b/interfaces/inner_kits/test/unittest/common/distributedhardwarefwkkit/BUILD.gn index bd72a3ee..913a5577 100644 --- a/interfaces/inner_kits/test/unittest/common/distributedhardwarefwkkit/BUILD.gn +++ b/interfaces/inner_kits/test/unittest/common/distributedhardwarefwkkit/BUILD.gn @@ -58,8 +58,6 @@ ohos_unittest("DistributedHardwareFwkKitTest") { "safwk:system_ability_fwk", "samgr:samgr_proxy", ] - - public_configs = [ "${innerkits_path}:dhfwk_idl_hardware_config" ] } group("distributed_hardware_fwk_kit_test") { diff --git a/interfaces/inner_kits/test/unittest/common/distributedhardwarefwkkit/include/distributed_hardware_fwk_kit_test.h b/interfaces/inner_kits/test/unittest/common/distributedhardwarefwkkit/include/distributed_hardware_fwk_kit_test.h index 70451e98..dd30bdf8 100644 --- a/interfaces/inner_kits/test/unittest/common/distributedhardwarefwkkit/include/distributed_hardware_fwk_kit_test.h +++ b/interfaces/inner_kits/test/unittest/common/distributedhardwarefwkkit/include/distributed_hardware_fwk_kit_test.h @@ -26,7 +26,6 @@ #include "dm_device_info.h" #include "device_manager.h" -#include "av_trans_errno.h" #include "distributed_hardware_fwk_kit.h" #include "get_dh_descriptors_callback_stub.h" #include "hardware_status_listener_stub.h" diff --git a/interfaces/inner_kits/test/unittest/common/distributedhardwarefwkkit/src/distributed_hardware_fwk_kit_test.cpp b/interfaces/inner_kits/test/unittest/common/distributedhardwarefwkkit/src/distributed_hardware_fwk_kit_test.cpp index 2efd64f2..f3298746 100644 --- a/interfaces/inner_kits/test/unittest/common/distributedhardwarefwkkit/src/distributed_hardware_fwk_kit_test.cpp +++ b/interfaces/inner_kits/test/unittest/common/distributedhardwarefwkkit/src/distributed_hardware_fwk_kit_test.cpp @@ -390,7 +390,7 @@ HWTEST_F(DistributedHardwareFwkKitTest, RegisterCtlCenterCallback_001, testing:: { ASSERT_TRUE(dhfwkPtr_ != nullptr); int32_t engineId = 0; - sptr callback = nullptr; + sptr callback = nullptr; int32_t ret = dhfwkPtr_->RegisterCtlCenterCallback(engineId, callback); EXPECT_EQ(ERR_DH_FWK_POINTER_IS_NULL, ret); } diff --git a/interfaces/inner_kits/test/unittest/common/ipc/dhfwk_sa_manager/BUILD.gn b/interfaces/inner_kits/test/unittest/common/ipc/dhfwk_sa_manager/BUILD.gn index 772eb9f8..2b65e96b 100644 --- a/interfaces/inner_kits/test/unittest/common/ipc/dhfwk_sa_manager/BUILD.gn +++ b/interfaces/inner_kits/test/unittest/common/ipc/dhfwk_sa_manager/BUILD.gn @@ -55,7 +55,6 @@ ohos_unittest("DhfwkSaManagerTest") { "ipc:ipc_core", "safwk:system_ability_fwk", "samgr:samgr_proxy", - "hilog:libhilog", ] cflags = [ diff --git a/interfaces/inner_kits/test/unittest/common/ipc/dhfwk_sa_manager/include/dhfwk_sa_manager_test.h b/interfaces/inner_kits/test/unittest/common/ipc/dhfwk_sa_manager/include/dhfwk_sa_manager_test.h index 38082580..0f5f633f 100644 --- a/interfaces/inner_kits/test/unittest/common/ipc/dhfwk_sa_manager/include/dhfwk_sa_manager_test.h +++ b/interfaces/inner_kits/test/unittest/common/ipc/dhfwk_sa_manager/include/dhfwk_sa_manager_test.h @@ -97,7 +97,7 @@ int32_t NotifyAVCenter(int32_t engineId, const AVTransEvent &event) return DH_FWK_SUCCESS; } -int32_t RegisterCtlCenterCallback(int32_t engineId, const sptr callback) +int32_t RegisterCtlCenterCallback(int32_t engineId, const sptr callback) { (void)engineId; (void)callback; diff --git a/interfaces/inner_kits/test/unittest/common/ipc/distributed_hardware_proxy/include/distributed_hardware_proxy_test.h b/interfaces/inner_kits/test/unittest/common/ipc/distributed_hardware_proxy/include/distributed_hardware_proxy_test.h index 3aa898c4..564f37d6 100644 --- a/interfaces/inner_kits/test/unittest/common/ipc/distributed_hardware_proxy/include/distributed_hardware_proxy_test.h +++ b/interfaces/inner_kits/test/unittest/common/ipc/distributed_hardware_proxy/include/distributed_hardware_proxy_test.h @@ -20,7 +20,6 @@ #include #include -#include "av_trans_errno.h" #include "device_type.h" #include "distributed_hardware_errno.h" #include "idistributed_hardware.h" @@ -51,7 +50,7 @@ public: int32_t ReleaseAVCenter(int32_t engineId); int32_t CreateControlChannel(int32_t engineId, const std::string &peerDevId); int32_t NotifyAVCenter(int32_t engineId, const AVTransEvent &event); - int32_t RegisterCtlCenterCallback(int32_t engineId, const sptr callback); + int32_t RegisterCtlCenterCallback(int32_t engineId, const sptr callback); int32_t NotifySourceRemoteSinkStarted(std::string &deviceId); int32_t PauseDistributedHardware(DHType dhType, const std::string &networkId); int32_t ResumeDistributedHardware(DHType dhType, const std::string &networkId); diff --git a/interfaces/inner_kits/test/unittest/common/ipc/distributed_hardware_proxy/src/distributed_hardware_proxy_test.cpp b/interfaces/inner_kits/test/unittest/common/ipc/distributed_hardware_proxy/src/distributed_hardware_proxy_test.cpp index fbf09771..a318789c 100644 --- a/interfaces/inner_kits/test/unittest/common/ipc/distributed_hardware_proxy/src/distributed_hardware_proxy_test.cpp +++ b/interfaces/inner_kits/test/unittest/common/ipc/distributed_hardware_proxy/src/distributed_hardware_proxy_test.cpp @@ -15,7 +15,6 @@ #include "distributed_hardware_proxy_test.h" #include "dhardware_ipc_interface_code.h" -#include "av_trans_errno.h" using namespace testing::ext; @@ -103,7 +102,7 @@ int32_t DistributedHardwareProxyTest::TestDistributedHardwareStub::NotifyAVCente } int32_t DistributedHardwareProxyTest::TestDistributedHardwareStub::RegisterCtlCenterCallback(int32_t engineId, - const sptr callback) + const sptr callback) { (void)engineId; (void)callback; @@ -471,7 +470,7 @@ HWTEST_F(DistributedHardwareProxyTest, NotifyAVCenter_001, TestSize.Level1) HWTEST_F(DistributedHardwareProxyTest, RegisterCtlCenterCallback_001, TestSize.Level1) { int32_t engineId = 0; - sptr callback = nullptr; + sptr callback = nullptr; sptr dhStubPtr(new TestDistributedHardwareStub()); ASSERT_TRUE(dhStubPtr != nullptr); DistributedHardwareProxy dhProxy(dhStubPtr); diff --git a/interfaces/inner_kits/test/unittest/common/ipc/hardware_status_listener_stub/BUILD.gn b/interfaces/inner_kits/test/unittest/common/ipc/hardware_status_listener_stub/BUILD.gn index e77d37db..a6fd17dc 100644 --- a/interfaces/inner_kits/test/unittest/common/ipc/hardware_status_listener_stub/BUILD.gn +++ b/interfaces/inner_kits/test/unittest/common/ipc/hardware_status_listener_stub/BUILD.gn @@ -54,7 +54,6 @@ ohos_unittest("HardwareStatusListenerStubTest") { "ipc:ipc_core", "safwk:system_ability_fwk", "samgr:samgr_proxy", - "hilog:libhilog", ] cflags = [ diff --git a/interfaces/inner_kits/test/unittest/common/ipc/publisher_listener_stub/BUILD.gn b/interfaces/inner_kits/test/unittest/common/ipc/publisher_listener_stub/BUILD.gn index c6c5cd6c..3da38ba0 100644 --- a/interfaces/inner_kits/test/unittest/common/ipc/publisher_listener_stub/BUILD.gn +++ b/interfaces/inner_kits/test/unittest/common/ipc/publisher_listener_stub/BUILD.gn @@ -55,7 +55,6 @@ ohos_unittest("PublisherListenerStubTest") { "ipc:ipc_core", "safwk:system_ability_fwk", "samgr:samgr_proxy", - "hilog:libhilog", ] cflags = [ diff --git a/interfaces/kits/napi/BUILD.gn b/interfaces/kits/napi/BUILD.gn index 456412b6..b57cb752 100644 --- a/interfaces/kits/napi/BUILD.gn +++ b/interfaces/kits/napi/BUILD.gn @@ -68,6 +68,4 @@ ohos_shared_library("hardwaremanager") { subsystem_name = "distributedhardware" relative_install_dir = "module/distributedhardware" part_name = "distributed_hardware_fwk" - - public_configs = [ "${innerkits_path}:dhfwk_idl_hardware_config" ] } diff --git a/services/distributedhardwarefwkservice/BUILD.gn b/services/distributedhardwarefwkservice/BUILD.gn index 210178dd..3fb8c7a3 100644 --- a/services/distributedhardwarefwkservice/BUILD.gn +++ b/services/distributedhardwarefwkservice/BUILD.gn @@ -56,6 +56,7 @@ ohos_shared_library("distributedhardwarefwksvr") { sources = [ "${av_center_svc_path}/src/av_sync_manager.cpp", "${av_center_svc_path}/src/av_trans_control_center.cpp", + "${av_center_svc_path}/src/ipc/av_trans_control_center_callback_proxy.cpp", "${av_trans_path}/common/src/av_sync_utils.cpp", "${av_trans_path}/common/src/av_trans_message.cpp", "${av_trans_path}/common/src/softbus_channel_adapter.cpp", @@ -114,10 +115,7 @@ ohos_shared_library("distributedhardwarefwksvr") { "src/versionmanager/version_manager.cpp", ] - deps = [ - "${utils_path}:distributedhardwareutils", - "${innerkits_path}:dhfwk_idl_hardware_source", - ] + deps = [ "${utils_path}:distributedhardwareutils" ] defines = [ "HI_LOG_ENABLE", @@ -189,6 +187,4 @@ ohos_shared_library("distributedhardwarefwksvr") { subsystem_name = "distributedhardware" part_name = "distributed_hardware_fwk" - - public_configs = [ "${innerkits_path}:dhfwk_idl_hardware_config" ] } diff --git a/services/distributedhardwarefwkservice/include/distributed_hardware_service.h b/services/distributedhardwarefwkservice/include/distributed_hardware_service.h index bb05468d..72521d74 100644 --- a/services/distributedhardwarefwkservice/include/distributed_hardware_service.h +++ b/services/distributedhardwarefwkservice/include/distributed_hardware_service.h @@ -47,7 +47,7 @@ public: int32_t ReleaseAVCenter(int32_t engineId) override; 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 RegisterCtlCenterCallback(int32_t engineId, const sptr callback) override; int32_t NotifySourceRemoteSinkStarted(std::string &deviceId) override; int32_t PauseDistributedHardware(DHType dhType, const std::string &networkId) override; int32_t ResumeDistributedHardware(DHType dhType, const std::string &networkId) override; diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp index 6d174079..c896a90c 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp @@ -287,7 +287,7 @@ int32_t DistributedHardwareService::NotifyAVCenter(int32_t engineId, const AVTra } int32_t DistributedHardwareService::RegisterCtlCenterCallback(int32_t engineId, - const sptr callback) + const sptr callback) { return AVTransControlCenter::GetInstance().RegisterCtlCenterCallback(engineId, callback); } diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_stub.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_stub.cpp index d3d773ff..d4caa3ce 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_stub.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_stub.cpp @@ -32,7 +32,6 @@ #include "distributed_hardware_log.h" #include "hdf_operate.h" #include "publisher_listener_proxy.h" -#include "av_trans_errno.h" namespace OHOS { namespace DistributedHardware { @@ -266,7 +265,7 @@ int32_t DistributedHardwareStub::RegisterControlCenterCallbackInner(MessageParce } int32_t engineId = data.ReadInt32(); - sptr callback = iface_cast(data.ReadRemoteObject()); + sptr callback = iface_cast(data.ReadRemoteObject()); if (callback == nullptr) { DHLOGE("Input av control center callback is null"); return ERR_DH_FWK_PARA_INVALID; diff --git a/services/distributedhardwarefwkservice/test/unittest/common/componentmanager/component_privacy/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/componentmanager/component_privacy/BUILD.gn index c1c128cb..4b5ca7df 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/componentmanager/component_privacy/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/componentmanager/component_privacy/BUILD.gn @@ -51,7 +51,6 @@ ohos_unittest("ComponentPrivacyTest") { "ipc:ipc_core", "ipc:ipc_single", "samgr:samgr_proxy", - "hilog:libhilog", ] cflags = [ diff --git a/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwarestub/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwarestub/BUILD.gn index c2b37a73..93d92848 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwarestub/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwarestub/BUILD.gn @@ -70,7 +70,6 @@ ohos_unittest("DistributedHardwareStubTest") { "googletest:gmock_main", "ipc:ipc_core", "safwk:system_ability_fwk", - "hilog:libhilog", ] } diff --git a/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwarestub/include/distributed_hardware_stub_test.h b/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwarestub/include/distributed_hardware_stub_test.h index c5004a1b..0f84636a 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwarestub/include/distributed_hardware_stub_test.h +++ b/services/distributedhardwarefwkservice/test/unittest/common/distributedhardwarestub/include/distributed_hardware_stub_test.h @@ -91,7 +91,7 @@ int32_t NotifyAVCenter(int32_t engineId, const AVTransEvent &event) return DH_FWK_SUCCESS; } -int32_t RegisterCtlCenterCallback(int32_t engineId, const sptr callback) +int32_t RegisterCtlCenterCallback(int32_t engineId, const sptr callback) { (void)engineId; (void)callback; diff --git a/services/distributedhardwarefwkservice/test/unittest/common/hidumphelper/enabledcompsdump/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/hidumphelper/enabledcompsdump/BUILD.gn index 6fb325db..8f5af6b5 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/hidumphelper/enabledcompsdump/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/hidumphelper/enabledcompsdump/BUILD.gn @@ -49,7 +49,6 @@ ohos_unittest("EnabledCompsDumpTest") { "eventhandler:libeventhandler", "ipc:ipc_core", "safwk:system_ability_fwk", - "hilog:libhilog", ] cflags = [ diff --git a/services/distributedhardwarefwkservice/test/unittest/common/ipc/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/ipc/BUILD.gn index e0aacd06..065abb95 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/ipc/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/ipc/BUILD.gn @@ -53,7 +53,6 @@ ohos_unittest("PublisherListenerProxyTest") { external_deps = [ "c_utils:utils", "ipc:ipc_core", - "hilog:libhilog", ] } diff --git a/services/distributedhardwarefwkservice/test/unittest/common/ipc/hardware_status_listener_proxy/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/ipc/hardware_status_listener_proxy/BUILD.gn index fa79de4a..e2ae6f39 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/ipc/hardware_status_listener_proxy/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/ipc/hardware_status_listener_proxy/BUILD.gn @@ -54,7 +54,6 @@ ohos_unittest("HardwareStatusListenerProxyTest") { external_deps = [ "c_utils:utils", "ipc:ipc_core", - "hilog:libhilog", ] } diff --git a/services/distributedhardwarefwkservice/test/unittest/common/lowlatency/lowlatency/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/lowlatency/lowlatency/BUILD.gn index 99bdedfa..133bf69f 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/lowlatency/lowlatency/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/lowlatency/lowlatency/BUILD.gn @@ -58,7 +58,6 @@ ohos_unittest("LowLatencyTest") { "eventhandler:libeventhandler", "ipc:ipc_core", "safwk:system_ability_fwk", - "hilog:libhilog", ] } diff --git a/services/distributedhardwarefwkservice/test/unittest/common/lowlatency/lowlatencylistener/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/lowlatency/lowlatencylistener/BUILD.gn index 27f054a2..02da53a7 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/lowlatency/lowlatencylistener/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/lowlatency/lowlatencylistener/BUILD.gn @@ -58,7 +58,6 @@ ohos_unittest("LowLatencyListenerTest") { "eventhandler:libeventhandler", "ipc:ipc_core", "safwk:system_ability_fwk", - "hilog:libhilog", ] } diff --git a/services/distributedhardwarefwkservice/test/unittest/common/publisher/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/publisher/BUILD.gn index c8b9d0ed..e34fbddd 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/publisher/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/publisher/BUILD.gn @@ -49,7 +49,6 @@ ohos_unittest("PublisherItemTest") { "ipc:ipc_core", "kv_store:distributeddata_inner", "safwk:system_ability_fwk", - "hilog:libhilog", ] } diff --git a/services/distributedhardwarefwkservice/test/unittest/common/versionmanager/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/versionmanager/BUILD.gn index 2729efb9..7fb04db8 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/versionmanager/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/versionmanager/BUILD.gn @@ -55,7 +55,6 @@ ohos_unittest("VersionManagerTest") { "c_utils:utils", "eventhandler:libeventhandler", "kv_store:distributeddata_inner", - "hilog:libhilog", ] defines = [ diff --git a/utils/BUILD.gn b/utils/BUILD.gn index a003f127..5064b360 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -32,10 +32,7 @@ ohos_shared_library("distributedhardwareutils") { debug = false } branch_protector_ret = "pac_ret" - public_configs = [ - ":utils_external_config", - "${innerkits_path}:dhfwk_idl_hardware_config" - ] + public_configs = [ ":utils_external_config" ] include_dirs = [ "${common_path}/log/include", diff --git a/utils/test/unittest/common/histreamer_ability_parser/BUILD.gn b/utils/test/unittest/common/histreamer_ability_parser/BUILD.gn index 2ff89c73..2f64105f 100644 --- a/utils/test/unittest/common/histreamer_ability_parser/BUILD.gn +++ b/utils/test/unittest/common/histreamer_ability_parser/BUILD.gn @@ -38,7 +38,6 @@ ohos_unittest("HistreamerAbilityParserTest") { external_deps = [ "cJSON:cjson", "c_utils:utils", - "hilog:libhilog", ] } diff --git a/utils/test/unittest/common/utilstool/BUILD.gn b/utils/test/unittest/common/utilstool/BUILD.gn index 2f816ac2..cdbc3907 100644 --- a/utils/test/unittest/common/utilstool/BUILD.gn +++ b/utils/test/unittest/common/utilstool/BUILD.gn @@ -41,7 +41,6 @@ ohos_unittest("UtilsToolTest") { "cJSON:cjson", "c_utils:utils", "hitrace:hitrace_meter", - "hilog:libhilog", ] } -- Gitee