diff --git a/common/include/input_check_param.cpp b/common/include/input_check_param.cpp index af980bd84347b5089540650e3a901dbcbaa75a91..be0a7a6126a6e88864ad31e234cd835c190c4f13 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 164372684eae88dc1fa68ec7ac57920395d42691..58eaeae72fc080472b081e715336870d0ce0fbed 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 c6ba5dddba26924620203ffd73d0f63bb32caae0..8967ee66e7ec9ca2d4fa78c6e68260cd198279fe 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 66e7cbff33cdd5403c034b0210fef0a162fe9537..d5e442dc2d7ce15256cbdbeb7ffbf306c4d5f572 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 12bebb26e7d733a61f9f60f8e4237ea4e74c0c62..fea7bffe5defbac8d4135daeeb3f81d3dffa83e0 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 543a3a14c11b97d66a44c70504e423e5889ae500..8e4ac025ce5264345836eb916f6d4c8ad1566249 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 2d128766af1b0363fa548bc98519b8bdf1b07c07..a4f81fd83df684b0210cb711f41af448206b33cc 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 6ce922e002bf14855fc5c8e5d0764c98bd77d6a2..df4c39a0fe9332e89a6e36560df15b4812ed2885 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 b8c01fe9211ebfa95be7585d53d72d33ed8f759d..b03989f09b0a5d5cfd64a4ffc19e8d57b53d5dd7 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 f2d6783c82c9688a40b1949800b6a416e8c3c9e4..9951204afdef8e8ccbaa49ca759de1dd8ac69e5a 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 7c06d7b7a4b7aec546a981d9f987b46e32fe9d31..bfb808a581a6a99a0e7524bdc7b3122be15ed6b4 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 9ee36e55f92a72f9edb692bd1decb04dadabf1d3..d4bc565a3c8b83b41c9a73ca18e11b68dff75363 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 8657cd016a84e5bb5a45286eb7bbe5097376e250..1193d00753996264f4358ba3a935b9982b8b21e3 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 a6a28041d9507cc0c8b95e6b806e22e847e5133b..5851313d53b69e2809a8de829f22d00efc8356e8 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 b7328dfaf2c3af0116f5d13367f7c5cd7a235bf6..9d2aa8e3ffee8520945dae8666b7a9cfef368030 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 a0b47b0a66a9339aa7a891bc9815c5b86a5b7350..fd69f2a09421077308eba28fea95a407ff685175 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 c78bf3b2bce6215742b41507e663836dae1a8c60..e0f0cbd376aa6d7facec54f255fa8089e78484d2 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 ae41aad483c65bccad0db29096b369bd47c45ed9..2a3f9b033e6361ceaf997633b14b7de6c9a1dac1 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."); }