mirror of
https://github.com/openharmony/distributedhardware_distributed_input.git
synced 2026-07-19 17:43:35 -04:00
Description: add dinput
Match-id-27cd4c64b9af561329bcdbc4f04fcdbcf06d955a
This commit is contained in:
@@ -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<IRemoteObject> &object)
|
||||
: IRemoteProxy<IAddWhiteListInfosCallback>(object)
|
||||
{
|
||||
}
|
||||
|
||||
AddWhiteListInfosCallbackProxy::~AddWhiteListInfosCallbackProxy()
|
||||
{
|
||||
}
|
||||
|
||||
void AddWhiteListInfosCallbackProxy::OnResult(const std::string& deviceId, const std::string& strJson)
|
||||
{
|
||||
sptr<IRemoteObject> 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<int32_t>(IAddWhiteListInfosCallback::Message::RESULT), data, reply, option);
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace DistributedInput
|
||||
} // namespace OHOS
|
||||
@@ -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<IAddWhiteListInfosCallback::Message>(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
|
||||
@@ -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<IRemoteObject> &object)
|
||||
: IRemoteProxy<IDelWhiteListInfosCallback>(object)
|
||||
{
|
||||
}
|
||||
|
||||
DelWhiteListInfosCallbackProxy::~DelWhiteListInfosCallbackProxy()
|
||||
{
|
||||
}
|
||||
|
||||
void DelWhiteListInfosCallbackProxy::OnResult(const std::string& deviceId)
|
||||
{
|
||||
sptr<IRemoteObject> 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<int32_t>(IDelWhiteListInfosCallback::Message::RESULT), data, reply, option);
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace DistributedInput
|
||||
} // namespace OHOS
|
||||
@@ -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<IDelWhiteListInfosCallback::Message>(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
|
||||
@@ -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 <iservice_registry.h>
|
||||
#include <system_ability_definition.h>
|
||||
#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<DHardWareFwkRegistInfo>::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<DHardWareFwkUnRegistInfo>::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<DInputServerType>(status)) {
|
||||
DistributedInputClient::GetInstance().serverType = DInputServerType::SOURCE_SERVER_TYPE;
|
||||
DistributedInputClient::GetInstance().inputTypes = inputTypes;
|
||||
} else if (DInputServerType::SINK_SERVER_TYPE == static_cast<DInputServerType>(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<RegisterCallback>& 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<UnregisterCallback>& 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<IPrepareDInputCallback> 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<IUnprepareDInputCallback> 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<IStartDInputCallback> 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<IStopDInputCallback> 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<DInputServerType>(retSource) != DInputServerType::NULL_SERVER_TYPE) {
|
||||
serverType = DInputServerType::SOURCE_SERVER_TYPE;
|
||||
} else if (static_cast<DInputServerType>(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<std::mutex> lock(mutex_);
|
||||
sptr<ISystemAbilityManager> systemAbilityManager =
|
||||
SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
|
||||
if (!systemAbilityManager) {
|
||||
return false;
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> remoteObject = systemAbilityManager->GetSystemAbility(
|
||||
DISTRIBUTED_HARDWARE_INPUT_SOURCE_SA_ID);
|
||||
if (!remoteObject) {
|
||||
return false;
|
||||
}
|
||||
|
||||
dInputSourceProxy_ = iface_cast<IDistributedSourceInput>(remoteObject);
|
||||
|
||||
if ((!dInputSourceProxy_) || (!dInputSourceProxy_->AsObject())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DistributedInputClient::GetDInputSinkProxy()
|
||||
{
|
||||
if (!dInputSinkProxy_) {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
sptr<ISystemAbilityManager> systemAbilityManager =
|
||||
SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (!systemAbilityManager) {
|
||||
return false;
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> remoteObject = systemAbilityManager->GetSystemAbility(
|
||||
DISTRIBUTED_HARDWARE_INPUT_SINK_SA_ID);
|
||||
if (!remoteObject) {
|
||||
return false;
|
||||
}
|
||||
|
||||
dInputSinkProxy_ = iface_cast<IDistributedSinkInput>(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
|
||||
@@ -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<IRemoteObject> &object)
|
||||
: IRemoteProxy<IDistributedSinkInput>(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<IStartDInputServerCallback> callback)
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!data.WriteUint32(inputType)) {
|
||||
return static_cast<int32_t>(DInputServerType::NULL_SERVER_TYPE);
|
||||
}
|
||||
if (!data.WriteRemoteObject(callback->AsObject())) {
|
||||
return static_cast<int32_t>(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<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
return false;
|
||||
}
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
int32_t result = remote->SendRequest(static_cast<uint32_t>(code), data, reply, option);
|
||||
if (result != OHOS::NO_ERROR) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace DistributedInput
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
@@ -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<uint32_t>(IDistributedSinkInput::MessageCode::INIT): {
|
||||
int32_t ret = Init();
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
return ERROR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case static_cast<uint32_t>(IDistributedSinkInput::MessageCode::RELEASE): {
|
||||
int32_t ret = Release();
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
return ERROR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case static_cast<uint32_t>(IDistributedSinkInput::MessageCode::ISSTART_REMOTE_INPUT): {
|
||||
uint32_t inputType = data.ReadUint32();
|
||||
sptr<IStartDInputServerCallback> callback =
|
||||
iface_cast<IStartDInputServerCallback>(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
|
||||
@@ -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<IRemoteObject> &object)
|
||||
: IRemoteProxy<IDistributedSourceInput>(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<IRegisterDInputCallback> 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<IUnregisterDInputCallback> 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<IPrepareDInputCallback> callback,
|
||||
sptr<IAddWhiteListInfosCallback> 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<IUnprepareDInputCallback> callback,
|
||||
sptr<IDelWhiteListInfosCallback> 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<IStartDInputCallback> 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<IStopDInputCallback> 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<IStartDInputServerCallback> callback)
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!data.WriteUint32(inputType)) {
|
||||
return static_cast<int32_t>(DInputServerType::NULL_SERVER_TYPE);
|
||||
}
|
||||
if (!data.WriteRemoteObject(callback->AsObject())) {
|
||||
return static_cast<int32_t>(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<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
return false;
|
||||
}
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
int32_t result = remote->SendRequest(static_cast<uint32_t>(code), data, reply, option);
|
||||
if (result != OHOS::NO_ERROR) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace DistributedInput
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
@@ -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<IRegisterDInputCallback> callback = iface_cast<IRegisterDInputCallback>(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<IUnregisterDInputCallback> callback = iface_cast<IUnregisterDInputCallback>(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<IPrepareDInputCallback> callback =
|
||||
iface_cast<IPrepareDInputCallback>(data.ReadRemoteObject());
|
||||
sptr<IAddWhiteListInfosCallback> addCallback =
|
||||
iface_cast<IAddWhiteListInfosCallback>(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<IUnprepareDInputCallback> callback =
|
||||
iface_cast<IUnprepareDInputCallback>(data.ReadRemoteObject());
|
||||
sptr<IDelWhiteListInfosCallback> delCallback =
|
||||
iface_cast<IDelWhiteListInfosCallback>(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<IStartDInputCallback> callback = iface_cast<IStartDInputCallback>(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<IStopDInputCallback> callback = iface_cast<IStopDInputCallback>(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<IStartDInputServerCallback> callback = iface_cast<IStartDInputServerCallback>(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<uint32_t>(IDistributedSourceInput::MessageCode::INIT): {
|
||||
int32_t ret = Init();
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
return ERROR;
|
||||
} else {
|
||||
return NO_ERROR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case static_cast<uint32_t>(IDistributedSourceInput::MessageCode::RELEASE): {
|
||||
int32_t ret = Release();
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
return ERROR;
|
||||
} else {
|
||||
return NO_ERROR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case static_cast<uint32_t>(IDistributedSourceInput::MessageCode::REGISTER_REMOTE_INPUT): {
|
||||
return HandleRegisterDistributedHardware(data, reply);
|
||||
break;
|
||||
}
|
||||
case static_cast<uint32_t>(IDistributedSourceInput::MessageCode::UNREGISTER_REMOTE_INPUT): {
|
||||
return HandleUnregisterDistributedHardware(data, reply);
|
||||
break;
|
||||
}
|
||||
case static_cast<uint32_t>(IDistributedSourceInput::MessageCode::PREPARE_REMOTE_INPUT): {
|
||||
return HandlePrepareRemoteInput(data, reply);
|
||||
break;
|
||||
}
|
||||
case static_cast<uint32_t>(IDistributedSourceInput::MessageCode::UNPREPARE_REMOTE_INPUT): {
|
||||
return HandleUnprepareRemoteInput(data, reply);
|
||||
break;
|
||||
}
|
||||
case static_cast<uint32_t>(IDistributedSourceInput::MessageCode::START_REMOTE_INPUT): {
|
||||
return HandleStartRemoteInput(data, reply);
|
||||
break;
|
||||
}
|
||||
case static_cast<uint32_t>(IDistributedSourceInput::MessageCode::STOP_REMOTE_INPUT): {
|
||||
return HandleStopRemoteInput(data, reply);
|
||||
break;
|
||||
}
|
||||
case static_cast<uint32_t>(IDistributedSourceInput::MessageCode::ISSTART_REMOTE_INPUT): {
|
||||
return HandleIsStartDistributedInput(data, reply);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
}
|
||||
} // namespace DistributedInput
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
@@ -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<IRemoteObject> &object)
|
||||
: IRemoteProxy<IPrepareDInputCallback>(object)
|
||||
{
|
||||
}
|
||||
|
||||
PrepareDInputCallbackProxy::~PrepareDInputCallbackProxy()
|
||||
{
|
||||
}
|
||||
|
||||
void PrepareDInputCallbackProxy::OnResult(const std::string& deviceId, const int32_t& status)
|
||||
{
|
||||
sptr<IRemoteObject> 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<int32_t>(IPrepareDInputCallback::Message::RESULT), data, reply, option);
|
||||
if (ret != 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace DistributedInput
|
||||
} // namespace OHOS
|
||||
@@ -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<IPrepareDInputCallback::Message>(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
|
||||
@@ -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<IRemoteObject> &object)
|
||||
: IRemoteProxy<IRegisterDInputCallback>(object)
|
||||
{
|
||||
}
|
||||
|
||||
RegisterDInputCallbackProxy::~RegisterDInputCallbackProxy()
|
||||
{
|
||||
}
|
||||
|
||||
void RegisterDInputCallbackProxy::OnResult(const std::string& devId, const std::string& dhId, const int32_t& status)
|
||||
{
|
||||
sptr<IRemoteObject> 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<int32_t>(IRegisterDInputCallback::Message::RESULT), data, reply, option);
|
||||
if (ret != 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace DistributedInput
|
||||
} // namespace OHOS
|
||||
@@ -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<IRegisterDInputCallback::Message>(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
|
||||
@@ -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<IRemoteObject> &object)
|
||||
: IRemoteProxy<IStartDInputCallback>(object)
|
||||
{
|
||||
}
|
||||
|
||||
StartDInputCallbackProxy::~StartDInputCallbackProxy()
|
||||
{
|
||||
}
|
||||
|
||||
void StartDInputCallbackProxy::OnResult(const std::string& devId, const uint32_t& inputTypes, const int32_t& status)
|
||||
{
|
||||
sptr<IRemoteObject> 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<int32_t>(IStartDInputCallback::Message::RESULT), data, reply, option);
|
||||
if (ret != 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace DistributedInput
|
||||
} // namespace OHOS
|
||||
@@ -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<IStartDInputCallback::Message>(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
|
||||
@@ -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<IRemoteObject> &object)
|
||||
: IRemoteProxy<IStartDInputServerCallback>(object)
|
||||
{
|
||||
}
|
||||
|
||||
StartDInputServerCallbackProxy::~StartDInputServerCallbackProxy()
|
||||
{
|
||||
}
|
||||
|
||||
void StartDInputServerCallbackProxy::OnResult(const int32_t& status, const uint32_t& inputTypes)
|
||||
{
|
||||
sptr<IRemoteObject> 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<int32_t>(IStartDInputServerCallback::Message::RESULT), data, reply, option);
|
||||
if (ret != 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace DistributedInput
|
||||
} // namespace OHOS
|
||||
@@ -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<IStartDInputServerCallback::Message>(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
|
||||
@@ -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<IRemoteObject> &object)
|
||||
: IRemoteProxy<IStopDInputCallback>(object)
|
||||
{
|
||||
}
|
||||
|
||||
StopDInputCallbackProxy::~StopDInputCallbackProxy()
|
||||
{
|
||||
}
|
||||
|
||||
void StopDInputCallbackProxy::OnResult(const std::string& devId, const uint32_t& inputTypes, const int32_t& status)
|
||||
{
|
||||
sptr<IRemoteObject> 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<int32_t>(IStopDInputCallback::Message::RESULT), data, reply, option);
|
||||
if (ret != 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace DistributedInput
|
||||
} // namespace OHOS
|
||||
@@ -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<IStopDInputCallback::Message>(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
|
||||
@@ -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<IRemoteObject> &object)
|
||||
: IRemoteProxy<IUnprepareDInputCallback>(object)
|
||||
{
|
||||
}
|
||||
|
||||
UnprepareDInputCallbackProxy::~UnprepareDInputCallbackProxy()
|
||||
{
|
||||
}
|
||||
|
||||
void UnprepareDInputCallbackProxy::OnResult(const std::string& deviceId, const int32_t& status)
|
||||
{
|
||||
sptr<IRemoteObject> 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<int32_t>(IUnprepareDInputCallback::Message::RESULT), data, reply, option);
|
||||
if (ret != 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace DistributedInput
|
||||
} // namespace OHOS
|
||||
@@ -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<IUnprepareDInputCallback::Message>(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
|
||||
@@ -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<IRemoteObject> &object)
|
||||
: IRemoteProxy<IUnregisterDInputCallback>(object)
|
||||
{
|
||||
}
|
||||
|
||||
UnregisterDInputCallbackProxy::~UnregisterDInputCallbackProxy()
|
||||
{
|
||||
}
|
||||
|
||||
void UnregisterDInputCallbackProxy::OnResult(const std::string& devId, const std::string& dhId, const int32_t& status)
|
||||
{
|
||||
sptr<IRemoteObject> 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<int32_t>(IUnregisterDInputCallback::Message::RESULT), data, reply, option);
|
||||
if (ret != 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace DistributedInput
|
||||
} // namespace OHOS
|
||||
@@ -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<IUnregisterDInputCallback::Message>(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
|
||||
Reference in New Issue
Block a user