From 038ae1adf2ef094bb6fc07637d661879f37727bb Mon Sep 17 00:00:00 2001 From: li-tiangang4 Date: Mon, 25 Nov 2024 13:47:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-tiangang4 --- common/include/input_check_param.cpp | 8 ++------ common/include/input_check_param.h | 6 ++++-- .../src/add_white_list_infos_call_back_proxy.cpp | 3 ++- .../src/del_white_list_infos_call_back_proxy.cpp | 3 ++- .../ipc/src/distributed_input_sink_proxy.cpp | 1 + .../get_sink_screen_infos_call_back_proxy.cpp | 3 ++- interfaces/ipc/src/input_node_listener_proxy.cpp | 2 ++ .../ipc/src/prepare_d_input_call_back_proxy.cpp | 3 ++- .../ipc/src/register_d_input_call_back_proxy.cpp | 3 ++- .../register_session_state_callback_proxy.cpp | 3 ++- .../ipc/src/start_d_input_call_back_proxy.cpp | 3 ++- .../src/start_stop_d_inputs_call_back_proxy.cpp | 1 + .../ipc/src/stop_d_input_call_back_proxy.cpp | 3 ++- .../src/unprepare_d_input_call_back_proxy.cpp | 3 ++- .../src/unregister_d_input_call_back_proxy.cpp | 3 ++- .../src/distributed_input_sink_manager.cpp | 16 ++++++++-------- .../src/distributed_input_node_manager.cpp | 3 +++ .../sourcemanager/src/dinput_source_listener.cpp | 3 +++ 18 files changed, 44 insertions(+), 26 deletions(-) diff --git a/common/include/input_check_param.cpp b/common/include/input_check_param.cpp index af980bd..be0a7a6 100644 --- a/common/include/input_check_param.cpp +++ b/common/include/input_check_param.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Copyright (c) 2022-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 @@ -21,11 +21,7 @@ namespace OHOS { namespace DistributedHardware { namespace DistributedInput { -DInputCheckParam &DInputCheckParam::GetInstance(void) -{ - static DInputCheckParam instance; - return instance; -} +IMPLEMENT_SINGLE_INSTANCE(DInputCheckParam); bool DInputCheckParam::CheckParam(const std::string &deviceId, sptr callback) { if (deviceId.empty() || deviceId.size() > DEV_ID_LENGTH_MAX) { diff --git a/common/include/input_check_param.h b/common/include/input_check_param.h index 1643726..58eaeae 100644 --- a/common/include/input_check_param.h +++ b/common/include/input_check_param.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-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 @@ -18,14 +18,16 @@ #include +#include "single_instance.h" + #include "idistributed_hardware_source.h" namespace OHOS { namespace DistributedHardware { namespace DistributedInput { class DInputCheckParam { +DECLARE_SINGLE_INSTANCE_BASE(DInputCheckParam); public: - static DInputCheckParam &GetInstance(void); bool CheckParam(const std::string &deviceId, sptr callback); bool CheckParam(const std::string &deviceId, const uint32_t &inputTypes, sptr callback); bool CheckParam(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes, diff --git a/interfaces/ipc/src/add_white_list_infos_call_back_proxy.cpp b/interfaces/ipc/src/add_white_list_infos_call_back_proxy.cpp index c6ba5dd..8967ee6 100644 --- a/interfaces/ipc/src/add_white_list_infos_call_back_proxy.cpp +++ b/interfaces/ipc/src/add_white_list_infos_call_back_proxy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -36,6 +36,7 @@ void AddWhiteListInfosCallbackProxy::OnResult(const std::string &deviceId, const { sptr remote = Remote(); if (remote == nullptr) { + DHLOGE("remote is null."); return; } diff --git a/interfaces/ipc/src/del_white_list_infos_call_back_proxy.cpp b/interfaces/ipc/src/del_white_list_infos_call_back_proxy.cpp index 66e7cbf..d5e442d 100644 --- a/interfaces/ipc/src/del_white_list_infos_call_back_proxy.cpp +++ b/interfaces/ipc/src/del_white_list_infos_call_back_proxy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -36,6 +36,7 @@ void DelWhiteListInfosCallbackProxy::OnResult(const std::string &deviceId) { sptr remote = Remote(); if (remote == nullptr) { + DHLOGE("remote is null."); return; } diff --git a/interfaces/ipc/src/distributed_input_sink_proxy.cpp b/interfaces/ipc/src/distributed_input_sink_proxy.cpp index 12bebb2..fea7bff 100644 --- a/interfaces/ipc/src/distributed_input_sink_proxy.cpp +++ b/interfaces/ipc/src/distributed_input_sink_proxy.cpp @@ -175,6 +175,7 @@ bool DistributedInputSinkProxy::SendRequest(uint32_t code, MessageParcel &data, { sptr remote = Remote(); if (remote == nullptr) { + DHLOGE("remote is null."); return false; } MessageOption option(MessageOption::TF_SYNC); diff --git a/interfaces/ipc/src/get_sink_screen_infos_call_back_proxy.cpp b/interfaces/ipc/src/get_sink_screen_infos_call_back_proxy.cpp index 543a3a1..8e4ac02 100644 --- a/interfaces/ipc/src/get_sink_screen_infos_call_back_proxy.cpp +++ b/interfaces/ipc/src/get_sink_screen_infos_call_back_proxy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Copyright (c) 2022-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 @@ -36,6 +36,7 @@ void GetSinkScreenInfosCallbackProxy::OnResult(const std::string &strJson) { sptr remote = Remote(); if (remote == nullptr) { + DHLOGE("remote is null."); return; } diff --git a/interfaces/ipc/src/input_node_listener_proxy.cpp b/interfaces/ipc/src/input_node_listener_proxy.cpp index 2d12876..a4f81fd 100644 --- a/interfaces/ipc/src/input_node_listener_proxy.cpp +++ b/interfaces/ipc/src/input_node_listener_proxy.cpp @@ -35,6 +35,7 @@ void InputNodeListenerProxy::OnNodeOnLine(const std::string &srcDevId, const std { sptr remote = Remote(); if (remote == nullptr) { + DHLOGE("remote is null."); return; } @@ -73,6 +74,7 @@ void InputNodeListenerProxy::OnNodeOffLine(const std::string &srcDevId, const st { sptr remote = Remote(); if (remote == nullptr) { + DHLOGE("remote is null."); return; } diff --git a/interfaces/ipc/src/prepare_d_input_call_back_proxy.cpp b/interfaces/ipc/src/prepare_d_input_call_back_proxy.cpp index 6ce922e..df4c39a 100644 --- a/interfaces/ipc/src/prepare_d_input_call_back_proxy.cpp +++ b/interfaces/ipc/src/prepare_d_input_call_back_proxy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -36,6 +36,7 @@ void PrepareDInputCallbackProxy::OnResult(const std::string &deviceId, const int { sptr remote = Remote(); if (remote == nullptr) { + DHLOGE("remote is null."); return; } diff --git a/interfaces/ipc/src/register_d_input_call_back_proxy.cpp b/interfaces/ipc/src/register_d_input_call_back_proxy.cpp index b8c01fe..b03989f 100644 --- a/interfaces/ipc/src/register_d_input_call_back_proxy.cpp +++ b/interfaces/ipc/src/register_d_input_call_back_proxy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -36,6 +36,7 @@ void RegisterDInputCallbackProxy::OnResult(const std::string &devId, const std:: { sptr remote = Remote(); if (remote == nullptr) { + DHLOGE("remote is null."); return; } diff --git a/interfaces/ipc/src/register_session_state_callback_proxy.cpp b/interfaces/ipc/src/register_session_state_callback_proxy.cpp index f2d6783..9951204 100644 --- a/interfaces/ipc/src/register_session_state_callback_proxy.cpp +++ b/interfaces/ipc/src/register_session_state_callback_proxy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 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 @@ -36,6 +36,7 @@ void RegisterSessionStateCallbackProxy::OnResult(const std::string &deviceId, co { sptr remote = Remote(); if (remote == nullptr) { + DHLOGE("remote is null."); return; } diff --git a/interfaces/ipc/src/start_d_input_call_back_proxy.cpp b/interfaces/ipc/src/start_d_input_call_back_proxy.cpp index 7c06d7b..bfb808a 100644 --- a/interfaces/ipc/src/start_d_input_call_back_proxy.cpp +++ b/interfaces/ipc/src/start_d_input_call_back_proxy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -36,6 +36,7 @@ void StartDInputCallbackProxy::OnResult(const std::string &devId, const uint32_t { sptr remote = Remote(); if (remote == nullptr) { + DHLOGE("remote is null."); return; } diff --git a/interfaces/ipc/src/start_stop_d_inputs_call_back_proxy.cpp b/interfaces/ipc/src/start_stop_d_inputs_call_back_proxy.cpp index 9ee36e5..d4bc565 100644 --- a/interfaces/ipc/src/start_stop_d_inputs_call_back_proxy.cpp +++ b/interfaces/ipc/src/start_stop_d_inputs_call_back_proxy.cpp @@ -34,6 +34,7 @@ void StartStopDInputsCallbackProxy::OnResultDhids(const std::string &devId, cons { sptr remote = Remote(); if (remote == nullptr) { + DHLOGE("remote is null."); return; } diff --git a/interfaces/ipc/src/stop_d_input_call_back_proxy.cpp b/interfaces/ipc/src/stop_d_input_call_back_proxy.cpp index 8657cd0..1193d00 100644 --- a/interfaces/ipc/src/stop_d_input_call_back_proxy.cpp +++ b/interfaces/ipc/src/stop_d_input_call_back_proxy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -36,6 +36,7 @@ void StopDInputCallbackProxy::OnResult(const std::string &devId, const uint32_t { sptr remote = Remote(); if (remote == nullptr) { + DHLOGE("remote is null."); return; } diff --git a/interfaces/ipc/src/unprepare_d_input_call_back_proxy.cpp b/interfaces/ipc/src/unprepare_d_input_call_back_proxy.cpp index a6a2804..5851313 100644 --- a/interfaces/ipc/src/unprepare_d_input_call_back_proxy.cpp +++ b/interfaces/ipc/src/unprepare_d_input_call_back_proxy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -36,6 +36,7 @@ void UnprepareDInputCallbackProxy::OnResult(const std::string &deviceId, const i { sptr remote = Remote(); if (remote == nullptr) { + DHLOGE("remote is null."); return; } diff --git a/interfaces/ipc/src/unregister_d_input_call_back_proxy.cpp b/interfaces/ipc/src/unregister_d_input_call_back_proxy.cpp index b7328df..9d2aa8e 100644 --- a/interfaces/ipc/src/unregister_d_input_call_back_proxy.cpp +++ b/interfaces/ipc/src/unregister_d_input_call_back_proxy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -36,6 +36,7 @@ void UnregisterDInputCallbackProxy::OnResult(const std::string &devId, const std { sptr remote = Remote(); if (remote == nullptr) { + DHLOGE("remote is null."); return; } diff --git a/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp b/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp index a0b47b0..fd69f2a 100644 --- a/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp +++ b/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp @@ -288,6 +288,10 @@ void DistributedInputSinkManager::DInputSinkListener::OnStopRemoteInput( void DistributedInputSinkManager::DInputSinkListener::OnStartRemoteInputDhid(const int32_t &sessionId, const std::string &strDhids) { + if (sinkManagerObj_ == nullptr) { + DHLOGE("sinkManagerObj is null."); + return; + } DHLOGI("OnStartRemoteInputDhid called, sessionId: %{public}d", sessionId); // set new session int32_t startRes = DistributedInputSinkSwitch::GetInstance().StartSwitch(sessionId); @@ -304,10 +308,6 @@ void DistributedInputSinkManager::DInputSinkListener::OnStartRemoteInputDhid(con DHLOGE("StartSwitch error."); return; } - if (sinkManagerObj_ == nullptr) { - DHLOGE("sinkManagerObj is null."); - return; - } std::vector devDhIds; SplitStringToVector(strDhids, INPUT_STRING_SPLIT_POINT, devDhIds); DInputSinkState::GetInstance().RecordDhIds(devDhIds, DhIdState::THROUGH_OUT, sessionId); @@ -362,6 +362,10 @@ void DistributedInputSinkManager::DInputSinkListener::OnStopRemoteInputDhid(cons void DistributedInputSinkManager::DInputSinkListener::OnRelayStartDhidRemoteInput(const int32_t &toSrcSessionId, const int32_t &toSinkSessionId, const std::string &deviceId, const std::string &strDhids) { + if (sinkManagerObj_ == nullptr) { + DHLOGE("sinkManagerObj is null."); + return; + } DHLOGI("onRelayStartDhidRemoteInput called, toSinkSessionId: %{public}d", toSinkSessionId); // set new session int32_t startRes = DistributedInputSinkSwitch::GetInstance().StartSwitch(toSinkSessionId); @@ -378,10 +382,6 @@ void DistributedInputSinkManager::DInputSinkListener::OnRelayStartDhidRemoteInpu DHLOGE("StartSwitch error."); return; } - if (sinkManagerObj_ == nullptr) { - DHLOGE("sinkManagerObj is null."); - return; - } std::vector devDhIds; SplitStringToVector(strDhids, INPUT_STRING_SPLIT_POINT, devDhIds); DInputSinkState::GetInstance().RecordDhIds(devDhIds, DhIdState::THROUGH_OUT, toSinkSessionId); diff --git a/services/source/inputinject/src/distributed_input_node_manager.cpp b/services/source/inputinject/src/distributed_input_node_manager.cpp index c78bf3b..e0f0cbd 100644 --- a/services/source/inputinject/src/distributed_input_node_manager.cpp +++ b/services/source/inputinject/src/distributed_input_node_manager.cpp @@ -40,6 +40,9 @@ DistributedInputNodeManager::DistributedInputNodeManager() : isInjectThreadCreat { DHLOGI("DistributedInputNodeManager ctor"); std::shared_ptr runner = AppExecFwk::EventRunner::Create(true); + if (runner == nullptr) { + DHLOGE("Creat eventrunner failed."); + } callBackHandler_ = std::make_shared(runner, this); } diff --git a/services/source/sourcemanager/src/dinput_source_listener.cpp b/services/source/sourcemanager/src/dinput_source_listener.cpp index ae41aad..2a3f9b0 100644 --- a/services/source/sourcemanager/src/dinput_source_listener.cpp +++ b/services/source/sourcemanager/src/dinput_source_listener.cpp @@ -38,6 +38,9 @@ namespace DistributedHardware { namespace DistributedInput { DInputSourceListener::DInputSourceListener(DistributedInputSourceManager *manager) { + if (manager == nullptr) { + DHLOGE("manager is null."); + } sourceManagerObj_ = manager; DHLOGI("DInputSourceListener init."); } -- Gitee