From bec12d80a9ad04162cf38e58b95f92790f5bd88c Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Thu, 11 Jul 2024 10:57:55 +0800 Subject: [PATCH] fix bug Signed-off-by: gaoqiang_strong --- .../src/distributed_input_inject.cpp | 13 +- .../src/distributed_input_node_manager.cpp | 32 ++- .../source/inputinject/src/virtual_device.cpp | 12 +- .../distributed_input_sourceinject_test.cpp | 9 + .../dinput_source_manager_event_handler.cpp | 235 +++++++++++++++++- .../src/distributed_input_source_manager.cpp | 169 ++++++++----- .../distributed_input_source_sa_cli_mgr.cpp | 6 +- .../distributed_input_sourcemanager_test.cpp | 148 +++++++++++ .../distributed_input_source_transport.cpp | 82 +++++- services/state/src/dinput_sink_state.cpp | 4 + .../dinput_sink_state_test.cpp | 3 + .../src/distributed_input_sink_handler.cpp | 4 + .../mock/mock_distributed_input_client.cpp | 8 +- .../src/distributed_input_source_handler.cpp | 4 + .../mock/mock_distributed_input_client.cpp | 8 +- 15 files changed, 634 insertions(+), 103 deletions(-) diff --git a/services/source/inputinject/src/distributed_input_inject.cpp b/services/source/inputinject/src/distributed_input_inject.cpp index 725a18e..21e4990 100644 --- a/services/source/inputinject/src/distributed_input_inject.cpp +++ b/services/source/inputinject/src/distributed_input_inject.cpp @@ -85,8 +85,9 @@ int32_t DistributedInputInject::UnregisterDistributedHardware(const std::string int32_t DistributedInputInject::StructTransJson(const InputDevice &pBuf, std::string &strDescriptor) { - DHLOGI("[%{public}s] %{public}d, %{public}d, %{public}d, %{public}d, %{public}s.\n", (pBuf.name).c_str(), - pBuf.bus, pBuf.vendor, pBuf.product, pBuf.version, GetAnonyString(pBuf.descriptor).c_str()); + DHLOGI("[%{public}s] %{public}d, %{public}d, %{public}d, %{public}d, %{public}s.\n", + GetAnonyString(pBuf.name).c_str(), pBuf.bus, pBuf.vendor, pBuf.product, + pBuf.version, GetAnonyString(pBuf.descriptor).c_str()); nlohmann::json tmpJson; tmpJson[DEVICE_NAME] = pBuf.name; tmpJson[PHYSICAL_PATH] = pBuf.physicalPath; @@ -184,12 +185,20 @@ int32_t DistributedInputInject::RegisterInjectEventCb(sptrRegisterInjectEventCb(callback); return DH_SUCCESS; } int32_t DistributedInputInject::UnregisterInjectEventCb() { + if (inputNodeManager_ == nullptr) { + DHLOGE("inputNodeManager is nullptr"); + return UN_INIT_FD_VALUE; + } inputNodeManager_->UnregisterInjectEventCb(); return DH_SUCCESS; } diff --git a/services/source/inputinject/src/distributed_input_node_manager.cpp b/services/source/inputinject/src/distributed_input_node_manager.cpp index af1f751..c9817f2 100644 --- a/services/source/inputinject/src/distributed_input_node_manager.cpp +++ b/services/source/inputinject/src/distributed_input_node_manager.cpp @@ -174,6 +174,10 @@ void DistributedInputNodeManager::DInputNodeManagerEventHandler::ProcessEvent( const AppExecFwk::InnerEvent::Pointer &event) { DHLOGI("ProcessEvent enter."); + if (event == nullptr) { + DHLOGE("event is nullptr"); + return; + } auto iter = eventFuncMap_.find(event->GetInnerEventId()); if (iter == eventFuncMap_.end()) { DHLOGE("Event Id %{public}d is undefined.", event->GetInnerEventId()); @@ -202,7 +206,15 @@ void DistributedInputNodeManager::DInputNodeManagerEventHandler::ScanAllNode( const AppExecFwk::InnerEvent::Pointer &event) { DHLOGI("ScanAllNode enter."); + if (event == nullptr) { + DHLOGE("event is nullptr"); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr || nodeManagerObj_ == nullptr) { + DHLOGE("dataMsg or nodeManagerObj_ is nullptr"); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *(it); std::string devId = innerMsg[INPUT_NODE_DEVID]; @@ -214,12 +226,20 @@ void DistributedInputNodeManager::NotifyNodeMgrScanVirNode(const std::string &de { DHLOGI("NotifyNodeMgrScanVirNode enter."); std::shared_ptr jsonArrayMsg = std::make_shared(); + if (jsonArrayMsg == nullptr) { + DHLOGE("jsonArrayMsg is nullptr"); + return; + } nlohmann::json tmpJson; tmpJson[INPUT_NODE_DEVID] = devId; tmpJson[INPUT_NODE_DHID] = dhId; jsonArrayMsg->push_back(tmpJson); AppExecFwk::InnerEvent::Pointer msgEvent = AppExecFwk::InnerEvent::Get( DINPUT_NODE_MANAGER_SCAN_ALL_NODE, jsonArrayMsg, 0); + if (callBackHandler_ == nullptr) { + DHLOGE("callBackHandler_ is nullptr"); + return; + } callBackHandler_->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); } @@ -233,10 +253,10 @@ bool DistributedInputNodeManager::IsVirtualDev(int fd) } buffer[sizeof(buffer) - 1] = '\0'; deviceName = buffer; - - DHLOGD("IsVirtualDev deviceName: %{public}s", buffer); + DHLOGD("IsVirtualDev deviceName: %{public}s", GetAnonyString(std::string(buffer)).c_str()); if (deviceName.find(VIRTUAL_DEVICE_NAME) == std::string::npos) { - DHLOGD("This is not a virtual device, fd %{public}d, deviceName: %{public}s.", fd, deviceName.c_str()); + DHLOGD("This is not a virtual device, fd %{public}d, deviceName: %{public}s.", fd, + GetAnonyString(deviceName).c_str()); return false; } return true; @@ -281,6 +301,10 @@ void DistributedInputNodeManager::SetPathForVirDev(const DhUniqueID &dhUniqueId, GetAnonyString(iter->first.second).c_str()); if (iter->first == dhUniqueId) { DHLOGD("Found the virtual device, set path :%{public}s", devicePath.c_str()); + if (iter->second == nullptr) { + DHLOGE("iter second is null"); + continue; + } iter->second->SetPath(devicePath); break; } @@ -378,7 +402,7 @@ int32_t DistributedInputNodeManager::CreateVirtualTouchScreenNode(const std::str std::unique_lock my_lock(operationMutex_); std::unique_ptr device; LocalAbsInfo info = DInputContext::GetInstance().GetLocalTouchScreenInfo().localAbsInfo; - DHLOGI("CreateVirtualTouchScreenNode, dhId: %{public}s, sourcePhyWidth: %{public}d, sourcePhyHeight: %{public}d", + DHLOGI("CreateVirtualTouchScreenNode, dhId: %{public}s, sourcePhyWidth: %{public}u, sourcePhyHeight: %{public}u", GetAnonyString(dhId).c_str(), sourcePhyWidth, sourcePhyHeight); device = std::make_unique(info.deviceInfo); if (!device->SetUp(info.deviceInfo, devId, dhId)) { diff --git a/services/source/inputinject/src/virtual_device.cpp b/services/source/inputinject/src/virtual_device.cpp index aa5dd6e..0f1ef7c 100644 --- a/services/source/inputinject/src/virtual_device.cpp +++ b/services/source/inputinject/src/virtual_device.cpp @@ -96,11 +96,11 @@ void VirtualDevice::SetABSInfo(struct uinput_user_dev &inputUserDev, const Input int absCode = item.first; std::vector absInfo = item.second; DHLOGI("SetABSInfo nodeName: %{public}s, absCode: %{public}d, absMin: %{public}d, absMax: %{public}d, " - "absFuzz: %{public}d, absFlat: %{public}d", inputDevice.name.c_str(), absCode, absInfo[ABS_MIN_POS], - absInfo[ABS_MAX_POS], absInfo[ABS_FUZZ_POS], absInfo[ABS_FLAT_POS]); + "absFuzz: %{public}d, absFlat: %{public}d", GetAnonyString(inputDevice.name).c_str(), + absCode, absInfo[ABS_MIN_POS], absInfo[ABS_MAX_POS], absInfo[ABS_FUZZ_POS], absInfo[ABS_FLAT_POS]); if (absInfo[ABS_MAX_POS] < absInfo[ABS_MIN_POS]) { - DHLOGE("NodeName: %{public}s, absCode: %{public}d, attributes is invalid.", inputDevice.name.c_str(), - absCode); + DHLOGE("NodeName: %{public}s, absCode: %{public}d, attributes is invalid.", + GetAnonyString(inputDevice.name).c_str(), absCode); continue; } inputUserDev.absmin[absCode] = absInfo[ABS_MIN_POS]; @@ -230,8 +230,8 @@ void VirtualDevice::RecordEventLog(const input_event &event) break; } DHLOGD("4.E2E-Test Source write event into input driver, EventType: %{public}s, Code: %{public}d, " - "Value: %{public}d, Sec: %ld, Sec1: %ld", eventType.c_str(), event.code, event.value, event.input_event_sec, - event.input_event_usec); + "Value: %{public}d, Sec: %{public}ld, Sec1: %{public}ld", eventType.c_str(), event.code, event.value, + event.input_event_sec, event.input_event_usec); } int32_t VirtualDevice::GetDeviceFd() diff --git a/services/source/inputinject/test/sourceinjectunittest/distributed_input_sourceinject_test.cpp b/services/source/inputinject/test/sourceinjectunittest/distributed_input_sourceinject_test.cpp index 82fa6ff..f7582c3 100644 --- a/services/source/inputinject/test/sourceinjectunittest/distributed_input_sourceinject_test.cpp +++ b/services/source/inputinject/test/sourceinjectunittest/distributed_input_sourceinject_test.cpp @@ -362,6 +362,7 @@ HWTEST_F(DistributedInputSourceInjectTest, RemoveVirtualTouchScreenNode_003, tes { std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8"; + ASSERT_NE(nullptr, DistributedInputInject::GetInstance().inputNodeManager_); int32_t ret = DistributedInputInject::GetInstance().inputNodeManager_->RemoveVirtualTouchScreenNode(devId, dhId); EXPECT_EQ(DH_SUCCESS, ret); } @@ -371,6 +372,7 @@ HWTEST_F(DistributedInputSourceInjectTest, GetDevice_001, testing::ext::TestSize std::string deviceId = "umkyu1b165e1be98151891erbe8r91ev"; std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8"; VirtualDevice* device = nullptr; + ASSERT_NE(nullptr, DistributedInputInject::GetInstance().inputNodeManager_); int32_t ret = DistributedInputInject::GetInstance().inputNodeManager_->GetDevice(deviceId, dhId, device); EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_GET_DEVICE_FAIL, ret); } @@ -380,16 +382,19 @@ HWTEST_F(DistributedInputSourceInjectTest, OpenDevicesNode_001, testing::ext::Te std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8"; std::string parameters = ""; + ASSERT_NE(nullptr, DistributedInputInject::GetInstance().inputNodeManager_); int32_t ret = DistributedInputInject::GetInstance().inputNodeManager_->OpenDevicesNode(devId, dhId, parameters); EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_OPEN_DEVICE_NODE_FAIL, ret); devId = ""; parameters = "parameters_test"; + ASSERT_NE(nullptr, DistributedInputInject::GetInstance().inputNodeManager_); ret = DistributedInputInject::GetInstance().inputNodeManager_->OpenDevicesNode(devId, dhId, parameters); EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_OPEN_DEVICE_NODE_FAIL, ret); devId = "umkyu1b165e1be98151891erbe8r91ev"; dhId = ""; + ASSERT_NE(nullptr, DistributedInputInject::GetInstance().inputNodeManager_); ret = DistributedInputInject::GetInstance().inputNodeManager_->OpenDevicesNode(devId, dhId, parameters); EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_OPEN_DEVICE_NODE_FAIL, ret); } @@ -399,16 +404,19 @@ HWTEST_F(DistributedInputSourceInjectTest, OpenDevicesNode_002, testing::ext::Te std::string devId(DEV_ID_LENGTH_MAX + 1, 'a'); std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8"; std::string parameters = "parameters_test"; + ASSERT_NE(nullptr, DistributedInputInject::GetInstance().inputNodeManager_); int32_t ret = DistributedInputInject::GetInstance().inputNodeManager_->OpenDevicesNode(devId, dhId, parameters); EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_OPEN_DEVICE_NODE_FAIL, ret); devId = "umkyu1b165e1be98151891erbe8r91ev"; std::string dhIds(DH_ID_LENGTH_MAX + 1, 'a'); + ASSERT_NE(nullptr, DistributedInputInject::GetInstance().inputNodeManager_); ret = DistributedInputInject::GetInstance().inputNodeManager_->OpenDevicesNode(devId, dhIds, parameters); EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_OPEN_DEVICE_NODE_FAIL, ret); std::string dhIdtest = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8"; std::string param(STRING_MAX_SIZE + 1, 'a'); + ASSERT_NE(nullptr, DistributedInputInject::GetInstance().inputNodeManager_); ret = DistributedInputInject::GetInstance().inputNodeManager_->OpenDevicesNode(devId, dhIdtest, param); EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_OPEN_DEVICE_NODE_FAIL, ret); } @@ -450,6 +458,7 @@ HWTEST_F(DistributedInputSourceInjectTest, MatchAndSavePhysicalPath_001, testing std::string devicePath = ""; std::string devId = ""; std::string dhId = ""; + ASSERT_NE(nullptr, DistributedInputInject::GetInstance().inputNodeManager_); auto ret = DistributedInputInject::GetInstance().inputNodeManager_->MatchAndSavePhysicalPath(devicePath, devId, dhId); EXPECT_EQ(false, ret); diff --git a/services/source/sourcemanager/src/dinput_source_manager_event_handler.cpp b/services/source/sourcemanager/src/dinput_source_manager_event_handler.cpp index 0039c90..3c20bdd 100644 --- a/services/source/sourcemanager/src/dinput_source_manager_event_handler.cpp +++ b/services/source/sourcemanager/src/dinput_source_manager_event_handler.cpp @@ -47,7 +47,15 @@ DInputSourceManagerEventHandler::~DInputSourceManagerEventHandler() void DInputSourceManagerEventHandler::NotifyRegisterCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is invaild."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is invaild."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -61,6 +69,10 @@ void DInputSourceManagerEventHandler::NotifyRegisterCallback(const AppExecFwk::I bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; DistributedInputSourceManager::InputDeviceId inputDeviceId {deviceId, dhId}; + if (sourceManagerObj_ == nullptr) { + DHLOGE("sourceManagerObj_ is invaild."); + return; + } std::vector tmpInputDevId = sourceManagerObj_->GetInputDeviceId(); // Find out if the dh exists auto devIt = std::find(tmpInputDevId.begin(), tmpInputDevId.end(), inputDeviceId); @@ -79,7 +91,15 @@ void DInputSourceManagerEventHandler::NotifyRegisterCallback(const AppExecFwk::I void DInputSourceManagerEventHandler::NotifyUnregisterCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is invaild."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is invaild."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -90,6 +110,10 @@ void DInputSourceManagerEventHandler::NotifyUnregisterCallback(const AppExecFwk: } std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; std::string dhId = innerMsg[INPUT_SOURCEMANAGER_KEY_HWID]; + if (sourceManagerObj_ == nullptr) { + DHLOGE("sourceManagerObj_ is invaild."); + return; + } bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; if (result) { sourceManagerObj_->SetDeviceMapValue(deviceId, DINPUT_SOURCE_SWITCH_OFF); @@ -100,7 +124,15 @@ void DInputSourceManagerEventHandler::NotifyUnregisterCallback(const AppExecFwk: void DInputSourceManagerEventHandler::NotifyPrepareCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is invaild."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is invaild."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -112,14 +144,25 @@ void DInputSourceManagerEventHandler::NotifyPrepareCallback(const AppExecFwk::In std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; std::string object = innerMsg[INPUT_SOURCEMANAGER_KEY_WHITELIST]; - + if (sourceManagerObj_ == nullptr) { + DHLOGE("sourceManagerObj_ is invaild."); + return; + } sourceManagerObj_->RunPrepareCallback(deviceId, result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_PREPARE_MSG_IS_BAD, object); } void DInputSourceManagerEventHandler::NotifyUnprepareCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is invaild."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is invaild."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -128,6 +171,10 @@ void DInputSourceManagerEventHandler::NotifyUnprepareCallback(const AppExecFwk:: return ; } std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; + if (sourceManagerObj_ == nullptr) { + DHLOGE("sourceManagerObj_ is invaild."); + return; + } bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; if (result) { sourceManagerObj_->SetDeviceMapValue(deviceId, DINPUT_SOURCE_SWITCH_OFF); @@ -138,7 +185,15 @@ void DInputSourceManagerEventHandler::NotifyUnprepareCallback(const AppExecFwk:: void DInputSourceManagerEventHandler::NotifyStartCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is invaild."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is invaild."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -150,8 +205,12 @@ void DInputSourceManagerEventHandler::NotifyStartCallback(const AppExecFwk::Inne std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; uint32_t inputTypes = innerMsg[INPUT_SOURCEMANAGER_KEY_ITP]; bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; - DHLOGI("Start DInput Recv Callback ret: %{public}s, devId: %{public}s, inputTypes: %{public}d", + DHLOGI("Start DInput Recv Callback ret: %{public}s, devId: %{public}s, inputTypes: %{public}u", result ? "true" : "false", GetAnonyString(deviceId).c_str(), inputTypes); + if (sourceManagerObj_ == nullptr) { + DHLOGE("sourceManagerObj_ is invaild."); + return; + } if (result) { sourceManagerObj_->SetInputTypesMap( deviceId, sourceManagerObj_->GetInputTypesMap(deviceId) | inputTypes); @@ -164,7 +223,15 @@ void DInputSourceManagerEventHandler::NotifyStartCallback(const AppExecFwk::Inne void DInputSourceManagerEventHandler::NotifyStopCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is invaild."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is invaild."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -176,9 +243,12 @@ void DInputSourceManagerEventHandler::NotifyStopCallback(const AppExecFwk::Inner std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; uint32_t inputTypes = innerMsg[INPUT_SOURCEMANAGER_KEY_ITP]; bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; - - DHLOGI("Stop DInput Recv Callback ret: %{public}d, devId: %{public}s, inputTypes: %{public}d", + DHLOGI("Stop DInput Recv Callback ret: %{public}d, devId: %{public}s, inputTypes: %{public}u", result, GetAnonyString(deviceId).c_str(), inputTypes); + if (sourceManagerObj_ == nullptr) { + DHLOGE("sourceManagerObj_ is invaild."); + return; + } if (result && (sourceManagerObj_->GetInputTypesMap(deviceId) & inputTypes)) { sourceManagerObj_->SetInputTypesMap( deviceId, sourceManagerObj_->GetInputTypesMap(deviceId) - @@ -201,7 +271,15 @@ void DInputSourceManagerEventHandler::NotifyStopCallback(const AppExecFwk::Inner void DInputSourceManagerEventHandler::NotifyStartDhidCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is invaild."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is invaild."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -213,14 +291,25 @@ void DInputSourceManagerEventHandler::NotifyStartDhidCallback(const AppExecFwk:: std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; std::string dhidStr = innerMsg[INPUT_SOURCEMANAGER_KEY_DHID]; bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; - + if (sourceManagerObj_ == nullptr) { + DHLOGE("sourceManagerObj_ is invaild."); + return; + } sourceManagerObj_->RunStartDhidCallback(deviceId, dhidStr, result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_MSG_IS_BAD); } void DInputSourceManagerEventHandler::NotifyStopDhidCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is invaild."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is invaild."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -232,14 +321,25 @@ void DInputSourceManagerEventHandler::NotifyStopDhidCallback(const AppExecFwk::I std::string deviceId = innerMsg[INPUT_SOURCEMANAGER_KEY_DEVID]; std::string dhidStr = innerMsg[INPUT_SOURCEMANAGER_KEY_DHID]; bool result = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; - + if (sourceManagerObj_ == nullptr) { + DHLOGE("sourceManagerObj_ is invaild."); + return; + } sourceManagerObj_->RunStopDhidCallback(deviceId, dhidStr, result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_MSG_IS_BAD); } void DInputSourceManagerEventHandler::NotifyKeyStateCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is invaild."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is invaild."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -255,13 +355,24 @@ void DInputSourceManagerEventHandler::NotifyKeyStateCallback(const AppExecFwk::I uint32_t keyType = innerMsg[INPUT_SOURCEMANAGER_KEY_TYPE]; uint32_t keyCode = innerMsg[INPUT_SOURCEMANAGER_KEY_CODE]; uint32_t keyValue = innerMsg[INPUT_SOURCEMANAGER_KEY_VALUE]; - + if (sourceManagerObj_ == nullptr) { + DHLOGE("sourceManagerObj_ is invaild."); + return; + } sourceManagerObj_->RunKeyStateCallback(deviceId, dhid, keyType, keyCode, keyValue); } void DInputSourceManagerEventHandler::NotifyStartServerCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is invaild."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is invaild."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsInt32(innerMsg, INPUT_SOURCEMANAGER_KEY_RESULT)) { @@ -270,13 +381,25 @@ void DInputSourceManagerEventHandler::NotifyStartServerCallback(const AppExecFwk } int32_t serType = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT]; DInputServerType startTransFlag = DInputServerType(serType); + if (sourceManagerObj_ == nullptr) { + DHLOGE("sourceManagerObj_ is invaild."); + return; + } sourceManagerObj_->SetStartTransFlag(startTransFlag); } void DInputSourceManagerEventHandler::NotifyRelayPrepareCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is invaild."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is invaild."); + return; + } nlohmann::json::iterator it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsInt32(innerMsg, INPUT_SOURCEMANAGER_KEY_VALUE) || @@ -288,13 +411,24 @@ void DInputSourceManagerEventHandler::NotifyRelayPrepareCallback(const AppExecFw int32_t status = innerMsg[INPUT_SOURCEMANAGER_KEY_VALUE]; std::string srcId = innerMsg[INPUT_SOURCEMANAGER_KEY_SRC_DEVID]; std::string sinkId = innerMsg[INPUT_SOURCEMANAGER_KEY_SINK_DEVID]; - + if (sourceManagerObj_ == nullptr) { + DHLOGE("sourceManagerObj_ is invaild."); + return; + } sourceManagerObj_->RunRelayPrepareCallback(srcId, sinkId, status); } void DInputSourceManagerEventHandler::NotifyRelayUnprepareCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is invaild."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is invaild."); + return; + } nlohmann::json::iterator it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsInt32(innerMsg, INPUT_SOURCEMANAGER_KEY_VALUE) || @@ -306,13 +440,24 @@ void DInputSourceManagerEventHandler::NotifyRelayUnprepareCallback(const AppExec int32_t status = innerMsg[INPUT_SOURCEMANAGER_KEY_VALUE]; std::string srcId = innerMsg[INPUT_SOURCEMANAGER_KEY_SRC_DEVID]; std::string sinkId = innerMsg[INPUT_SOURCEMANAGER_KEY_SINK_DEVID]; - + if (sourceManagerObj_ == nullptr) { + DHLOGE("sourceManagerObj_ is invaild."); + return; + } sourceManagerObj_->RunRelayUnprepareCallback(srcId, sinkId, status); } void DInputSourceManagerEventHandler::NotifyRelayPrepareRemoteInput(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is invaild."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is invaild."); + return; + } nlohmann::json::iterator it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -339,12 +484,24 @@ void DInputSourceManagerEventHandler::NotifyRelayPrepareRemoteInput(const AppExe DHLOGE("ProcessEvent DINPUT_SOURCE_MANAGER_RELAY_PREPARE_RESULT_TO_ORIGIN notify is fail."); return; } + if (sourceManagerObj_ == nullptr) { + DHLOGE("sourceManagerObj_ is invaild."); + return; + } sourceManagerObj_->RunWhiteListCallback(deviceId, object); } void DInputSourceManagerEventHandler::NotifyRelayUnprepareRemoteInput(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is invaild."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is invaild."); + return; + } nlohmann::json::iterator it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -372,7 +529,15 @@ void DInputSourceManagerEventHandler::NotifyRelayUnprepareRemoteInput(const AppE void DInputSourceManagerEventHandler::NotifyRelayStartDhidCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is invaild."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is invaild."); + return; + } nlohmann::json::iterator it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsInt32(innerMsg, INPUT_SOURCEMANAGER_KEY_VALUE) || @@ -386,13 +551,24 @@ void DInputSourceManagerEventHandler::NotifyRelayStartDhidCallback(const AppExec std::string srcId = innerMsg[INPUT_SOURCEMANAGER_KEY_SRC_DEVID]; std::string sinkId = innerMsg[INPUT_SOURCEMANAGER_KEY_SINK_DEVID]; std::string dhids = innerMsg[INPUT_SOURCEMANAGER_KEY_DHID]; - + if (sourceManagerObj_ == nullptr) { + DHLOGE("sourceManagerObj_ is invaild."); + return; + } sourceManagerObj_->RunRelayStartDhidCallback(srcId, sinkId, status, dhids); } void DInputSourceManagerEventHandler::NotifyRelayStopDhidCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is invaild."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is invaild."); + return; + } nlohmann::json::iterator it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsInt32(innerMsg, INPUT_SOURCEMANAGER_KEY_VALUE) || @@ -406,13 +582,24 @@ void DInputSourceManagerEventHandler::NotifyRelayStopDhidCallback(const AppExecF std::string srcId = innerMsg[INPUT_SOURCEMANAGER_KEY_SRC_DEVID]; std::string sinkId = innerMsg[INPUT_SOURCEMANAGER_KEY_SINK_DEVID]; std::string dhids = innerMsg[INPUT_SOURCEMANAGER_KEY_DHID]; - + if (sourceManagerObj_ == nullptr) { + DHLOGE("sourceManagerObj_ is invaild."); + return; + } sourceManagerObj_->RunRelayStopDhidCallback(srcId, sinkId, status, dhids); } void DInputSourceManagerEventHandler::NotifyRelayStartTypeCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is invaild."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is invaild."); + return; + } nlohmann::json::iterator it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsInt32(innerMsg, INPUT_SOURCEMANAGER_KEY_VALUE) || @@ -426,13 +613,24 @@ void DInputSourceManagerEventHandler::NotifyRelayStartTypeCallback(const AppExec std::string srcId = innerMsg[INPUT_SOURCEMANAGER_KEY_SRC_DEVID]; std::string sinkId = innerMsg[INPUT_SOURCEMANAGER_KEY_SINK_DEVID]; uint32_t inputTypes = innerMsg[INPUT_SOURCEMANAGER_KEY_TYPE]; - + if (sourceManagerObj_ == nullptr) { + DHLOGE("sourceManagerObj_ is invaild."); + return; + } sourceManagerObj_->RunRelayStartTypeCallback(srcId, sinkId, status, inputTypes); } void DInputSourceManagerEventHandler::NotifyRelayStopTypeCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is invaild."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is invaild."); + return; + } nlohmann::json::iterator it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsInt32(innerMsg, INPUT_SOURCEMANAGER_KEY_VALUE) || @@ -446,12 +644,19 @@ void DInputSourceManagerEventHandler::NotifyRelayStopTypeCallback(const AppExecF std::string srcId = innerMsg[INPUT_SOURCEMANAGER_KEY_SRC_DEVID]; std::string sinkId = innerMsg[INPUT_SOURCEMANAGER_KEY_SINK_DEVID]; uint32_t inputTypes = innerMsg[INPUT_SOURCEMANAGER_KEY_TYPE]; - + if (sourceManagerObj_ == nullptr) { + DHLOGE("sourceManagerObj_ is invaild."); + return; + } sourceManagerObj_->RunRelayStopTypeCallback(srcId, sinkId, status, inputTypes); } void DInputSourceManagerEventHandler::ProcessEventInner(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is invaild."); + return; + } switch (event->GetInnerEventId()) { case DINPUT_SOURCE_MANAGER_RELAY_UNPREPARE_RESULT_TO_ORIGIN: NotifyRelayUnprepareRemoteInput(event); @@ -481,6 +686,10 @@ void DInputSourceManagerEventHandler::ProcessEventInner(const AppExecFwk::InnerE void DInputSourceManagerEventHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is invaild."); + return; + } switch (event->GetInnerEventId()) { case DINPUT_SOURCE_MANAGER_RIGISTER_MSG: NotifyRegisterCallback(event); diff --git a/services/source/sourcemanager/src/distributed_input_source_manager.cpp b/services/source/sourcemanager/src/distributed_input_source_manager.cpp index 34a2b86..32fd55a 100644 --- a/services/source/sourcemanager/src/distributed_input_source_manager.cpp +++ b/services/source/sourcemanager/src/distributed_input_source_manager.cpp @@ -99,6 +99,10 @@ void DistributedInputSourceManager::OnStart() return; } serviceRunningState_ = ServiceSourceRunningState::STATE_RUNNING; + if (runner_ == nullptr) { + DHLOGE("runner_ is nullptr."); + return; + } runner_->Run(); /* @@ -288,32 +292,33 @@ int32_t DistributedInputSourceManager::RegisterDistributedHardware(const std::st // 2.create input node int32_t ret = DistributedInputInject::GetInstance().RegisterDistributedHardware(devId, dhId, parameters); - if (ret != DH_SUCCESS) { - HisyseventUtil::GetInstance().SysEventWriteFault(DINPUT_REGISTER_FAIL, devId, dhId, - ERR_DH_INPUT_SERVER_SOURCE_MANAGER_REGISTER_FAIL, "Dinputregister failed in create input node."); - DHLOGE("RegisterDistributedHardware called, create node fail."); + if (ret == DH_SUCCESS) { + // 3.save device + DHLOGI("inputDevice push deviceId: %{public}s, dhId: %{public}s", GetAnonyString(inputDeviceId.devId).c_str(), + GetAnonyString(inputDeviceId.dhId).c_str()); + inputDevice_.push_back(inputDeviceId); + + // 4.notify source distributedfwk register hardware success + callback->OnResult(devId, dhId, DH_SUCCESS); - for (auto iter = regCallbacks_.begin(); iter != regCallbacks_.end(); ++iter) { - if (iter->devId == devId && iter->dhId == dhId) { + // 5. Notify node mgr to scan vir dev node info + DistributedInputInject::GetInstance().NotifyNodeMgrScanVirNode(devId, dhId); + return DH_SUCCESS; + } + HisyseventUtil::GetInstance().SysEventWriteFault(DINPUT_REGISTER_FAIL, devId, dhId, + ERR_DH_INPUT_SERVER_SOURCE_MANAGER_REGISTER_FAIL, "Dinputregister failed in create input node."); + DHLOGE("RegisterDistributedHardware called, create node fail."); + + for (auto iter = regCallbacks_.begin(); iter != regCallbacks_.end(); ++iter) { + if (iter->devId == devId && iter->dhId == dhId) { + if (iter->callback != nullptr) { iter->callback->OnResult(iter->devId, iter->dhId, ERR_DH_INPUT_SERVER_SOURCE_MANAGER_REGISTER_FAIL); - regCallbacks_.erase(iter); - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_REGISTER_FAIL; } + regCallbacks_.erase(iter); + return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_REGISTER_FAIL; } - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_REGISTER_FAIL; } - - // 3.save device - DHLOGI("inputDevice push deviceId: %{public}s, dhId: %{public}s", GetAnonyString(inputDeviceId.devId).c_str(), - GetAnonyString(inputDeviceId.dhId).c_str()); - inputDevice_.push_back(inputDeviceId); - - // 4.notify source distributedfwk register hardware success - callback->OnResult(devId, dhId, DH_SUCCESS); - - // 5. Notify node mgr to scan vir dev node info - DistributedInputInject::GetInstance().NotifyNodeMgrScanVirNode(devId, dhId); - return DH_SUCCESS; + return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_REGISTER_FAIL; } void DistributedInputSourceManager::handleStartServerCallback(const std::string &devId) @@ -356,7 +361,9 @@ int32_t DistributedInputSourceManager::UnregCallbackNotify(const std::string &de { for (auto iter = unregCallbacks_.begin(); iter != unregCallbacks_.end(); ++iter) { if (iter->devId == devId && iter->dhId == dhId) { - iter->callback->OnResult(iter->devId, iter->dhId, ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNREGISTER_FAIL); + if (iter->callback != nullptr) { + iter->callback->OnResult(iter->devId, iter->dhId, ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNREGISTER_FAIL); + } unregCallbacks_.erase(iter); return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNREGISTER_FAIL; } @@ -503,7 +510,9 @@ int32_t DistributedInputSourceManager::PrepareRemoteInput( ERR_DH_INPUT_SERVER_SOURCE_MANAGER_PREPARE_FAIL, "Dinput prepare failed in transport prepare"); FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_PREPARE_START, DINPUT_PREPARE_TASK); DHLOGE("Can not send message by softbus, prepare fail, ret: %{public}d", ret); - info.preCallback->OnResult(deviceId, ERR_DH_INPUT_SERVER_SOURCE_MANAGER_PREPARE_FAIL); + if (info.preCallback != nullptr) { + info.preCallback->OnResult(deviceId, ERR_DH_INPUT_SERVER_SOURCE_MANAGER_PREPARE_FAIL); + } RemovePrepareCallbacks(info); return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_PREPARE_FAIL; } @@ -530,7 +539,9 @@ int32_t DistributedInputSourceManager::UnprepareRemoteInput( HisyseventUtil::GetInstance().SysEventWriteFault(DINPUT_OPT_FAIL, deviceId, ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNPREPARE_FAIL, "Dinput unprepare failed in transport unprepare."); FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_UNPREPARE_START, DINPUT_UNPREPARE_TASK); - info.unpreCallback->OnResult(deviceId, ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNPREPARE_FAIL); + if (info.unpreCallback != nullptr) { + info.unpreCallback->OnResult(deviceId, ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNPREPARE_FAIL); + } RemoveUnPrepareCallbacks(info); return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNPREPARE_FAIL; } @@ -549,7 +560,7 @@ int32_t DistributedInputSourceManager::StartRemoteInput( return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL; } - DHLOGI("Start called, deviceId: %{public}s, inputTypes: %{public}d", GetAnonyString(deviceId).c_str(), inputTypes); + DHLOGI("Start called, deviceId: %{public}s, inputTypes: %{public}u", GetAnonyString(deviceId).c_str(), inputTypes); for (auto iter : staCallbacks_) { if (iter.devId == deviceId && iter.inputTypes == inputTypes) { callback->OnResult(deviceId, inputTypes, ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL); @@ -564,21 +575,24 @@ int32_t DistributedInputSourceManager::StartRemoteInput( staCallbacks_.push_back(info); DeviceMap_[deviceId] = DINPUT_SOURCE_SWITCH_OFF; int32_t ret = DistributedInputSourceTransport::GetInstance().StartRemoteInput(deviceId, inputTypes); - if (ret != DH_SUCCESS) { - HisyseventUtil::GetInstance().SysEventWriteFault(DINPUT_OPT_FAIL, deviceId, - ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, "Dinput start use failed in transport start"); - FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_START_START, DINPUT_START_TASK); - DHLOGE("Start fail."); - for (auto iter = staCallbacks_.begin(); iter != staCallbacks_.end(); ++iter) { - if (iter->devId == deviceId && iter->inputTypes == inputTypes) { - iter->callback->OnResult(iter->devId, iter->inputTypes, ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL); - staCallbacks_.erase(iter); - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL; + if (ret == DH_SUCCESS) { + return DH_SUCCESS; + } + HisyseventUtil::GetInstance().SysEventWriteFault(DINPUT_OPT_FAIL, deviceId, + ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, "Dinput start use failed in transport start"); + FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_START_START, DINPUT_START_TASK); + DHLOGE("Start fail."); + for (auto iter = staCallbacks_.begin(); iter != staCallbacks_.end(); ++iter) { + if (iter->devId == deviceId && iter->inputTypes == inputTypes) { + if (iter->callback != nullptr) { + iter->callback->OnResult(iter->devId, iter->inputTypes, + ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL); } + staCallbacks_.erase(iter); + return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL; } - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL; } - return DH_SUCCESS; + return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL; } int32_t DistributedInputSourceManager::StopRemoteInput( @@ -592,8 +606,7 @@ int32_t DistributedInputSourceManager::StopRemoteInput( FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_START_START, DINPUT_START_TASK); return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL; } - - DHLOGI("Stop called, deviceId: %{public}s, inputTypes: %{public}d", GetAnonyString(deviceId).c_str(), inputTypes); + DHLOGI("Stop called, deviceId: %{public}s, inputTypes: %{public}u", GetAnonyString(deviceId).c_str(), inputTypes); for (auto iter : stpCallbacks_) { if (iter.devId == deviceId && iter.inputTypes == inputTypes) { callback->OnResult(deviceId, inputTypes, ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL); @@ -607,21 +620,24 @@ int32_t DistributedInputSourceManager::StopRemoteInput( DInputClientStopInfo info {deviceId, inputTypes, callback}; stpCallbacks_.push_back(info); int32_t ret = DistributedInputSourceTransport::GetInstance().StopRemoteInput(deviceId, inputTypes); - if (ret != DH_SUCCESS) { - DHLOGE("Stop fail."); - HisyseventUtil::GetInstance().SysEventWriteFault(DINPUT_OPT_FAIL, deviceId, - ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, "Dinput stop use failed in transport stop."); - FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_STOP_START, DINPUT_STOP_TASK); - for (auto iter = stpCallbacks_.begin(); iter != stpCallbacks_.end(); ++iter) { - if (iter->devId == deviceId && iter->inputTypes == inputTypes) { - iter->callback->OnResult(iter->devId, iter->inputTypes, ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL); - stpCallbacks_.erase(iter); - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL; + if (ret == DH_SUCCESS) { + return DH_SUCCESS; + } + DHLOGE("Stop fail."); + HisyseventUtil::GetInstance().SysEventWriteFault(DINPUT_OPT_FAIL, deviceId, + ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, "Dinput stop use failed in transport stop."); + FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_STOP_START, DINPUT_STOP_TASK); + for (auto iter = stpCallbacks_.begin(); iter != stpCallbacks_.end(); ++iter) { + if (iter->devId == deviceId && iter->inputTypes == inputTypes) { + if (iter->callback != nullptr) { + iter->callback->OnResult(iter->devId, iter->inputTypes, + ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL); } + stpCallbacks_.erase(iter); + return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL; } - return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL; } - return DH_SUCCESS; + return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL; } int32_t DistributedInputSourceManager::StartRemoteInput(const std::string &srcId, const std::string &sinkId, @@ -635,8 +651,7 @@ int32_t DistributedInputSourceManager::StartRemoteInput(const std::string &srcId FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_STOP_START, DINPUT_STOP_TASK); return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL; } - - DHLOGI("StartRemoteInput called, srcId: %{public}s, sinkId: %{public}s, inputTypes: %{public}d", + DHLOGI("StartRemoteInput called, srcId: %{public}s, sinkId: %{public}s, inputTypes: %{public}u", GetAnonyString(srcId).c_str(), GetAnonyString(sinkId).c_str(), inputTypes); std::string localNetworkId = GetLocalNetworkId(); if (localNetworkId.empty()) { @@ -680,7 +695,7 @@ int32_t DistributedInputSourceManager::StopRemoteInput(const std::string &srcId, FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_STOP_START, DINPUT_STOP_TASK); return ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL; } - DHLOGI("StopRemoteInput called, srcId: %{public}s, sinkId: %{public}s, inputTypes: %{public}d", + DHLOGI("StopRemoteInput called, srcId: %{public}s, sinkId: %{public}s, inputTypes: %{public}u", GetAnonyString(srcId).c_str(), GetAnonyString(sinkId).c_str(), inputTypes); std::string localNetworkId = GetLocalNetworkId(); if (localNetworkId.empty()) { @@ -1160,7 +1175,9 @@ void DistributedInputSourceManager::RunRegisterCallback( for (auto iter = regCallbacks_.begin(); iter != regCallbacks_.end(); ++iter) { if (iter->devId == devId && iter->dhId == dhId) { DHLOGI("ProcessEvent DINPUT_SOURCE_MANAGER_RIGISTER_MSG"); - iter->callback->OnResult(devId, dhId, status); + if (iter->callback != nullptr) { + iter->callback->OnResult(devId, dhId, status); + } regCallbacks_.erase(iter); return; } @@ -1175,7 +1192,9 @@ void DistributedInputSourceManager::RunUnregisterCallback( for (auto iter = unregCallbacks_.begin(); iter != unregCallbacks_.end(); ++iter) { if (iter->devId == devId && iter->dhId == dhId) { DHLOGI("ProcessEvent DINPUT_SOURCE_MANAGER_UNRIGISTER_MSG"); - iter->callback->OnResult(devId, dhId, status); + if (iter->callback != nullptr) { + iter->callback->OnResult(devId, dhId, status); + } unregCallbacks_.erase(iter); return; } @@ -1191,7 +1210,9 @@ void DistributedInputSourceManager::RunPrepareCallback( for (auto iter = preCallbacks_.begin(); iter != preCallbacks_.end(); ++iter) { if (iter->devId == devId) { DHLOGI("ProcessEvent DINPUT_SOURCE_MANAGER_PREPARE_MSG"); - iter->preCallback->OnResult(devId, status); + if (iter->preCallback != nullptr) { + iter->preCallback->OnResult(devId, status); + } preCallbacks_.erase(iter); RunWhiteListCallback(devId, object); return; @@ -1265,7 +1286,9 @@ void DistributedInputSourceManager::RunUnprepareCallback(const std::string &devI for (auto iter = unpreCallbacks_.begin(); iter != unpreCallbacks_.end(); ++iter) { if (iter->devId == devId) { DHLOGI("ProcessEvent DINPUT_SOURCE_MANAGER_UNPREPARE_MSG"); - iter->unpreCallback->OnResult(devId, status); + if (iter->unpreCallback != nullptr) { + iter->unpreCallback->OnResult(devId, status); + } unpreCallbacks_.erase(iter); std::lock_guard whiteListLock(whiteListMutex_); if (delWhiteListCallbacks_.size() == 0) { @@ -1288,7 +1311,9 @@ void DistributedInputSourceManager::RunStartCallback( for (auto iter = staCallbacks_.begin(); iter != staCallbacks_.end(); ++iter) { if (iter->devId == devId && iter->inputTypes == inputTypes) { DHLOGI("ProcessEvent DINPUT_SOURCE_MANAGER_START_MSG"); - iter->callback->OnResult(devId, inputTypes, status); + if (iter->callback != nullptr) { + iter->callback->OnResult(devId, inputTypes, status); + } staCallbacks_.erase(iter); break; } @@ -1302,7 +1327,9 @@ void DistributedInputSourceManager::RunStopCallback( for (auto iter = stpCallbacks_.begin(); iter != stpCallbacks_.end(); ++iter) { if (iter->devId == devId && iter->inputTypes == inputTypes) { DHLOGI("ProcessEvent DINPUT_SOURCE_MANAGER_STOP_MSG"); - iter->callback->OnResult(devId, inputTypes, status); + if (iter->callback != nullptr) { + iter->callback->OnResult(devId, inputTypes, status); + } stpCallbacks_.erase(iter); break; } @@ -1325,7 +1352,9 @@ void DistributedInputSourceManager::RunStartDhidCallback(const std::string &sink if (iter->sinkId != sinkId || !IsStringDataSame(iter->dhIds, dhidsVec)) { continue; } - iter->callback->OnResultDhids(sinkId, status); + if (iter->callback != nullptr) { + iter->callback->OnResultDhids(sinkId, status); + } staStringCallbacks_.erase(iter); break; } @@ -1346,7 +1375,9 @@ void DistributedInputSourceManager::RunStopDhidCallback(const std::string &sinkI if (iter->sinkId != sinkId || !IsStringDataSame(iter->dhIds, dhidsVec)) { continue; } - iter->callback->OnResultDhids(sinkId, status); + if (iter->callback != nullptr) { + iter->callback->OnResultDhids(sinkId, status); + } stpStringCallbacks_.erase(iter); break; } @@ -1411,7 +1442,9 @@ void DistributedInputSourceManager::RunRelayStartTypeCallback(const std::string relayStaTypeCallbacks_.begin(); iter != relayStaTypeCallbacks_.end(); ++iter) { if (iter->srcId == srcId && iter->sinkId == sinkId && iter->inputTypes == inputTypes) { DHLOGI("ProcessEvent DINPUT_SOURCE_MANAGER_RELAY_STARTTYPE_RESULT_MMI"); - iter->callback->OnResult(sinkId, inputTypes, status); + if (iter->callback != nullptr) { + iter->callback->OnResult(sinkId, inputTypes, status); + } relayStaTypeCallbacks_.erase(iter); isCbRun = true; break; @@ -1432,7 +1465,9 @@ void DistributedInputSourceManager::RunRelayStopTypeCallback(const std::string & relayStpTypeCallbacks_.begin(); iter != relayStpTypeCallbacks_.end(); ++iter) { if (iter->srcId == srcId && iter->sinkId == sinkId && iter->inputTypes == inputTypes) { DHLOGI("ProcessEvent DINPUT_SOURCE_MANAGER_RELAY_STOPTYPE_RESULT_MMI"); - iter->callback->OnResult(sinkId, inputTypes, status); + if (iter->callback != nullptr) { + iter->callback->OnResult(sinkId, inputTypes, status); + } relayStpTypeCallbacks_.erase(iter); isCbRun = true; break; @@ -1555,7 +1590,7 @@ void DistributedInputSourceManager::StartDScreenListener::OnMessage(const DHTopi { DHLOGI("StartDScreenListener OnMessage!"); if (topic != DHTopic::TOPIC_START_DSCREEN) { - DHLOGE("this topic is wrong, %{public}d", static_cast(topic)); + DHLOGE("this topic is wrong, %{public}u", static_cast(topic)); return; } if (message.size() > SCREEN_MSG_MAX) { @@ -1655,8 +1690,8 @@ int32_t DistributedInputSourceManager::StartDScreenListener::UpdateSrcScreenInfo srcScreenInfo.sourcePhyWidth = tmpInfo.sourceWinWidth; srcScreenInfo.sourcePhyHeight = tmpInfo.sourceWinHeight; DHLOGI("StartDScreenListener UpdateSrcScreenInfo the data: devId: %{public}s, sourceWinId: %{public}" PRIu64 ", " - "sourceWinWidth: %{public}d, sourceWinHeight: %{public}d, sourcePhyId: %{public}s, sourcePhyFd: %{public}d, " - "sourcePhyWidth: %{public}d, sourcePhyHeight: %{public}d", + "sourceWinWidth: %{public}u, sourceWinHeight: %{public}u, sourcePhyId: %{public}s, sourcePhyFd: %{public}u, " + "sourcePhyWidth: %{public}u, sourcePhyHeight: %{public}u", GetAnonyString(srcScreenInfo.devId).c_str(), srcScreenInfo.sourceWinId, srcScreenInfo.sourceWinWidth, srcScreenInfo.sourceWinHeight, GetAnonyString(srcScreenInfo.sourcePhyId).c_str(), srcScreenInfo.sourcePhyFd, srcScreenInfo.sourcePhyWidth, srcScreenInfo.sourcePhyHeight); diff --git a/services/source/sourcemanager/src/distributed_input_source_sa_cli_mgr.cpp b/services/source/sourcemanager/src/distributed_input_source_sa_cli_mgr.cpp index 7b303c4..9dd0a8d 100644 --- a/services/source/sourcemanager/src/distributed_input_source_sa_cli_mgr.cpp +++ b/services/source/sourcemanager/src/distributed_input_source_sa_cli_mgr.cpp @@ -110,7 +110,7 @@ void DInputSourceSACliMgr::AddRemoteCli(const std::string &devId, sptr lock(remoteCliLock); auto item = remoteCliMap.find(devId); - if ((item != remoteCliMap.end()) && item->second != nullptr) { + if ((item != remoteCliMap.end()) && item->second != nullptr && item->second->AsObject() != nullptr) { item->second->AsObject()->RemoveDeathRecipient(remoteCliDeathRcv); } remoteCliMap[devId] = iface_cast(object); @@ -126,7 +126,7 @@ void DInputSourceSACliMgr::DeleteRemoteCli(const std::string &devId) return; } - if (item->second != nullptr) { + if (item->second != nullptr && item->second->AsObject() != nullptr) { item->second->AsObject()->RemoveDeathRecipient(remoteCliDeathRcv); } remoteCliMap.erase(item); @@ -145,7 +145,7 @@ void DInputSourceSACliMgr::DeleteRemoteCli(const sptr remote) } DHLOGI("VirtualHardwareManager::DeleteRemoteCli remote.devId=%{public}s", GetAnonyString(iter->first).c_str()); - if (iter->second != nullptr) { + if (iter->second != nullptr && iter->second->AsObject() != nullptr) { iter->second->AsObject()->RemoveDeathRecipient(remoteCliDeathRcv); } remoteCliMap.erase(iter); diff --git a/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp b/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp index a013204..49739d2 100644 --- a/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp +++ b/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.cpp @@ -221,6 +221,7 @@ int32_t DistributedInputSourceManagerTest::StructTransJson(const InputDevice &pB HWTEST_F(DistributedInputSourceManagerTest, OnStart_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); sourceManager_->serviceRunningState_ = ServiceSourceRunningState::STATE_RUNNING; sourceManager_->OnStart(); EXPECT_EQ(0, sourceManager_->inputDevice_.size()); @@ -232,12 +233,14 @@ HWTEST_F(DistributedInputSourceManagerTest, OnStart_01, testing::ext::TestSize.L HWTEST_F(DistributedInputSourceManagerTest, Init01, testing::ext::TestSize.Level0) { + ASSERT_NE(sourceManager_, nullptr); int32_t ret = sourceManager_->Init(); EXPECT_EQ(DH_SUCCESS, ret); } HWTEST_F(DistributedInputSourceManagerTest, CheckRegisterParam_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); sourceManager_->UnregisterDHFwkPublisher(); sourceManager_->startDScreenListener_ = nullptr; @@ -258,6 +261,7 @@ HWTEST_F(DistributedInputSourceManagerTest, CheckRegisterParam_01, testing::ext: HWTEST_F(DistributedInputSourceManagerTest, CheckRegisterParam_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; std::string dhId = ""; std::string parameters = ""; @@ -271,6 +275,7 @@ HWTEST_F(DistributedInputSourceManagerTest, CheckRegisterParam_02, testing::ext: HWTEST_F(DistributedInputSourceManagerTest, CheckRegisterParam_03, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8"; std::string parameters = ""; @@ -284,6 +289,7 @@ HWTEST_F(DistributedInputSourceManagerTest, CheckRegisterParam_03, testing::ext: HWTEST_F(DistributedInputSourceManagerTest, RegisterDistributedHardware_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = ""; std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8"; std::string parameters = ""; @@ -294,6 +300,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RegisterDistributedHardware_01, test HWTEST_F(DistributedInputSourceManagerTest, RegisterDistributedHardware_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); InputDevice pBuffer; pBuffer.name = "uinput_name_touch"; pBuffer.bus = 0x03; @@ -318,6 +325,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RegisterDistributedHardware_02, test HWTEST_F(DistributedInputSourceManagerTest, handleStartServerCallback_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; std::string dhId = "input_slkdiek3kddkeojfe"; DistributedInputSourceManager::InputDeviceId inputDeviceId {devId, dhId}; @@ -328,6 +336,7 @@ HWTEST_F(DistributedInputSourceManagerTest, handleStartServerCallback_01, testin HWTEST_F(DistributedInputSourceManagerTest, handleStartServerCallback_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; sourceManager_->handleStartServerCallback(devId); @@ -339,6 +348,7 @@ HWTEST_F(DistributedInputSourceManagerTest, handleStartServerCallback_02, testin HWTEST_F(DistributedInputSourceManagerTest, UnregCallbackNotify_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; std::string dhId = "input_slkdiek3kddkeojfe"; int32_t ret = sourceManager_->UnregCallbackNotify(devId, dhId); @@ -362,6 +372,7 @@ HWTEST_F(DistributedInputSourceManagerTest, UnregCallbackNotify_01, testing::ext HWTEST_F(DistributedInputSourceManagerTest, CheckUnregisterParam_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = ""; std::string dhId = ""; sptr callback = nullptr; @@ -383,6 +394,7 @@ HWTEST_F(DistributedInputSourceManagerTest, CheckUnregisterParam_01, testing::ex HWTEST_F(DistributedInputSourceManagerTest, CheckDeviceIsExists_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8"; sptr callback(new TestUnregisterDInputCb()); @@ -395,6 +407,7 @@ HWTEST_F(DistributedInputSourceManagerTest, CheckDeviceIsExists_01, testing::ext HWTEST_F(DistributedInputSourceManagerTest, UnregisterDistributedHardware_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = ""; std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8"; sptr callback(new TestUnregisterDInputCb()); @@ -404,6 +417,7 @@ HWTEST_F(DistributedInputSourceManagerTest, UnregisterDistributedHardware_01, te HWTEST_F(DistributedInputSourceManagerTest, UnregisterDistributedHardware_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8"; sptr callback(new TestUnregisterDInputCb()); @@ -419,6 +433,7 @@ HWTEST_F(DistributedInputSourceManagerTest, UnregisterDistributedHardware_02, te */ HWTEST_F(DistributedInputSourceManagerTest, PrepareRemoteInput_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = ""; sptr callback(new TestPrepareDInputCallback()); int32_t ret = sourceManager_->PrepareRemoteInput(devId, callback); @@ -427,6 +442,7 @@ HWTEST_F(DistributedInputSourceManagerTest, PrepareRemoteInput_01, testing::ext: HWTEST_F(DistributedInputSourceManagerTest, PrepareRemoteInput_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; sptr callback(new TestPrepareDInputCallback()); int32_t ret = sourceManager_->PrepareRemoteInput(devId, callback); @@ -436,6 +452,7 @@ HWTEST_F(DistributedInputSourceManagerTest, PrepareRemoteInput_02, testing::ext: HWTEST_F(DistributedInputSourceManagerTest, UnprepareRemoteInput_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; int32_t sessionId = 1; sptr callback(new TestUnprepareDInputCallback()); @@ -446,6 +463,7 @@ HWTEST_F(DistributedInputSourceManagerTest, UnprepareRemoteInput_01, testing::ex HWTEST_F(DistributedInputSourceManagerTest, UnprepareRemoteInput_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = ""; sptr callback(new TestUnprepareDInputCallback()); int32_t ret = sourceManager_->UnprepareRemoteInput(devId, callback); @@ -465,6 +483,7 @@ HWTEST_F(DistributedInputSourceManagerTest, UnprepareRemoteInput_02, testing::ex */ HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; int32_t sessionId = 1; sptr callback(new TestStartDInputCallback()); @@ -478,6 +497,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_01, testing::ext::T HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = ""; sptr callback(new TestStartDInputCallback()); int32_t ret = sourceManager_->StartRemoteInput(devId, INPUTTYPE, callback); @@ -494,6 +514,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_02, testing::ext::T HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_03, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = "devId_4810input4809_test"; sptr callback(new TestStartDInputCallback()); int32_t ret = sourceManager_->StartRemoteInput(devId, INPUTTYPE, callback); @@ -508,6 +529,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_03, testing::ext::T */ HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; sptr callback(new TestStopDInputCallback()); int32_t ret = sourceManager_->StopRemoteInput(devId, INPUTTYPE, callback); @@ -519,6 +541,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_01, testing::ext::Te HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = ""; sptr callback(new TestStopDInputCallback()); int32_t ret = sourceManager_->StopRemoteInput(devId, INPUTTYPE, callback); @@ -532,6 +555,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_02, testing::ext::Te HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_03, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); sptr callback(new TestStopDInputCallback()); std::string devId = "devId_4810input4809_test"; int32_t ret = sourceManager_->StopRemoteInput(devId, INPUTTYPE, callback); @@ -546,6 +570,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_03, testing::ext::Te */ HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_04, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; sptr callback(new TestStartDInputCallback()); @@ -555,6 +580,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_04, testing::ext::T HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_05, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = ""; std::string sinkId = ""; sptr callback(new TestStartDInputCallback()); @@ -576,6 +602,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_05, testing::ext::T HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_06, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); sptr callback(new TestStartDInputCallback()); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; std::string sinkId = "devId_4810input4809_test"; @@ -591,6 +618,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_06, testing::ext::T */ HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_04, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; int32_t sessionId = 1; @@ -602,6 +630,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_04, testing::ext::Te HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_05, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = ""; std::string sinkId = ""; sptr callback(new TestStopDInputCallback()); @@ -624,6 +653,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_05, testing::ext::Te HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_06, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); sptr callback(new TestStopDInputCallback()); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; std::string sinkId = "devId_4810input4809_test"; @@ -633,6 +663,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_06, testing::ext::Te HWTEST_F(DistributedInputSourceManagerTest, RelayStartRemoteInputByType_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; sptr callback(new TestStartDInputCallback()); @@ -652,6 +683,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RelayStartRemoteInputByType_01, test HWTEST_F(DistributedInputSourceManagerTest, RelayStartRemoteInputByType_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; sptr callback(new TestStartDInputCallback()); @@ -662,6 +694,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RelayStartRemoteInputByType_02, test HWTEST_F(DistributedInputSourceManagerTest, RelayStopRemoteInputByType_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; sptr callback(new TestStopDInputCallback()); @@ -681,6 +714,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RelayStopRemoteInputByType_01, testi HWTEST_F(DistributedInputSourceManagerTest, RelayStopRemoteInputByType_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; sptr callback(new TestStopDInputCallback()); @@ -697,6 +731,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RelayStopRemoteInputByType_02, testi */ HWTEST_F(DistributedInputSourceManagerTest, PrepareRemoteInput_03, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = ""; std::string sinkId = ""; sptr callback(new TestPrepareDInputCallback()); @@ -723,6 +758,7 @@ HWTEST_F(DistributedInputSourceManagerTest, PrepareRemoteInput_03, testing::ext: HWTEST_F(DistributedInputSourceManagerTest, UnprepareRemoteInput_04, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; int32_t sessionId = 1; @@ -735,6 +771,7 @@ HWTEST_F(DistributedInputSourceManagerTest, UnprepareRemoteInput_04, testing::ex HWTEST_F(DistributedInputSourceManagerTest, UnprepareRemoteInput_05, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = ""; std::string sinkId = ""; sptr callback(new TestUnprepareDInputCallback()); @@ -764,6 +801,7 @@ HWTEST_F(DistributedInputSourceManagerTest, UnprepareRemoteInput_05, testing::ex */ HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_07, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::vector dhIds; int32_t sessionId = 1; std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; @@ -786,6 +824,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_07, testing::ext::T HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_08, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; std::string sinkId = ""; std::vector dhIds; @@ -803,6 +842,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_08, testing::ext::T HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_09, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::vector dhIds; dhIds.push_back("Input_slkdiek3kddkeojfe"); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; @@ -822,6 +862,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_09, testing::ext::T */ HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_07, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::vector dhIds; sptr callback(new TestStartStopVectorCallbackStub()); std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; @@ -845,6 +886,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_07, testing::ext::Te HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_08, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; std::string sinkId = ""; std::vector dhIds; @@ -860,6 +902,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_08, testing::ext::Te HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_09, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::vector dhIds; dhIds.push_back("Input_slkdiek3kddkeojfe"); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; @@ -879,6 +922,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_09, testing::ext::Te */ HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_10, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::vector dhIds; sptr callback(new TestStartStopVectorCallbackStub()); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; @@ -904,6 +948,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_10, testing::ext::T HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_11, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = ""; std::string sinkId = ""; std::vector dhIds; @@ -928,6 +973,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_11, testing::ext::T HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_12, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::vector dhIds; dhIds.push_back("Input_slkdiek3kddkeojfe"); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; @@ -947,6 +993,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_12, testing::ext::T */ HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_10, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::vector dhIds; sptr callback(new TestStartStopVectorCallbackStub()); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; @@ -972,6 +1019,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_10, testing::ext::Te HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_11, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = ""; std::string sinkId = ""; std::vector dhIds; @@ -996,6 +1044,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_11, testing::ext::Te HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_12, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::vector dhIds; dhIds.push_back("Input_slkdiek3kddkeojfe"); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; @@ -1009,6 +1058,7 @@ HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_12, testing::ext::Te HWTEST_F(DistributedInputSourceManagerTest, IsStringDataSame_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::vector oldDhIds; std::vector newDhIds; oldDhIds.push_back("afv4s8b1dr1b8er1bd65fb16redb1dfb18d1b56df1b68d"); @@ -1018,6 +1068,7 @@ HWTEST_F(DistributedInputSourceManagerTest, IsStringDataSame_01, testing::ext::T HWTEST_F(DistributedInputSourceManagerTest, IsStringDataSame_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::vector oldDhIds; std::vector newDhIds; oldDhIds.push_back("afv4s8b1dr1b8er1bd65fb16redb1dfb18d1b56df1b68d"); @@ -1032,6 +1083,7 @@ HWTEST_F(DistributedInputSourceManagerTest, IsStringDataSame_02, testing::ext::T HWTEST_F(DistributedInputSourceManagerTest, RegisterAddWhiteListCallback01, testing::ext::TestSize.Level0) { + ASSERT_NE(sourceManager_, nullptr); sptr callback = nullptr; int32_t ret = sourceManager_->RegisterAddWhiteListCallback(callback); EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_REG_CALLBACK_ERR, ret); @@ -1039,6 +1091,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RegisterAddWhiteListCallback01, test HWTEST_F(DistributedInputSourceManagerTest, RegisterAddWhiteListCallback02, testing::ext::TestSize.Level0) { + ASSERT_NE(sourceManager_, nullptr); sptr callback(new TestAddWhiteListInfosCb()); int32_t ret = sourceManager_->RegisterAddWhiteListCallback(callback); EXPECT_EQ(DH_SUCCESS, ret); @@ -1046,6 +1099,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RegisterAddWhiteListCallback02, test HWTEST_F(DistributedInputSourceManagerTest, RegisterDelWhiteListCallback01, testing::ext::TestSize.Level0) { + ASSERT_NE(sourceManager_, nullptr); sptr callback = nullptr; int32_t ret = sourceManager_->RegisterDelWhiteListCallback(callback); EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_REG_CALLBACK_ERR, ret); @@ -1053,6 +1107,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RegisterDelWhiteListCallback01, test HWTEST_F(DistributedInputSourceManagerTest, RegisterDelWhiteListCallback02, testing::ext::TestSize.Level0) { + ASSERT_NE(sourceManager_, nullptr); sptr callback(new TestDelWhiteListInfosCb()); int32_t ret = sourceManager_->RegisterDelWhiteListCallback(callback); EXPECT_EQ(DH_SUCCESS, ret); @@ -1060,6 +1115,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RegisterDelWhiteListCallback02, test HWTEST_F(DistributedInputSourceManagerTest, RegisterSimulationEventListener_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); sptr callback = nullptr; int32_t ret = sourceManager_->RegisterSimulationEventListener(callback); EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_SIMULATION_EVENT_CALLBACK_ERR, ret); @@ -1070,6 +1126,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RegisterSimulationEventListener_01, HWTEST_F(DistributedInputSourceManagerTest, UnregisterSimulationEventListener_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); sptr callback(new TestSimulationEventCb()); int32_t ret = sourceManager_->RegisterSimulationEventListener(callback); EXPECT_EQ(DH_SUCCESS, ret); @@ -1080,6 +1137,7 @@ HWTEST_F(DistributedInputSourceManagerTest, UnregisterSimulationEventListener_02 HWTEST_F(DistributedInputSourceManagerTest, RelayPrepareRemoteInput_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; sptr callback(new TestPrepareDInputCallback()); @@ -1096,6 +1154,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RelayPrepareRemoteInput_01, testing: HWTEST_F(DistributedInputSourceManagerTest, RelayUnprepareRemoteInput_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; sptr callback(new TestUnprepareDInputCallback()); @@ -1109,6 +1168,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RelayUnprepareRemoteInput_01, testin HWTEST_F(DistributedInputSourceManagerTest, RelayUnprepareRemoteInput_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; sptr callback(new TestUnprepareDInputCallback()); @@ -1119,6 +1179,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RelayUnprepareRemoteInput_02, testin HWTEST_F(DistributedInputSourceManagerTest, RelayStartRemoteInputByDhid_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; std::vector dhIds; @@ -1145,6 +1206,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RelayStartRemoteInputByDhid_01, test HWTEST_F(DistributedInputSourceManagerTest, RelayStartRemoteInputByDhid_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; std::vector dhIds; @@ -1157,6 +1219,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RelayStartRemoteInputByDhid_02, test HWTEST_F(DistributedInputSourceManagerTest, RelayStopRemoteInputByDhid_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; std::vector dhIds; @@ -1183,6 +1246,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RelayStopRemoteInputByDhid_01, testi HWTEST_F(DistributedInputSourceManagerTest, RelayStopRemoteInputByDhid_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; std::vector dhIds; @@ -1195,6 +1259,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RelayStopRemoteInputByDhid_02, testi HWTEST_F(DistributedInputSourceManagerTest, RunRegisterCallback_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; std::string dhId = "input_slkdiek3kddkeojfe"; int32_t status = 0; @@ -1221,6 +1286,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RunRegisterCallback_01, testing::ext HWTEST_F(DistributedInputSourceManagerTest, RunUnregisterCallback_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; std::string dhId = "input_slkdiek3kddkeojfe"; int32_t status = 0; @@ -1247,6 +1313,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RunUnregisterCallback_01, testing::e HWTEST_F(DistributedInputSourceManagerTest, RunPrepareCallback_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; int32_t status = 0; std::string object = "runprepareobject"; @@ -1265,6 +1332,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RunPrepareCallback_01, testing::ext: HWTEST_F(DistributedInputSourceManagerTest, RunWhiteListCallback_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; std::string object = "runwhitelistobject"; sptr callback(new TestAddWhiteListInfosCb()); @@ -1275,6 +1343,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RunWhiteListCallback_01, testing::ex HWTEST_F(DistributedInputSourceManagerTest, RunRelayPrepareCallback_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; int32_t status = 0; @@ -1301,6 +1370,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RunRelayPrepareCallback_01, testing: HWTEST_F(DistributedInputSourceManagerTest, RunRelayUnprepareCallback_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); sourceManager_->relayUnpreCallbacks_.clear(); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; @@ -1328,6 +1398,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RunRelayUnprepareCallback_01, testin HWTEST_F(DistributedInputSourceManagerTest, RunUnprepareCallback_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; int32_t status = 0; std::string object = "runprepareobject"; @@ -1347,6 +1418,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RunUnprepareCallback_01, testing::ex HWTEST_F(DistributedInputSourceManagerTest, RunStartCallback_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; int32_t status = 0; uint32_t inputTypes = 1; @@ -1373,6 +1445,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RunStartCallback_01, testing::ext::T HWTEST_F(DistributedInputSourceManagerTest, RunStopCallback_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; int32_t status = 0; uint32_t inputTypes = 1; @@ -1399,6 +1472,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RunStopCallback_01, testing::ext::Te HWTEST_F(DistributedInputSourceManagerTest, RunStartDhidCallback_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; int32_t status = 0; std::string dhId = "input_slkdiek3kddkeojfe"; @@ -1425,6 +1499,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RunStartDhidCallback_01, testing::ex HWTEST_F(DistributedInputSourceManagerTest, RunStopDhidCallback_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; int32_t status = 0; std::string dhId = "input_slkdiek3kddkeojfe"; @@ -1451,6 +1526,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RunStopDhidCallback_01, testing::ext HWTEST_F(DistributedInputSourceManagerTest, RunRelayStartDhidCallback_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; int32_t status = 0; @@ -1481,6 +1557,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RunRelayStartDhidCallback_01, testin HWTEST_F(DistributedInputSourceManagerTest, RunRelayStartDhidCallback_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; int32_t status = 0; @@ -1497,6 +1574,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RunRelayStartDhidCallback_02, testin HWTEST_F(DistributedInputSourceManagerTest, RunRelayStopDhidCallback_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; int32_t status = 0; @@ -1527,6 +1605,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RunRelayStopDhidCallback_01, testing HWTEST_F(DistributedInputSourceManagerTest, RunRelayStopDhidCallback_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; int32_t status = 0; @@ -1543,6 +1622,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RunRelayStopDhidCallback_02, testing HWTEST_F(DistributedInputSourceManagerTest, RunRelayStartTypeCallback_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; int32_t status = 0; @@ -1570,6 +1650,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RunRelayStartTypeCallback_01, testin HWTEST_F(DistributedInputSourceManagerTest, RunRelayStopTypeCallback_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00"; std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev"; int32_t status = 0; @@ -1597,6 +1678,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RunRelayStopTypeCallback_01, testing HWTEST_F(DistributedInputSourceManagerTest, RemoveInputDeviceId_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string deviceId = "umkyu1b165e1be98151891erbe8r91ev"; std::string dhId = "input_slkdiek3kddkeojfe"; sourceManager_->RemoveInputDeviceId(deviceId, dhId); @@ -1610,6 +1692,7 @@ HWTEST_F(DistributedInputSourceManagerTest, RemoveInputDeviceId_01, testing::ext HWTEST_F(DistributedInputSourceManagerTest, GetDeviceMapAllDevSwitchOff_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; sourceManager_->DeviceMap_[devId] = DINPUT_SOURCE_SWITCH_OFF; bool ret = sourceManager_->GetDeviceMapAllDevSwitchOff(); @@ -1618,6 +1701,7 @@ HWTEST_F(DistributedInputSourceManagerTest, GetDeviceMapAllDevSwitchOff_01, test HWTEST_F(DistributedInputSourceManagerTest, GetDeviceMapAllDevSwitchOff_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; sourceManager_->DeviceMap_[devId] = DINPUT_SOURCE_SWITCH_ON; bool ret = sourceManager_->GetDeviceMapAllDevSwitchOff(); @@ -1626,6 +1710,7 @@ HWTEST_F(DistributedInputSourceManagerTest, GetDeviceMapAllDevSwitchOff_02, test HWTEST_F(DistributedInputSourceManagerTest, GetInputTypesMap_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; sourceManager_->InputTypesMap_[devId] = 1; uint32_t ret = sourceManager_->GetInputTypesMap(devId); @@ -1634,6 +1719,7 @@ HWTEST_F(DistributedInputSourceManagerTest, GetInputTypesMap_01, testing::ext::T HWTEST_F(DistributedInputSourceManagerTest, GetAllInputTypesMap_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; sourceManager_->InputTypesMap_[devId] = 1; uint32_t ret = sourceManager_->GetAllInputTypesMap(); @@ -1642,6 +1728,7 @@ HWTEST_F(DistributedInputSourceManagerTest, GetAllInputTypesMap_01, testing::ext HWTEST_F(DistributedInputSourceManagerTest, SetInputTypesMap_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); std::string devId = "umkyu1b165e1be98151891erbe8r91ev"; uint32_t value = 0; sourceManager_->InputTypesMap_[devId] = 1; @@ -1659,6 +1746,8 @@ HWTEST_F(DistributedInputSourceManagerTest, Dump_01, testing::ext::TestSize.Leve HWTEST_F(DistributedInputSourceManagerTest, OnResponseRegisterDistributedHardware_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); std::string deviceId = "djfhskjdhf5465456ds4f654sdf6"; std::string dhId = "Input_s4df65s5d6f56asd5f6asdfasdfasdfv"; bool result = true; @@ -1672,6 +1761,8 @@ HWTEST_F(DistributedInputSourceManagerTest, OnResponseRegisterDistributedHardwar HWTEST_F(DistributedInputSourceManagerTest, OnResponsePrepareRemoteInput_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); std::string deviceId = "djfhskjdhf5465456ds4f654sdf6"; bool result = true; std::string object = "46sdf5g454dfsdfg4sd6fg"; @@ -1685,6 +1776,8 @@ HWTEST_F(DistributedInputSourceManagerTest, OnResponsePrepareRemoteInput_01, tes HWTEST_F(DistributedInputSourceManagerTest, OnResponseUnprepareRemoteInput_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); std::string deviceId = "djfhskjdhf5465456ds4f654sdf6"; bool result = true; callback_->OnResponseUnprepareRemoteInput(deviceId, result); @@ -1697,6 +1790,8 @@ HWTEST_F(DistributedInputSourceManagerTest, OnResponseUnprepareRemoteInput_01, t HWTEST_F(DistributedInputSourceManagerTest, OnResponseStartRemoteInput_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); std::string deviceId = "djfhskjdhf5465456ds4f654sdf6"; uint32_t inputTypes = 7; bool result = true; @@ -1710,6 +1805,8 @@ HWTEST_F(DistributedInputSourceManagerTest, OnResponseStartRemoteInput_01, testi HWTEST_F(DistributedInputSourceManagerTest, OnResponseStopRemoteInput_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); std::string deviceId = "djfhskjdhf5465456ds4f654sdf6"; uint32_t inputTypes = 7; bool result = true; @@ -1723,6 +1820,8 @@ HWTEST_F(DistributedInputSourceManagerTest, OnResponseStopRemoteInput_01, testin HWTEST_F(DistributedInputSourceManagerTest, OnResponseStartRemoteInputDhid_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); std::string deviceId = "djfhskjdhf5465456ds4f654sdf6"; std::string dhids = "Input_s4df65s5d6f56asd5f6asdfasdfasdfv"; bool result = true; @@ -1736,6 +1835,8 @@ HWTEST_F(DistributedInputSourceManagerTest, OnResponseStartRemoteInputDhid_01, t HWTEST_F(DistributedInputSourceManagerTest, OnResponseStopRemoteInputDhid_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); std::string deviceId = "djfhskjdhf5465456ds4f654sdf6"; std::string dhids = "Input_s4df65s5d6f56asd5f6asdfasdfasdfv"; bool result = true; @@ -1749,6 +1850,8 @@ HWTEST_F(DistributedInputSourceManagerTest, OnResponseStopRemoteInputDhid_01, te HWTEST_F(DistributedInputSourceManagerTest, OnResponseRelayPrepareRemoteInput_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); int32_t toSrcSessionId = 1; std::string deviceId = "as5d4a65sd4a65sd456as4d"; bool result = true; @@ -1763,6 +1866,8 @@ HWTEST_F(DistributedInputSourceManagerTest, OnResponseRelayPrepareRemoteInput_01 HWTEST_F(DistributedInputSourceManagerTest, OnResponseRelayUnprepareRemoteInput_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); int32_t toSrcSessionId = 1; std::string deviceId = "as5d4a65sd4a65sd456as4d"; bool result = true; @@ -1776,6 +1881,8 @@ HWTEST_F(DistributedInputSourceManagerTest, OnResponseRelayUnprepareRemoteInput_ HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayPrepareResult_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); int32_t status = 1; std::string srcId = "djfhskjdhf5465456ds4f654sdf6"; std::string sinkId = "asd4a65sd46as4da6s4d6asdasdafwebrb"; @@ -1789,6 +1896,8 @@ HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayPrepareResult_01, test HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayUnprepareResult_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); int32_t status = 1; std::string srcId = "djfhskjdhf5465456ds4f654sdf6"; std::string sinkId = "asd4a65sd46as4da6s4d6asdasdafwebrb"; @@ -1802,6 +1911,8 @@ HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayUnprepareResult_01, te HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStartDhidResult_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); int32_t status = 1; std::string srcId = "djfhskjdhf5465456ds4f654sdf6"; std::string sinkId = "asd4a65sd46as4da6s4d6asdasdafwebrb"; @@ -1816,6 +1927,8 @@ HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStartDhidResult_01, te HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStopDhidResult_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); int32_t status = 1; std::string srcId = "djfhskjdhf5465456ds4f654sdf6"; std::string sinkId = "asd4a65sd46as4da6s4d6asdasdafwebrb"; @@ -1830,6 +1943,8 @@ HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStopDhidResult_01, tes HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStartTypeResult_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); int32_t status = 1; std::string srcId = "djfhskjdhf5465456ds4f654sdf6"; std::string sinkId = "asd4a65sd46as4da6s4d6asdasdafwebrb"; @@ -1844,6 +1959,8 @@ HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStartTypeResult_01, te HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStopTypeResult_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); int32_t status = 1; std::string srcId = "djfhskjdhf5465456ds4f654sdf6"; std::string sinkId = "asd4a65sd46as4da6s4d6asdasdafwebrb"; @@ -1858,12 +1975,15 @@ HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStopTypeResult_01, tes HWTEST_F(DistributedInputSourceManagerTest, InitAuto_01, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); bool ret = sourceManager_->InitAuto(); EXPECT_EQ(true, ret); } HWTEST_F(DistributedInputSourceManagerTest, OnResponseRegisterDistributedHardware_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); sourceManager_->InitAuto(); std::string deviceId = "djfhskjdhf5465456ds4f654sdf6"; @@ -1879,6 +1999,8 @@ HWTEST_F(DistributedInputSourceManagerTest, OnResponseRegisterDistributedHardwar HWTEST_F(DistributedInputSourceManagerTest, OnResponsePrepareRemoteInput_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); sourceManager_->InitAuto(); std::string deviceId = "djfhskjdhf5465456ds4f654sdf6"; @@ -1894,6 +2016,8 @@ HWTEST_F(DistributedInputSourceManagerTest, OnResponsePrepareRemoteInput_02, tes HWTEST_F(DistributedInputSourceManagerTest, OnResponseUnprepareRemoteInput_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); sourceManager_->InitAuto(); std::string deviceId = "djfhskjdhf5465456ds4f654sdf6"; @@ -1908,6 +2032,8 @@ HWTEST_F(DistributedInputSourceManagerTest, OnResponseUnprepareRemoteInput_02, t HWTEST_F(DistributedInputSourceManagerTest, OnResponseStartRemoteInput_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); sourceManager_->InitAuto(); std::string deviceId = "djfhskjdhf5465456ds4f654sdf6"; @@ -1923,6 +2049,8 @@ HWTEST_F(DistributedInputSourceManagerTest, OnResponseStartRemoteInput_02, testi HWTEST_F(DistributedInputSourceManagerTest, OnResponseStopRemoteInput_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); sourceManager_->InitAuto(); std::string deviceId = "djfhskjdhf5465456ds4f654sdf6"; @@ -1938,6 +2066,8 @@ HWTEST_F(DistributedInputSourceManagerTest, OnResponseStopRemoteInput_02, testin HWTEST_F(DistributedInputSourceManagerTest, OnResponseStartRemoteInputDhid_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); sourceManager_->InitAuto(); std::string deviceId = "djfhskjdhf5465456ds4f654sdf6"; @@ -1953,6 +2083,8 @@ HWTEST_F(DistributedInputSourceManagerTest, OnResponseStartRemoteInputDhid_02, t HWTEST_F(DistributedInputSourceManagerTest, OnResponseStopRemoteInputDhid_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); sourceManager_->InitAuto(); std::string deviceId = "djfhskjdhf5465456ds4f654sdf6"; @@ -1968,6 +2100,8 @@ HWTEST_F(DistributedInputSourceManagerTest, OnResponseStopRemoteInputDhid_02, te HWTEST_F(DistributedInputSourceManagerTest, OnResponseRelayPrepareRemoteInput_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); sourceManager_->InitAuto(); int32_t toSrcSessionId = 1; @@ -1984,6 +2118,8 @@ HWTEST_F(DistributedInputSourceManagerTest, OnResponseRelayPrepareRemoteInput_02 HWTEST_F(DistributedInputSourceManagerTest, OnResponseRelayUnprepareRemoteInput_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); sourceManager_->InitAuto(); int32_t toSrcSessionId = 1; @@ -1999,6 +2135,8 @@ HWTEST_F(DistributedInputSourceManagerTest, OnResponseRelayUnprepareRemoteInput_ HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayPrepareResult_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); sourceManager_->InitAuto(); int32_t status = 1; @@ -2014,6 +2152,8 @@ HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayPrepareResult_02, test HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayUnprepareResult_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); sourceManager_->InitAuto(); int32_t status = 1; @@ -2029,6 +2169,8 @@ HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayUnprepareResult_02, te HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStartDhidResult_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); sourceManager_->InitAuto(); int32_t status = 1; @@ -2045,6 +2187,8 @@ HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStartDhidResult_02, te HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStopDhidResult_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); sourceManager_->InitAuto(); int32_t status = 1; @@ -2061,6 +2205,8 @@ HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStopDhidResult_02, tes HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStartTypeResult_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); sourceManager_->InitAuto(); int32_t status = 1; @@ -2077,6 +2223,8 @@ HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStartTypeResult_02, te HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStopTypeResult_02, testing::ext::TestSize.Level1) { + ASSERT_NE(sourceManager_, nullptr); + ASSERT_NE(callback_, nullptr); sourceManager_->InitAuto(); int32_t status = 1; diff --git a/services/source/transport/src/distributed_input_source_transport.cpp b/services/source/transport/src/distributed_input_source_transport.cpp index 88317f3..b8dd680 100644 --- a/services/source/transport/src/distributed_input_source_transport.cpp +++ b/services/source/transport/src/distributed_input_source_transport.cpp @@ -616,8 +616,8 @@ void DistributedInputSourceTransport::StartLatencyCount(const std::string &devic while (isLatencyThreadRunning_.load()) { if (sendNum_ >= INPUT_LATENCY_DELAY_TIMES) { uint64_t latency = (uint64_t)(deltaTimeAll_ / 2 / INPUT_LATENCY_DELAY_TIMES); - DHLOGI("LatencyCount average single-channel latency is %{public}" PRIu64 " us, send times is %{public}d, " - "recive times is %{public}d.", latency, sendNum_, recvNum_); + DHLOGI("LatencyCount average single-channel latency is %{public}" PRIu64 " us, send times is %{public}u, " + "recive times is %{public}u.", latency, sendNum_, recvNum_); DHLOGD("each RTT latency details is %{public}s", eachLatencyDetails_.c_str()); deltaTimeAll_ = 0; sendNum_ = 0; @@ -884,6 +884,10 @@ void DistributedInputSourceTransport::NotifyResponsePrepareRemoteInput(int32_t s DHLOGE("OnBytesReceived cmdType is TRANS_SINK_MSG_ONPREPARE, deviceId is error."); return; } + if (callback_ == nullptr) { + DHLOGE("callback_ is nullptr"); + return; + } callback_->OnResponsePrepareRemoteInput(deviceId, recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE], recMsg[DINPUT_SOFTBUS_KEY_WHITE_LIST]); } @@ -901,6 +905,10 @@ void DistributedInputSourceTransport::NotifyResponseUnprepareRemoteInput(int32_t DHLOGE("OnBytesReceived cmdType is TRANS_SINK_MSG_ONUNPREPARE, deviceId is error."); return; } + if (callback_ == nullptr) { + DHLOGE("callback_ is nullptr"); + return; + } callback_->OnResponseUnprepareRemoteInput(deviceId, recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE]); CloseInputSoftbus(deviceId, false); } @@ -918,6 +926,10 @@ void DistributedInputSourceTransport::NotifyResponseStartRemoteInput(int32_t ses DHLOGE("OnBytesReceived cmdType is TRANS_SINK_MSG_ONSTART, deviceId is error."); return; } + if (callback_ == nullptr) { + DHLOGE("callback_ is nullptr"); + return; + } callback_->OnResponseStartRemoteInput( deviceId, recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE], recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE]); } @@ -935,6 +947,10 @@ void DistributedInputSourceTransport::NotifyResponseStopRemoteInput(int32_t sess DHLOGE("OnBytesReceived cmdType TRANS_SINK_MSG_ONSTOP, deviceId is error."); return; } + if (callback_ == nullptr) { + DHLOGE("callback_ is nullptr"); + return; + } callback_->OnResponseStopRemoteInput( deviceId, recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE], recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE]); } @@ -953,6 +969,10 @@ void DistributedInputSourceTransport::NotifyResponseStartRemoteInputDhid(int32_t DHLOGE("OnBytesReceived cmdType is TRANS_SINK_MSG_DHID_ONSTART, deviceId is error."); return; } + if (callback_ == nullptr) { + DHLOGE("callback_ is nullptr"); + return; + } callback_->OnResponseStartRemoteInputDhid( deviceId, recMsg[DINPUT_SOFTBUS_KEY_VECTOR_DHID], recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE]); } @@ -970,6 +990,10 @@ void DistributedInputSourceTransport::NotifyResponseStopRemoteInputDhid(int32_t DHLOGE("OnBytesReceived cmdType is TRANS_SINK_MSG_DHID_ONSTOP, deviceId is error."); return; } + if (callback_ == nullptr) { + DHLOGE("callback_ is nullptr"); + return; + } callback_->OnResponseStopRemoteInputDhid( deviceId, recMsg[DINPUT_SOFTBUS_KEY_VECTOR_DHID], recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE]); } @@ -989,6 +1013,10 @@ void DistributedInputSourceTransport::NotifyResponseKeyState(int32_t sessionId, DHLOGE("OnBytesReceived cmdType is TRANS_SINK_MSG_KEY_STATE, deviceId is error."); return; } + if (callback_ == nullptr) { + DHLOGE("callback_ is nullptr"); + return; + } callback_->OnResponseKeyState(deviceId, recMsg[DINPUT_SOFTBUS_KEY_KEYSTATE_DHID], recMsg[DINPUT_SOFTBUS_KEY_KEYSTATE_TYPE], recMsg[DINPUT_SOFTBUS_KEY_KEYSTATE_CODE], recMsg[DINPUT_SOFTBUS_KEY_KEYSTATE_VALUE]); @@ -1007,6 +1035,10 @@ void DistributedInputSourceTransport::NotifyResponseKeyStateBatch(int32_t sessio return; } std::string inputDataStr = recMsg[DINPUT_SOFTBUS_KEY_INPUT_DATA]; + if (callback_ == nullptr) { + DHLOGE("callback_ is nullptr"); + return; + } callback_->OnResponseKeyStateBatch(deviceId, inputDataStr); } @@ -1024,6 +1056,10 @@ void DistributedInputSourceTransport::NotifyReceivedEventRemoteInput(int32_t ses return; } std::string inputDataStr = recMsg[DINPUT_SOFTBUS_KEY_INPUT_DATA]; + if (callback_ == nullptr) { + DHLOGE("callback_ is nullptr"); + return; + } callback_->OnReceivedEventRemoteInput(deviceId, inputDataStr); } @@ -1059,7 +1095,10 @@ void DistributedInputSourceTransport::ReceiveSrcTSrcRelayPrepare(int32_t session return; } std::string deviceId = recMsg[DINPUT_SOFTBUS_KEY_DEVICE_ID]; - + if (callback_ == nullptr) { + DHLOGE("callback_ is nullptr"); + return; + } // continue notify to A_sink_trans int32_t ret = OpenInputSoftbus(deviceId, false); if (ret != DH_SUCCESS) { @@ -1081,7 +1120,10 @@ void DistributedInputSourceTransport::ReceiveSrcTSrcRelayUnprepare(int32_t sessi DHLOGE("The key is invaild."); return; } - + if (callback_ == nullptr) { + DHLOGE("callback_ is nullptr"); + return; + } std::string deviceId = recMsg[DINPUT_SOFTBUS_KEY_DEVICE_ID]; int32_t ret = UnprepareRemoteInput(sessionId, deviceId); if (ret != DH_SUCCESS) { @@ -1106,6 +1148,10 @@ void DistributedInputSourceTransport::NotifyResponseRelayPrepareRemoteInput(int3 DHLOGE("OnBytesReceived cmdType is TRANS_SINK_MSG_ON_RELAY_PREPARE, sinkDevId is error."); return; } + if (callback_ == nullptr) { + DHLOGE("callback_ is nullptr"); + return; + } callback_->OnResponseRelayPrepareRemoteInput(recMsg[DINPUT_SOFTBUS_KEY_SESSION_ID], sinkDevId, recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE], recMsg[DINPUT_SOFTBUS_KEY_WHITE_LIST]); } @@ -1124,6 +1170,10 @@ void DistributedInputSourceTransport::NotifyResponseRelayUnprepareRemoteInput(in DHLOGE("OnBytesReceived cmdType is TRANS_SINK_MSG_ON_RELAY_UNPREPARE, sinkDevId is error."); return; } + if (callback_ == nullptr) { + DHLOGE("callback_ is nullptr"); + return; + } callback_->OnResponseRelayUnprepareRemoteInput(recMsg[DINPUT_SOFTBUS_KEY_SESSION_ID], sinkDevId, recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE]); @@ -1147,6 +1197,10 @@ void DistributedInputSourceTransport::ReceiveRelayPrepareResult(int32_t sessionI std::string srcId = recMsg[DINPUT_SOFTBUS_KEY_SRC_DEV_ID]; std::string sinkId = recMsg[DINPUT_SOFTBUS_KEY_SINK_DEV_ID]; int32_t status = recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE]; + if (callback_ == nullptr) { + DHLOGE("callback_ is nullptr"); + return; + } callback_->OnReceiveRelayPrepareResult(status, srcId, sinkId); } @@ -1163,6 +1217,10 @@ void DistributedInputSourceTransport::ReceiveRelayUnprepareResult(int32_t sessio std::string srcId = recMsg[DINPUT_SOFTBUS_KEY_SRC_DEV_ID]; std::string sinkId = recMsg[DINPUT_SOFTBUS_KEY_SINK_DEV_ID]; int32_t status = recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE]; + if (callback_ == nullptr) { + DHLOGE("callback_ is nullptr"); + return; + } callback_->OnReceiveRelayUnprepareResult(status, srcId, sinkId); CloseInputSoftbus(srcId, true); } @@ -1282,6 +1340,10 @@ void DistributedInputSourceTransport::ReceiveRelayStartDhidResult(int32_t sessio std::string sinkId = recMsg[DINPUT_SOFTBUS_KEY_SINK_DEV_ID]; int32_t status = recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE]; std::string dhids = recMsg[DINPUT_SOFTBUS_KEY_VECTOR_DHID]; + if (callback_ == nullptr) { + DHLOGE("callback_ is nullptr"); + return; + } callback_->OnReceiveRelayStartDhidResult(status, srcId, sinkId, dhids); } @@ -1300,6 +1362,10 @@ void DistributedInputSourceTransport::ReceiveRelayStopDhidResult(int32_t session std::string sinkId = recMsg[DINPUT_SOFTBUS_KEY_SINK_DEV_ID]; int32_t status = recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE]; std::string dhids = recMsg[DINPUT_SOFTBUS_KEY_VECTOR_DHID]; + if (callback_ == nullptr) { + DHLOGE("callback_ is nullptr"); + return; + } callback_->OnReceiveRelayStopDhidResult(status, srcId, sinkId, dhids); } @@ -1418,6 +1484,10 @@ void DistributedInputSourceTransport::ReceiveRelayStartTypeResult(int32_t sessio std::string sinkId = recMsg[DINPUT_SOFTBUS_KEY_SINK_DEV_ID]; int32_t status = recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE]; uint32_t inputTypes = recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE]; + if (callback_ == nullptr) { + DHLOGE("callback_ is nullptr"); + return; + } callback_->OnReceiveRelayStartTypeResult(status, srcId, sinkId, inputTypes); } @@ -1436,6 +1506,10 @@ void DistributedInputSourceTransport::ReceiveRelayStopTypeResult(int32_t session std::string sinkId = recMsg[DINPUT_SOFTBUS_KEY_SINK_DEV_ID]; int32_t status = recMsg[DINPUT_SOFTBUS_KEY_RESP_VALUE]; uint32_t inputTypes = recMsg[DINPUT_SOFTBUS_KEY_INPUT_TYPE]; + if (callback_ == nullptr) { + DHLOGE("callback_ is nullptr"); + return; + } callback_->OnReceiveRelayStopTypeResult(status, srcId, sinkId, inputTypes); } diff --git a/services/state/src/dinput_sink_state.cpp b/services/state/src/dinput_sink_state.cpp index 8bf357f..b0f0bc0 100644 --- a/services/state/src/dinput_sink_state.cpp +++ b/services/state/src/dinput_sink_state.cpp @@ -160,6 +160,10 @@ void DInputSinkState::SimulateKeyDownEvent(const int32_t sessionId, const std::s void DInputSinkState::SimulateTouchPadEvents(const int32_t sessionId, const std::string &dhId) { + if (touchPadEventFragMgr_ == nullptr) { + DHLOGE("touchPadEventFragMgr_ is nullptr"); + return; + } std::vector events = this->touchPadEventFragMgr_->GetAndClearEvents(dhId); if (events.empty()) { return; diff --git a/services/state/test/dinpusinkstatetest/dinput_sink_state_test.cpp b/services/state/test/dinpusinkstatetest/dinput_sink_state_test.cpp index 05008ee..bd49dcd 100644 --- a/services/state/test/dinpusinkstatetest/dinput_sink_state_test.cpp +++ b/services/state/test/dinpusinkstatetest/dinput_sink_state_test.cpp @@ -151,6 +151,7 @@ HWTEST_F(DinputSinkStateTest, RemoveKeyDownState_001, testing::ext::TestSize.Lev HWTEST_F(DinputSinkStateTest, IsPositionEvent_001, testing::ext::TestSize.Level0) { + ASSERT_NE(DInputSinkState::GetInstance().GetTouchPadEventFragMgr(), nullptr); DInputSinkState::GetInstance().Init(); auto ret = DInputSinkState::GetInstance().GetTouchPadEventFragMgr()->IsPositionEvent(EVENT_2); EXPECT_EQ(false, ret); @@ -158,6 +159,7 @@ HWTEST_F(DinputSinkStateTest, IsPositionEvent_001, testing::ext::TestSize.Level0 HWTEST_F(DinputSinkStateTest, PushEvent_001, testing::ext::TestSize.Level0) { + ASSERT_NE(DInputSinkState::GetInstance().GetTouchPadEventFragMgr(), nullptr); auto ret = DInputSinkState::GetInstance().GetTouchPadEventFragMgr()->PushEvent(DHID_1, EVENT_1); EXPECT_EQ(false, ret.first); @@ -167,6 +169,7 @@ HWTEST_F(DinputSinkStateTest, PushEvent_001, testing::ext::TestSize.Level0) HWTEST_F(DinputSinkStateTest, GetAndClearEvents_001, testing::ext::TestSize.Level0) { + ASSERT_NE(DInputSinkState::GetInstance().GetTouchPadEventFragMgr(), nullptr); std::string dhId = "dhId_test"; auto ret = DInputSinkState::GetInstance().GetTouchPadEventFragMgr()->GetAndClearEvents(dhId); EXPECT_EQ(0, ret.size()); diff --git a/sinkhandler/src/distributed_input_sink_handler.cpp b/sinkhandler/src/distributed_input_sink_handler.cpp index 066a8bb..6b98d11 100644 --- a/sinkhandler/src/distributed_input_sink_handler.cpp +++ b/sinkhandler/src/distributed_input_sink_handler.cpp @@ -78,6 +78,10 @@ void DistributedInputSinkHandler::FinishStartSA(const std::string ¶ms, const DHLOGE("sinkSvrRecipient is nullptr."); return; } + if (remoteObject == nullptr) { + DHLOGE("remoteObject is nullptr."); + return; + } remoteObject->AddDeathRecipient(sinkSvrRecipient_); dInputSinkProxy_ = iface_cast(remoteObject); DInputSAManager::GetInstance().SetDInputSinkProxy(remoteObject); diff --git a/sinkhandler/test/unittest/mock/mock_distributed_input_client.cpp b/sinkhandler/test/unittest/mock/mock_distributed_input_client.cpp index df24e9e..9994ca0 100644 --- a/sinkhandler/test/unittest/mock/mock_distributed_input_client.cpp +++ b/sinkhandler/test/unittest/mock/mock_distributed_input_client.cpp @@ -36,7 +36,9 @@ void DistributedInputClient::RegisterDInputCb::OnResult( auto iter = DistributedInputClient::GetInstance().dHardWareFwkRstInfos.begin(); for (; iter != DistributedInputClient::GetInstance().dHardWareFwkRstInfos.end(); ++iter) { if (iter->devId == devId && iter->dhId == dhId) { - iter->callback->OnRegisterResult(devId, dhId, status, ""); + if (iter->callback != nullptr) { + iter->callback->OnRegisterResult(devId, dhId, status, ""); + } DistributedInputClient::GetInstance().dHardWareFwkRstInfos.erase(iter); return; } @@ -49,7 +51,9 @@ void DistributedInputClient::UnregisterDInputCb::OnResult( auto iter = DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.begin(); for (; iter != DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.end(); ++iter) { if (iter->devId == devId && iter->dhId == dhId) { - iter->callback->OnUnregisterResult(devId, dhId, status, ""); + if (iter->callback != nullptr) { + iter->callback->OnUnregisterResult(devId, dhId, status, ""); + } DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.erase(iter); return; } diff --git a/sourcehandler/src/distributed_input_source_handler.cpp b/sourcehandler/src/distributed_input_source_handler.cpp index 5650deb..ea9e3b4 100644 --- a/sourcehandler/src/distributed_input_source_handler.cpp +++ b/sourcehandler/src/distributed_input_source_handler.cpp @@ -77,6 +77,10 @@ void DistributedInputSourceHandler::FinishStartSA(const std::string ¶ms, con DHLOGE("sourceSvrRecipient is nullptr."); return; } + if (remoteObject == nullptr) { + DHLOGE("sourceSvrRecipient is nullptr."); + return; + } remoteObject->AddDeathRecipient(sourceSvrRecipient_); dInputSourceProxy_ = iface_cast(remoteObject); DInputSAManager::GetInstance().SetDInputSourceProxy(remoteObject); diff --git a/sourcehandler/test/unittest/mock/mock_distributed_input_client.cpp b/sourcehandler/test/unittest/mock/mock_distributed_input_client.cpp index ecf6c16..15bef0f 100644 --- a/sourcehandler/test/unittest/mock/mock_distributed_input_client.cpp +++ b/sourcehandler/test/unittest/mock/mock_distributed_input_client.cpp @@ -37,7 +37,9 @@ void DistributedInputClient::RegisterDInputCb::OnResult( auto iter = DistributedInputClient::GetInstance().dHardWareFwkRstInfos.begin(); for (; iter != DistributedInputClient::GetInstance().dHardWareFwkRstInfos.end(); ++iter) { if (iter->devId == devId && iter->dhId == dhId) { - iter->callback->OnRegisterResult(devId, dhId, status, ""); + if (iter->callback != nullptr) { + iter->callback->OnRegisterResult(devId, dhId, status, ""); + } DistributedInputClient::GetInstance().dHardWareFwkRstInfos.erase(iter); return; } @@ -50,7 +52,9 @@ void DistributedInputClient::UnregisterDInputCb::OnResult( auto iter = DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.begin(); for (; iter != DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.end(); ++iter) { if (iter->devId == devId && iter->dhId == dhId) { - iter->callback->OnUnregisterResult(devId, dhId, status, ""); + if (iter->callback != nullptr) { + iter->callback->OnUnregisterResult(devId, dhId, status, ""); + } DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.erase(iter); return; } -- Gitee