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 521da97b89c93aea51b8cc7beb6997be0e26e27c..8ec6257cacc2d8fa375f0dafe050adc95da056aa 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 0000000000000000000000000000000000000000..5732732886299097156a600ab30bd91cb0575e91 --- /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 7fb896fed8738afb4be4abfd27515d388c8f51ec..832d0079e282e33ac63261f19cabff660315e51b 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 0000000000000000000000000000000000000000..696bfb12e560ea5221cf78f8190672283a9f6e00 --- /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 8d31239e3493800009749b0f78be651277184356..4f97415cc21772d82726d974a40d157944d0c012 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 0000000000000000000000000000000000000000..9b657f4bf9fe2b9519341e652be97dec2913a12a --- /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 5a888269d153db151f03d6e8a77edf08ef9364f1..525791ad9efee5a8ffe983c0d838a3139dbec24a 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 0000000000000000000000000000000000000000..7a6268f73da34023ceff81ad2c36776c796bb77b --- /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 ee237584e1f5054f475205040c5058b28c945dd5..19a3e19b83808b5198146f39da4cdf682dc71a82 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 51edaa07cdd4209548f8d565e032fef313387afc..b9a4c6ab1156b42637fb2455bcac1544bcef82eb 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 65131eee02d390dde3d1605f80564ca77fce0fc3..50336f17c7c906895a6b692b4b766f25f1ca6894 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 d3ba3dd90ce8bdcc7cf565f662b0bdd032b9c31e..63c488d7e0c646b057af3f8afcee3d282aac2179 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 5d753f84e8d6d9f0ff48e53b5662c7740936ab74..7ab4a3a976c39541072b94d725408a95d031b14f 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 92aa39a0c986b88d4159dee9409f8dacd0547aa4..9f17b28cd7a4c5f6eb34ffe3935e9d23e569b3a8 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 d4cd7c426cc5906084cfa4531ce48636ade7a1b0..66c5c5ef7bde2d019629b01a7d621f13d7f11693 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 0000000000000000000000000000000000000000..6ce4af8e73146f1cb9c9524e9b94168f9f5ddad5 --- /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 0000000000000000000000000000000000000000..984fa7a60034e1709e44efc99ac6acf2d853ed9c --- /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 572afca178777099d47ee5f0f354e61a8006d94b..29d2a14f26cc113f4f5942bd1fafa397a9346dea 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 0000000000000000000000000000000000000000..6198079a28e860189d4294f6598f8ac6804c0dff --- /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 0000000000000000000000000000000000000000..7133b2b92440904a5ed04b838733acea0f97486a --- /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 3111ed5c8dac5bebd3dc9d711860de8411391cf8..42b720d8f3970ef0677717b370151df85956f1ea 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 0000000000000000000000000000000000000000..9095fae3b215a0a6836d5ad7c1f95d353f3bd750 --- /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 0000000000000000000000000000000000000000..7bbbaf0dd51ef75ce90bf2d6bfd9a5cebc26a4d4 --- /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 d02eff92d31768866cfc8920d8715744609dbae0..3cf337251fe877527652f7f25c6d8534f79c4d9f 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 32511d0833f86e670c102445bdf3633de9f7d1f7..664f68e8ce25736b168a8aa72fb9b5f19729235b 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 926d6bca12e8a9f6022e1bd9a0dd910a11acd5bb..c0ab074435993b279e038334744aa9b3967c02e2 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 8f6514b80ab92c710cce7bfc6c1347b373b9c825..de15b15b90cb99483754e5ad5a6f9e3eaf99377b 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 0ed9f0c16a150f0a2c5a95b3eac819d73127928e..4e31909f1a79336c944f5052776a1e8fde8d5a92 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 f2d091383ab608e2828d7a3f68ce4d07093bb1aa..c93f8bd3d5ac5dabb8547eebdaeb543c1a4530bc 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 3ca251c9f3742de737cbcf4a540108250a2ffba7..d17dafb4a314166ff150796b383c1abca516fcfe 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 b0c8e3a5d28ed08d9d7d21a5c8019485e2dae91d..d44da2b50af2200da1d6d45a57846fc3ea68dc31 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 0f01c383217991f5cb15c58177649e8d0a629003..b2c42b5cdcdf535b636bf089d310a9e5ce04fa52 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 41d15659cd6543e72d12c281b9c9d77bbb2196e2..1b9fa37c40beee5a603163a4e0abf798b9f095b2 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 71a2cd3ffd8063bfbd131eb1376c1ee90980baf4..4d6ee1d64204422ba0861f30e47b4757ef2b76fb 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 0c0a5c00e8a1210d50dfdd65d5190bf333f23586..cb9ca677abdab4f58f696b5043b85aafe6296e55 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 3afb85ef59ac3fbaad97aab8c50f53689f09217a..194df3d238ade59929d8156f775b1d0b880b33b6 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 21414068b0150ae1591de7d4b317683898827514..4da514723215400e3e682388292c5396857181c6 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 0000000000000000000000000000000000000000..bcbe6338f28ed5bd4d945efd8464c0c979fbd7f3 --- /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 a0effd235f33700e2c14ada880073f01af2b0346..c46f6431ed80e1784bea150abf1a38956dc66e2e 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 a42e7ca0cf6678ebb4afca56290fee28d4b9257b..0d6f0583c762c9365ff0c30e318250908223a1a6 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 fc3d04fccc5d317f0d830d421f1bd82b3c6c26d6..906561a2586c534292d727da3afb43969d4a04ec 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 0a7f1e5959e1643501139f755e27f7710dc0c5b4..831fafebe966b774f55d6339eac9cf5ae97509f8 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 7c8811afcbc394f280d25ff247e8903f0b0bae15..211d4f674db5acd5df3cbd5284939d4d09d0a4ec 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 bf32212103426e6f8687e4e0219fcba0c3dc86ac..3e2516c7d5f3a96f5af0d76c58e8cfafe2ab0bfe 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 90ad5174257d96da2eefd676df6c22a406861e01..d8077a9f81a6d7e0c8913d960d54ac4e9b22a829 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 5d6c9dbbfa344c09e0fb433682de61a025c87ce2..d4a2cbd8e6fd4bde5185cb22edce9e8d77f43b1f 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 3519afa057eb702140ccaabeb9dfa7747269fcc2..ebbd5ab2ceb5ec06591f59d8482b843d78d71efa 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 ba099657d5f1434b07894a48e1a79cd59e676ab5..8dffe7458959e9d7dda8d22f4ddd593ae7db2023 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 1f4dfa41236218d8a23b855b6902973b8d544210..ebdaf5453d2c90c79da1e65a8c7d3845b055ae21 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 397d08d5ac326987a6ffcc3d40edd9fb3ddb087c..a344a08bfb8ab5cb093fa43feb1d533244b9a815 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 bd72a3eeeb05b2421aa4a273c1bffc931c18af52..913a5577aa92e07d20baf14bd48d213e22b365bf 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 70451e981714d8a47d71a9dfe66b9d0dbb7d050c..dd30bdf8aa09102deea99869b169afeaf4b2aeae 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 2efd64f2181bb9da82273e260427532aa08909a7..f329874640f870b871404d20b44f98e4df00604b 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 772eb9f8b4676e95913723920ba273c9c036b7e0..2b65e96b98b50d6d8e12f8c51894b6af21d850b4 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 3808258024ee4a562979c37fe062379edc49858f..0f5f633f943e2e932b4b00f53c6bd7793796216b 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 3aa898c4368c85d63101d006de798ef0f0020225..564f37d6a967d6bbae278545dff9a6902fcdf2ef 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 fbf09771f167c4315fe3368e6cfd681f175b0821..a318789c972cf1dd1961da250a3d10392a922c86 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 e77d37db8208ff26d8a6298a9df0b041365ea3d0..a6fd17dc2099bfc620cf242ef4dd81728e29f509 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 c6c5cd6c5a61b059127cc2cbe67e59629095e15c..3da38ba05789b8e7d33ba1d887a5471d579a2040 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 456412b6f6a44cb469d1b5125f994c4be6c44361..b57cb752007906fdd124bf783174d29a6e4b7be0 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 210178dd9acf542e7e1bf303ae30f45088e46c42..3fb8c7a35366928680e5d1394ed3defe2f49cd1d 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 bb05468df7784abb9a8ae510a1e6f8382d5426ee..72521d743b59f3283a4e691ca52751c707c3f1fa 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 6d1740792d6b2b7e09ed02e49759a45ae291bddb..c896a90ce7b87a9bf73aa14f082d9a7b59ad46df 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 d3d773ff511435292f7bdd177291d75341cd3a5b..d4caa3cee5cc6dd64b05fe84ac068d06e335277b 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 c1c128cb21b2ae4404a7c90aa200df672342d4a6..4b5ca7df68fb32dc45776bf9f174075106535b7c 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 c2b37a73b43da8eb016a7650875e0979d82ba610..93d928483fa71fd289c370825f747c64373fb30a 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 c5004a1ba6b30b4e4eb94984cdeddba87766917a..0f84636a6d9bf163fbaa67b17fe10e681433dba2 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 6fb325dbd365dbbbfbed5aa16f7ee2e82c38577d..8f5af6b519ed09bbb3f0e235694eee54339e416f 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 e0aacd067b0d2d69f2265644326e1524b654b8b4..065abb95447b7d9bde7e488ebf05805db7ed0e03 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 fa79de4a42af71aa7abff1de91a3086387a55b00..e2ae6f393c530c454e58337b95c40604d030d1dc 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 99bdedfa95ec80a4bc3a4ef54e02d9233ccbbe3d..133bf69fc3b07b553203ac565b4d45b59b7b64a5 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 27f054a2f193a7de8a8b174e703fff1ca4dc38c7..02da53a7a8d2e342a37d17f89a3d9b44a1ae6b3c 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 c8b9d0edd118ec5dc479009e9c1110c94690bfb8..e34fbdddf06506ed9aa7fd5d73a04b1a50da2c62 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 2729efb94dfef8a5a58b63c430bd963695eadb84..7fb04db8527b50f22de425371a1c9f1d7198c00e 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 a003f1273f9b2187e11f1ecdfd2830c5380ecc92..5064b36087da379c60727dc40ca15d159f2df571 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 2ff89c73db22b5f69863a238a3810687305228d9..2f64105f1aeb03702d7fd01a29b122cb91b90fe0 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 2f816ac25b253c4a1d749d560168ade6139a3a22..cdbc3907b2fb08c208c919280ca12eeb266d412e 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", ] }