From c48d9aedd99b2d49d554ffc308a3f1dc96765453 Mon Sep 17 00:00:00 2001 From: xxxx Date: Tue, 17 May 2022 16:42:57 +0800 Subject: [PATCH] Description: add dinput Match-id-27cd4c64b9af561329bcdbc4f04fcdbcf06d955a --- .../add_white_list_infos_call_back_proxy.cpp | 53 +++ .../add_white_list_infos_call_back_stub.cpp | 53 +++ .../del_white_list_infos_call_back_proxy.cpp | 50 +++ .../del_white_list_infos_call_back_stub.cpp | 52 +++ .../ipc/src/distributed_input_client.cpp | 422 ++++++++++++++++++ .../ipc/src/distributed_input_sink_proxy.cpp | 87 ++++ .../ipc/src/distributed_input_sink_stub.cpp | 65 +++ .../src/distributed_input_source_proxy.cpp | 226 ++++++++++ .../ipc/src/distributed_input_source_stub.cpp | 172 +++++++ .../src/prepare_d_input_call_back_proxy.cpp | 57 +++ .../src/prepare_d_input_call_back_stub.cpp | 53 +++ .../src/register_d_input_call_back_proxy.cpp | 60 +++ .../src/register_d_input_call_back_stub.cpp | 54 +++ .../ipc/src/start_d_input_call_back_proxy.cpp | 60 +++ .../ipc/src/start_d_input_call_back_stub.cpp | 54 +++ .../start_d_input_server_call_back_proxy.cpp | 57 +++ .../start_d_input_server_call_back_stub.cpp | 53 +++ .../ipc/src/stop_d_input_call_back_proxy.cpp | 60 +++ .../ipc/src/stop_d_input_call_back_stub.cpp | 54 +++ .../src/unprepare_d_input_call_back_proxy.cpp | 57 +++ .../src/unprepare_d_input_call_back_stub.cpp | 53 +++ .../unregister_d_input_call_back_proxy.cpp | 60 +++ .../src/unregister_d_input_call_back_stub.cpp | 54 +++ 23 files changed, 1966 insertions(+) create mode 100644 interfaces/ipc/src/add_white_list_infos_call_back_proxy.cpp create mode 100644 interfaces/ipc/src/add_white_list_infos_call_back_stub.cpp create mode 100644 interfaces/ipc/src/del_white_list_infos_call_back_proxy.cpp create mode 100644 interfaces/ipc/src/del_white_list_infos_call_back_stub.cpp create mode 100644 interfaces/ipc/src/distributed_input_client.cpp create mode 100644 interfaces/ipc/src/distributed_input_sink_proxy.cpp create mode 100644 interfaces/ipc/src/distributed_input_sink_stub.cpp create mode 100644 interfaces/ipc/src/distributed_input_source_proxy.cpp create mode 100644 interfaces/ipc/src/distributed_input_source_stub.cpp create mode 100644 interfaces/ipc/src/prepare_d_input_call_back_proxy.cpp create mode 100644 interfaces/ipc/src/prepare_d_input_call_back_stub.cpp create mode 100644 interfaces/ipc/src/register_d_input_call_back_proxy.cpp create mode 100644 interfaces/ipc/src/register_d_input_call_back_stub.cpp create mode 100644 interfaces/ipc/src/start_d_input_call_back_proxy.cpp create mode 100644 interfaces/ipc/src/start_d_input_call_back_stub.cpp create mode 100644 interfaces/ipc/src/start_d_input_server_call_back_proxy.cpp create mode 100644 interfaces/ipc/src/start_d_input_server_call_back_stub.cpp create mode 100644 interfaces/ipc/src/stop_d_input_call_back_proxy.cpp create mode 100644 interfaces/ipc/src/stop_d_input_call_back_stub.cpp create mode 100644 interfaces/ipc/src/unprepare_d_input_call_back_proxy.cpp create mode 100644 interfaces/ipc/src/unprepare_d_input_call_back_stub.cpp create mode 100644 interfaces/ipc/src/unregister_d_input_call_back_proxy.cpp create mode 100644 interfaces/ipc/src/unregister_d_input_call_back_stub.cpp diff --git a/interfaces/ipc/src/add_white_list_infos_call_back_proxy.cpp b/interfaces/ipc/src/add_white_list_infos_call_back_proxy.cpp new file mode 100644 index 0000000..ee00c76 --- /dev/null +++ b/interfaces/ipc/src/add_white_list_infos_call_back_proxy.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "add_white_list_infos_call_back_proxy.h" +#include "ipc_types.h" +#include "parcel.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +AddWhiteListInfosCallbackProxy::AddWhiteListInfosCallbackProxy(const sptr &object) + : IRemoteProxy(object) +{ +} + +AddWhiteListInfosCallbackProxy::~AddWhiteListInfosCallbackProxy() +{ +} + +void AddWhiteListInfosCallbackProxy::OnResult(const std::string& deviceId, const std::string& strJson) +{ + sptr remote = Remote(); + if (remote == nullptr) { + return; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + data.WriteInterfaceToken(IAddWhiteListInfosCallback::GetDescriptor()); + if (!data.WriteString(deviceId)) { + return; + } + if (!data.WriteString(strJson)) { + return; + } + remote->SendRequest(static_cast(IAddWhiteListInfosCallback::Message::RESULT), data, reply, option); +} +} // namespace DistributedHardware +} // namespace DistributedInput +} // namespace OHOS diff --git a/interfaces/ipc/src/add_white_list_infos_call_back_stub.cpp b/interfaces/ipc/src/add_white_list_infos_call_back_stub.cpp new file mode 100644 index 0000000..28dff03 --- /dev/null +++ b/interfaces/ipc/src/add_white_list_infos_call_back_stub.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "add_white_list_infos_call_back_stub.h" +#include "string_ex.h" +#include "constants_dinput.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +AddWhiteListInfosCallbackStub::AddWhiteListInfosCallbackStub() +{ +} + +AddWhiteListInfosCallbackStub::~AddWhiteListInfosCallbackStub() +{ +} + +int32_t AddWhiteListInfosCallbackStub::OnRemoteRequest( + uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) +{ + std::u16string descriptor = data.ReadInterfaceToken(); + if (descriptor != IAddWhiteListInfosCallback::GetDescriptor()) { + return ERROR; + } + IAddWhiteListInfosCallback::Message msgCode = static_cast(code); + switch (msgCode) { + case IAddWhiteListInfosCallback::Message::RESULT: { + std::string deviceId = data.ReadString(); + std::string strJsion = data.ReadString(); + OnResult(deviceId, strJsion); + break; + } + default: + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); + } + return NO_ERROR; +} +} // namespace DistributedHardware +} // namespace DistributedInput +} // namespace OHOS diff --git a/interfaces/ipc/src/del_white_list_infos_call_back_proxy.cpp b/interfaces/ipc/src/del_white_list_infos_call_back_proxy.cpp new file mode 100644 index 0000000..066089a --- /dev/null +++ b/interfaces/ipc/src/del_white_list_infos_call_back_proxy.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "del_white_list_infos_call_back_proxy.h" +#include "ipc_types.h" +#include "parcel.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +DelWhiteListInfosCallbackProxy::DelWhiteListInfosCallbackProxy(const sptr &object) + : IRemoteProxy(object) +{ +} + +DelWhiteListInfosCallbackProxy::~DelWhiteListInfosCallbackProxy() +{ +} + +void DelWhiteListInfosCallbackProxy::OnResult(const std::string& deviceId) +{ + sptr remote = Remote(); + if (remote == nullptr) { + return; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + data.WriteInterfaceToken(IDelWhiteListInfosCallback::GetDescriptor()); + if (!data.WriteString(deviceId)) { + return; + } + remote->SendRequest(static_cast(IDelWhiteListInfosCallback::Message::RESULT), data, reply, option); +} +} // namespace DistributedHardware +} // namespace DistributedInput +} // namespace OHOS diff --git a/interfaces/ipc/src/del_white_list_infos_call_back_stub.cpp b/interfaces/ipc/src/del_white_list_infos_call_back_stub.cpp new file mode 100644 index 0000000..f9e358c --- /dev/null +++ b/interfaces/ipc/src/del_white_list_infos_call_back_stub.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "del_white_list_infos_call_back_stub.h" +#include "string_ex.h" +#include "constants_dinput.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +DelWhiteListInfosCallbackStub::DelWhiteListInfosCallbackStub() +{ +} + +DelWhiteListInfosCallbackStub::~DelWhiteListInfosCallbackStub() +{ +} + +int32_t DelWhiteListInfosCallbackStub::OnRemoteRequest( + uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) +{ + std::u16string descriptor = data.ReadInterfaceToken(); + if (descriptor != IDelWhiteListInfosCallback::GetDescriptor()) { + return ERROR; + } + IDelWhiteListInfosCallback::Message msgCode = static_cast(code); + switch (msgCode) { + case IDelWhiteListInfosCallback::Message::RESULT: { + std::string deviceId = data.ReadString(); + OnResult(deviceId); + break; + } + default: + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); + } + return NO_ERROR; +} +} // namespace DistributedHardware +} // namespace DistributedInput +} // namespace OHOS diff --git a/interfaces/ipc/src/distributed_input_client.cpp b/interfaces/ipc/src/distributed_input_client.cpp new file mode 100644 index 0000000..1f3be75 --- /dev/null +++ b/interfaces/ipc/src/distributed_input_client.cpp @@ -0,0 +1,422 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "distributed_input_client.h" +#include +#include +#include "constants_dinput.h" +#include "white_list_util.h" +#include "distributed_hardware_log.h" +#include "nlohmann/json.hpp" +#include "softbus_bus_center.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +DistributedInputClient &DistributedInputClient::GetInstance() +{ + static DistributedInputClient instance; + return instance; +} + +void DistributedInputClient::RegisterDInputCb::OnResult( + const std::string& devId, const std::string& dhId, const int32_t& status) +{ + for (std::vector::iterator iter = + DistributedInputClient::GetInstance().dHardWareFwkRstInfos.begin(); + iter != DistributedInputClient::GetInstance().dHardWareFwkRstInfos.end(); + iter++) { + if (iter->devId == devId && iter->dhId == dhId) { + iter->callback->OnRegisterResult(devId, dhId, status, ""); + DistributedInputClient::GetInstance().dHardWareFwkRstInfos.erase(iter); + return; + } + } + DHLOGI("dinputtest 13"); +} + +void DistributedInputClient::UnregisterDInputCb::OnResult( + const std::string& devId, const std::string& dhId, const int32_t& status) + +{ + for (std::vector::iterator iter = + DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.begin(); + iter != DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.end(); + iter++) { + if (iter->devId == devId && iter->dhId == dhId) { + iter->callback->OnUnregisterResult(devId, dhId, status, ""); + DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.erase(iter); + return; + } + } +} + +void DistributedInputClient::StartDInputServerCb::OnResult(const int32_t& status, const uint32_t& inputTypes) +{ + if (DInputServerType::SOURCE_SERVER_TYPE == static_cast(status)) { + DistributedInputClient::GetInstance().serverType = DInputServerType::SOURCE_SERVER_TYPE; + DistributedInputClient::GetInstance().inputTypes = inputTypes; + } else if (DInputServerType::SINK_SERVER_TYPE == static_cast(status)) { + DistributedInputClient::GetInstance().serverType = DInputServerType::SINK_SERVER_TYPE; + DistributedInputClient::GetInstance().inputTypes = inputTypes; + } else { + DistributedInputClient::GetInstance().serverType = DInputServerType::NULL_SERVER_TYPE; + DistributedInputClient::GetInstance().inputTypes = INPUT_TYPE_NULL; + } +} + +void DistributedInputClient::AddWhiteListInfosCb::OnResult(const std::string &deviceId, const std::string &strJson) +{ + DHLOGI("AddWhiteListInfosCb deviceId :%s. \n", deviceId.c_str()); + + if (strJson.empty()) { + DHLOGI("AddWhiteListInfosCb whitelist is empty.\n", deviceId.c_str()); + return; + } + + DistributedInputClient::GetInstance().AddWhiteListInfos(deviceId, strJson); +} + +void DistributedInputClient::DelWhiteListInfosCb::OnResult(const std::string& deviceId) +{ + DistributedInputClient::GetInstance().DelWhiteListInfos(deviceId); +} + +int32_t DistributedInputClient::InitSource() +{ + if (!GetDInputSourceProxy()) { + return FAILURE_DIS; + } + return dInputSourceProxy_->Init(); +} + +int32_t DistributedInputClient::InitSink() +{ + if (!GetDInputSinkProxy()) { + return FAILURE_DIS; + } + return dInputSinkProxy_->Init(); +} + +int32_t DistributedInputClient::ReleaseSource() +{ + if (!GetDInputSourceProxy()) { + return FAILURE_DIS; + } + + serverType = DInputServerType::NULL_SERVER_TYPE; + inputTypes = INPUT_TYPE_NULL; + m_bIsAlreadyInitWhiteList = false; + callbackRegister = nullptr; + callbackUnregister = nullptr; + sinkTypeCallback = nullptr; + sourceTypeCallback = nullptr; + addWhiteListCallback = nullptr; + delWhiteListCallback = nullptr; + WhiteListUtil::GetInstance().ClearWhiteList(); + return dInputSourceProxy_->Release(); +} + +int32_t DistributedInputClient::ReleaseSink() +{ + if (!GetDInputSinkProxy()) { + return FAILURE_DIS; + } + serverType = DInputServerType::NULL_SERVER_TYPE; + inputTypes = INPUT_TYPE_NULL; + m_bIsAlreadyInitWhiteList = false; + sinkTypeCallback = nullptr; + WhiteListUtil::GetInstance().ClearWhiteList(localDevId_); + return dInputSinkProxy_->Release(); +} + +int32_t DistributedInputClient::RegisterDistributedHardware(const std::string& devId, const std::string& dhId, + const std::string& parameters, const std::shared_ptr& callback) +{ + DHLOGI("%s called, deviceId: %s, dhId: %s, parameters: %s", + __func__, devId.c_str(), devId.c_str(), parameters.c_str()); + + if (!GetDInputSourceProxy()) { + DHLOGE("RegisterDistributedHardware client fail"); + return FAILURE_DIS; + } + + if (devId.empty() || dhId.empty() || parameters.empty() || !IsJsonData(parameters) || callback == nullptr) { + return FAILURE; + } + + for (auto iter : dHardWareFwkRstInfos) { + if (iter.devId == devId && iter.dhId == dhId) { + return FAILURE_REGISTING; + } + } + + DHardWareFwkRegistInfo info; + info.devId = devId; + info.dhId = dhId; + info.callback = callback; + dHardWareFwkRstInfos.push_back(info); + + callbackRegister = new(std::nothrow) RegisterDInputCb(); + return dInputSourceProxy_->RegisterDistributedHardware(devId, dhId, parameters, callbackRegister); +} + +int32_t DistributedInputClient::UnregisterDistributedHardware(const std::string& devId, const std::string& dhId, + const std::shared_ptr& callback) +{ + DHLOGI("%s called, deviceId: %s, dhId: %s", __func__, devId.c_str(), devId.c_str()); + + if (!GetDInputSourceProxy()) { + DHLOGE("UnregisterDistributedHardware client fail"); + return FAILURE_DIS; + } + + if (devId.empty() || dhId.empty() || callback == nullptr) { + return FAILURE; + } + + for (auto iter : dHardWareFwkUnRstInfos) { + if (iter.devId == devId && iter.dhId == dhId) { + return FAILURE_UNREGISTING; + } + } + + DHardWareFwkUnRegistInfo info; + info.devId = devId; + info.dhId = dhId; + info.callback = callback; + dHardWareFwkUnRstInfos.push_back(info); + + callbackUnregister = new(std::nothrow) UnregisterDInputCb(); + return dInputSourceProxy_->UnregisterDistributedHardware(devId, dhId, callbackUnregister); +} + +int32_t DistributedInputClient::PrepareRemoteInput( + const std::string& deviceId, sptr callback) +{ + DHLOGI("%s called, deviceId: %s", __func__, deviceId.c_str()); + + if (!GetDInputSourceProxy()) { + DHLOGE("PrepareRemoteInput client fail"); + return FAILURE_DIS; + } + + if (deviceId.empty() || callback == nullptr) { + return FAILURE; + } + + addWhiteListCallback = new(std::nothrow) AddWhiteListInfosCb(); + return dInputSourceProxy_->PrepareRemoteInput(deviceId, callback, addWhiteListCallback); +} + +int32_t DistributedInputClient::UnprepareRemoteInput( + const std::string& deviceId, sptr callback) +{ + DHLOGI("%s called, deviceId: %s", __func__, deviceId.c_str()); + + if (!GetDInputSourceProxy()) { + DHLOGE("PrepareRemoteInput client fail"); + return FAILURE_DIS; + } + + if (deviceId.empty() || callback == nullptr) { + return FAILURE; + } + + delWhiteListCallback = new(std::nothrow) DelWhiteListInfosCb(); + return dInputSourceProxy_->UnprepareRemoteInput(deviceId, callback, delWhiteListCallback); +} + +int32_t DistributedInputClient::StartRemoteInput( + const std::string& deviceId, const uint32_t& inputTypes, sptr callback) +{ + DHLOGI("%s called, deviceId: %s, inputTypes: %d", __func__, deviceId.c_str(), inputTypes); + + if (!GetDInputSourceProxy()) { + DHLOGE("StartRemoteInput client fail"); + return FAILURE_DIS; + } + + if (deviceId.empty() || callback == nullptr || + inputTypes > INPUT_TYPE_ALL || inputTypes == INPUT_TYPE_NULL || + !(inputTypes & INPUT_TYPE_ALL)) { + return FAILURE; + } + + return dInputSourceProxy_->StartRemoteInput(deviceId, inputTypes, callback); +} + +int32_t DistributedInputClient::StopRemoteInput( + const std::string& deviceId, const uint32_t& inputTypes, sptr callback) +{ + DHLOGI("%s called, deviceId: %s, inputTypes: %d", __func__, deviceId.c_str(), inputTypes); + + if (!GetDInputSourceProxy()) { + DHLOGE("StopRemoteInput client fail"); + return FAILURE_DIS; + } + + if (deviceId.empty() || callback == nullptr || + inputTypes > INPUT_TYPE_ALL || inputTypes == INPUT_TYPE_NULL || + !(inputTypes & INPUT_TYPE_ALL)) { + return FAILURE; + } + + return dInputSourceProxy_->StopRemoteInput(deviceId, inputTypes, callback); +} + +bool DistributedInputClient::IsNeedFilterOut(const std::string& deviceId, const BusinessEvent& event) +{ + DHLOGI("%s called, deviceId: %s", __func__, deviceId.c_str()); + if (serverType == DInputServerType::NULL_SERVER_TYPE) { + DHLOGE("No sa start using."); + return true; + } + + if (serverType == DInputServerType::SINK_SERVER_TYPE) { + if (m_bIsAlreadyInitWhiteList) { + return WhiteListUtil::GetInstance().IsNeedFilterOut(localDevId_, event); + } + + if (SUCCESS != WhiteListUtil::GetInstance().Init(localDevId_)) { + return true; + } + m_bIsAlreadyInitWhiteList = true; + + return WhiteListUtil::GetInstance().IsNeedFilterOut(localDevId_, event); + } + + return !WhiteListUtil::GetInstance().IsNeedFilterOut(deviceId, event); +} + +DInputServerType DistributedInputClient::IsStartDistributedInput(const uint32_t& inputType) +{ + DHLOGI("%s called, inputType: %d, inputTypes: %d, ", __func__, inputType, inputTypes); + int32_t retSource = 0; + int32_t retSink = 0; + + if (sourceTypeCallback == nullptr && GetDInputSourceProxy()) { + sourceTypeCallback = new(std::nothrow) StartDInputServerCb(); + retSource = dInputSourceProxy_->IsStartDistributedInput(inputType, sourceTypeCallback); + } + + if (sinkTypeCallback == nullptr && GetDInputSinkProxy()) { + sinkTypeCallback = new(std::nothrow) StartDInputServerCb(); + retSink = dInputSinkProxy_->IsStartDistributedInput(inputType, sinkTypeCallback); + } + + if (static_cast(retSource) != DInputServerType::NULL_SERVER_TYPE) { + serverType = DInputServerType::SOURCE_SERVER_TYPE; + } else if (static_cast(retSink) != DInputServerType::NULL_SERVER_TYPE) { + serverType = DInputServerType::SINK_SERVER_TYPE; + } + + if (inputType & inputTypes) { + return serverType; + } else { + return DInputServerType::NULL_SERVER_TYPE; + } +} + +bool DistributedInputClient::GetDInputSourceProxy() +{ + if (!dInputSourceProxy_) { + std::lock_guard lock(mutex_); + sptr systemAbilityManager = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + + if (!systemAbilityManager) { + return false; + } + + sptr remoteObject = systemAbilityManager->GetSystemAbility( + DISTRIBUTED_HARDWARE_INPUT_SOURCE_SA_ID); + if (!remoteObject) { + return false; + } + + dInputSourceProxy_ = iface_cast(remoteObject); + + if ((!dInputSourceProxy_) || (!dInputSourceProxy_->AsObject())) { + return false; + } + } + return true; +} + +bool DistributedInputClient::GetDInputSinkProxy() +{ + if (!dInputSinkProxy_) { + std::lock_guard lock(mutex_); + sptr systemAbilityManager = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (!systemAbilityManager) { + return false; + } + + sptr remoteObject = systemAbilityManager->GetSystemAbility( + DISTRIBUTED_HARDWARE_INPUT_SINK_SA_ID); + if (!remoteObject) { + return false; + } + + dInputSinkProxy_ = iface_cast(remoteObject); + + if ((!dInputSinkProxy_) || (!dInputSinkProxy_->AsObject())) { + return false; + } + } + return true; +} + +bool DistributedInputClient::IsJsonData(std::string strData) const +{ + if (strData[0] != '{') { + return false; + } + + int num = 1; + for (int i = 1; i < strData.length(); ++i) { + if (strData[i] == '{') { + ++num; + } else if (strData[i] == '}') { + --num; + } + if (num == 0) { + return true; + } + } + + return false; +} + +void DistributedInputClient::AddWhiteListInfos( + const std::string &deviceId, const std::string &strJson) const +{ + nlohmann::json inputData = nlohmann::json::parse(strJson); + int jsonSize = inputData.size(); + DHLOGI("AddWhiteListInfosCb OnResult json size:%d.\n", jsonSize); + TYPE_WHITE_LIST_VEC vecWhiteList = inputData; + WhiteListUtil::GetInstance().SyncWhiteList(deviceId, vecWhiteList); +} + +void DistributedInputClient::DelWhiteListInfos( + const std::string &deviceId) const +{ + WhiteListUtil::GetInstance().ClearWhiteList(deviceId); +} +} // namespace DistributedInput +} // namespace DistributedHardware +} // namespace OHOS diff --git a/interfaces/ipc/src/distributed_input_sink_proxy.cpp b/interfaces/ipc/src/distributed_input_sink_proxy.cpp new file mode 100644 index 0000000..424c455 --- /dev/null +++ b/interfaces/ipc/src/distributed_input_sink_proxy.cpp @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "distributed_input_sink_proxy.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +DistributedInputSinkProxy::DistributedInputSinkProxy(const sptr &object) + : IRemoteProxy(object) +{} + +DistributedInputSinkProxy::~DistributedInputSinkProxy() +{} + +int32_t DistributedInputSinkProxy::Init() +{ + MessageParcel data; + MessageParcel reply; + int32_t result = ERROR; + bool ret = SendRequest(IDistributedSinkInput::MessageCode::INIT, data, reply); + if (ret) { + result = reply.ReadInt32(); + } + return result; +} + +int32_t DistributedInputSinkProxy::Release() +{ + MessageParcel data; + MessageParcel reply; + int32_t result = ERROR; + bool ret = SendRequest(IDistributedSinkInput::MessageCode::RELEASE, data, reply); + if (ret) { + result = reply.ReadInt32(); + } + return result; +} + +int32_t DistributedInputSinkProxy::IsStartDistributedInput( + const uint32_t& inputType, sptr callback) +{ + MessageParcel data; + if (!data.WriteUint32(inputType)) { + return static_cast(DInputServerType::NULL_SERVER_TYPE); + } + if (!data.WriteRemoteObject(callback->AsObject())) { + return static_cast(DInputServerType::NULL_SERVER_TYPE); + } + MessageParcel reply; + int32_t result = ERROR; + bool ret = SendRequest(IDistributedSinkInput::MessageCode::ISSTART_REMOTE_INPUT, data, reply); + if (ret) { + result = reply.ReadInt32(); + } + return result; +} + +bool DistributedInputSinkProxy::SendRequest( + IDistributedSinkInput::MessageCode code, MessageParcel &data, MessageParcel &reply) +{ + sptr remote = Remote(); + if (remote == nullptr) { + return false; + } + MessageOption option(MessageOption::TF_SYNC); + int32_t result = remote->SendRequest(static_cast(code), data, reply, option); + if (result != OHOS::NO_ERROR) { + return false; + } + return true; +} +} // namespace DistributedInput +} // namespace DistributedHardware +} // namespace OHOS diff --git a/interfaces/ipc/src/distributed_input_sink_stub.cpp b/interfaces/ipc/src/distributed_input_sink_stub.cpp new file mode 100644 index 0000000..d2238b1 --- /dev/null +++ b/interfaces/ipc/src/distributed_input_sink_stub.cpp @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "distributed_input_sink_stub.h" +#include "constants_dinput.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +DistributedInputSinkStub::DistributedInputSinkStub() +{} + +DistributedInputSinkStub::~DistributedInputSinkStub() +{} + +int32_t DistributedInputSinkStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, + MessageOption &option) +{ + switch (code) { + case static_cast(IDistributedSinkInput::MessageCode::INIT): { + int32_t ret = Init(); + if (!reply.WriteInt32(ret)) { + return ERROR; + } + break; + } + + case static_cast(IDistributedSinkInput::MessageCode::RELEASE): { + int32_t ret = Release(); + if (!reply.WriteInt32(ret)) { + return ERROR; + } + break; + } + + case static_cast(IDistributedSinkInput::MessageCode::ISSTART_REMOTE_INPUT): { + uint32_t inputType = data.ReadUint32(); + sptr callback = + iface_cast(data.ReadRemoteObject()); + int32_t ret = IsStartDistributedInput(inputType, callback); + if (!reply.WriteInt32(ret)) { + return ERROR; + } + break; + } + default: + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); + } + return NO_ERROR; +} +} // namespace DistributedInput +} // namespace DistributedHardware +} // namespace OHOS diff --git a/interfaces/ipc/src/distributed_input_source_proxy.cpp b/interfaces/ipc/src/distributed_input_source_proxy.cpp new file mode 100644 index 0000000..007430e --- /dev/null +++ b/interfaces/ipc/src/distributed_input_source_proxy.cpp @@ -0,0 +1,226 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "distributed_input_source_proxy.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +const int32_t DISTRIBUTED_INPUT_DENIED = -1; + +DistributedInputSourceProxy::DistributedInputSourceProxy(const sptr &object) + : IRemoteProxy(object) +{} + +DistributedInputSourceProxy::~DistributedInputSourceProxy() +{} + +int32_t DistributedInputSourceProxy::Init() +{ + MessageParcel data; + MessageParcel reply; + int32_t result = ERROR; + bool ret = SendRequest(IDistributedSourceInput::MessageCode::INIT, data, reply); + if (ret) { + result = reply.ReadInt32(); + } + return result; +} + +int32_t DistributedInputSourceProxy::Release() +{ + MessageParcel data; + MessageParcel reply; + int32_t result = ERROR; + bool ret = SendRequest(IDistributedSourceInput::MessageCode::RELEASE, data, reply); + if (ret) { + result = reply.ReadInt32(); + } + return result; +} + +int32_t DistributedInputSourceProxy::RegisterDistributedHardware(const std::string& devId, const std::string& dhId, + const std::string& parameters, sptr callback) +{ + MessageParcel data; + if (!data.WriteString(devId)) { + return DISTRIBUTED_INPUT_DENIED; + } + if (!data.WriteString(dhId)) { + return DISTRIBUTED_INPUT_DENIED; + } + if (!data.WriteString(parameters)) { + return DISTRIBUTED_INPUT_DENIED; + } + if (!data.WriteRemoteObject(callback->AsObject())) { + return DISTRIBUTED_INPUT_DENIED; + } + MessageParcel reply; + int32_t result = ERROR; + bool ret = SendRequest(IDistributedSourceInput::MessageCode::REGISTER_REMOTE_INPUT, data, reply); + if (ret) { + result = reply.ReadInt32(); + } + return result; +} + +int32_t DistributedInputSourceProxy::UnregisterDistributedHardware(const std::string& devId, const std::string& dhId, + sptr callback) +{ + MessageParcel data; + if (!data.WriteString(devId)) { + return DISTRIBUTED_INPUT_DENIED; + } + if (!data.WriteString(dhId)) { + return DISTRIBUTED_INPUT_DENIED; + } + if (!data.WriteRemoteObject(callback->AsObject())) { + return DISTRIBUTED_INPUT_DENIED; + } + MessageParcel reply; + int32_t result = ERROR; + bool ret = SendRequest(IDistributedSourceInput::MessageCode::UNREGISTER_REMOTE_INPUT, data, reply); + if (ret) { + result = reply.ReadInt32(); + } + return result; +} + +int32_t DistributedInputSourceProxy::PrepareRemoteInput( + const std::string& deviceId, sptr callback, + sptr addWhiteListCallback) +{ + MessageParcel data; + if (!data.WriteString(deviceId)) { + return DISTRIBUTED_INPUT_DENIED; + } + if (!data.WriteRemoteObject(callback->AsObject())) { + return DISTRIBUTED_INPUT_DENIED; + } + if (!data.WriteRemoteObject(addWhiteListCallback->AsObject())) { + return DISTRIBUTED_INPUT_DENIED; + } + MessageParcel reply; + int32_t result = ERROR; + bool ret = SendRequest(IDistributedSourceInput::MessageCode::PREPARE_REMOTE_INPUT, data, reply); + if (ret) { + result = reply.ReadInt32(); + } + return result; +} + +int32_t DistributedInputSourceProxy::UnprepareRemoteInput( + const std::string& deviceId, sptr callback, + sptr delWhiteListCallback) +{ + MessageParcel data; + if (!data.WriteString(deviceId)) { + return DISTRIBUTED_INPUT_DENIED; + } + if (!data.WriteRemoteObject(callback->AsObject())) { + return DISTRIBUTED_INPUT_DENIED; + } + if (!data.WriteRemoteObject(delWhiteListCallback->AsObject())) { + return DISTRIBUTED_INPUT_DENIED; + } + MessageParcel reply; + int32_t result = ERROR; + bool ret = SendRequest(IDistributedSourceInput::MessageCode::UNPREPARE_REMOTE_INPUT, data, reply); + if (ret) { + result = reply.ReadInt32(); + } + return result; +} + +int32_t DistributedInputSourceProxy::StartRemoteInput( + const std::string& deviceId, const uint32_t& inputTypes, sptr callback) +{ + MessageParcel data; + if (!data.WriteString(deviceId)) { + return DISTRIBUTED_INPUT_DENIED; + } + if (!data.WriteUint32(inputTypes)) { + return DISTRIBUTED_INPUT_DENIED; + } + if (!data.WriteRemoteObject(callback->AsObject())) { + return DISTRIBUTED_INPUT_DENIED; + } + MessageParcel reply; + int32_t result = ERROR; + bool ret = SendRequest(IDistributedSourceInput::MessageCode::START_REMOTE_INPUT, data, reply); + if (ret) { + result = reply.ReadInt32(); + } + return result; +} + +int32_t DistributedInputSourceProxy::StopRemoteInput( + const std::string& deviceId, const uint32_t& inputTypes, sptr callback) +{ + MessageParcel data; + if (!data.WriteString(deviceId)) { + return DISTRIBUTED_INPUT_DENIED; + } + if (!data.WriteUint32(inputTypes)) { + return DISTRIBUTED_INPUT_DENIED; + } + if (!data.WriteRemoteObject(callback->AsObject())) { + return DISTRIBUTED_INPUT_DENIED; + } + MessageParcel reply; + int32_t result = ERROR; + bool ret = SendRequest(IDistributedSourceInput::MessageCode::STOP_REMOTE_INPUT, data, reply); + if (ret) { + result = reply.ReadInt32(); + } + return result; +} + +int32_t DistributedInputSourceProxy::IsStartDistributedInput( + const uint32_t& inputType, sptr callback) +{ + MessageParcel data; + if (!data.WriteUint32(inputType)) { + return static_cast(DInputServerType::NULL_SERVER_TYPE); + } + if (!data.WriteRemoteObject(callback->AsObject())) { + return static_cast(DInputServerType::NULL_SERVER_TYPE); + } + MessageParcel reply; + int32_t result = ERROR; + bool ret = SendRequest(IDistributedSourceInput::MessageCode::ISSTART_REMOTE_INPUT, data, reply); + if (ret) { + result = reply.ReadInt32(); + } + return result; +} + +bool DistributedInputSourceProxy::SendRequest( + const IDistributedSourceInput::MessageCode code, MessageParcel &data, MessageParcel &reply) +{ + sptr remote = Remote(); + if (remote == nullptr) { + return false; + } + MessageOption option(MessageOption::TF_SYNC); + int32_t result = remote->SendRequest(static_cast(code), data, reply, option); + if (result != OHOS::NO_ERROR) { + return false; + } + return true; +} +} // namespace DistributedInput +} // namespace DistributedHardware +} // namespace OHOS diff --git a/interfaces/ipc/src/distributed_input_source_stub.cpp b/interfaces/ipc/src/distributed_input_source_stub.cpp new file mode 100644 index 0000000..d23c05c --- /dev/null +++ b/interfaces/ipc/src/distributed_input_source_stub.cpp @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "distributed_input_source_stub.h" +#include "constants_dinput.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +DistributedInputSourceStub::DistributedInputSourceStub() +{} + +DistributedInputSourceStub::~DistributedInputSourceStub() +{} + +int32_t DistributedInputSourceStub::HandleRegisterDistributedHardware(MessageParcel &data, MessageParcel &reply) +{ + std::string devId = data.ReadString(); + std::string dhId = data.ReadString(); + std::string params = data.ReadString(); + sptr callback = iface_cast(data.ReadRemoteObject()); + int32_t ret = RegisterDistributedHardware(devId, dhId, params, callback); + if (!reply.WriteInt32(ret)) { + return ERROR; + } + return NO_ERROR; +} + +int32_t DistributedInputSourceStub::HandleUnregisterDistributedHardware(MessageParcel &data, MessageParcel &reply) +{ + std::string devId = data.ReadString(); + std::string dhId = data.ReadString(); + sptr callback = iface_cast(data.ReadRemoteObject()); + int32_t ret = UnregisterDistributedHardware(devId, dhId, callback); + if (!reply.WriteInt32(ret)) { + return ERROR; + } + return NO_ERROR; +} + +int32_t DistributedInputSourceStub::HandlePrepareRemoteInput(MessageParcel &data, MessageParcel &reply) +{ + std::string deviceId = data.ReadString(); + sptr callback = + iface_cast(data.ReadRemoteObject()); + sptr addCallback = + iface_cast(data.ReadRemoteObject()); + int32_t ret = PrepareRemoteInput(deviceId, callback, addCallback); + if (!reply.WriteInt32(ret)) { + return ERROR; + } + return NO_ERROR; +} + +int32_t DistributedInputSourceStub::HandleUnprepareRemoteInput(MessageParcel &data, MessageParcel &reply) +{ + std::string deviceId = data.ReadString(); + sptr callback = + iface_cast(data.ReadRemoteObject()); + sptr delCallback = + iface_cast(data.ReadRemoteObject()); + int32_t ret = UnprepareRemoteInput(deviceId, callback, delCallback); + if (!reply.WriteInt32(ret)) { + return ERROR; + } + return NO_ERROR; +} + +int32_t DistributedInputSourceStub::HandleStartRemoteInput(MessageParcel &data, MessageParcel &reply) +{ + std::string deviceId = data.ReadString(); + uint32_t inputTypes = data.ReadUint32(); + sptr callback = iface_cast(data.ReadRemoteObject()); + int32_t ret = StartRemoteInput(deviceId, inputTypes, callback); + if (!reply.WriteInt32(ret)) { + return ERROR; + } + return NO_ERROR; +} + +int32_t DistributedInputSourceStub::HandleStopRemoteInput(MessageParcel &data, MessageParcel &reply) +{ + std::string deviceId = data.ReadString(); + uint32_t inputTypes = data.ReadUint32(); + sptr callback = iface_cast(data.ReadRemoteObject()); + int32_t ret = StopRemoteInput(deviceId, inputTypes, callback); + if (!reply.WriteInt32(ret)) { + return ERROR; + } + return NO_ERROR; +} + +int32_t DistributedInputSourceStub::HandleIsStartDistributedInput(MessageParcel &data, MessageParcel &reply) +{ + uint32_t inputType = data.ReadUint32(); + sptr callback = iface_cast(data.ReadRemoteObject()); + int32_t ret = IsStartDistributedInput(inputType, callback); + if (!reply.WriteInt32(ret)) { + return ERROR; + } + return NO_ERROR; +} + +int32_t DistributedInputSourceStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, + MessageOption &option) +{ + switch (code) { + case static_cast(IDistributedSourceInput::MessageCode::INIT): { + int32_t ret = Init(); + if (!reply.WriteInt32(ret)) { + return ERROR; + } else { + return NO_ERROR; + } + break; + } + case static_cast(IDistributedSourceInput::MessageCode::RELEASE): { + int32_t ret = Release(); + if (!reply.WriteInt32(ret)) { + return ERROR; + } else { + return NO_ERROR; + } + break; + } + case static_cast(IDistributedSourceInput::MessageCode::REGISTER_REMOTE_INPUT): { + return HandleRegisterDistributedHardware(data, reply); + break; + } + case static_cast(IDistributedSourceInput::MessageCode::UNREGISTER_REMOTE_INPUT): { + return HandleUnregisterDistributedHardware(data, reply); + break; + } + case static_cast(IDistributedSourceInput::MessageCode::PREPARE_REMOTE_INPUT): { + return HandlePrepareRemoteInput(data, reply); + break; + } + case static_cast(IDistributedSourceInput::MessageCode::UNPREPARE_REMOTE_INPUT): { + return HandleUnprepareRemoteInput(data, reply); + break; + } + case static_cast(IDistributedSourceInput::MessageCode::START_REMOTE_INPUT): { + return HandleStartRemoteInput(data, reply); + break; + } + case static_cast(IDistributedSourceInput::MessageCode::STOP_REMOTE_INPUT): { + return HandleStopRemoteInput(data, reply); + break; + } + case static_cast(IDistributedSourceInput::MessageCode::ISSTART_REMOTE_INPUT): { + return HandleIsStartDistributedInput(data, reply); + break; + } + default: + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); + } +} +} // namespace DistributedInput +} // namespace DistributedHardware +} // namespace OHOS diff --git a/interfaces/ipc/src/prepare_d_input_call_back_proxy.cpp b/interfaces/ipc/src/prepare_d_input_call_back_proxy.cpp new file mode 100644 index 0000000..805a053 --- /dev/null +++ b/interfaces/ipc/src/prepare_d_input_call_back_proxy.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "prepare_d_input_call_back_proxy.h" +#include "ipc_types.h" +#include "parcel.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +PrepareDInputCallbackProxy::PrepareDInputCallbackProxy(const sptr &object) + : IRemoteProxy(object) +{ +} + +PrepareDInputCallbackProxy::~PrepareDInputCallbackProxy() +{ +} + +void PrepareDInputCallbackProxy::OnResult(const std::string& deviceId, const int32_t& status) +{ + sptr remote = Remote(); + if (remote == nullptr) { + return; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + data.WriteInterfaceToken(IPrepareDInputCallback::GetDescriptor()); + if (!data.WriteString(deviceId)) { + return; + } + if (!data.WriteInt32(status)) { + return; + } + int32_t ret = remote->SendRequest( + static_cast(IPrepareDInputCallback::Message::RESULT), data, reply, option); + if (ret != 0) { + return; + } +} +} // namespace DistributedHardware +} // namespace DistributedInput +} // namespace OHOS diff --git a/interfaces/ipc/src/prepare_d_input_call_back_stub.cpp b/interfaces/ipc/src/prepare_d_input_call_back_stub.cpp new file mode 100644 index 0000000..0209641 --- /dev/null +++ b/interfaces/ipc/src/prepare_d_input_call_back_stub.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "prepare_d_input_call_back_stub.h" +#include "string_ex.h" +#include "constants_dinput.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +PrepareDInputCallbackStub::PrepareDInputCallbackStub() +{ +} + +PrepareDInputCallbackStub::~PrepareDInputCallbackStub() +{ +} + +int32_t PrepareDInputCallbackStub::OnRemoteRequest( + uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) +{ + std::u16string descriptor = data.ReadInterfaceToken(); + if (descriptor != IPrepareDInputCallback::GetDescriptor()) { + return ERROR; + } + IPrepareDInputCallback::Message msgCode = static_cast(code); + switch (msgCode) { + case IPrepareDInputCallback::Message::RESULT: { + std::string deviceId = data.ReadString(); + int32_t status = data.ReadInt32(); + OnResult(deviceId, status); + break; + } + default: + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); + } + return NO_ERROR; +} +} // namespace DistributedHardware +} // namespace DistributedInput +} // namespace OHOS diff --git a/interfaces/ipc/src/register_d_input_call_back_proxy.cpp b/interfaces/ipc/src/register_d_input_call_back_proxy.cpp new file mode 100644 index 0000000..8874c04 --- /dev/null +++ b/interfaces/ipc/src/register_d_input_call_back_proxy.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "register_d_input_call_back_proxy.h" +#include "ipc_types.h" +#include "parcel.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +RegisterDInputCallbackProxy::RegisterDInputCallbackProxy(const sptr &object) + : IRemoteProxy(object) +{ +} + +RegisterDInputCallbackProxy::~RegisterDInputCallbackProxy() +{ +} + +void RegisterDInputCallbackProxy::OnResult(const std::string& devId, const std::string& dhId, const int32_t& status) +{ + sptr remote = Remote(); + if (remote == nullptr) { + return; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + data.WriteInterfaceToken(IRegisterDInputCallback::GetDescriptor()); + if (!data.WriteString(devId)) { + return; + } + if (!data.WriteString(dhId)) { + return; + } + if (!data.WriteInt32(status)) { + return; + } + int32_t ret = remote->SendRequest( + static_cast(IRegisterDInputCallback::Message::RESULT), data, reply, option); + if (ret != 0) { + return; + } +} +} // namespace DistributedHardware +} // namespace DistributedInput +} // namespace OHOS diff --git a/interfaces/ipc/src/register_d_input_call_back_stub.cpp b/interfaces/ipc/src/register_d_input_call_back_stub.cpp new file mode 100644 index 0000000..a2dd517 --- /dev/null +++ b/interfaces/ipc/src/register_d_input_call_back_stub.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "register_d_input_call_back_stub.h" +#include "string_ex.h" +#include "constants_dinput.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +RegisterDInputCallbackStub::RegisterDInputCallbackStub() +{ +} + +RegisterDInputCallbackStub::~RegisterDInputCallbackStub() +{ +} + +int32_t RegisterDInputCallbackStub::OnRemoteRequest( + uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) +{ + std::u16string descriptor = data.ReadInterfaceToken(); + if (descriptor != IRegisterDInputCallback::GetDescriptor()) { + return ERROR; + } + IRegisterDInputCallback::Message msgCode = static_cast(code); + switch (msgCode) { + case IRegisterDInputCallback::Message::RESULT: { + std::string devId = data.ReadString(); + std::string dhId = data.ReadString(); + int32_t status = data.ReadInt32(); + OnResult(devId, dhId, status); + break; + } + default: + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); + } + return NO_ERROR; +} +} // namespace DistributedHardware +} // namespace DistributedInput +} // namespace OHOS diff --git a/interfaces/ipc/src/start_d_input_call_back_proxy.cpp b/interfaces/ipc/src/start_d_input_call_back_proxy.cpp new file mode 100644 index 0000000..d8eeceb --- /dev/null +++ b/interfaces/ipc/src/start_d_input_call_back_proxy.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "start_d_input_call_back_proxy.h" +#include "ipc_types.h" +#include "parcel.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +StartDInputCallbackProxy::StartDInputCallbackProxy(const sptr &object) + : IRemoteProxy(object) +{ +} + +StartDInputCallbackProxy::~StartDInputCallbackProxy() +{ +} + +void StartDInputCallbackProxy::OnResult(const std::string& devId, const uint32_t& inputTypes, const int32_t& status) +{ + sptr remote = Remote(); + if (remote == nullptr) { + return; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + data.WriteInterfaceToken(IStartDInputCallback::GetDescriptor()); + if (!data.WriteString(devId)) { + return; + } + if (!data.WriteUint32(inputTypes)) { + return; + } + if (!data.WriteInt32(status)) { + return; + } + int32_t ret = remote->SendRequest( + static_cast(IStartDInputCallback::Message::RESULT), data, reply, option); + if (ret != 0) { + return; + } +} +} // namespace DistributedHardware +} // namespace DistributedInput +} // namespace OHOS diff --git a/interfaces/ipc/src/start_d_input_call_back_stub.cpp b/interfaces/ipc/src/start_d_input_call_back_stub.cpp new file mode 100644 index 0000000..9c13630 --- /dev/null +++ b/interfaces/ipc/src/start_d_input_call_back_stub.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "start_d_input_call_back_stub.h" +#include "string_ex.h" +#include "constants_dinput.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +StartDInputCallbackStub::StartDInputCallbackStub() +{ +} + +StartDInputCallbackStub::~StartDInputCallbackStub() +{ +} + +int32_t StartDInputCallbackStub::OnRemoteRequest( + uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) +{ + std::u16string descriptor = data.ReadInterfaceToken(); + if (descriptor != IStartDInputCallback::GetDescriptor()) { + return ERROR; + } + IStartDInputCallback::Message msgCode = static_cast(code); + switch (msgCode) { + case IStartDInputCallback::Message::RESULT: { + std::string deviceId = data.ReadString(); + uint32_t inputTypes = data.ReadUint32(); + int32_t status = data.ReadInt32(); + OnResult(deviceId, inputTypes, status); + break; + } + default: + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); + } + return NO_ERROR; +} +} // namespace DistributedHardware +} // namespace DistributedInput +} // namespace OHOS diff --git a/interfaces/ipc/src/start_d_input_server_call_back_proxy.cpp b/interfaces/ipc/src/start_d_input_server_call_back_proxy.cpp new file mode 100644 index 0000000..fa20da1 --- /dev/null +++ b/interfaces/ipc/src/start_d_input_server_call_back_proxy.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "start_d_input_server_call_back_proxy.h" +#include "ipc_types.h" +#include "parcel.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +StartDInputServerCallbackProxy::StartDInputServerCallbackProxy(const sptr &object) + : IRemoteProxy(object) +{ +} + +StartDInputServerCallbackProxy::~StartDInputServerCallbackProxy() +{ +} + +void StartDInputServerCallbackProxy::OnResult(const int32_t& status, const uint32_t& inputTypes) +{ + sptr remote = Remote(); + if (remote == nullptr) { + return; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + data.WriteInterfaceToken(IStartDInputServerCallback::GetDescriptor()); + if (!data.WriteInt32(status)) { + return; + } + if (!data.WriteUint32(inputTypes)) { + return; + } + int32_t ret = remote->SendRequest( + static_cast(IStartDInputServerCallback::Message::RESULT), data, reply, option); + if (ret != 0) { + return; + } +} +} // namespace DistributedHardware +} // namespace DistributedInput +} // namespace OHOS diff --git a/interfaces/ipc/src/start_d_input_server_call_back_stub.cpp b/interfaces/ipc/src/start_d_input_server_call_back_stub.cpp new file mode 100644 index 0000000..d957c03 --- /dev/null +++ b/interfaces/ipc/src/start_d_input_server_call_back_stub.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "start_d_input_server_call_back_stub.h" +#include "string_ex.h" +#include "constants_dinput.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +StartDInputServerCallbackStub::StartDInputServerCallbackStub() +{ +} + +StartDInputServerCallbackStub::~StartDInputServerCallbackStub() +{ +} + +int32_t StartDInputServerCallbackStub::OnRemoteRequest( + uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) +{ + std::u16string descriptor = data.ReadInterfaceToken(); + if (descriptor != IStartDInputServerCallback::GetDescriptor()) { + return ERROR; + } + IStartDInputServerCallback::Message msgCode = static_cast(code); + switch (msgCode) { + case IStartDInputServerCallback::Message::RESULT: { + int32_t status = data.ReadInt32(); + uint32_t inputTypes = data.ReadUint32(); + OnResult(status, inputTypes); + break; + } + default: + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); + } + return NO_ERROR; +} +} // namespace DistributedHardware +} // namespace DistributedInput +} // namespace OHOS diff --git a/interfaces/ipc/src/stop_d_input_call_back_proxy.cpp b/interfaces/ipc/src/stop_d_input_call_back_proxy.cpp new file mode 100644 index 0000000..b028713 --- /dev/null +++ b/interfaces/ipc/src/stop_d_input_call_back_proxy.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "stop_d_input_call_back_proxy.h" +#include "ipc_types.h" +#include "parcel.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +StopDInputCallbackProxy::StopDInputCallbackProxy(const sptr &object) + : IRemoteProxy(object) +{ +} + +StopDInputCallbackProxy::~StopDInputCallbackProxy() +{ +} + +void StopDInputCallbackProxy::OnResult(const std::string& devId, const uint32_t& inputTypes, const int32_t& status) +{ + sptr remote = Remote(); + if (remote == nullptr) { + return; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + data.WriteInterfaceToken(IStopDInputCallback::GetDescriptor()); + if (!data.WriteString(devId)) { + return; + } + if (!data.WriteUint32(inputTypes)) { + return; + } + if (!data.WriteInt32(status)) { + return; + } + int32_t ret = remote->SendRequest( + static_cast(IStopDInputCallback::Message::RESULT), data, reply, option); + if (ret != 0) { + return; + } +} +} // namespace DistributedHardware +} // namespace DistributedInput +} // namespace OHOS diff --git a/interfaces/ipc/src/stop_d_input_call_back_stub.cpp b/interfaces/ipc/src/stop_d_input_call_back_stub.cpp new file mode 100644 index 0000000..0b7fb10 --- /dev/null +++ b/interfaces/ipc/src/stop_d_input_call_back_stub.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "stop_d_input_call_back_stub.h" +#include "string_ex.h" +#include "constants_dinput.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +StopDInputCallbackStub::StopDInputCallbackStub() +{ +} + +StopDInputCallbackStub::~StopDInputCallbackStub() +{ +} + +int32_t StopDInputCallbackStub::OnRemoteRequest( + uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) +{ + std::u16string descriptor = data.ReadInterfaceToken(); + if (descriptor != IStopDInputCallback::GetDescriptor()) { + return ERROR; + } + IStopDInputCallback::Message msgCode = static_cast(code); + switch (msgCode) { + case IStopDInputCallback::Message::RESULT: { + std::string deviceId = data.ReadString(); + uint32_t inputTypes = data.ReadUint32(); + int32_t status = data.ReadInt32(); + OnResult(deviceId, inputTypes, status); + break; + } + default: + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); + } + return NO_ERROR; +} +} // namespace DistributedHardware +} // namespace DistributedInput +} // namespace OHOS diff --git a/interfaces/ipc/src/unprepare_d_input_call_back_proxy.cpp b/interfaces/ipc/src/unprepare_d_input_call_back_proxy.cpp new file mode 100644 index 0000000..d1d1bc7 --- /dev/null +++ b/interfaces/ipc/src/unprepare_d_input_call_back_proxy.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "unprepare_d_input_call_back_proxy.h" +#include "ipc_types.h" +#include "parcel.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +UnprepareDInputCallbackProxy::UnprepareDInputCallbackProxy(const sptr &object) + : IRemoteProxy(object) +{ +} + +UnprepareDInputCallbackProxy::~UnprepareDInputCallbackProxy() +{ +} + +void UnprepareDInputCallbackProxy::OnResult(const std::string& deviceId, const int32_t& status) +{ + sptr remote = Remote(); + if (remote == nullptr) { + return; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + data.WriteInterfaceToken(IUnprepareDInputCallback::GetDescriptor()); + if (!data.WriteString(deviceId)) { + return; + } + if (!data.WriteInt32(status)) { + return; + } + int32_t ret = remote->SendRequest( + static_cast(IUnprepareDInputCallback::Message::RESULT), data, reply, option); + if (ret != 0) { + return; + } +} +} // namespace DistributedHardware +} // namespace DistributedInput +} // namespace OHOS diff --git a/interfaces/ipc/src/unprepare_d_input_call_back_stub.cpp b/interfaces/ipc/src/unprepare_d_input_call_back_stub.cpp new file mode 100644 index 0000000..68e9c1e --- /dev/null +++ b/interfaces/ipc/src/unprepare_d_input_call_back_stub.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "unprepare_d_input_call_back_stub.h" +#include "string_ex.h" +#include "constants_dinput.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +UnprepareDInputCallbackStub::UnprepareDInputCallbackStub() +{ +} + +UnprepareDInputCallbackStub::~UnprepareDInputCallbackStub() +{ +} + +int32_t UnprepareDInputCallbackStub::OnRemoteRequest( + uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) +{ + std::u16string descriptor = data.ReadInterfaceToken(); + if (descriptor != IUnprepareDInputCallback::GetDescriptor()) { + return ERROR; + } + IUnprepareDInputCallback::Message msgCode = static_cast(code); + switch (msgCode) { + case IUnprepareDInputCallback::Message::RESULT: { + std::string deviceId = data.ReadString(); + int32_t status = data.ReadInt32(); + OnResult(deviceId, status); + break; + } + default: + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); + } + return NO_ERROR; +} +} // namespace DistributedHardware +} // namespace DistributedInput +} // namespace OHOS diff --git a/interfaces/ipc/src/unregister_d_input_call_back_proxy.cpp b/interfaces/ipc/src/unregister_d_input_call_back_proxy.cpp new file mode 100644 index 0000000..8047555 --- /dev/null +++ b/interfaces/ipc/src/unregister_d_input_call_back_proxy.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "unregister_d_input_call_back_proxy.h" +#include "ipc_types.h" +#include "parcel.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +UnregisterDInputCallbackProxy::UnregisterDInputCallbackProxy(const sptr &object) + : IRemoteProxy(object) +{ +} + +UnregisterDInputCallbackProxy::~UnregisterDInputCallbackProxy() +{ +} + +void UnregisterDInputCallbackProxy::OnResult(const std::string& devId, const std::string& dhId, const int32_t& status) +{ + sptr remote = Remote(); + if (remote == nullptr) { + return; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + data.WriteInterfaceToken(IUnregisterDInputCallback::GetDescriptor()); + if (!data.WriteString(devId)) { + return; + } + if (!data.WriteString(dhId)) { + return; + } + if (!data.WriteInt32(status)) { + return; + } + int32_t ret = remote->SendRequest( + static_cast(IUnregisterDInputCallback::Message::RESULT), data, reply, option); + if (ret != 0) { + return; + } +} +} // namespace DistributedHardware +} // namespace DistributedInput +} // namespace OHOS diff --git a/interfaces/ipc/src/unregister_d_input_call_back_stub.cpp b/interfaces/ipc/src/unregister_d_input_call_back_stub.cpp new file mode 100644 index 0000000..6ac2e4d --- /dev/null +++ b/interfaces/ipc/src/unregister_d_input_call_back_stub.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "unregister_d_input_call_back_stub.h" +#include "string_ex.h" +#include "constants_dinput.h" + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +UnregisterDInputCallbackStub::UnregisterDInputCallbackStub() +{ +} + +UnregisterDInputCallbackStub::~UnregisterDInputCallbackStub() +{ +} + +int32_t UnregisterDInputCallbackStub::OnRemoteRequest( + uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) +{ + std::u16string descriptor = data.ReadInterfaceToken(); + if (descriptor != IUnregisterDInputCallback::GetDescriptor()) { + return ERROR; + } + IUnregisterDInputCallback::Message msgCode = static_cast(code); + switch (msgCode) { + case IUnregisterDInputCallback::Message::RESULT: { + std::string devId = data.ReadString(); + std::string dhId = data.ReadString(); + int32_t status = data.ReadInt32(); + OnResult(devId, dhId, status); + break; + } + default: + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); + } + return NO_ERROR; +} +} // namespace DistributedHardware +} // namespace DistributedInput +} // namespace OHOS