mirror of
https://github.com/openharmony/distributedhardware_distributed_input.git
synced 2026-07-20 21:41:02 -04:00
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -48,9 +48,6 @@ public:
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_MOVE(DistributedInputSinkStub);
|
||||
using DistributedInputSinkFunc = int32_t (DistributedInputSinkStub::*)(MessageParcel &data, MessageParcel &reply,
|
||||
MessageOption &option);
|
||||
std::map<int32_t, DistributedInputSinkFunc> memberFuncMap_;
|
||||
};
|
||||
} // namespace DistributedInput
|
||||
} // namespace DistributedHardware
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -32,7 +32,6 @@ public:
|
||||
DistributedInputSourceStub();
|
||||
~DistributedInputSourceStub() override;
|
||||
|
||||
void RegRespFunMap();
|
||||
int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||
|
||||
private:
|
||||
@@ -60,13 +59,11 @@ private:
|
||||
int32_t HandleUnregisterSessionStateCb(MessageParcel &data, MessageParcel &reply);
|
||||
bool HasEnableDHPermission();
|
||||
bool HasAccessDHPermission();
|
||||
int32_t HandleRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
||||
DISALLOW_COPY_AND_MOVE(DistributedInputSourceStub);
|
||||
private:
|
||||
std::atomic<bool> sourceManagerInitFlag_ {false};
|
||||
std::mutex operatorMutex_;
|
||||
using DistributedInputSourceFunc = int32_t (DistributedInputSourceStub::*)(MessageParcel &data,
|
||||
MessageParcel &reply);
|
||||
std::map<uint32_t, DistributedInputSourceFunc> memberFuncMap_;
|
||||
};
|
||||
} // namespace DistributedInput
|
||||
} // namespace DistributedHardware
|
||||
|
||||
@@ -30,24 +30,11 @@ namespace DistributedInput {
|
||||
DistributedInputSinkStub::DistributedInputSinkStub()
|
||||
{
|
||||
DHLOGI("DistributedInputSinkStub ctor!");
|
||||
memberFuncMap_[static_cast<uint32_t>(IDInputSinkInterfaceCode::INIT)] =
|
||||
&DistributedInputSinkStub::InitInner;
|
||||
memberFuncMap_[static_cast<uint32_t>(IDInputSinkInterfaceCode::RELEASE)] =
|
||||
&DistributedInputSinkStub::ReleaseInner;
|
||||
memberFuncMap_[static_cast<uint32_t>(IDInputSinkInterfaceCode::NOTIFY_START_DSCREEN)] =
|
||||
&DistributedInputSinkStub::NotifyStartDScreenInner;
|
||||
memberFuncMap_[static_cast<uint32_t>(IDInputSinkInterfaceCode::NOTIFY_STOP_DSCREEN)] =
|
||||
&DistributedInputSinkStub::NotifyStopDScreenInner;
|
||||
memberFuncMap_[static_cast<uint32_t>(IDInputSinkInterfaceCode::REGISTER_SHARING_DHID_LISTENER)] =
|
||||
&DistributedInputSinkStub::RegisterSharingDhIdListenerInner;
|
||||
memberFuncMap_[static_cast<uint32_t>(IDInputSinkInterfaceCode::GET_SINK_SCREEN_INFOS)] =
|
||||
&DistributedInputSinkStub::RegisterGetSinkScreenInfosInner;
|
||||
}
|
||||
|
||||
DistributedInputSinkStub::~DistributedInputSinkStub()
|
||||
{
|
||||
DHLOGI("DistributedInputSinkStub dtor!");
|
||||
memberFuncMap_.clear();
|
||||
}
|
||||
|
||||
bool DistributedInputSinkStub::HasEnableDHPermission()
|
||||
@@ -66,13 +53,23 @@ int32_t DistributedInputSinkStub::OnRemoteRequest(uint32_t code, MessageParcel &
|
||||
DHLOGE("DistributedInputSinkStub read token valid failed");
|
||||
return ERR_DH_INPUT_IPC_READ_TOKEN_VALID_FAIL;
|
||||
}
|
||||
auto iter = memberFuncMap_.find(code);
|
||||
if (iter == memberFuncMap_.end()) {
|
||||
DHLOGE("invalid request code is %{public}d.", code);
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
switch (code) {
|
||||
case static_cast<uint32_t>(IDInputSinkInterfaceCode::INIT):
|
||||
return InitInner(data, reply, option);
|
||||
case static_cast<uint32_t>(IDInputSinkInterfaceCode::RELEASE):
|
||||
return ReleaseInner(data, reply, option);
|
||||
case static_cast<uint32_t>(IDInputSinkInterfaceCode::NOTIFY_START_DSCREEN):
|
||||
return NotifyStartDScreenInner(data, reply, option);
|
||||
case static_cast<uint32_t>(IDInputSinkInterfaceCode::NOTIFY_STOP_DSCREEN):
|
||||
return NotifyStopDScreenInner(data, reply, option);
|
||||
case static_cast<uint32_t>(IDInputSinkInterfaceCode::REGISTER_SHARING_DHID_LISTENER):
|
||||
return RegisterSharingDhIdListenerInner(data, reply, option);
|
||||
case static_cast<uint32_t>(IDInputSinkInterfaceCode::GET_SINK_SCREEN_INFOS):
|
||||
return RegisterGetSinkScreenInfosInner(data, reply, option);
|
||||
default:
|
||||
DHLOGE("invalid request code is %{public}u.", code);
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
DistributedInputSinkFunc &func = iter->second;
|
||||
return (this->*func)(data, reply, option);
|
||||
}
|
||||
|
||||
int32_t DistributedInputSinkStub::InitInner(MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
|
||||
@@ -27,56 +27,10 @@ namespace DistributedHardware {
|
||||
namespace DistributedInput {
|
||||
DistributedInputSourceStub::DistributedInputSourceStub()
|
||||
{
|
||||
RegRespFunMap();
|
||||
}
|
||||
|
||||
DistributedInputSourceStub::~DistributedInputSourceStub()
|
||||
{
|
||||
memberFuncMap_.clear();
|
||||
}
|
||||
|
||||
void DistributedInputSourceStub::RegRespFunMap()
|
||||
{
|
||||
memberFuncMap_[static_cast<uint32_t>(IDInputSourceInterfaceCode::REGISTER_REMOTE_INPUT)] =
|
||||
&DistributedInputSourceStub::HandleRegisterDistributedHardware;
|
||||
memberFuncMap_[static_cast<uint32_t>(IDInputSourceInterfaceCode::UNREGISTER_REMOTE_INPUT)] =
|
||||
&DistributedInputSourceStub::HandleUnregisterDistributedHardware;
|
||||
memberFuncMap_[static_cast<uint32_t>(IDInputSourceInterfaceCode::PREPARE_REMOTE_INPUT)] =
|
||||
&DistributedInputSourceStub::HandlePrepareRemoteInput;
|
||||
memberFuncMap_[static_cast<uint32_t>(IDInputSourceInterfaceCode::UNPREPARE_REMOTE_INPUT)] =
|
||||
&DistributedInputSourceStub::HandleUnprepareRemoteInput;
|
||||
memberFuncMap_[static_cast<uint32_t>(IDInputSourceInterfaceCode::START_REMOTE_INPUT)] =
|
||||
&DistributedInputSourceStub::HandleStartRemoteInput;
|
||||
memberFuncMap_[static_cast<uint32_t>(IDInputSourceInterfaceCode::STOP_REMOTE_INPUT)] =
|
||||
&DistributedInputSourceStub::HandleStopRemoteInput;
|
||||
memberFuncMap_[static_cast<uint32_t>(IDInputSourceInterfaceCode::START_RELAY_TYPE_REMOTE_INPUT)] =
|
||||
&DistributedInputSourceStub::HandleStartRelayTypeRemoteInput;
|
||||
memberFuncMap_[static_cast<uint32_t>(IDInputSourceInterfaceCode::STOP_RELAY_TYPE_REMOTE_INPUT)] =
|
||||
&DistributedInputSourceStub::HandleStopRelayTypeRemoteInput;
|
||||
memberFuncMap_[static_cast<uint32_t>(IDInputSourceInterfaceCode::PREPARE_RELAY_REMOTE_INPUT)] =
|
||||
&DistributedInputSourceStub::HandlePrepareRelayRemoteInput;
|
||||
memberFuncMap_[static_cast<uint32_t>(IDInputSourceInterfaceCode::UNPREPARE_RELAY_REMOTE_INPUT)] =
|
||||
&DistributedInputSourceStub::HandleUnprepareRelayRemoteInput;
|
||||
memberFuncMap_[static_cast<uint32_t>(IDInputSourceInterfaceCode::START_DHID_REMOTE_INPUT)] =
|
||||
&DistributedInputSourceStub::HandleStartDhidRemoteInput;
|
||||
memberFuncMap_[static_cast<uint32_t>(IDInputSourceInterfaceCode::STOP_DHID_REMOTE_INPUT)] =
|
||||
&DistributedInputSourceStub::HandleStopDhidRemoteInput;
|
||||
memberFuncMap_[static_cast<uint32_t>(IDInputSourceInterfaceCode::START_RELAY_DHID_REMOTE_INPUT)] =
|
||||
&DistributedInputSourceStub::HandleStartRelayDhidRemoteInput;
|
||||
memberFuncMap_[static_cast<uint32_t>(IDInputSourceInterfaceCode::STOP_RELAY_DHID_REMOTE_INPUT)] =
|
||||
&DistributedInputSourceStub::HandleStopRelayDhidRemoteInput;
|
||||
memberFuncMap_[static_cast<uint32_t>(IDInputSourceInterfaceCode::REGISTER_ADD_WHITE_LIST_CB_REMOTE_INPUT)] =
|
||||
&DistributedInputSourceStub::HandleRegisterAddWhiteListCallback;
|
||||
memberFuncMap_[static_cast<uint32_t>(IDInputSourceInterfaceCode::REGISTER_DEL_WHITE_LIST_CB_REMOTE_INPUT)] =
|
||||
&DistributedInputSourceStub::HandleRegisterDelWhiteListCallback;
|
||||
memberFuncMap_[static_cast<uint32_t>(IDInputSourceInterfaceCode::REGISTER_SIMULATION_EVENT_LISTENER)] =
|
||||
&DistributedInputSourceStub::HandleRegisterSimulationEventListener;
|
||||
memberFuncMap_[static_cast<uint32_t>(IDInputSourceInterfaceCode::UNREGISTER_SIMULATION_EVENT_LISTENER)] =
|
||||
&DistributedInputSourceStub::HandleUnregisterSimulationEventListener;
|
||||
memberFuncMap_[static_cast<uint32_t>(IDInputSourceInterfaceCode::REGISTER_SESSION_STATE_CB)] =
|
||||
&DistributedInputSourceStub::HandleRegisterSessionStateCb;
|
||||
memberFuncMap_[static_cast<uint32_t>(IDInputSourceInterfaceCode::UNREGISTER_SESSION_STATE_CB)] =
|
||||
&DistributedInputSourceStub::HandleUnregisterSessionStateCb;
|
||||
}
|
||||
|
||||
bool DistributedInputSourceStub::HasEnableDHPermission()
|
||||
@@ -595,6 +549,32 @@ int32_t DistributedInputSourceStub::HandleUnregisterSessionStateCb(MessageParcel
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DistributedInputSourceStub::HandleRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
|
||||
MessageOption &option)
|
||||
{
|
||||
switch (code) {
|
||||
case static_cast<uint32_t>(IDInputSourceInterfaceCode::START_RELAY_DHID_REMOTE_INPUT):
|
||||
return HandleStartRelayDhidRemoteInput(data, reply);
|
||||
case static_cast<uint32_t>(IDInputSourceInterfaceCode::STOP_RELAY_DHID_REMOTE_INPUT):
|
||||
return HandleStopRelayDhidRemoteInput(data, reply);
|
||||
case static_cast<uint32_t>(IDInputSourceInterfaceCode::REGISTER_ADD_WHITE_LIST_CB_REMOTE_INPUT):
|
||||
return HandleRegisterAddWhiteListCallback(data, reply);
|
||||
case static_cast<uint32_t>(IDInputSourceInterfaceCode::REGISTER_DEL_WHITE_LIST_CB_REMOTE_INPUT):
|
||||
return HandleRegisterDelWhiteListCallback(data, reply);
|
||||
case static_cast<uint32_t>(IDInputSourceInterfaceCode::REGISTER_SIMULATION_EVENT_LISTENER):
|
||||
return HandleRegisterSimulationEventListener(data, reply);
|
||||
case static_cast<uint32_t>(IDInputSourceInterfaceCode::UNREGISTER_SIMULATION_EVENT_LISTENER):
|
||||
return HandleUnregisterSimulationEventListener(data, reply);
|
||||
case static_cast<uint32_t>(IDInputSourceInterfaceCode::REGISTER_SESSION_STATE_CB):
|
||||
return HandleRegisterSessionStateCb(data, reply);
|
||||
case static_cast<uint32_t>(IDInputSourceInterfaceCode::UNREGISTER_SESSION_STATE_CB):
|
||||
return HandleUnregisterSessionStateCb(data, reply);
|
||||
default:
|
||||
DHLOGE("invalid request code is %{public}u.", code);
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t DistributedInputSourceStub::OnRemoteRequest(
|
||||
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
@@ -610,18 +590,38 @@ int32_t DistributedInputSourceStub::OnRemoteRequest(
|
||||
if (code == static_cast<uint32_t>(IDInputSourceInterfaceCode::UNREGISTER_REMOTE_INPUT)) {
|
||||
DHLOGI("Receive UnRegister DInput cmd");
|
||||
}
|
||||
if (code == static_cast<uint32_t>(IDInputSourceInterfaceCode::INIT)) {
|
||||
return HandleInitDistributedHardware(reply);
|
||||
} else if (code == static_cast<uint32_t>(IDInputSourceInterfaceCode::RELEASE)) {
|
||||
return HandleReleaseDistributedHardware(reply);
|
||||
} else {
|
||||
auto iter = memberFuncMap_.find(code);
|
||||
if (iter != memberFuncMap_.end()) {
|
||||
const DistributedInputSourceFunc &func = iter->second;
|
||||
return (this->*func)(data, reply);
|
||||
}
|
||||
switch (code) {
|
||||
case static_cast<uint32_t>(IDInputSourceInterfaceCode::INIT):
|
||||
return HandleInitDistributedHardware(reply);
|
||||
case static_cast<uint32_t>(IDInputSourceInterfaceCode::RELEASE):
|
||||
return HandleReleaseDistributedHardware(reply);
|
||||
case static_cast<uint32_t>(IDInputSourceInterfaceCode::REGISTER_REMOTE_INPUT):
|
||||
return HandleRegisterDistributedHardware(data, reply);
|
||||
case static_cast<uint32_t>(IDInputSourceInterfaceCode::UNREGISTER_REMOTE_INPUT):
|
||||
return HandleUnregisterDistributedHardware(data, reply);
|
||||
case static_cast<uint32_t>(IDInputSourceInterfaceCode::PREPARE_REMOTE_INPUT):
|
||||
return HandlePrepareRemoteInput(data, reply);
|
||||
case static_cast<uint32_t>(IDInputSourceInterfaceCode::UNPREPARE_REMOTE_INPUT):
|
||||
return HandleUnprepareRemoteInput(data, reply);
|
||||
case static_cast<uint32_t>(IDInputSourceInterfaceCode::START_REMOTE_INPUT):
|
||||
return HandleStartRemoteInput(data, reply);
|
||||
case static_cast<uint32_t>(IDInputSourceInterfaceCode::STOP_REMOTE_INPUT):
|
||||
return HandleStopRemoteInput(data, reply);
|
||||
case static_cast<uint32_t>(IDInputSourceInterfaceCode::START_RELAY_TYPE_REMOTE_INPUT):
|
||||
return HandleStartRelayTypeRemoteInput(data, reply);
|
||||
case static_cast<uint32_t>(IDInputSourceInterfaceCode::STOP_RELAY_TYPE_REMOTE_INPUT):
|
||||
return HandleStopRelayTypeRemoteInput(data, reply);
|
||||
case static_cast<uint32_t>(IDInputSourceInterfaceCode::PREPARE_RELAY_REMOTE_INPUT):
|
||||
return HandlePrepareRelayRemoteInput(data, reply);
|
||||
case static_cast<uint32_t>(IDInputSourceInterfaceCode::UNPREPARE_RELAY_REMOTE_INPUT):
|
||||
return HandleUnprepareRelayRemoteInput(data, reply);
|
||||
case static_cast<uint32_t>(IDInputSourceInterfaceCode::START_DHID_REMOTE_INPUT):
|
||||
return HandleStartDhidRemoteInput(data, reply);
|
||||
case static_cast<uint32_t>(IDInputSourceInterfaceCode::STOP_DHID_REMOTE_INPUT):
|
||||
return HandleStopDhidRemoteInput(data, reply);
|
||||
default:
|
||||
return HandleRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
} // namespace DistributedInput
|
||||
} // namespace DistributedHardware
|
||||
|
||||
-1
@@ -389,7 +389,6 @@ void DistributedInputSourceStubFuzzTest(const uint8_t *data, size_t size)
|
||||
|
||||
sptr<DistributedInput::DistributedInputSourceStub> distributedInputSourceStub(new (std::nothrow)
|
||||
DInputSourceCallBackStubFuzz());
|
||||
distributedInputSourceStub->RegRespFunMap();
|
||||
distributedInputSourceStub->HasEnableDHPermission();
|
||||
distributedInputSourceStub->HasAccessDHPermission();
|
||||
distributedInputSourceStub->HandleInitDistributedHardware(reply);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
private:
|
||||
int32_t SendMessage(int32_t sessionId, std::string &message);
|
||||
void HandleData(int32_t sessionId, const std::string &message);
|
||||
void RegRespFunMap();
|
||||
void HandleEventInner(int32_t sessionId, const nlohmann::json &recMsg);
|
||||
void NotifyPrepareRemoteInput(int32_t sessionId, const nlohmann::json &recMsg);
|
||||
void NotifyUnprepareRemoteInput(int32_t sessionId, const nlohmann::json &recMsg);
|
||||
void NotifyStartRemoteInput(int32_t sessionId, const nlohmann::json &recMsg);
|
||||
@@ -102,10 +102,6 @@ private:
|
||||
std::shared_ptr<DistributedInputSinkTransport::DInputSinkEventHandler> eventHandler_;
|
||||
std::shared_ptr<DistributedInputSinkTransport::DInputTransbaseSinkListener> statuslistener_;
|
||||
std::shared_ptr<DInputSinkTransCallback> callback_;
|
||||
|
||||
using SinkTransportFunc = void (DistributedInputSinkTransport::*)(int32_t sessionId,
|
||||
const nlohmann::json &recMsg);
|
||||
std::map<int32_t, SinkTransportFunc> memberFuncMap_;
|
||||
};
|
||||
} // namespace DistributedInput
|
||||
} // namespace DistributedHardware
|
||||
|
||||
@@ -106,7 +106,6 @@ int32_t DistributedInputSinkTransport::Init()
|
||||
|
||||
statuslistener_ = std::make_shared<DInputTransbaseSinkListener>(this);
|
||||
DistributedInputTransportBase::GetInstance().RegisterSinkHandleSessionCallback(statuslistener_);
|
||||
RegRespFunMap();
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -522,26 +521,31 @@ void DistributedInputSinkTransport::DInputTransbaseSinkListener::HandleSessionDa
|
||||
DistributedInputSinkTransport::GetInstance().HandleData(sessionId, message);
|
||||
}
|
||||
|
||||
void DistributedInputSinkTransport::RegRespFunMap()
|
||||
void DistributedInputSinkTransport::HandleEventInner(int32_t sessionId, const nlohmann::json &recMsg)
|
||||
{
|
||||
memberFuncMap_[TRANS_SOURCE_MSG_PREPARE] = &DistributedInputSinkTransport::NotifyPrepareRemoteInput;
|
||||
memberFuncMap_[TRANS_SOURCE_MSG_UNPREPARE] = &DistributedInputSinkTransport::NotifyUnprepareRemoteInput;
|
||||
memberFuncMap_[TRANS_SOURCE_MSG_START_TYPE] = &DistributedInputSinkTransport::NotifyStartRemoteInput;
|
||||
memberFuncMap_[TRANS_SOURCE_MSG_STOP_TYPE] = &DistributedInputSinkTransport::NotifyStopRemoteInput;
|
||||
memberFuncMap_[TRANS_SOURCE_MSG_LATENCY] = &DistributedInputSinkTransport::NotifyLatency;
|
||||
memberFuncMap_[TRANS_SOURCE_MSG_START_DHID] = &DistributedInputSinkTransport::NotifyStartRemoteInputDhid;
|
||||
memberFuncMap_[TRANS_SOURCE_MSG_STOP_DHID] = &DistributedInputSinkTransport::NotifyStopRemoteInputDhid;
|
||||
memberFuncMap_[TRANS_SOURCE_MSG_PREPARE_FOR_REL] = &DistributedInputSinkTransport::NotifyRelayPrepareRemoteInput;
|
||||
memberFuncMap_[TRANS_SOURCE_MSG_UNPREPARE_FOR_REL] =
|
||||
&DistributedInputSinkTransport::NotifyRelayUnprepareRemoteInput;
|
||||
memberFuncMap_[TRANS_SOURCE_MSG_START_DHID_FOR_REL] =
|
||||
&DistributedInputSinkTransport::NotifyRelayStartDhidRemoteInput;
|
||||
memberFuncMap_[TRANS_SOURCE_MSG_STOP_DHID_FOR_REL] =
|
||||
&DistributedInputSinkTransport::NotifyRelayStopDhidRemoteInput;
|
||||
memberFuncMap_[TRANS_SOURCE_MSG_START_TYPE_FOR_REL] =
|
||||
&DistributedInputSinkTransport::NotifyRelayStartTypeRemoteInput;
|
||||
memberFuncMap_[TRANS_SOURCE_MSG_STOP_TYPE_FOR_REL] =
|
||||
&DistributedInputSinkTransport::NotifyRelayStopTypeRemoteInput;
|
||||
uint32_t cmdType = recMsg[DINPUT_SOFTBUS_KEY_CMD_TYPE];
|
||||
switch (cmdType) {
|
||||
case TRANS_SOURCE_MSG_PREPARE_FOR_REL:
|
||||
NotifyRelayPrepareRemoteInput(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SOURCE_MSG_UNPREPARE_FOR_REL:
|
||||
NotifyRelayUnprepareRemoteInput(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SOURCE_MSG_START_DHID_FOR_REL:
|
||||
NotifyRelayStartDhidRemoteInput(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SOURCE_MSG_STOP_DHID_FOR_REL:
|
||||
NotifyRelayStopDhidRemoteInput(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SOURCE_MSG_START_TYPE_FOR_REL:
|
||||
NotifyRelayStartTypeRemoteInput(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SOURCE_MSG_STOP_TYPE_FOR_REL:
|
||||
NotifyRelayStopTypeRemoteInput(sessionId, recMsg);
|
||||
break;
|
||||
default:
|
||||
DHLOGE("OnBytesReceived cmdType %{public}u is undefined.", cmdType);
|
||||
}
|
||||
}
|
||||
|
||||
void DistributedInputSinkTransport::HandleData(int32_t sessionId, const std::string &message)
|
||||
@@ -561,13 +565,31 @@ void DistributedInputSinkTransport::HandleData(int32_t sessionId, const std::str
|
||||
return;
|
||||
}
|
||||
uint32_t cmdType = recMsg[DINPUT_SOFTBUS_KEY_CMD_TYPE];
|
||||
auto iter = memberFuncMap_.find(cmdType);
|
||||
if (iter == memberFuncMap_.end()) {
|
||||
DHLOGE("OnBytesReceived cmdType %{public}u is undefined.", cmdType);
|
||||
return;
|
||||
switch (cmdType) {
|
||||
case TRANS_SOURCE_MSG_PREPARE:
|
||||
NotifyPrepareRemoteInput(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SOURCE_MSG_UNPREPARE:
|
||||
NotifyUnprepareRemoteInput(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SOURCE_MSG_START_TYPE:
|
||||
NotifyStartRemoteInput(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SOURCE_MSG_STOP_TYPE:
|
||||
NotifyStopRemoteInput(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SOURCE_MSG_LATENCY:
|
||||
NotifyLatency(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SOURCE_MSG_START_DHID:
|
||||
NotifyStartRemoteInputDhid(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SOURCE_MSG_STOP_DHID:
|
||||
NotifyStopRemoteInputDhid(sessionId, recMsg);
|
||||
break;
|
||||
default:
|
||||
HandleEventInner(sessionId, recMsg);
|
||||
}
|
||||
SinkTransportFunc &func = iter->second;
|
||||
(this->*func)(sessionId, recMsg);
|
||||
}
|
||||
|
||||
void DistributedInputSinkTransport::CloseAllSession()
|
||||
|
||||
@@ -455,7 +455,7 @@ void DistributedInputNodeManager::StartInjectThread()
|
||||
DHLOGI("InjectThread does not created");
|
||||
isInjectThreadCreated_.store(true);
|
||||
isInjectThreadRunning_.store(true);
|
||||
eventInjectThread_ = std::thread(&DistributedInputNodeManager::InjectEvent, this);
|
||||
eventInjectThread_ = std::thread([this]() { this->InjectEvent(); });
|
||||
}
|
||||
|
||||
void DistributedInputNodeManager::StopInjectThread()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -64,10 +64,8 @@ private:
|
||||
void NotifyRelayStopTypeCallback(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
void NotifyRelayPrepareRemoteInput(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
void NotifyRelayUnprepareRemoteInput(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
void ProcessEventInner(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
|
||||
using SourceEventFunc = void (DInputSourceManagerEventHandler::*)(
|
||||
const AppExecFwk::InnerEvent::Pointer &event);
|
||||
std::map<int32_t, SourceEventFunc> eventFuncMap_;
|
||||
DistributedInputSourceManager *sourceManagerObj_;
|
||||
};
|
||||
} // namespace DistributedInput
|
||||
|
||||
@@ -37,39 +37,11 @@ DInputSourceManagerEventHandler::DInputSourceManagerEventHandler(
|
||||
const std::shared_ptr<AppExecFwk::EventRunner> &runner, DistributedInputSourceManager *manager)
|
||||
: AppExecFwk::EventHandler(runner)
|
||||
{
|
||||
eventFuncMap_[DINPUT_SOURCE_MANAGER_RIGISTER_MSG] = &DInputSourceManagerEventHandler::NotifyRegisterCallback;
|
||||
eventFuncMap_[DINPUT_SOURCE_MANAGER_UNRIGISTER_MSG] = &DInputSourceManagerEventHandler::NotifyUnregisterCallback;
|
||||
eventFuncMap_[DINPUT_SOURCE_MANAGER_PREPARE_MSG] = &DInputSourceManagerEventHandler::NotifyPrepareCallback;
|
||||
eventFuncMap_[DINPUT_SOURCE_MANAGER_UNPREPARE_MSG] = &DInputSourceManagerEventHandler::NotifyUnprepareCallback;
|
||||
eventFuncMap_[DINPUT_SOURCE_MANAGER_START_MSG] = &DInputSourceManagerEventHandler::NotifyStartCallback;
|
||||
eventFuncMap_[DINPUT_SOURCE_MANAGER_STOP_MSG] = &DInputSourceManagerEventHandler::NotifyStopCallback;
|
||||
eventFuncMap_[DINPUT_SOURCE_MANAGER_START_DHID_MSG] = &DInputSourceManagerEventHandler::NotifyStartDhidCallback;
|
||||
eventFuncMap_[DINPUT_SOURCE_MANAGER_STOP_DHID_MSG] = &DInputSourceManagerEventHandler::NotifyStopDhidCallback;
|
||||
eventFuncMap_[DINPUT_SOURCE_MANAGER_KEY_STATE_MSG] = &DInputSourceManagerEventHandler::NotifyKeyStateCallback;
|
||||
eventFuncMap_[DINPUT_SOURCE_MANAGER_STARTSERVER_MSG] = &DInputSourceManagerEventHandler::NotifyStartServerCallback;
|
||||
eventFuncMap_[DINPUT_SOURCE_MANAGER_RELAY_PREPARE_RESULT_TO_ORIGIN] =
|
||||
&DInputSourceManagerEventHandler::NotifyRelayPrepareRemoteInput;
|
||||
eventFuncMap_[DINPUT_SOURCE_MANAGER_RELAY_UNPREPARE_RESULT_TO_ORIGIN] =
|
||||
&DInputSourceManagerEventHandler::NotifyRelayUnprepareRemoteInput;
|
||||
eventFuncMap_[DINPUT_SOURCE_MANAGER_RELAY_PREPARE_RESULT_MMI] =
|
||||
&DInputSourceManagerEventHandler::NotifyRelayPrepareCallback;
|
||||
eventFuncMap_[DINPUT_SOURCE_MANAGER_RELAY_UNPREPARE_RESULT_MMI] =
|
||||
&DInputSourceManagerEventHandler::NotifyRelayUnprepareCallback;
|
||||
eventFuncMap_[DINPUT_SOURCE_MANAGER_RELAY_STARTDHID_RESULT_MMI] =
|
||||
&DInputSourceManagerEventHandler::NotifyRelayStartDhidCallback;
|
||||
eventFuncMap_[DINPUT_SOURCE_MANAGER_RELAY_STOPDHID_RESULT_MMI] =
|
||||
&DInputSourceManagerEventHandler::NotifyRelayStopDhidCallback;
|
||||
eventFuncMap_[DINPUT_SOURCE_MANAGER_RELAY_STARTTYPE_RESULT_MMI] =
|
||||
&DInputSourceManagerEventHandler::NotifyRelayStartTypeCallback;
|
||||
eventFuncMap_[DINPUT_SOURCE_MANAGER_RELAY_STOPTYPE_RESULT_MMI] =
|
||||
&DInputSourceManagerEventHandler::NotifyRelayStopTypeCallback;
|
||||
|
||||
sourceManagerObj_ = manager;
|
||||
}
|
||||
|
||||
DInputSourceManagerEventHandler::~DInputSourceManagerEventHandler()
|
||||
{
|
||||
eventFuncMap_.clear();
|
||||
sourceManagerObj_ = nullptr;
|
||||
}
|
||||
|
||||
@@ -478,15 +450,74 @@ void DInputSourceManagerEventHandler::NotifyRelayStopTypeCallback(const AppExecF
|
||||
sourceManagerObj_->RunRelayStopTypeCallback(srcId, sinkId, status, inputTypes);
|
||||
}
|
||||
|
||||
void DInputSourceManagerEventHandler::ProcessEventInner(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
{
|
||||
switch (event->GetInnerEventId()) {
|
||||
case DINPUT_SOURCE_MANAGER_RELAY_UNPREPARE_RESULT_TO_ORIGIN:
|
||||
NotifyRelayUnprepareRemoteInput(event);
|
||||
break;
|
||||
case DINPUT_SOURCE_MANAGER_RELAY_PREPARE_RESULT_MMI:
|
||||
NotifyRelayPrepareCallback(event);
|
||||
break;
|
||||
case DINPUT_SOURCE_MANAGER_RELAY_UNPREPARE_RESULT_MMI:
|
||||
NotifyRelayUnprepareCallback(event);
|
||||
break;
|
||||
case DINPUT_SOURCE_MANAGER_RELAY_STARTDHID_RESULT_MMI:
|
||||
NotifyRelayStartDhidCallback(event);
|
||||
break;
|
||||
case DINPUT_SOURCE_MANAGER_RELAY_STOPDHID_RESULT_MMI:
|
||||
NotifyRelayStopDhidCallback(event);
|
||||
break;
|
||||
case DINPUT_SOURCE_MANAGER_RELAY_STARTTYPE_RESULT_MMI:
|
||||
NotifyRelayStartTypeCallback(event);
|
||||
break;
|
||||
case DINPUT_SOURCE_MANAGER_RELAY_STOPTYPE_RESULT_MMI:
|
||||
NotifyRelayStopTypeCallback(event);
|
||||
break;
|
||||
default:
|
||||
DHLOGE("Event Id %{public}d is undefined.", event->GetInnerEventId());
|
||||
}
|
||||
}
|
||||
|
||||
void DInputSourceManagerEventHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
{
|
||||
auto iter = eventFuncMap_.find(event->GetInnerEventId());
|
||||
if (iter == eventFuncMap_.end()) {
|
||||
DHLOGE("Event Id %{public}d is undefined.", event->GetInnerEventId());
|
||||
return;
|
||||
switch (event->GetInnerEventId()) {
|
||||
case DINPUT_SOURCE_MANAGER_RIGISTER_MSG:
|
||||
NotifyRegisterCallback(event);
|
||||
break;
|
||||
case DINPUT_SOURCE_MANAGER_UNRIGISTER_MSG:
|
||||
NotifyUnregisterCallback(event);
|
||||
break;
|
||||
case DINPUT_SOURCE_MANAGER_PREPARE_MSG:
|
||||
NotifyPrepareCallback(event);
|
||||
break;
|
||||
case DINPUT_SOURCE_MANAGER_UNPREPARE_MSG:
|
||||
NotifyUnprepareCallback(event);
|
||||
break;
|
||||
case DINPUT_SOURCE_MANAGER_START_MSG:
|
||||
NotifyStartCallback(event);
|
||||
break;
|
||||
case DINPUT_SOURCE_MANAGER_STOP_MSG:
|
||||
NotifyStopCallback(event);
|
||||
break;
|
||||
case DINPUT_SOURCE_MANAGER_START_DHID_MSG:
|
||||
NotifyStartDhidCallback(event);
|
||||
break;
|
||||
case DINPUT_SOURCE_MANAGER_STOP_DHID_MSG:
|
||||
NotifyStopDhidCallback(event);
|
||||
break;
|
||||
case DINPUT_SOURCE_MANAGER_KEY_STATE_MSG:
|
||||
NotifyKeyStateCallback(event);
|
||||
break;
|
||||
case DINPUT_SOURCE_MANAGER_STARTSERVER_MSG:
|
||||
NotifyStartServerCallback(event);
|
||||
break;
|
||||
case DINPUT_SOURCE_MANAGER_RELAY_PREPARE_RESULT_TO_ORIGIN:
|
||||
NotifyRelayPrepareRemoteInput(event);
|
||||
break;
|
||||
default:
|
||||
ProcessEventInner(event);
|
||||
}
|
||||
SourceEventFunc &func = iter->second;
|
||||
(this->*func)(event);
|
||||
}
|
||||
} // namespace DistributedInput
|
||||
} // namespace DistributedHardware
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -91,6 +91,8 @@ public:
|
||||
private:
|
||||
int32_t SendMessage(int32_t sessionId, std::string &message);
|
||||
void HandleData(int32_t sessionId, const std::string &message);
|
||||
void HandleEventFirst(int32_t sessionId, const nlohmann::json &recMsg);
|
||||
void HandleEventSecond(int32_t sessionId, const nlohmann::json &recMsg);
|
||||
void SessionClosed();
|
||||
void NotifyResponsePrepareRemoteInput(int32_t sessionId, const nlohmann::json &recMsg);
|
||||
void NotifyResponseUnprepareRemoteInput(int32_t sessionId, const nlohmann::json &recMsg);
|
||||
@@ -135,8 +137,6 @@ private:
|
||||
void ReceiveRelayStopTypeResult(int32_t sessionId, const nlohmann::json &recMsg);
|
||||
|
||||
void CalculateLatency(int32_t sessionId, const nlohmann::json &recMsg);
|
||||
void RegRespFunMap();
|
||||
|
||||
void ResetKeyboardKeyState(const std::string &deviceId, const std::vector<std::string> &dhids);
|
||||
private:
|
||||
std::mutex operationMutex_;
|
||||
@@ -155,10 +155,6 @@ private:
|
||||
std::string eachLatencyDetails_ = "";
|
||||
std::atomic<int32_t> injectThreadNum = 0;
|
||||
std::atomic<int32_t> latencyThreadNum = 0;
|
||||
|
||||
using SourceTransportFunc = void (DistributedInputSourceTransport::*)(int32_t sessionId,
|
||||
const nlohmann::json &recMsg);
|
||||
std::map<int32_t, SourceTransportFunc> memberFuncMap_;
|
||||
};
|
||||
} // namespace DistributedInput
|
||||
} // namespace DistributedHardware
|
||||
|
||||
@@ -65,59 +65,9 @@ int32_t DistributedInputSourceTransport::Init()
|
||||
|
||||
statuslistener_ = std::make_shared<DInputTransbaseSourceListener>(this);
|
||||
DistributedInputTransportBase::GetInstance().RegisterSrcHandleSessionCallback(statuslistener_);
|
||||
RegRespFunMap();
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
void DistributedInputSourceTransport::RegRespFunMap()
|
||||
{
|
||||
memberFuncMap_[TRANS_SINK_MSG_ONPREPARE] = &DistributedInputSourceTransport::NotifyResponsePrepareRemoteInput;
|
||||
memberFuncMap_[TRANS_SINK_MSG_ONUNPREPARE] = &DistributedInputSourceTransport::NotifyResponseUnprepareRemoteInput;
|
||||
memberFuncMap_[TRANS_SINK_MSG_ONSTART] = &DistributedInputSourceTransport::NotifyResponseStartRemoteInput;
|
||||
memberFuncMap_[TRANS_SINK_MSG_ONSTOP] = &DistributedInputSourceTransport::NotifyResponseStopRemoteInput;
|
||||
memberFuncMap_[TRANS_SINK_MSG_BODY_DATA] = &DistributedInputSourceTransport::NotifyReceivedEventRemoteInput;
|
||||
memberFuncMap_[TRANS_SINK_MSG_LATENCY] = &DistributedInputSourceTransport::CalculateLatency;
|
||||
memberFuncMap_[TRANS_SINK_MSG_DHID_ONSTART] = &DistributedInputSourceTransport::NotifyResponseStartRemoteInputDhid;
|
||||
memberFuncMap_[TRANS_SINK_MSG_DHID_ONSTOP] = &DistributedInputSourceTransport::NotifyResponseStopRemoteInputDhid;
|
||||
memberFuncMap_[TRANS_SINK_MSG_KEY_STATE] = &DistributedInputSourceTransport::NotifyResponseKeyState;
|
||||
memberFuncMap_[TRANS_SINK_MSG_KEY_STATE_BATCH] = &DistributedInputSourceTransport::NotifyResponseKeyStateBatch;
|
||||
memberFuncMap_[TRANS_SOURCE_TO_SOURCE_MSG_PREPARE] = &DistributedInputSourceTransport::ReceiveSrcTSrcRelayPrepare;
|
||||
memberFuncMap_[TRANS_SINK_MSG_ON_RELAY_PREPARE] =
|
||||
&DistributedInputSourceTransport::NotifyResponseRelayPrepareRemoteInput;
|
||||
memberFuncMap_[TRANS_SINK_MSG_ON_RELAY_UNPREPARE] =
|
||||
&DistributedInputSourceTransport::NotifyResponseRelayUnprepareRemoteInput;
|
||||
memberFuncMap_[TRANS_SOURCE_TO_SOURCE_MSG_UNPREPARE] =
|
||||
&DistributedInputSourceTransport::ReceiveSrcTSrcRelayUnprepare;
|
||||
memberFuncMap_[TRANS_SOURCE_TO_SOURCE_MSG_PREPARE_RESULT] =
|
||||
&DistributedInputSourceTransport::ReceiveRelayPrepareResult;
|
||||
memberFuncMap_[TRANS_SOURCE_TO_SOURCE_MSG_UNPREPARE_RESULT] =
|
||||
&DistributedInputSourceTransport::ReceiveRelayUnprepareResult;
|
||||
memberFuncMap_[TRANS_SOURCE_TO_SOURCE_MSG_START_DHID] =
|
||||
&DistributedInputSourceTransport::ReceiveSrcTSrcRelayStartDhid;
|
||||
memberFuncMap_[TRANS_SOURCE_TO_SOURCE_MSG_STOP_DHID] =
|
||||
&DistributedInputSourceTransport::ReceiveSrcTSrcRelayStopDhid;
|
||||
memberFuncMap_[TRANS_SINK_MSG_ON_RELAY_STARTDHID] =
|
||||
&DistributedInputSourceTransport::NotifyResponseRelayStartDhidRemoteInput;
|
||||
memberFuncMap_[TRANS_SINK_MSG_ON_RELAY_STOPDHID] =
|
||||
&DistributedInputSourceTransport::NotifyResponseRelayStopDhidRemoteInput;
|
||||
memberFuncMap_[TRANS_SOURCE_TO_SOURCE_MSG_START_DHID_RESULT] =
|
||||
&DistributedInputSourceTransport::ReceiveRelayStartDhidResult;
|
||||
memberFuncMap_[TRANS_SOURCE_TO_SOURCE_MSG_STOP_DHID_RESULT] =
|
||||
&DistributedInputSourceTransport::ReceiveRelayStopDhidResult;
|
||||
memberFuncMap_[TRANS_SOURCE_TO_SOURCE_MSG_START_TYPE] =
|
||||
&DistributedInputSourceTransport::ReceiveSrcTSrcRelayStartType;
|
||||
memberFuncMap_[TRANS_SOURCE_TO_SOURCE_MSG_STOP_TYPE] =
|
||||
&DistributedInputSourceTransport::ReceiveSrcTSrcRelayStopType;
|
||||
memberFuncMap_[TRANS_SINK_MSG_ON_RELAY_STARTTYPE] =
|
||||
&DistributedInputSourceTransport::NotifyResponseRelayStartTypeRemoteInput;
|
||||
memberFuncMap_[TRANS_SINK_MSG_ON_RELAY_STOPTYPE] =
|
||||
&DistributedInputSourceTransport::NotifyResponseRelayStopTypeRemoteInput;
|
||||
memberFuncMap_[TRANS_SOURCE_TO_SOURCE_MSG_START_TYPE_RESULT] =
|
||||
&DistributedInputSourceTransport::ReceiveRelayStartTypeResult;
|
||||
memberFuncMap_[TRANS_SOURCE_TO_SOURCE_MSG_STOP_TYPE_RESULT] =
|
||||
&DistributedInputSourceTransport::ReceiveRelayStopTypeResult;
|
||||
}
|
||||
|
||||
void DistributedInputSourceTransport::Release()
|
||||
{
|
||||
DHLOGI("Release Source Transport");
|
||||
@@ -685,7 +635,7 @@ void DistributedInputSourceTransport::StartLatencyThread(const std::string &devi
|
||||
{
|
||||
DHLOGI("start");
|
||||
isLatencyThreadRunning_.store(true);
|
||||
latencyThread_ = std::thread(&DistributedInputSourceTransport::StartLatencyCount, this, deviceId);
|
||||
latencyThread_ = std::thread([this, deviceId]() { this->StartLatencyCount(deviceId); });
|
||||
DHLOGI("end");
|
||||
}
|
||||
|
||||
@@ -1489,6 +1439,81 @@ void DistributedInputSourceTransport::ReceiveRelayStopTypeResult(int32_t session
|
||||
callback_->OnReceiveRelayStopTypeResult(status, srcId, sinkId, inputTypes);
|
||||
}
|
||||
|
||||
void DistributedInputSourceTransport::HandleEventSecond(int32_t sessionId, const nlohmann::json &recMsg)
|
||||
{
|
||||
uint32_t cmdType = recMsg[DINPUT_SOFTBUS_KEY_CMD_TYPE];
|
||||
switch (cmdType) {
|
||||
case TRANS_SOURCE_TO_SOURCE_MSG_START_TYPE:
|
||||
ReceiveSrcTSrcRelayStartType(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SOURCE_TO_SOURCE_MSG_STOP_TYPE:
|
||||
ReceiveSrcTSrcRelayStopType(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SINK_MSG_ON_RELAY_STARTTYPE:
|
||||
NotifyResponseRelayStartTypeRemoteInput(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SINK_MSG_ON_RELAY_STOPTYPE:
|
||||
NotifyResponseRelayStopTypeRemoteInput(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SOURCE_TO_SOURCE_MSG_START_TYPE_RESULT:
|
||||
ReceiveRelayStartTypeResult(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SOURCE_TO_SOURCE_MSG_STOP_TYPE_RESULT:
|
||||
ReceiveRelayStopTypeResult(sessionId, recMsg);
|
||||
break;
|
||||
default:
|
||||
DHLOGE("OnBytesReceived cmdType %{public}u is undefined.", cmdType);
|
||||
}
|
||||
}
|
||||
|
||||
void DistributedInputSourceTransport::HandleEventFirst(int32_t sessionId, const nlohmann::json &recMsg)
|
||||
{
|
||||
uint32_t cmdType = recMsg[DINPUT_SOFTBUS_KEY_CMD_TYPE];
|
||||
switch (cmdType) {
|
||||
case TRANS_SINK_MSG_KEY_STATE_BATCH:
|
||||
NotifyResponseKeyStateBatch(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SOURCE_TO_SOURCE_MSG_PREPARE:
|
||||
ReceiveSrcTSrcRelayPrepare(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SINK_MSG_ON_RELAY_PREPARE:
|
||||
NotifyResponseRelayPrepareRemoteInput(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SINK_MSG_ON_RELAY_UNPREPARE:
|
||||
NotifyResponseRelayUnprepareRemoteInput(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SOURCE_TO_SOURCE_MSG_UNPREPARE:
|
||||
ReceiveSrcTSrcRelayUnprepare(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SOURCE_TO_SOURCE_MSG_PREPARE_RESULT:
|
||||
ReceiveRelayPrepareResult(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SOURCE_TO_SOURCE_MSG_UNPREPARE_RESULT:
|
||||
ReceiveRelayUnprepareResult(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SOURCE_TO_SOURCE_MSG_START_DHID:
|
||||
ReceiveSrcTSrcRelayStartDhid(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SOURCE_TO_SOURCE_MSG_STOP_DHID:
|
||||
ReceiveSrcTSrcRelayStopDhid(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SINK_MSG_ON_RELAY_STARTDHID:
|
||||
NotifyResponseRelayStartDhidRemoteInput(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SINK_MSG_ON_RELAY_STOPDHID:
|
||||
NotifyResponseRelayStopDhidRemoteInput(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SOURCE_TO_SOURCE_MSG_START_DHID_RESULT:
|
||||
ReceiveRelayStartDhidResult(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SOURCE_TO_SOURCE_MSG_STOP_DHID_RESULT:
|
||||
ReceiveRelayStopDhidResult(sessionId, recMsg);
|
||||
break;
|
||||
default:
|
||||
HandleEventSecond(sessionId, recMsg);
|
||||
}
|
||||
}
|
||||
|
||||
void DistributedInputSourceTransport::DInputTransbaseSourceListener::HandleSessionData(int32_t sessionId,
|
||||
const std::string &message)
|
||||
{
|
||||
@@ -1501,7 +1526,6 @@ void DistributedInputSourceTransport::HandleData(int32_t sessionId, const std::s
|
||||
DHLOGE("OnBytesReceived the callback_ is null, the message:%{public}s abort.", SetAnonyId(message).c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
nlohmann::json recMsg = nlohmann::json::parse(message, nullptr, false);
|
||||
if (recMsg.is_discarded()) {
|
||||
DHLOGE("recMsg parse failed!");
|
||||
@@ -1512,15 +1536,38 @@ void DistributedInputSourceTransport::HandleData(int32_t sessionId, const std::s
|
||||
return;
|
||||
}
|
||||
uint32_t cmdType = recMsg[DINPUT_SOFTBUS_KEY_CMD_TYPE];
|
||||
auto iter = memberFuncMap_.find(cmdType);
|
||||
if (iter == memberFuncMap_.end()) {
|
||||
DHLOGE("OnBytesReceived cmdType %{public}u is undefined.", cmdType);
|
||||
return;
|
||||
switch (cmdType) {
|
||||
case TRANS_SINK_MSG_ONPREPARE:
|
||||
NotifyResponsePrepareRemoteInput(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SINK_MSG_ONUNPREPARE:
|
||||
NotifyResponseUnprepareRemoteInput(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SINK_MSG_ONSTART:
|
||||
NotifyResponseStartRemoteInput(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SINK_MSG_ONSTOP:
|
||||
NotifyResponseStopRemoteInput(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SINK_MSG_BODY_DATA:
|
||||
NotifyReceivedEventRemoteInput(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SINK_MSG_LATENCY:
|
||||
CalculateLatency(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SINK_MSG_DHID_ONSTART:
|
||||
NotifyResponseStartRemoteInputDhid(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SINK_MSG_DHID_ONSTOP:
|
||||
NotifyResponseStopRemoteInputDhid(sessionId, recMsg);
|
||||
break;
|
||||
case TRANS_SINK_MSG_KEY_STATE:
|
||||
NotifyResponseKeyState(sessionId, recMsg);
|
||||
break;
|
||||
default:
|
||||
HandleEventFirst(sessionId, recMsg);
|
||||
}
|
||||
SourceTransportFunc &func = iter->second;
|
||||
(this->*func)(sessionId, recMsg);
|
||||
}
|
||||
|
||||
} // namespace DistributedInput
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
Reference in New Issue
Block a user