Description: modify dinput PartI and PartII conflit

Match-id-95701c9f395e01f22f32df0471d2b2e76d2edc0f
This commit is contained in:
xxxx
2022-08-30 21:21:57 +08:00
parent da85b1dfbc
commit f0cc34789c
43 changed files with 465 additions and 537 deletions
+2
View File
@@ -164,6 +164,8 @@ namespace DistributedInput {
constexpr int32_t ERR_DH_INPUT_NOTIFY_STOP_DSCREEN_FAIL = -67051;
constexpr int32_t ERR_DH_INPUT_RPC_REPLY_FAIL = -67052;
constexpr int32_t ERR_DH_INPUT_SA_REQUEST_CODE_INVALID = -67053;
constexpr int32_t ERR_DH_INPUT_SINK_PROXY_REGISTER_SHARING_DHID_LISTENER_FAIL = -67054;
constexpr int32_t ERR_DH_INPUT_SINK_STUB_REGISTER_SHARING_DHID_LISTENER_FAIL = -67055;
// Hidump Helper error code
constexpr int32_t ERR_DH_INPUT_HIDUMP_INVALID_ARGS = -68000;
+22 -6
View File
@@ -938,18 +938,30 @@ bool InputHub::IsSupportInputTypes(uint32_t classes)
return classes & inputTypes_;
}
void InputHub::SetSupportInputType(const uint32_t &inputTypes)
void InputHub::SaveAffectDhId(bool isEnable, const std::string &dhId, AffectDhIds &affDhIds)
{
if (isEnable) {
affDhIds.sharingDhIds.push_back(dhId);
} else {
affDhIds.noSharingDhIds.push_back(dhId);
}
}
AffectDhIds InputHub::SetSupportInputType(bool enabled, const uint32_t &inputTypes)
{
AffectDhIds affDhIds;
inputTypes_ = inputTypes;
DHLOGI("SetSupportInputType: inputTypes=0x%x,", inputTypes_.load());
std::unique_lock<std::mutex> deviceLock(devicesMutex_);
for (const auto &[id, device] : devices_) {
if (device->classes & inputTypes_) {
device->isShare = true;
} else {
device->isShare = false;
device->isShare = enabled;
DHLOGW("ByType dhid:%s, isshare:%d", device->identifier.descriptor.c_str(), enabled);
SaveAffectDhId(enabled, device->identifier.descriptor, affDhIds);
}
}
return affDhIds;
}
void InputHub::GetDeviceDhIdByFd(int32_t fd, std::string &dhId)
@@ -964,18 +976,22 @@ void InputHub::GetDeviceDhIdByFd(int32_t fd, std::string &dhId)
dhId.clear();
}
void InputHub::SetSharingDevices(bool enabled, std::vector<std::string> dhIds)
AffectDhIds InputHub::SetSharingDevices(bool enabled, std::vector<std::string> dhIds)
{
AffectDhIds affDhIds;
std::unique_lock<std::mutex> deviceLock(devicesMutex_);
for (auto dhId : dhIds) {
for (const auto &[id, device] : devices_) {
if (device->identifier.descriptor == dhId) {
device->isShare = enabled;
DHLOGW("dhid:%s, isshare:%d,", device->identifier.descriptor.c_str(), enabled);
DHLOGW("dhid:%s, isshare:%d", device->identifier.descriptor.c_str(), enabled);
SaveAffectDhId(enabled, device->identifier.descriptor, affDhIds);
break;
}
}
}
return affDhIds;
}
void InputHub::GetShareMousePathByDhId(std::vector<std::string> dhIds, std::string &path, std::string &dhId)
+13 -2
View File
@@ -31,6 +31,11 @@
namespace OHOS {
namespace DistributedHardware {
namespace DistributedInput {
struct AffectDhIds {
std::vector<std::string> sharingDhIds;
std::vector<std::string> noSharingDhIds;
};
class InputHub {
public:
InputHub();
@@ -41,8 +46,10 @@ public:
void StopCollectInputHandler();
size_t DeviceIsExists(InputDeviceEvent* event, size_t capacity);
std::vector<InputDevice> GetAllInputDevices();
void SetSupportInputType(const uint32_t &inputType);
void SetSharingDevices(bool enabled, std::vector<std::string> dhIds);
// return efftive dhids
AffectDhIds SetSupportInputType(bool enabled, const uint32_t &inputType);
// return efftive dhids
AffectDhIds SetSharingDevices(bool enabled, std::vector<std::string> dhIds);
void GetDeviceDhIdByFd(int32_t fd, std::string &dhId);
void GetDevicesInfoByType(int32_t inputTypes, std::map<int32_t, std::string> &datas);
void GetDevicesInfoByDhId(std::vector<std::string> dhidsVec, std::map<int32_t, std::string> &datas);
@@ -130,6 +137,10 @@ private:
bool CheckTouchPointRegion(struct input_event readBuffer[], const AbsInfo& absInfo, Device* device);
size_t CollectEvent(RawEvent* buffer, size_t& capacity, Device* device, struct input_event readBuffer[],
const size_t count);
/*
* isEnable: true for sharing dhid, false for no sharing dhid
*/
void SaveAffectDhId(bool isEnable, const std::string &dhId, AffectDhIds &affDhIds);
int epollFd_;
int iNotifyFd_;
@@ -23,7 +23,8 @@
#include "constants_dinput.h"
#include "dinput_context.h"
#include "i_start_d_input_server_call_back.h"
#include "i_distributed_sink_input.h"
#include "i_sharing_dhid_listener.h"
namespace OHOS {
namespace DistributedHardware {
@@ -33,16 +34,13 @@ public:
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.DistributedHardware.DistributedInput.IDistributedSinkInput");
/*
* Init, Release and IsStartDistributedInput are IPC interface,
* Init and Release are IPC interface,
* which are used for interacting by dhareware and dinput
*/
virtual int32_t Init() = 0;
virtual int32_t Release() = 0;
virtual int32_t IsStartDistributedInput(
const uint32_t& inputType, sptr<IStartDInputServerCallback> callback) = 0;
/*
* NotifyStartDScreen and NotifyStopDScreen are RPC interface,
* which are used for interacting by dinput source and dinput sink
@@ -51,12 +49,14 @@ public:
virtual int32_t NotifyStopDScreen(const std::string &srcScreenInfoKey) = 0;
virtual int32_t RegisterSharingDhIdListener(sptr<ISharingDhIdListener> sharingDhIdListener) = 0;
enum {
INIT = 0xf011U,
RELEASE = 0xf012U,
IS_START_REMOTE_INPUT = 0xf013U,
NOTIFY_START_DSCREEN = 0xf014U,
NOTIFY_STOP_DSCREEN = 0xf015U,
NOTIFY_START_DSCREEN = 0xf013U,
NOTIFY_STOP_DSCREEN = 0xf014U,
REGISTER_SHARING_DHID_LISTENER = 0xf015U,
};
};
} // namespace DistributedInput
@@ -28,7 +28,6 @@
#include "i_prepare_d_input_call_back.h"
#include "i_register_d_input_call_back.h"
#include "i_start_d_input_call_back.h"
#include "i_start_d_input_server_call_back.h"
#include "i_stop_d_input_call_back.h"
#include "i_start_stop_d_inputs_call_back.h"
#include "i_start_stop_result_call_back.h"
@@ -90,9 +89,6 @@ public:
virtual int32_t StopRemoteInput(const std::string &srcId, const std::string &sinkId,
const std::vector<std::string> &dhIds, sptr<IStartStopDInputsCallback> callback) = 0;
virtual int32_t IsStartDistributedInput(
const uint32_t& inputType, sptr<IStartDInputServerCallback> callback) = 0;
virtual int32_t RegisterAddWhiteListCallback(sptr<IAddWhiteListInfosCallback> addWhiteListCallback) = 0;
virtual int32_t RegisterDelWhiteListCallback(sptr<IDelWhiteListInfosCallback> delWhiteListCallback) = 0;
virtual int32_t RegisterInputNodeListener(sptr<InputNodeListener> listener) = 0;
@@ -112,7 +108,6 @@ public:
UNPREPARE_REMOTE_INPUT = 0xf006,
START_REMOTE_INPUT = 0xf007,
STOP_REMOTE_INPUT = 0xf008,
ISSTART_REMOTE_INPUT = 0xf009,
PREPARE_RELAY_REMOTE_INPUT = 0xf00a,
UNPREPARE_RELAY_REMOTE_INPUT = 0xf00b,
START_RELAY_TYPE_REMOTE_INPUT = 0xf00c,
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Copyright (c) 2022 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
@@ -13,30 +13,30 @@
* limitations under the License.
*/
#ifndef I_START_D_INPUT_SERVER_CALL_BACK_H
#define I_START_D_INPUT_SERVER_CALL_BACK_H
#ifndef I_SHARING_DHID_LISTENER_H
#define I_SHARING_DHID_LISTENER_H
#include <string>
#include <iremote_broker.h>
#include "constants_dinput.h"
namespace OHOS {
namespace DistributedHardware {
namespace DistributedInput {
class IStartDInputServerCallback : public IRemoteBroker {
class ISharingDhIdListener : public IRemoteBroker {
public:
virtual void OnResult(const int32_t& status, const uint32_t& inputTypes) = 0;
virtual int32_t OnSharing(std::string dhId) = 0;
virtual int32_t OnNoSharing(std::string dhId) = 0;
enum class Message {
RESULT,
SHARING,
NO_SHARING
};
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.DistributedHardware.DistributedInput.IStartDInputServerCallback");
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.DistributedHardware.DistributedInput.ISharingDhIdListener");
};
} // namespace DistributedInput
} // namespace DistributedHardware
} // namespace OHOS
#endif // I_START_D_INPUT_SERVER_CALL_BACK_H
#endif // I_SHARING_DHID_LISTENER_H
+4 -4
View File
@@ -51,16 +51,16 @@ ohos_shared_library("libdinput_sdk") {
"${ipc_path}/src/distributed_input_source_stub.cpp",
"${ipc_path}/src/input_node_listener_proxy.cpp",
"${ipc_path}/src/input_node_listener_stub.cpp",
"${ipc_path}/src/simulation_event_listener_proxy.cpp",
"${ipc_path}/src/simulation_event_listener_stub.cpp",
"${ipc_path}/src/prepare_d_input_call_back_proxy.cpp",
"${ipc_path}/src/prepare_d_input_call_back_stub.cpp",
"${ipc_path}/src/register_d_input_call_back_proxy.cpp",
"${ipc_path}/src/register_d_input_call_back_stub.cpp",
"${ipc_path}/src/sharing_dhid_listener_proxy.cpp",
"${ipc_path}/src/sharing_dhid_listener_stub.cpp",
"${ipc_path}/src/simulation_event_listener_proxy.cpp",
"${ipc_path}/src/simulation_event_listener_stub.cpp",
"${ipc_path}/src/start_d_input_call_back_proxy.cpp",
"${ipc_path}/src/start_d_input_call_back_stub.cpp",
"${ipc_path}/src/start_d_input_server_call_back_proxy.cpp",
"${ipc_path}/src/start_d_input_server_call_back_stub.cpp",
"${ipc_path}/src/start_stop_d_inputs_call_back_proxy.cpp",
"${ipc_path}/src/start_stop_d_inputs_call_back_stub.cpp",
"${ipc_path}/src/start_stop_result_call_back_proxy.cpp",
@@ -70,6 +70,12 @@ public:
static bool IsTouchEventNeedFilterOut(const TouchScreenEvent &event);
static DInputServerType IsStartDistributedInput(const uint32_t& inputType);
/*
* check is dhId sharing to other devices
* true: dhId sharing to other device
* false: dhId NOT sharing to other device
*/
static bool IsStartDistributedInput(const std::string& dhId);
static int32_t RegisterInputNodeListener(sptr<InputNodeListener> listener);
static int32_t UnregisterInputNodeListener(sptr<InputNodeListener> listener);
@@ -66,7 +66,12 @@ bool DistributedInputKit::IsTouchEventNeedFilterOut(const TouchScreenEvent &even
DInputServerType DistributedInputKit::IsStartDistributedInput(const uint32_t& inputType)
{
return DistributedInputClient::GetInstance().IsStartDistributedInput(inputType);
return DInputServerType::NULL_SERVER_TYPE;
}
bool DistributedInputKit::IsStartDistributedInput(const std::string& dhId)
{
return DistributedInputClient::GetInstance().IsStartDistributedInput(dhId);
}
int32_t DistributedInputKit::PrepareRemoteInput(const std::string &srcId, const std::string &sinkId,
+4 -2
View File
@@ -58,10 +58,12 @@ ohos_unittest("distributed_input_inner_test") {
"${ipc_path}/src/distributed_input_source_proxy.cpp",
"${ipc_path}/src/input_node_listener_proxy.cpp",
"${ipc_path}/src/input_node_listener_stub.cpp",
"${ipc_path}/src/simulation_event_listener_proxy.cpp",
"${ipc_path}/src/simulation_event_listener_stub.cpp",
"${ipc_path}/src/prepare_d_input_call_back_proxy.cpp",
"${ipc_path}/src/prepare_d_input_call_back_stub.cpp",
"${ipc_path}/src/sharing_dhid_listener_proxy.cpp",
"${ipc_path}/src/sharing_dhid_listener_stub.cpp",
"${ipc_path}/src/simulation_event_listener_proxy.cpp",
"${ipc_path}/src/simulation_event_listener_stub.cpp",
"${ipc_path}/src/register_d_input_call_back_proxy.cpp",
"${ipc_path}/src/register_d_input_call_back_stub.cpp",
"${ipc_path}/src/start_d_input_call_back_proxy.cpp",
@@ -402,30 +402,6 @@ HWTEST_F(DistributedInputInnerTest, IsTouchEventNeedFilterOut01, testing::ext::T
ret = DistributedInputKit::IsTouchEventNeedFilterOut(event);
EXPECT_EQ(false, ret);
}
HWTEST_F(DistributedInputInnerTest, IsStartDistributedInput1, testing::ext::TestSize.Level0)
{
DistributedInputClient::GetInstance().ReleaseSource();
DistributedInputClient::GetInstance().InitSink();
DInputServerType ret = DistributedInputKit::IsStartDistributedInput(static_cast<uint32_t>(DInputDeviceType::ALL));
if (ret == DInputServerType::NULL_SERVER_TYPE) {
EXPECT_EQ(DH_SUCCESS, 0);
} else {
EXPECT_EQ(DH_SUCCESS, -1);
}
}
HWTEST_F(DistributedInputInnerTest, IsStartDistributedInput2, testing::ext::TestSize.Level0)
{
DInputServerType ret = DistributedInputKit::IsStartDistributedInput(static_cast<uint32_t>(DInputDeviceType::ALL));
if (ret == DInputServerType::NULL_SERVER_TYPE) {
EXPECT_EQ(DH_SUCCESS, 0);
} else {
EXPECT_EQ(DH_SUCCESS, -1);
}
}
} // namespace DistributedInput
} // namespace DistributedHardware
} // namespace OHOS
@@ -65,20 +65,6 @@ void DistributedInputClient::UnregisterDInputCb::OnResult(
}
}
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_ = static_cast<DInputDeviceType>(inputTypes);
} else if (DInputServerType::SINK_SERVER_TYPE == static_cast<DInputServerType>(status)) {
DistributedInputClient::GetInstance().serverType = DInputServerType::SINK_SERVER_TYPE;
DistributedInputClient::GetInstance().inputTypes_ = static_cast<DInputDeviceType>(inputTypes);
} else {
DistributedInputClient::GetInstance().serverType = DInputServerType::NULL_SERVER_TYPE;
DistributedInputClient::GetInstance().inputTypes_ = DInputDeviceType::NONE;
}
}
void DistributedInputClient::AddWhiteListInfosCb::OnResult(const std::string &deviceId, const std::string &strJson)
{
nlohmann::json inputData = nlohmann::json::parse(strJson);
@@ -182,11 +168,6 @@ bool DistributedInputClient::IsTouchEventNeedFilterOut(const TouchScreenEvent &e
return false;
}
DInputServerType DistributedInputClient::IsStartDistributedInput(const uint32_t& inputType)
{
return serverType;
}
bool DistributedInputClient::IsJsonData(std::string strData) const
{
return true;
+4 -1
View File
@@ -31,7 +31,10 @@
namespace OHOS {
namespace DistributedHardware {
namespace DistributedInput {
const uint32_t DINPUT_CLIENT_CHECK_CALLBACK_REGISTER_MSG = 1;
const uint32_t DINPUT_CLIENT_CHECK_SOURCE_CALLBACK_REGISTER_MSG = 1;
const uint32_t DINPUT_CLIENT_CHECK_SINK_CALLBACK_REGISTER_MSG = 2;
const uint32_t DINPUT_CLIENT_CLEAR_SOURCE_CALLBACK_REGISTER_MSG = 3;
const uint32_t DINPUT_CLIENT_CLEAR_SINK_CALLBACK_REGISTER_MSG = 4;
class DInputSAManager {
DECLARE_SINGLE_INSTANCE_BASE(DInputSAManager);
public:
@@ -21,19 +21,21 @@
#include <mutex>
#include <string>
#include "event_handler.h"
#include "add_white_list_infos_call_back_stub.h"
#include "del_white_list_infos_call_back_stub.h"
#include "i_distributed_source_input.h"
#include "i_distributed_sink_input.h"
#include "i_sharing_dhid_listener.h"
#include "register_d_input_call_back_stub.h"
#include "start_d_input_server_call_back_stub.h"
#include "unregister_d_input_call_back_stub.h"
#include "sharing_dhid_listener_stub.h"
#include "start_stop_d_inputs_call_back_stub.h"
#include "dinput_sa_manager.h"
#include "idistributed_hardware_source.h"
#include "idistributed_hardware_sink.h"
#include "event_handler.h"
namespace OHOS {
namespace DistributedHardware {
@@ -92,7 +94,7 @@ public:
bool IsNeedFilterOut(const std::string &deviceId, const BusinessEvent &event);
bool IsTouchEventNeedFilterOut(const TouchScreenEvent &event);
DInputServerType IsStartDistributedInput(const uint32_t& inputType);
bool IsStartDistributedInput(const std::string& dhId);
int32_t NotifyStartDScreen(const std::string &networkId, const std::string& srcDevId, const uint64_t srcWinId);
int32_t NotifyStopDScreen(const std::string &networkId, const std::string& srcScreenInfoKey);
@@ -103,12 +105,15 @@ public:
int32_t RegisterSimulationEventListener(sptr<ISimulationEventListener> listener);
int32_t UnregisterSimulationEventListener(sptr<ISimulationEventListener> listener);
void CheckRegisterCallback();
void CheckSourceRegisterCallback();
void CheckWhiteListCallback();
void CheckNodeMonitorCallback();
void CheckKeyStateCallback();
void CheckStartStopResultCallback();
void CheckSinkRegisterCallback();
void CheckSharingDhIdsCallback();
public:
class RegisterDInputCb : public OHOS::DistributedHardware::DistributedInput::RegisterDInputCallbackStub {
public:
@@ -124,13 +129,6 @@ public:
void OnResult(const std::string& devId, const std::string& dhId, const int32_t& status);
};
class StartDInputServerCb : public OHOS::DistributedHardware::DistributedInput::StartDInputServerCallbackStub {
public:
StartDInputServerCb() = default;
virtual ~StartDInputServerCb() = default;
void OnResult(const int32_t& status, const uint32_t& inputTypes);
};
class AddWhiteListInfosCb : public OHOS::DistributedHardware::DistributedInput::AddWhiteListInfosCallbackStub {
public:
AddWhiteListInfosCb() = default;
@@ -145,6 +143,14 @@ public:
void OnResult(const std::string &deviceId);
};
class SharingDhIdListenerCb : public OHOS::DistributedHardware::DistributedInput::SharingDhIdListenerStub {
public:
SharingDhIdListenerCb() = default;
virtual ~SharingDhIdListenerCb() = default;
int32_t OnSharing(std::string dhId);
int32_t OnNoSharing(std::string dhId);
};
class DInputClientEventHandler : public AppExecFwk::EventHandler {
public:
DInputClientEventHandler(const std::shared_ptr<AppExecFwk::EventRunner> &runner);
@@ -166,23 +172,21 @@ private:
DInputServerType serverType = DInputServerType::NULL_SERVER_TYPE;
DInputDeviceType inputTypes_ = DInputDeviceType::NONE;
sptr<StartDInputServerCb> sinkTypeCallback = nullptr;
sptr<StartDInputServerCb> sourceTypeCallback = nullptr;
sptr<AddWhiteListInfosCb> addWhiteListCallback_ = nullptr;
sptr<DelWhiteListInfosCb> delWhiteListCallback_ = nullptr;
sptr<InputNodeListener> regNodeListener_ = nullptr;
sptr<InputNodeListener> unregNodeListener_ = nullptr;
sptr<ISimulationEventListener> regSimulationEventListener_ = nullptr;
sptr<ISimulationEventListener> unregSimulationEventListener_ = nullptr;
sptr<ISharingDhIdListener> sharingDhIdListener_ = nullptr;
std::shared_ptr<DistributedInputClient::DInputClientEventHandler> eventHandler_;
bool isAddWhiteListCbReg;
bool isDelWhiteListCbReg;
bool isNodeMonitorCbReg;
bool isNodeMonitorCbUnreg;
bool isSimulationEventCbReg;
bool isSimulationEventCbUnreg;
std::atomic<bool> isAddWhiteListCbReg;
std::atomic<bool> isDelWhiteListCbReg;
std::atomic<bool> isNodeMonitorCbReg;
std::atomic<bool> isSimulationEventCbReg;
std::atomic<bool> isSharingDhIdsReg;
struct DHardWareFwkRegistInfo {
std::string devId;
@@ -199,6 +203,10 @@ private:
std::vector<DHardWareFwkRegistInfo> dHardWareFwkRstInfos;
std::vector<DHardWareFwkUnRegistInfo> dHardWareFwkUnRstInfos;
std::mutex operationMutex_;
std::mutex sharingDhIdsMtx_;
// sharing local dhids
std::set<std::string> sharingDhIds_;
};
} // namespace DistributedInput
} // namespace DistributedHardware
@@ -22,6 +22,8 @@
#include "iremote_proxy.h"
#include "i_sharing_dhid_listener.h"
namespace OHOS {
namespace DistributedHardware {
namespace DistributedInput {
@@ -36,12 +38,11 @@ public:
virtual int32_t Release() override;
virtual int32_t IsStartDistributedInput(
const uint32_t& inputType, sptr<IStartDInputServerCallback> callback) override;
virtual int32_t NotifyStartDScreen(const SrcScreenInfo& srcScreenRemoteCtrlInfo) override;
virtual int32_t NotifyStopDScreen(const std::string& srcScreenInfoKey) override;
virtual int32_t RegisterSharingDhIdListener(sptr<ISharingDhIdListener> sharingDhIdListener) override;
private:
bool SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply);
@@ -37,12 +37,12 @@ public:
int32_t ReleaseInner(MessageParcel &data, MessageParcel &reply, MessageOption &option);
int32_t IsStartDistributedInputInner(MessageParcel &data, MessageParcel &reply, MessageOption &option);
int32_t NotifyStartDScreenInner(MessageParcel &data, MessageParcel &reply, MessageOption &option);
int32_t NotifyStopDScreenInner(MessageParcel &data, MessageParcel &reply, MessageOption &option);
int32_t RegisterSharingDhIdListenerInner(MessageParcel &data, MessageParcel &reply, MessageOption &option);
private:
DISALLOW_COPY_AND_MOVE(DistributedInputSinkStub);
using DistributedInputSinkFunc = int32_t (DistributedInputSinkStub::*)(MessageParcel &data, MessageParcel &reply,
@@ -76,9 +76,6 @@ public:
virtual int32_t StopRemoteInput(const std::string &srcId, const std::string &sinkId,
const std::vector<std::string> &dhIds, sptr<IStartStopDInputsCallback> callback) override;
virtual int32_t IsStartDistributedInput(
const uint32_t& inputType, sptr<IStartDInputServerCallback> callback) override;
virtual int32_t RegisterAddWhiteListCallback(sptr<IAddWhiteListInfosCallback> addWhiteListCallback) override;
virtual int32_t RegisterDelWhiteListCallback(sptr<IDelWhiteListInfosCallback> delWhiteListCallback) override;
virtual int32_t RegisterInputNodeListener(sptr<InputNodeListener> listener) override;
@@ -50,7 +50,6 @@ private:
int32_t HandleStopDhidRemoteInput(MessageParcel &data, MessageParcel &reply);
int32_t HandleStartRelayDhidRemoteInput(MessageParcel &data, MessageParcel &reply);
int32_t HandleStopRelayDhidRemoteInput(MessageParcel &data, MessageParcel &reply);
int32_t HandleIsStartDistributedInput(MessageParcel &data, MessageParcel &reply);
int32_t HandleRegisterAddWhiteListCallback(MessageParcel &data, MessageParcel &reply);
int32_t HandleRegisterDelWhiteListCallback(MessageParcel &data, MessageParcel &reply);
int32_t HandleRegisterInputNodeListener(MessageParcel &data, MessageParcel &reply);
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Copyright (c) 2022 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
@@ -13,10 +13,10 @@
* limitations under the License.
*/
#ifndef START_D_INPUT_SERVER_CALL_BACK_PROXY_H
#define START_D_INPUT_SERVER_CALL_BACK_PROXY_H
#ifndef SHARING_DHID_LISTENER_PROXY_H
#define SHARING_DHID_LISTENER_PROXY_H
#include "i_start_d_input_server_call_back.h"
#include "i_sharing_dhid_listener.h"
#include <string>
@@ -25,19 +25,20 @@
namespace OHOS {
namespace DistributedHardware {
namespace DistributedInput {
class StartDInputServerCallbackProxy : public IRemoteProxy<IStartDInputServerCallback> {
class SharingDhIdListenerProxy : public IRemoteProxy<ISharingDhIdListener> {
public:
explicit StartDInputServerCallbackProxy(const sptr<IRemoteObject> &object);
explicit SharingDhIdListenerProxy(const sptr<IRemoteObject> &object);
virtual ~StartDInputServerCallbackProxy() override;
virtual ~SharingDhIdListenerProxy() override;
virtual void OnResult(const int32_t& status, const uint32_t& inputTypes) override;
virtual int32_t OnSharing(std::string dhId) override;
virtual int32_t OnNoSharing(std::string dhId) override;
private:
static inline BrokerDelegator<StartDInputServerCallbackProxy> delegator_;
static inline BrokerDelegator<SharingDhIdListenerProxy> delegator_;
};
} // namespace DistributedInput
} // namespace DistributedHardware
} // namespace OHOS
#endif // START_D_INPUT_CALL_BACK_PROXY_H
#endif // SHARING_DHID_LISTENER_PROXY_H
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Copyright (c) 2022 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
@@ -13,10 +13,10 @@
* limitations under the License.
*/
#ifndef START_D_INPUT_SERVER_CALL_BACK_STUB_H
#define START_D_INPUT_SERVER_CALL_BACK_STUB_H
#ifndef SHARING_DHID_LISTENER_STUB_H
#define SHARING_DHID_LISTENER_STUB_H
#include "i_start_d_input_server_call_back.h"
#include "i_sharing_dhid_listener.h"
#include <string>
@@ -25,18 +25,18 @@
namespace OHOS {
namespace DistributedHardware {
namespace DistributedInput {
class StartDInputServerCallbackStub : public IRemoteStub<IStartDInputServerCallback> {
class SharingDhIdListenerStub : public IRemoteStub<ISharingDhIdListener> {
public:
StartDInputServerCallbackStub();
virtual ~StartDInputServerCallbackStub() override;
SharingDhIdListenerStub();
virtual ~SharingDhIdListenerStub() override;
int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
private:
DISALLOW_COPY_AND_MOVE(StartDInputServerCallbackStub);
DISALLOW_COPY_AND_MOVE(SharingDhIdListenerStub);
};
} // namespace DistributedInput
} // namespace DistributedHardware
} // namespace OHOS
#endif // START_D_INPUT_SERVER_CALL_BACK_STUB_H
#endif // SHARING_DHID_LISTENER_STUB_H
+45 -9
View File
@@ -26,17 +26,43 @@ namespace OHOS {
namespace DistributedHardware {
namespace DistributedInput {
IMPLEMENT_SINGLE_INSTANCE(DInputSAManager);
const uint32_t DINPUT_CLIENT_HANDLER_MSG_DELAY_TIME = 50; // million seconds
const uint32_t DINPUT_CLIENT_HANDLER_MSG_DELAY_TIME = 100; // million seconds
void DInputSAManager::SystemAbilityListener::OnRemoveSystemAbility(int32_t systemAbilityId, const std::string &deviceId)
{
if (systemAbilityId == DISTRIBUTED_HARDWARE_INPUT_SOURCE_SA_ID) {
DInputSAManager::GetInstance().dInputSourceSAOnline.store(false);
std::lock_guard<std::mutex> lock(DInputSAManager::GetInstance().sourceMutex_);
DInputSAManager::GetInstance().dInputSourceProxy_ = nullptr;
} else if (systemAbilityId == DISTRIBUTED_HARDWARE_INPUT_SINK_SA_ID) {
{
std::lock_guard<std::mutex> lock(DInputSAManager::GetInstance().sourceMutex_);
DInputSAManager::GetInstance().dInputSourceProxy_ = nullptr;
}
{
std::lock_guard<std::mutex> lock(DInputSAManager::GetInstance().handlerMutex_);
if (DInputSAManager::GetInstance().eventHandler_ != nullptr) {
DHLOGI("SendEvent DINPUT_CLIENT_CLEAR_SOURCE_CALLBACK_REGISTER_MSG");
AppExecFwk::InnerEvent::Pointer msgEvent =
AppExecFwk::InnerEvent::Get(DINPUT_CLIENT_CLEAR_SOURCE_CALLBACK_REGISTER_MSG, systemAbilityId);
DInputSAManager::GetInstance().eventHandler_->SendEvent(msgEvent, DINPUT_CLIENT_HANDLER_MSG_DELAY_TIME,
AppExecFwk::EventQueue::Priority::IMMEDIATE);
}
}
}
if (systemAbilityId == DISTRIBUTED_HARDWARE_INPUT_SINK_SA_ID) {
DInputSAManager::GetInstance().dInputSinkSAOnline.store(false);
std::lock_guard<std::mutex> lock(DInputSAManager::GetInstance().sinkMutex_);
DInputSAManager::GetInstance().dInputSinkProxy_ = nullptr;
{
std::lock_guard<std::mutex> lock(DInputSAManager::GetInstance().sinkMutex_);
DInputSAManager::GetInstance().dInputSinkProxy_ = nullptr;
}
{
std::lock_guard<std::mutex> lock(DInputSAManager::GetInstance().handlerMutex_);
if (DInputSAManager::GetInstance().eventHandler_ != nullptr) {
DHLOGI("SendEvent DINPUT_CLIENT_CLEAR_SINK_CALLBACK_REGISTER_MSG");
AppExecFwk::InnerEvent::Pointer msgEvent =
AppExecFwk::InnerEvent::Get(DINPUT_CLIENT_CLEAR_SINK_CALLBACK_REGISTER_MSG, systemAbilityId);
DInputSAManager::GetInstance().eventHandler_->SendEvent(msgEvent, DINPUT_CLIENT_HANDLER_MSG_DELAY_TIME,
AppExecFwk::EventQueue::Priority::IMMEDIATE);
}
}
}
DHLOGI("sa %d is removed.", systemAbilityId);
}
@@ -47,14 +73,24 @@ void DInputSAManager::SystemAbilityListener::OnAddSystemAbility(int32_t systemAb
DInputSAManager::GetInstance().dInputSourceSAOnline.store(true);
std::lock_guard<std::mutex> lock(DInputSAManager::GetInstance().handlerMutex_);
if (DInputSAManager::GetInstance().eventHandler_ != nullptr) {
DHLOGI("SendEvent DINPUT_CLIENT_CHECK_CALLBACK_REGISTER_MSG");
DHLOGI("SendEvent DINPUT_CLIENT_CHECK_SOURCE_CALLBACK_REGISTER_MSG");
AppExecFwk::InnerEvent::Pointer msgEvent =
AppExecFwk::InnerEvent::Get(DINPUT_CLIENT_CHECK_CALLBACK_REGISTER_MSG, systemAbilityId);
AppExecFwk::InnerEvent::Get(DINPUT_CLIENT_CHECK_SOURCE_CALLBACK_REGISTER_MSG, systemAbilityId);
DInputSAManager::GetInstance().eventHandler_->SendEvent(msgEvent, DINPUT_CLIENT_HANDLER_MSG_DELAY_TIME,
AppExecFwk::EventQueue::Priority::IMMEDIATE);
}
} else if (systemAbilityId == DISTRIBUTED_HARDWARE_INPUT_SINK_SA_ID) {
}
if (systemAbilityId == DISTRIBUTED_HARDWARE_INPUT_SINK_SA_ID) {
DInputSAManager::GetInstance().dInputSinkSAOnline.store(true);
std::lock_guard<std::mutex> lock(DInputSAManager::GetInstance().handlerMutex_);
if (DInputSAManager::GetInstance().eventHandler_ != nullptr) {
DHLOGI("SendEvent DINPUT_CLIENT_CHECK_SINK_CALLBACK_REGISTER_MSG");
AppExecFwk::InnerEvent::Pointer msgEvent =
AppExecFwk::InnerEvent::Get(DINPUT_CLIENT_CHECK_SINK_CALLBACK_REGISTER_MSG, systemAbilityId);
DInputSAManager::GetInstance().eventHandler_->SendEvent(msgEvent, DINPUT_CLIENT_HANDLER_MSG_DELAY_TIME,
AppExecFwk::EventQueue::Priority::IMMEDIATE);
}
}
DHLOGI("sa %d is added.", systemAbilityId);
}
+76 -85
View File
@@ -34,8 +34,7 @@ namespace DistributedHardware {
namespace DistributedInput {
std::shared_ptr<DistributedInputClient> DistributedInputClient::instance(new DistributedInputClient());
DistributedInputClient::DistributedInputClient() : isAddWhiteListCbReg(false), isDelWhiteListCbReg(false),
isNodeMonitorCbReg(false), isNodeMonitorCbUnreg(false),
isSimulationEventCbReg(false), isSimulationEventCbUnreg(false)
isNodeMonitorCbReg(false), isSimulationEventCbReg(false), isSharingDhIdsReg(false)
{
DHLOGI("DistributedInputClient init start");
std::shared_ptr<AppExecFwk::EventRunner> runner = AppExecFwk::EventRunner::Create(true);
@@ -82,21 +81,6 @@ void DistributedInputClient::UnregisterDInputCb::OnResult(
}
}
void DistributedInputClient::StartDInputServerCb::OnResult(const int32_t& status, const uint32_t& inputTypes)
{
DHLOGI("StartDInputServerCb status: %d, inputTypes: %d, addr: %p", status, inputTypes, this);
if (DInputServerType::SOURCE_SERVER_TYPE == static_cast<DInputServerType>(status)) {
DistributedInputClient::GetInstance().serverType = DInputServerType::SOURCE_SERVER_TYPE;
DistributedInputClient::GetInstance().inputTypes_ = static_cast<DInputDeviceType>(inputTypes);
} else if (DInputServerType::SINK_SERVER_TYPE == static_cast<DInputServerType>(status)) {
DistributedInputClient::GetInstance().serverType = DInputServerType::SINK_SERVER_TYPE;
DistributedInputClient::GetInstance().inputTypes_ = static_cast<DInputDeviceType>(inputTypes);
} else {
DistributedInputClient::GetInstance().serverType = DInputServerType::NULL_SERVER_TYPE;
DistributedInputClient::GetInstance().inputTypes_ = DInputDeviceType::NONE;
}
}
void DistributedInputClient::AddWhiteListInfosCb::OnResult(const std::string &deviceId, const std::string &strJson)
{
if (!strJson.empty()) {
@@ -109,6 +93,22 @@ void DistributedInputClient::DelWhiteListInfosCb::OnResult(const std::string& de
DistributedInputClient::GetInstance().DelWhiteListInfos(deviceId);
}
int32_t DistributedInputClient::SharingDhIdListenerCb::OnSharing(std::string dhId)
{
std::lock_guard<std::mutex> lock(DistributedInputClient::GetInstance().sharingDhIdsMtx_);
DHLOGI("Add Sharing Local dhId: %s", GetAnonyString(dhId).c_str());
DistributedInputClient::GetInstance().sharingDhIds_.insert(dhId);
return DH_SUCCESS;
}
int32_t DistributedInputClient::SharingDhIdListenerCb::OnNoSharing(std::string dhId)
{
std::lock_guard<std::mutex> lock(DistributedInputClient::GetInstance().sharingDhIdsMtx_);
DHLOGI("Remove No Sharing Local dhId: %s", GetAnonyString(dhId).c_str());
DistributedInputClient::GetInstance().sharingDhIds_.erase(dhId);
return DH_SUCCESS;
}
DistributedInputClient::DInputClientEventHandler::DInputClientEventHandler(
const std::shared_ptr<AppExecFwk::EventRunner> &runner)
: AppExecFwk::EventHandler(runner)
@@ -119,25 +119,70 @@ void DistributedInputClient::DInputClientEventHandler::ProcessEvent(const AppExe
{
uint32_t eventId = event->GetInnerEventId();
DHLOGI("DInputClientEventHandler ProcessEvent start eventId:%d.", eventId);
if (eventId == DINPUT_CLIENT_CHECK_CALLBACK_REGISTER_MSG) {
DistributedInputClient::GetInstance().CheckRegisterCallback();
} else {
DHLOGE("DInputClientEventHandler ProcessEvent error, because eventId is unkonwn.");
if (eventId == DINPUT_CLIENT_CHECK_SOURCE_CALLBACK_REGISTER_MSG) {
DistributedInputClient::GetInstance().CheckSourceRegisterCallback();
return;
}
if (eventId == DINPUT_CLIENT_CHECK_SINK_CALLBACK_REGISTER_MSG) {
DistributedInputClient::GetInstance().CheckSinkRegisterCallback();
return;
}
if (eventId == DINPUT_CLIENT_CLEAR_SOURCE_CALLBACK_REGISTER_MSG) {
DHLOGI("Source SA exit, clear callback flag");
DistributedInputClient::GetInstance().isAddWhiteListCbReg = false;
DistributedInputClient::GetInstance().isDelWhiteListCbReg = false;
DistributedInputClient::GetInstance().isNodeMonitorCbReg = false;
DistributedInputClient::GetInstance().isSimulationEventCbReg = false;
return;
}
if (eventId == DINPUT_CLIENT_CLEAR_SINK_CALLBACK_REGISTER_MSG) {
DHLOGI("Sink SA exit, clear callback flag");
DistributedInputClient::GetInstance().isSharingDhIdsReg = false;
return;
}
DHLOGI("DInputClientEventHandler ProcessEvent end");
}
void DistributedInputClient::CheckRegisterCallback()
void DistributedInputClient::CheckSourceRegisterCallback()
{
DHLOGI("CheckRegisterCallback called, awl[%d], dwl[%d], rnm[%d], unm[%d], rmd[%d], umd[%d]",
isAddWhiteListCbReg, isDelWhiteListCbReg, isNodeMonitorCbReg, isNodeMonitorCbUnreg, isSimulationEventCbReg,
isSimulationEventCbUnreg);
DHLOGI("CheckSourceRegisterCallback called, isAddWhiteListCbReg[%d], isDelWhiteListCbReg[%d],"
"isNodeMonitorCbReg[%d], isSimulationEventCbReg[%d]",
isAddWhiteListCbReg.load(), isDelWhiteListCbReg.load(), isNodeMonitorCbReg.load(),
isSimulationEventCbReg.load());
CheckWhiteListCallback();
CheckNodeMonitorCallback();
CheckKeyStateCallback();
}
void DistributedInputClient::CheckSinkRegisterCallback()
{
DHLOGI("CheckSinkRegisterCallback called, isSharingDhIdsReg[%d]", isSharingDhIdsReg.load());
CheckSharingDhIdsCallback();
}
void DistributedInputClient::CheckSharingDhIdsCallback()
{
if (!DInputSAManager::GetInstance().GetDInputSinkProxy()) {
DHLOGE("CheckWhiteListCallback client get source proxy fail");
return;
}
if (!isSharingDhIdsReg) {
if (sharingDhIdListener_ == nullptr) {
sharingDhIdListener_ = new (std::nothrow) SharingDhIdListenerCb();
}
int32_t ret =
DInputSAManager::GetInstance().dInputSinkProxy_->RegisterSharingDhIdListener(sharingDhIdListener_);
if (ret == DH_SUCCESS) {
isSharingDhIdsReg = true;
} else {
DHLOGE("CheckSharingDhIdsCallback client RegisterSharingDhIdListener fail");
}
}
}
void DistributedInputClient::CheckWhiteListCallback()
{
if (!DInputSAManager::GetInstance().GetDInputSourceProxy()) {
@@ -181,12 +226,6 @@ void DistributedInputClient::CheckNodeMonitorCallback()
DInputSAManager::GetInstance().dInputSourceProxy_->RegisterInputNodeListener(regNodeListener_);
isNodeMonitorCbReg = true;
}
if (!isNodeMonitorCbUnreg && unregNodeListener_ != nullptr) {
DHLOGI("CheckNodeMonitorCallback need continue register unregNodeListener_.");
DInputSAManager::GetInstance().dInputSourceProxy_->UnregisterInputNodeListener(unregNodeListener_);
isNodeMonitorCbUnreg = true;
}
}
void DistributedInputClient::CheckKeyStateCallback()
@@ -199,12 +238,6 @@ void DistributedInputClient::CheckKeyStateCallback()
DInputSAManager::GetInstance().dInputSourceProxy_->RegisterSimulationEventListener(regSimulationEventListener_);
isSimulationEventCbReg = true;
}
if (!isSimulationEventCbUnreg && unregSimulationEventListener_ != nullptr) {
DInputSAManager::GetInstance().dInputSourceProxy_->UnregisterSimulationEventListener(
unregSimulationEventListener_);
isSimulationEventCbUnreg = true;
}
}
int32_t DistributedInputClient::InitSource()
@@ -231,8 +264,6 @@ int32_t DistributedInputClient::ReleaseSource()
serverType = DInputServerType::NULL_SERVER_TYPE;
inputTypes_ = DInputDeviceType::NONE;
sinkTypeCallback = nullptr;
sourceTypeCallback = nullptr;
addWhiteListCallback_ = nullptr;
delWhiteListCallback_ = nullptr;
regNodeListener_ = nullptr;
@@ -251,7 +282,6 @@ int32_t DistributedInputClient::ReleaseSink()
}
serverType = DInputServerType::NULL_SERVER_TYPE;
inputTypes_ = DInputDeviceType::NONE;
sinkTypeCallback = nullptr;
WhiteListUtil::GetInstance().ClearWhiteList();
return DInputSAManager::GetInstance().dInputSinkProxy_->Release();
}
@@ -572,37 +602,10 @@ bool DistributedInputClient::IsTouchEventNeedFilterOut(const TouchScreenEvent &e
return false;
}
DInputServerType DistributedInputClient::IsStartDistributedInput(const uint32_t& inputType)
bool DistributedInputClient::IsStartDistributedInput(const std::string& dhId)
{
DHLOGI("IsStartDistributedInput called, inputType: %d, current inputTypes: %d",
inputType, static_cast<uint32_t>(inputTypes_));
int32_t retSource = 0;
int32_t retSink = 0;
if (sourceTypeCallback == nullptr && DInputSAManager::GetInstance().GetDInputSourceProxy()) {
DHLOGI("Init sourceTypeCallback");
sourceTypeCallback = new(std::nothrow) StartDInputServerCb();
retSource = DInputSAManager::GetInstance().dInputSourceProxy_->IsStartDistributedInput(inputType,
sourceTypeCallback);
}
if (sinkTypeCallback == nullptr && DInputSAManager::GetInstance().GetDInputSinkProxy()) {
DHLOGI("Init sinkTypeCallback");
sinkTypeCallback = new(std::nothrow) StartDInputServerCb();
retSink = DInputSAManager::GetInstance().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 & static_cast<uint32_t>(inputTypes_)) {
return serverType;
} else {
return DInputServerType::NULL_SERVER_TYPE;
}
std::lock_guard<std::mutex> lock(sharingDhIdsMtx_);
return sharingDhIds_.find(dhId) != sharingDhIds_.end();
}
int32_t DistributedInputClient::RegisterInputNodeListener(sptr<InputNodeListener> listener)
@@ -639,17 +642,11 @@ int32_t DistributedInputClient::UnregisterInputNodeListener(sptr<InputNodeListen
}
if (!DInputSAManager::GetInstance().GetDInputSourceProxy()) {
DHLOGE("UnregisterInputNodeListener proxy error, client fail");
isNodeMonitorCbUnreg = false;
unregNodeListener_ = listener;
return ERR_DH_INPUT_CLIENT_GET_SOURCE_PROXY_FAIL;
}
int32_t ret = DInputSAManager::GetInstance().dInputSourceProxy_->UnregisterInputNodeListener(listener);
if (ret == DH_SUCCESS) {
isNodeMonitorCbUnreg = true;
} else {
isNodeMonitorCbUnreg = false;
unregNodeListener_ = listener;
if (ret != DH_SUCCESS) {
DHLOGE("DInputSAManager UnregisterInputNodeListener Failed, ret = %d", ret);
}
return ret;
@@ -689,17 +686,11 @@ int32_t DistributedInputClient::UnregisterSimulationEventListener(sptr<ISimulati
}
if (!DInputSAManager::GetInstance().GetDInputSourceProxy()) {
DHLOGE("UnregisterSimulationEventListener proxy error, client fail");
isSimulationEventCbUnreg = false;
unregSimulationEventListener_ = listener;
return ERR_DH_INPUT_CLIENT_GET_SOURCE_PROXY_FAIL;
}
int32_t ret = DInputSAManager::GetInstance().dInputSourceProxy_->UnregisterSimulationEventListener(listener);
if (ret == DH_SUCCESS) {
isSimulationEventCbUnreg = true;
} else {
isSimulationEventCbUnreg = false;
unregSimulationEventListener_ = listener;
if (ret != DH_SUCCESS) {
DHLOGE("UnregisterSimulationEventListener Failed, ret = %d", ret);
}
return ret;
@@ -67,33 +67,6 @@ int32_t DistributedInputSinkProxy::Release()
return result;
}
int32_t DistributedInputSinkProxy::IsStartDistributedInput(
const uint32_t& inputType, sptr<IStartDInputServerCallback> callback)
{
MessageParcel data;
if (!data.WriteInterfaceToken(GetDescriptor())) {
DHLOGE("DistributedInputSinkProxy write token valid failed");
return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL;
}
if (!data.WriteUint32(inputType)) {
DHLOGE("DistributedInputSinkProxy write inputType failed");
return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL;
}
if (!data.WriteRemoteObject(callback->AsObject())) {
DHLOGE("DistributedInputSinkProxy write callback failed");
return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL;
}
MessageParcel reply;
int32_t result = ERR_DH_INPUT_SINK_PROXY_IS_START_INPUT_FAIL;
bool ret = SendRequest(IS_START_REMOTE_INPUT, data, reply);
if (!ret) {
DHLOGE("SendRequest fail!");
return ERR_DH_INPUT_SINK_PROXY_IS_START_INPUT_FAIL;
}
result = reply.ReadInt32();
return result;
}
int32_t DistributedInputSinkProxy::NotifyStartDScreen(const SrcScreenInfo &remoteCtrlInfo)
{
MessageParcel data;
@@ -147,6 +120,27 @@ int32_t DistributedInputSinkProxy::NotifyStopDScreen(const std::string &srcScree
return result;
}
int32_t DistributedInputSinkProxy::RegisterSharingDhIdListener(sptr<ISharingDhIdListener> sharingDhIdListener)
{
MessageParcel data;
if (!data.WriteInterfaceToken(GetDescriptor())) {
DHLOGE("RegisterSharingDhIdListener write token valid failed");
return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL;
}
if (!data.WriteRemoteObject(sharingDhIdListener->AsObject())) {
DHLOGE("RegisterSharingDhIdListener write callback failed");
return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL;
}
MessageParcel reply;
int32_t result = ERR_DH_INPUT_SINK_PROXY_REGISTER_SHARING_DHID_LISTENER_FAIL;
bool ret = SendRequest(REGISTER_SHARING_DHID_LISTENER, data, reply);
if (ret) {
result = reply.ReadInt32();
}
return result;
}
bool DistributedInputSinkProxy::SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply)
{
sptr<IRemoteObject> remote = Remote();
@@ -20,6 +20,7 @@
#include "constants_dinput.h"
#include "dinput_errcode.h"
#include "i_sharing_dhid_listener.h"
namespace OHOS {
namespace DistributedHardware {
@@ -29,9 +30,9 @@ DistributedInputSinkStub::DistributedInputSinkStub()
DHLOGI("DistributedInputSinkStub ctor!");
memberFuncMap_[INIT] = &DistributedInputSinkStub::InitInner;
memberFuncMap_[RELEASE] = &DistributedInputSinkStub::ReleaseInner;
memberFuncMap_[IS_START_REMOTE_INPUT] = &DistributedInputSinkStub::IsStartDistributedInputInner;
memberFuncMap_[NOTIFY_START_DSCREEN] = &DistributedInputSinkStub::NotifyStartDScreenInner;
memberFuncMap_[NOTIFY_STOP_DSCREEN] = &DistributedInputSinkStub::NotifyStopDScreenInner;
memberFuncMap_[REGISTER_SHARING_DHID_LISTENER] = &DistributedInputSinkStub::RegisterSharingDhIdListenerInner;
}
DistributedInputSinkStub::~DistributedInputSinkStub()
@@ -77,20 +78,6 @@ int32_t DistributedInputSinkStub::ReleaseInner(MessageParcel &data, MessageParce
return ret;
}
int32_t DistributedInputSinkStub::IsStartDistributedInputInner(MessageParcel &data, MessageParcel &reply,
MessageOption &option)
{
uint32_t inputType = data.ReadUint32();
sptr<IStartDInputServerCallback> callback =
iface_cast<IStartDInputServerCallback>(data.ReadRemoteObject());
int32_t ret = IsStartDistributedInput(inputType, callback);
if (!reply.WriteInt32(ret)) {
DHLOGE("DistributedInputSinkStub write ret failed");
return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL;
}
return ret;
}
int32_t DistributedInputSinkStub::NotifyStartDScreenInner(MessageParcel &data, MessageParcel &reply,
MessageOption &option)
{
@@ -140,6 +127,19 @@ int32_t DistributedInputSinkStub::NotifyStopDScreenInner(MessageParcel &data, Me
}
return ret;
}
int32_t DistributedInputSinkStub::RegisterSharingDhIdListenerInner(MessageParcel &data, MessageParcel &reply,
MessageOption &option)
{
sptr<ISharingDhIdListener> listener = iface_cast<ISharingDhIdListener>(data.ReadRemoteObject());
int32_t ret = RegisterSharingDhIdListener(listener);
if (!reply.WriteInt32(ret)) {
DHLOGE("RegisterSharingDhIdListenerInner write ret failed, ret = %d", ret);
return ERR_DH_INPUT_SINK_STUB_REGISTER_SHARING_DHID_LISTENER_FAIL;
}
return DH_SUCCESS;
}
} // namespace DistributedInput
} // namespace DistributedHardware
} // namespace OHOS
@@ -525,31 +525,6 @@ int32_t DistributedInputSourceProxy::StopRemoteInput(const std::string &srcId, c
return result;
}
int32_t DistributedInputSourceProxy::IsStartDistributedInput(
const uint32_t& inputType, sptr<IStartDInputServerCallback> callback)
{
MessageParcel data;
if (!data.WriteInterfaceToken(GetDescriptor())) {
DHLOGE("DistributedInputSourceProxy write token valid failed");
return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL;
}
if (!data.WriteUint32(inputType)) {
DHLOGE("DistributedInputSourceProxy write inputType failed");
return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL;
}
if (!data.WriteRemoteObject(callback->AsObject())) {
DHLOGE("DistributedInputSourceProxy write callback failed");
return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL;
}
MessageParcel reply;
int32_t result = ERR_DH_INPUT_SOURCE_PROXY_IS_START_INPUT_FAIL;
bool ret = SendRequest(IDistributedSourceInput::MessageCode::ISSTART_REMOTE_INPUT, data, reply);
if (ret) {
result = reply.ReadInt32();
}
return result;
}
int32_t DistributedInputSourceProxy::RegisterAddWhiteListCallback(sptr<IAddWhiteListInfosCallback> addWhiteListCallback)
{
if (addWhiteListCallback == nullptr) {
@@ -262,18 +262,6 @@ int32_t DistributedInputSourceStub::HandleStopRelayDhidRemoteInput(MessageParcel
return DH_SUCCESS;
}
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)) {
DHLOGE("DistributedInputSourceStub isStartDistributedInput write ret failed");
return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL;
}
return DH_SUCCESS;
}
int32_t DistributedInputSourceStub::HandleSyncNodeInfoRemoteInput(MessageParcel &data, MessageParcel &reply)
{
std::string userDevId = data.ReadString();
@@ -439,9 +427,6 @@ int32_t DistributedInputSourceStub::OnRemoteRequest(
case static_cast<uint32_t>(IDistributedSourceInput::MessageCode::SYNC_NODE_INFO_REMOTE_INPUT): {
return HandleSyncNodeInfoRemoteInput(data, reply);
}
case static_cast<uint32_t>(IDistributedSourceInput::MessageCode::ISSTART_REMOTE_INPUT): {
return HandleIsStartDistributedInput(data, reply);
}
default:
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
}
@@ -0,0 +1,96 @@
/*
* Copyright (c) 2022 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 "sharing_dhid_listener_proxy.h"
#include "distributed_hardware_log.h"
#include "dinput_errcode.h"
#include "ipc_types.h"
#include "parcel.h"
namespace OHOS {
namespace DistributedHardware {
namespace DistributedInput {
SharingDhIdListenerProxy::SharingDhIdListenerProxy(const sptr<IRemoteObject> &object)
: IRemoteProxy<ISharingDhIdListener>(object)
{
}
SharingDhIdListenerProxy::~SharingDhIdListenerProxy() {}
int32_t SharingDhIdListenerProxy::OnSharing(std::string dhId)
{
int32_t result = ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL;
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
DHLOGE("SharingDhIdListenerProxy get remote failed");
return result;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
DHLOGE("SharingDhIdListenerProxy write token valid failed");
return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL;
}
if (!data.WriteString(dhId)) {
DHLOGE("SharingDhIdListenerProxy write dhId failed");
return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL;
}
int32_t ret =
remote->SendRequest(static_cast<int32_t>(ISharingDhIdListener::Message::SHARING), data, reply, option);
if (ret == DH_SUCCESS) {
result = reply.ReadInt32();
} else {
DHLOGE("SharingDhIdListenerProxy SendRequest error: %d", ret);
}
return result;
}
int32_t SharingDhIdListenerProxy::OnNoSharing(std::string dhId)
{
int32_t result = ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL;
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
DHLOGE("SharingDhIdListenerProxy get remote failed");
return result;
}
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
DHLOGE("SharingDhIdListenerProxy write token valid failed");
return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL;
}
if (!data.WriteString(dhId)) {
DHLOGE("SharingDhIdListenerProxy write dhId failed");
return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL;
}
int32_t ret =
remote->SendRequest(static_cast<int32_t>(ISharingDhIdListener::Message::NO_SHARING), data, reply, option);
if (ret == DH_SUCCESS) {
result = reply.ReadInt32();
} else {
DHLOGE("SharingDhIdListenerProxy SendRequest error: %d", ret);
}
return result;
}
} // namespace DistributedInput
} // namespace DistributedHardware
} // namespace OHOS
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Copyright (c) 2022 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
@@ -13,7 +13,7 @@
* limitations under the License.
*/
#include "start_d_input_server_call_back_stub.h"
#include "sharing_dhid_listener_stub.h"
#include "distributed_hardware_log.h"
#include "string_ex.h"
@@ -24,27 +24,35 @@
namespace OHOS {
namespace DistributedHardware {
namespace DistributedInput {
StartDInputServerCallbackStub::StartDInputServerCallbackStub()
{
}
SharingDhIdListenerStub::SharingDhIdListenerStub() {}
StartDInputServerCallbackStub::~StartDInputServerCallbackStub()
{
}
SharingDhIdListenerStub::~SharingDhIdListenerStub() {}
int32_t StartDInputServerCallbackStub::OnRemoteRequest(
int32_t SharingDhIdListenerStub::OnRemoteRequest(
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
{
if (data.ReadInterfaceToken() != GetDescriptor()) {
DHLOGE("StartDInputServerCallbackStub read token valid failed");
DHLOGE("SharingDhIdListenerStub read token valid failed");
return ERR_DH_INPUT_IPC_READ_TOKEN_VALID_FAIL;
}
IStartDInputServerCallback::Message msgCode = static_cast<IStartDInputServerCallback::Message>(code);
ISharingDhIdListener::Message msgCode = static_cast<ISharingDhIdListener::Message>(code);
switch (msgCode) {
case IStartDInputServerCallback::Message::RESULT: {
int32_t status = data.ReadInt32();
uint32_t inputTypes = data.ReadUint32();
OnResult(status, inputTypes);
case ISharingDhIdListener::Message::SHARING: {
std::string dhId = data.ReadString();
int32_t ret = OnSharing(dhId);
if (!reply.WriteInt32(ret)) {
DHLOGE("SharingDhIdListenerStub write ret failed");
return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL;
}
break;
}
case ISharingDhIdListener::Message::NO_SHARING: {
std::string dhId = data.ReadString();
int32_t ret = OnNoSharing(dhId);
if (!reply.WriteInt32(ret)) {
DHLOGE("SharingDhIdListenerStub write ret failed");
return ERR_DH_INPUT_IPC_WRITE_VALID_FAIL;
}
break;
}
default:
@@ -43,7 +43,7 @@ int32_t SimulationEventListenerStub::OnRemoteRequest(
int32_t eventValue = data.ReadInt32();
int32_t ret = OnSimulationEvent(eventType, eventCode, eventValue);
if (!reply.WriteInt32(ret)) {
DHLOGE("DistributedInputSourceStub write ret failed");
DHLOGE("SimulationEventListenerStub write ret failed");
return ERR_DH_INPUT_IPC_WRITE_TOKEN_VALID_FAIL;
}
break;
@@ -1,64 +0,0 @@
/*
* Copyright (c) 2021-2022 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 "distributed_hardware_log.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;
if (!data.WriteInterfaceToken(GetDescriptor())) {
DHLOGE("StartDInputServerCallbackProxy write token valid failed");
return;
}
if (!data.WriteInt32(status)) {
DHLOGE("StartDInputServerCallbackProxy write status failed");
return;
}
if (!data.WriteUint32(inputTypes)) {
DHLOGE("StartDInputServerCallbackProxy write inputTypes failed");
return;
}
int32_t ret = remote->SendRequest(
static_cast<int32_t>(IStartDInputServerCallback::Message::RESULT), data, reply, option);
if (ret != 0) {
return;
}
}
} // namespace DistributedInput
} // namespace DistributedHardware
} // namespace OHOS
+1
View File
@@ -21,6 +21,7 @@ ohos_shared_library("libdinput_collector") {
"${common_path}/include",
"//commonlibrary/c_utils/base/include",
"//utils/system/safwk/native/include",
"${frameworks_path}/include",
"${fwk_common_path}/log/include",
"${fwk_common_path}/utils/include",
"${fwk_utils_path}/include/log",
@@ -25,9 +25,11 @@
#include <linux/input.h>
#include "event_handler.h"
#include "refbase.h"
#include "constants_dinput.h"
#include "input_hub.h"
#include "i_sharing_dhid_listener.h"
namespace OHOS {
namespace DistributedHardware {
@@ -37,11 +39,12 @@ public:
static DistributedInputCollector &GetInstance();
int32_t Init(std::shared_ptr<AppExecFwk::EventHandler> sinkHandler);
void Release();
void SetSharingTypes(const uint32_t &inputType);
void SetSharingTypes(bool enabled, const uint32_t &inputType);
void SetSharingDhIds(bool enabled, std::vector<std::string> dhIds);
void GetMouseNodePath(std::vector<std::string> dhIds, std::string &mouseNodePath, std::string &dhid);
// false for sharing device exist, true for all devices stop sharing
bool IsAllDevicesStoped();
int32_t RegisterSharingDhIdListener(sptr<ISharingDhIdListener> sharingDhIdListener);
private:
DistributedInputCollector();
@@ -51,6 +54,7 @@ private:
static void *CollectEventsThread(void *param);
void StartCollectEventsThread();
void StopCollectEventsThread();
void ReportDhIdSharingState(const AffectDhIds &dhIds);
RawEvent mEventBuffer[INPUT_EVENT_BUFFER_SIZE];
pthread_t collectThreadID_;
@@ -59,6 +63,9 @@ private:
std::unique_ptr<InputHub> inputHub_;
std::shared_ptr<AppExecFwk::EventHandler> sinkHandler_;
uint32_t inputTypes_;
std::mutex sharingDhIdListenerMtx_;
sptr<ISharingDhIdListener> sharingDhIdListener_ = nullptr;
};
} // namespace DistributedInput
} // namespace DistributedHardware
@@ -140,10 +140,11 @@ void DistributedInputCollector::StopCollectEventsThread()
DHLOGW("DistributedInputCollector::StopCollectEventsThread exit!");
}
void DistributedInputCollector::SetSharingTypes(const uint32_t &inputType)
void DistributedInputCollector::SetSharingTypes(bool enabled, const uint32_t &inputType)
{
inputTypes_ = 0;
if ((inputType & static_cast<uint32_t>(DInputDeviceType::MOUSE)) != 0) {
if ((inputType & static_cast<uint32_t>(DInputDeviceType::MOUSE)) != 0 ||
(inputType & static_cast<uint32_t>(DInputDeviceType::TOUCHPAD)) != 0) {
inputTypes_ |= INPUT_DEVICE_CLASS_CURSOR;
}
if ((inputType & static_cast<uint32_t>(DInputDeviceType::KEYBOARD)) != 0) {
@@ -153,7 +154,27 @@ void DistributedInputCollector::SetSharingTypes(const uint32_t &inputType)
inputTypes_ |= INPUT_DEVICE_CLASS_TOUCH_MT | INPUT_DEVICE_CLASS_TOUCH;
}
inputHub_->SetSupportInputType(inputTypes_);
AffectDhIds dhIds = inputHub_->SetSupportInputType(enabled, inputTypes_);
ReportDhIdSharingState(dhIds);
}
void DistributedInputCollector::ReportDhIdSharingState(const AffectDhIds &dhIds)
{
std::lock_guard<std::mutex> lock(sharingDhIdListenerMtx_);
if (sharingDhIdListener_ == nullptr) {
DHLOGI("sharingDhIdListener_ is null, can not report sharing dhid");
return;
}
for (auto const &id : dhIds.sharingDhIds) {
DHLOGI("Sharing DhId: %s", id.c_str());
sharingDhIdListener_->OnSharing(id);
}
for (auto const &id : dhIds.noSharingDhIds) {
DHLOGI("No Sharing DhId: %s", id.c_str());
sharingDhIdListener_->OnNoSharing(id);
}
}
void DistributedInputCollector::Release()
@@ -163,7 +184,8 @@ void DistributedInputCollector::Release()
void DistributedInputCollector::SetSharingDhIds(bool enabled, std::vector<std::string> dhIds)
{
inputHub_->SetSharingDevices(enabled, dhIds);
AffectDhIds affdhIds = inputHub_->SetSharingDevices(enabled, dhIds);
ReportDhIdSharingState(affdhIds);
}
void DistributedInputCollector::GetMouseNodePath(
@@ -176,6 +198,14 @@ bool DistributedInputCollector::IsAllDevicesStoped()
{
return inputHub_->IsAllDevicesStoped();
}
int32_t DistributedInputCollector::RegisterSharingDhIdListener(sptr<ISharingDhIdListener> sharingDhIdListener)
{
DHLOGI("RegisterSharingDhIdListener");
std::lock_guard<std::mutex> lock(sharingDhIdListenerMtx_);
sharingDhIdListener_ = sharingDhIdListener;
return DH_SUCCESS;
}
} // namespace DistributedInput
} // namespace DistributedHardware
} // namespace OHOS
-2
View File
@@ -46,8 +46,6 @@ ohos_shared_library("libdinput_sink") {
sources = [
"${common_path}/include/white_list_util.cpp",
"${ipc_path}/src/distributed_input_sink_stub.cpp",
"${ipc_path}/src/start_d_input_server_call_back_proxy.cpp",
"${ipc_path}/src/start_d_input_server_call_back_stub.cpp",
"src/distributed_input_sink_event_handler.cpp",
"src/distributed_input_sink_manager.cpp",
]
@@ -97,11 +97,6 @@ public:
virtual int32_t Release() override;
virtual int32_t IsStartDistributedInput(
const uint32_t& inputType, sptr<IStartDInputServerCallback> callback) override;
IStartDInputServerCallback* GetStartDInputServerCback();
DInputServerType GetStartTransFlag();
void SetStartTransFlag(const DInputServerType flag);
@@ -121,6 +116,8 @@ public:
int32_t NotifyStopDScreen(const std::string& srcScreenInfoKey) override;
int32_t RegisterSharingDhIdListener(sptr<ISharingDhIdListener> sharingDhIdListener) override;
int32_t Dump(int32_t fd, const std::vector<std::u16string>& args) override;
private:
@@ -130,7 +127,6 @@ private:
ServiceSinkRunningState serviceRunningState_ = ServiceSinkRunningState::STATE_NOT_START;
DInputServerType isStartTrans_ = DInputServerType::NULL_SERVER_TYPE;
std::shared_ptr<DistributedInputSinkManager::DInputSinkListener> statuslistener_;
sptr<IStartDInputServerCallback> startServerCallback_ = nullptr;
std::shared_ptr<AppExecFwk::EventRunner> runner_;
std::shared_ptr<DistributedInputSinkEventHandler> handler_;
@@ -156,15 +156,7 @@ void DistributedInputSinkManager::DInputSinkListener::onStartRemoteInput(
// add the input type
if (startRes == DH_SUCCESS) {
sinkManagerObj_->SetInputTypes(sinkManagerObj_->GetInputTypes() | inputTypes);
DistributedInputCollector::GetInstance().SetSharingTypes(sinkManagerObj_->GetInputTypes());
}
IStartDInputServerCallback *startServerCB = sinkManagerObj_->GetStartDInputServerCback();
if (startServerCB == nullptr) {
DHLOGE("onStartRemoteInput called, startServerCB is null.");
} else {
startServerCB->OnResult(
static_cast<int32_t>(sinkManagerObj_->GetStartTransFlag()), sinkManagerObj_->GetInputTypes());
DistributedInputCollector::GetInstance().SetSharingTypes(true, sinkManagerObj_->GetInputTypes());
}
}
@@ -176,7 +168,7 @@ void DistributedInputSinkManager::DInputSinkListener::onStopRemoteInput(
sinkManagerObj_->SetInputTypes(sinkManagerObj_->GetInputTypes() -
(sinkManagerObj_->GetInputTypes() & inputTypes));
DistributedInputCollector::GetInstance().SetSharingTypes(sinkManagerObj_->GetInputTypes());
DistributedInputCollector::GetInstance().SetSharingTypes(false, inputTypes);
nlohmann::json jsonStr;
jsonStr[DINPUT_SOFTBUS_KEY_CMD_TYPE] = TRANS_SINK_MSG_ONSTOP;
@@ -194,14 +186,6 @@ void DistributedInputSinkManager::DInputSinkListener::onStopRemoteInput(
sinkManagerObj_->SetStartTransFlag(DInputServerType::NULL_SERVER_TYPE);
}
}
IStartDInputServerCallback *startServerCB = sinkManagerObj_->GetStartDInputServerCback();
if (startServerCB == nullptr) {
DHLOGE("startServerCB is null.");
} else {
startServerCB->OnResult(
static_cast<int32_t>(sinkManagerObj_->GetStartTransFlag()), sinkManagerObj_->GetInputTypes());
}
}
void DistributedInputSinkManager::DInputSinkListener::onStartRemoteInputDhid(const int32_t &sessionId,
@@ -518,13 +502,6 @@ int32_t DistributedInputSinkManager::Release()
// 3.notify callback servertype
SetStartTransFlag(DInputServerType::NULL_SERVER_TYPE);
IStartDInputServerCallback *startServerCB = GetStartDInputServerCback();
if (startServerCB == nullptr) {
DHLOGE("Release() called, startServerCB is null.");
} else {
startServerCB->OnResult(0, 0);
}
// 4.Release input collect resource
DistributedInputCollector::GetInstance().Release();
@@ -540,28 +517,6 @@ int32_t DistributedInputSinkManager::Release()
return DH_SUCCESS;
}
int32_t DistributedInputSinkManager::IsStartDistributedInput(
const uint32_t& inputType, sptr<IStartDInputServerCallback> callback)
{
if (callback != nullptr) {
startServerCallback_ = callback;
if (GetStartTransFlag() != DInputServerType::NULL_SERVER_TYPE) {
startServerCallback_->OnResult(static_cast<int32_t>(GetStartTransFlag()), GetInputTypes());
}
}
if (inputType & GetInputTypes()) {
return static_cast<int32_t>(isStartTrans_);
} else {
return static_cast<int32_t>(DInputServerType::NULL_SERVER_TYPE);
}
}
IStartDInputServerCallback* DistributedInputSinkManager::GetStartDInputServerCback()
{
return startServerCallback_;
}
DInputServerType DistributedInputSinkManager::GetStartTransFlag()
{
return isStartTrans_;
@@ -754,6 +709,13 @@ int32_t DistributedInputSinkManager::NotifyStopDScreen(const std::string& srcScr
return DInputContext::GetInstance().RemoveSinkScreenInfo(srcScreenInfoKey);
}
int32_t DistributedInputSinkManager::RegisterSharingDhIdListener(sptr<ISharingDhIdListener> sharingDhIdListener)
{
DHLOGI("RegisterSharingDhIdListener");
DistributedInputCollector::GetInstance().RegisterSharingDhIdListener(sharingDhIdListener);
return DH_SUCCESS;
}
int32_t DistributedInputSinkManager::Dump(int32_t fd, const std::vector<std::u16string>& args)
{
DHLOGI("DistributedInputSinkManager Dump.");
@@ -58,8 +58,6 @@ ohos_unittest("distributed_input_sinkmanager_test") {
"${common_path}/include/input_hub.cpp",
"${common_path}/include/white_list_util.cpp",
"${ipc_path}/src/distributed_input_sink_stub.cpp",
"${ipc_path}/src/start_d_input_server_call_back_proxy.cpp",
"${ipc_path}/src/start_d_input_server_call_back_stub.cpp",
"${services_sink_path}/inputcollector/src/distributed_input_collector.cpp",
"//foundation/distributedhardware/distributed_input/services/sink/sinkmanager/src/distributed_input_sink_event_handler.cpp",
"//foundation/distributedhardware/distributed_input/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp",
+2 -2
View File
@@ -61,8 +61,6 @@ ohos_shared_library("libdinput_source") {
"${ipc_path}/src/register_d_input_call_back_stub.cpp",
"${ipc_path}/src/start_d_input_call_back_proxy.cpp",
"${ipc_path}/src/start_d_input_call_back_stub.cpp",
"${ipc_path}/src/start_d_input_server_call_back_proxy.cpp",
"${ipc_path}/src/start_d_input_server_call_back_stub.cpp",
"${ipc_path}/src/stop_d_input_call_back_proxy.cpp",
"${ipc_path}/src/stop_d_input_call_back_stub.cpp",
"${ipc_path}/src/start_stop_d_inputs_call_back_proxy.cpp",
@@ -71,6 +69,8 @@ ohos_shared_library("libdinput_source") {
"${ipc_path}/src/start_stop_result_call_back_stub.cpp",
"${ipc_path}/src/input_node_listener_proxy.cpp",
"${ipc_path}/src/input_node_listener_stub.cpp",
"${ipc_path}/src/sharing_dhid_listener_proxy.cpp",
"${ipc_path}/src/sharing_dhid_listener_stub.cpp",
"${ipc_path}/src/simulation_event_listener_proxy.cpp",
"${ipc_path}/src/simulation_event_listener_stub.cpp",
"${ipc_path}/src/unprepare_d_input_call_back_proxy.cpp",
@@ -155,8 +155,6 @@ public:
virtual int32_t StopRemoteInput(const std::string &srcId, const std::string &sinkId,
const std::vector<std::string> &dhIds, sptr<IStartStopDInputsCallback> callback) override;
virtual int32_t IsStartDistributedInput(
const uint32_t& inputType, sptr<IStartDInputServerCallback> callback) override;
virtual int32_t RegisterAddWhiteListCallback(sptr<IAddWhiteListInfosCallback> addWhiteListCallback) override;
virtual int32_t RegisterDelWhiteListCallback(sptr<IDelWhiteListInfosCallback> delWhiteListCallback) override;
virtual int32_t RegisterInputNodeListener(sptr<InputNodeListener> listener) override;
@@ -275,7 +273,6 @@ public:
void RunKeyStateCallback(const std::string &sinkId, const std::string &dhId, const uint32_t type,
const uint32_t code, const uint32_t value);
IStartDInputServerCallback* GetStartDInputServerCback();
DInputServerType GetStartTransFlag();
void SetStartTransFlag(const DInputServerType flag);
std::vector<InputDeviceId> GetInputDeviceId();
@@ -353,7 +350,6 @@ private:
std::vector<DInputClientUnprepareInfo> unpreCallbacks_;
std::vector<DInputClientStartInfo> staCallbacks_;
std::vector<DInputClientStopInfo> stpCallbacks_;
sptr<IStartDInputServerCallback> startServerCallback_ = nullptr;
std::vector<DInputClientStartDhidInfo> staStringCallbacks_;
std::vector<DInputClientStopDhidInfo> stpStringCallbacks_;
@@ -495,13 +495,6 @@ void DistributedInputSourceManager::DInputSourceManagerEventHandler::NotifyStart
}
sourceManagerObj_->SetStartTransFlag((result && (sourceManagerObj_->GetInputTypesMap(deviceId) > 0)) ?
DInputServerType::SOURCE_SERVER_TYPE : DInputServerType::NULL_SERVER_TYPE);
if (sourceManagerObj_->GetStartDInputServerCback() != nullptr) {
sourceManagerObj_->GetStartDInputServerCback()->OnResult(
static_cast<int32_t>(sourceManagerObj_->GetStartTransFlag()),
sourceManagerObj_->GetAllInputTypesMap());
} else {
DHLOGE("ProcessEvent GetStartDInputServerCback() or is null.");
}
sourceManagerObj_->RunStartCallback(deviceId, inputTypes,
result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_MSG_IS_BAD);
}
@@ -534,13 +527,6 @@ void DistributedInputSourceManager::DInputSourceManagerEventHandler::NotifyStopC
DHLOGI("All Dev Switch Off");
sourceManagerObj_->SetStartTransFlag(DInputServerType::NULL_SERVER_TYPE);
}
if (sourceManagerObj_->GetStartDInputServerCback() != nullptr) {
sourceManagerObj_->GetStartDInputServerCback()->OnResult(
static_cast<int32_t>(sourceManagerObj_->GetStartTransFlag()),
sourceManagerObj_->GetAllInputTypesMap());
} else {
DHLOGE("ProcessEvent GetStartDInputServerCback() is null.");
}
sourceManagerObj_->RunStopCallback(deviceId, inputTypes,
result ? DH_SUCCESS : ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_MSG_IS_BAD);
}
@@ -605,13 +591,6 @@ void DistributedInputSourceManager::DInputSourceManagerEventHandler::NotifyStart
int32_t serType = innerMsg[INPUT_SOURCEMANAGER_KEY_RESULT];
DInputServerType startTransFlag = DInputServerType(serType);
sourceManagerObj_->SetStartTransFlag(startTransFlag);
if (sourceManagerObj_->GetStartDInputServerCback() != nullptr) {
sourceManagerObj_->GetStartDInputServerCback()->OnResult(
serType, static_cast<uint32_t>(DInputDeviceType::NONE));
} else {
DHLOGE("ProcessEvent GetStartDInputServerCback() is null.");
}
}
void DistributedInputSourceManager::DInputSourceManagerEventHandler::ProcessEvent(
@@ -1690,24 +1669,6 @@ int32_t DistributedInputSourceManager::StopRemoteInput(const std::string &srcId,
return DH_SUCCESS;
}
int32_t DistributedInputSourceManager::IsStartDistributedInput(
const uint32_t& inputType, sptr<IStartDInputServerCallback> callback)
{
if (callback != nullptr) {
startServerCallback_ = callback;
if (GetStartTransFlag() != DInputServerType::NULL_SERVER_TYPE) {
startServerCallback_->OnResult(static_cast<int32_t>(GetStartTransFlag()), GetAllInputTypesMap());
}
}
DHLOGI("param inputType: %d, allInputTypes: %d", inputType, GetAllInputTypesMap());
if (inputType & GetAllInputTypesMap()) {
return static_cast<int32_t>(isStartTrans_);
} else {
return static_cast<int32_t>(DInputServerType::NULL_SERVER_TYPE);
}
}
int32_t DistributedInputSourceManager::RegisterAddWhiteListCallback(sptr<IAddWhiteListInfosCallback> callback)
{
DHLOGI("RegisterAddWhiteListCallback called.");
@@ -2090,11 +2051,6 @@ void DistributedInputSourceManager::StringSplitToVector(const std::string &str,
}
}
IStartDInputServerCallback* DistributedInputSourceManager::GetStartDInputServerCback()
{
return startServerCallback_;
}
DInputServerType DistributedInputSourceManager::GetStartTransFlag()
{
return isStartTrans_;
@@ -73,8 +73,6 @@ ohos_unittest("distributed_input_sourcemanager_test") {
"${ipc_path}/src/register_d_input_call_back_stub.cpp",
"${ipc_path}/src/start_d_input_call_back_proxy.cpp",
"${ipc_path}/src/start_d_input_call_back_stub.cpp",
"${ipc_path}/src/start_d_input_server_call_back_proxy.cpp",
"${ipc_path}/src/start_d_input_server_call_back_stub.cpp",
"${ipc_path}/src/stop_d_input_call_back_proxy.cpp",
"${ipc_path}/src/stop_d_input_call_back_stub.cpp",
"${ipc_path}/src/unprepare_d_input_call_back_proxy.cpp",
@@ -61,20 +61,6 @@ void DistributedInputClient::UnregisterDInputCb::OnResult(
}
}
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_ = static_cast<DInputDeviceType>(inputTypes);
} else if (DInputServerType::SINK_SERVER_TYPE == static_cast<DInputServerType>(status)) {
DistributedInputClient::GetInstance().serverType = DInputServerType::SINK_SERVER_TYPE;
DistributedInputClient::GetInstance().inputTypes_ = static_cast<DInputDeviceType>(inputTypes);
} else {
DistributedInputClient::GetInstance().serverType = DInputServerType::NULL_SERVER_TYPE;
DistributedInputClient::GetInstance().inputTypes_ = DInputDeviceType::NONE;
}
}
void DistributedInputClient::AddWhiteListInfosCb::OnResult(const std::string &deviceId, const std::string &strJson)
{
nlohmann::json inputData = nlohmann::json::parse(strJson);
@@ -150,11 +136,6 @@ bool DistributedInputClient::IsNeedFilterOut(const std::string& deviceId, const
return true;
}
DInputServerType DistributedInputClient::IsStartDistributedInput(const uint32_t& inputType)
{
return serverType;
}
bool DistributedInputClient::IsJsonData(std::string strData) const
{
return true;
@@ -61,20 +61,6 @@ void DistributedInputClient::UnregisterDInputCb::OnResult(
}
}
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_ = static_cast<DInputDeviceType>(inputTypes);
} else if (DInputServerType::SINK_SERVER_TYPE == static_cast<DInputServerType>(status)) {
DistributedInputClient::GetInstance().serverType = DInputServerType::SINK_SERVER_TYPE;
DistributedInputClient::GetInstance().inputTypes_ = static_cast<DInputDeviceType>(inputTypes);
} else {
DistributedInputClient::GetInstance().serverType = DInputServerType::NULL_SERVER_TYPE;
DistributedInputClient::GetInstance().inputTypes_ = DInputDeviceType::NONE;
}
}
void DistributedInputClient::AddWhiteListInfosCb::OnResult(const std::string &deviceId, const std::string &strJson)
{
nlohmann::json inputData = nlohmann::json::parse(strJson);
@@ -150,11 +136,6 @@ bool DistributedInputClient::IsNeedFilterOut(const std::string& deviceId, const
return true;
}
DInputServerType DistributedInputClient::IsStartDistributedInput(const uint32_t& inputType)
{
return serverType;
}
bool DistributedInputClient::IsJsonData(std::string strData) const
{
return true;