mirror of
https://github.com/openharmony/distributedhardware_distributed_input.git
synced 2026-07-15 05:55:38 -04:00
Description:sync code
Match-id-ae901069d012cb1ccf50efd2545d870f46d2fe14
This commit is contained in:
@@ -64,7 +64,7 @@ ohos_unittest("distributed_input_white_list_test") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//foundation/bundlemanager/bundle_framework/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//utils/native/base:utils",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"//foundation/communication/dsoftbus/sdk:softbus_client",
|
||||
|
||||
@@ -40,7 +40,7 @@ ohos_shared_library("libdinput_handler") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//foundation/bundlemanager/bundle_framework/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//utils/native/base:utils",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"//third_party/openssl:libcrypto_static",
|
||||
|
||||
@@ -47,8 +47,6 @@ private:
|
||||
int32_t GetDeviceInfo(std::string& deviceId);
|
||||
std::shared_ptr<PluginListener> m_listener;
|
||||
bool InitCollectEventsThread();
|
||||
bool Init();
|
||||
bool Release();
|
||||
void NotifyHardWare(int iCnt);
|
||||
|
||||
pthread_t collectThreadID_;
|
||||
|
||||
@@ -33,6 +33,18 @@ namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
namespace DistributedInput {
|
||||
IMPLEMENT_SINGLE_INSTANCE(DistributedInputHandler);
|
||||
DistributedInputHandler::DistributedInputHandler()
|
||||
: collectThreadID_(-1), isCollectingEvents_(false),
|
||||
isStartCollectEventThread(false)
|
||||
{
|
||||
inputHub_ = std::make_unique<InputHub>();
|
||||
this->m_listener = nullptr;
|
||||
}
|
||||
|
||||
DistributedInputHandler::~DistributedInputHandler()
|
||||
{
|
||||
StopInputMonitorDeviceThread();
|
||||
}
|
||||
|
||||
void DistributedInputHandler::StructTransJson(const InputDevice& pBuf, std::string& strDescriptor)
|
||||
{
|
||||
@@ -56,24 +68,6 @@ void DistributedInputHandler::StructTransJson(const InputDevice& pBuf, std::stri
|
||||
return;
|
||||
}
|
||||
|
||||
DistributedInputHandler::DistributedInputHandler()
|
||||
: collectThreadID_(-1), isCollectingEvents_(false),
|
||||
isStartCollectEventThread(false)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
DistributedInputHandler::~DistributedInputHandler()
|
||||
{
|
||||
Release();
|
||||
}
|
||||
|
||||
bool DistributedInputHandler::Release()
|
||||
{
|
||||
StopInputMonitorDeviceThread();
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t DistributedInputHandler::Initialize()
|
||||
{
|
||||
if (!isStartCollectEventThread) {
|
||||
@@ -83,13 +77,6 @@ int32_t DistributedInputHandler::Initialize()
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
bool DistributedInputHandler::Init()
|
||||
{
|
||||
inputHub_ = std::make_unique<InputHub>();
|
||||
this->m_listener = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<DHItem> DistributedInputHandler::Query()
|
||||
{
|
||||
std::vector<DHItem> retInfos;
|
||||
|
||||
@@ -84,7 +84,7 @@ ohos_unittest("distributed_input_inner_test") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//foundation/bundlemanager/bundle_framework/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//utils/native/base:utils",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
]
|
||||
|
||||
@@ -39,7 +39,7 @@ ohos_shared_library("libdinput_collector") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//foundation/bundlemanager/bundle_framework/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//utils/native/base:utils",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"//third_party/openssl:libcrypto_static",
|
||||
|
||||
@@ -39,8 +39,6 @@ private:
|
||||
~DistributedInputCollector();
|
||||
|
||||
bool InitCollectEventsThread();
|
||||
bool Initialize();
|
||||
bool Release();
|
||||
static void *CollectEventsThread(void *param);
|
||||
void StartCollectEventsThread();
|
||||
void StopCollectEventsThread();
|
||||
|
||||
@@ -38,18 +38,12 @@ DistributedInputCollector::DistributedInputCollector()
|
||||
: collectThreadID_(-1), isCollectingEvents_(false),
|
||||
isStartGetDeviceHandlerThread(false), input_types_(0)
|
||||
{
|
||||
Initialize();
|
||||
inputHub_ = std::make_unique<InputHub>();
|
||||
}
|
||||
|
||||
DistributedInputCollector::~DistributedInputCollector()
|
||||
{
|
||||
Release();
|
||||
}
|
||||
|
||||
bool DistributedInputCollector::Release()
|
||||
{
|
||||
StopCollectEventsThread();
|
||||
return true;
|
||||
}
|
||||
|
||||
DistributedInputCollector &DistributedInputCollector::GetInstance()
|
||||
@@ -72,12 +66,6 @@ int32_t DistributedInputCollector::Init(std::shared_ptr<AppExecFwk::EventHandler
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
bool DistributedInputCollector::Initialize()
|
||||
{
|
||||
inputHub_ = std::make_unique<InputHub>();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DistributedInputCollector::InitCollectEventsThread()
|
||||
{
|
||||
pthread_attr_t attr;
|
||||
|
||||
@@ -52,7 +52,7 @@ ohos_shared_library("libdinput_sink") {
|
||||
|
||||
deps = [
|
||||
"//foundation/distributedhardware/distributedinput/interfaces/inner_kits:libdinput_sdk",
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//foundation/bundlemanager/bundle_framework/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//utils/native/base:utils",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"//foundation/distributedhardware/distributedinput/services/sink/transport:libdinput_sink_trans",
|
||||
|
||||
@@ -232,10 +232,6 @@ bool DistributedInputSinkManager::InitAuto()
|
||||
}
|
||||
|
||||
handler_ = std::make_shared<DistributedInputSinkEventHandler>(runner_);
|
||||
if (handler_ == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
DHLOGI("init success");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ ohos_unittest("distributed_input_sinkmanager_test") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//foundation/bundlemanager/bundle_framework/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//utils/native/base:utils",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"//foundation/communication/dsoftbus/sdk:softbus_client",
|
||||
|
||||
@@ -41,7 +41,7 @@ ohos_shared_library("libdinput_sink_trans") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//foundation/bundlemanager/bundle_framework/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy",
|
||||
"//utils/native/base:utils",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
|
||||
@@ -21,12 +21,6 @@
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
namespace DistributedInput {
|
||||
DistributedInputSinkSwitch &DistributedInputSinkSwitch::GetInstance()
|
||||
{
|
||||
static DistributedInputSinkSwitch instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
DistributedInputSinkSwitch::DistributedInputSinkSwitch()
|
||||
{
|
||||
InitSwitch();
|
||||
@@ -38,6 +32,12 @@ DistributedInputSinkSwitch::~DistributedInputSinkSwitch()
|
||||
InitSwitch();
|
||||
}
|
||||
|
||||
DistributedInputSinkSwitch &DistributedInputSinkSwitch::GetInstance()
|
||||
{
|
||||
static DistributedInputSinkSwitch instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void DistributedInputSinkSwitch::InitSwitch()
|
||||
{
|
||||
DHLOGI("InitSwitch.");
|
||||
@@ -57,8 +57,7 @@ int32_t DistributedInputSinkSwitch::StartSwitch(int32_t sessionId)
|
||||
if ((*it).sessionId == sessionId) {
|
||||
(*it).switchState = true;
|
||||
findOld = true;
|
||||
} else {
|
||||
(*it).switchState = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,26 @@
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
namespace DistributedInput {
|
||||
DistributedInputSinkTransport::DistributedInputSinkTransport()
|
||||
{
|
||||
std::shared_ptr<AppExecFwk::EventRunner> runner = AppExecFwk::EventRunner::Create(true);
|
||||
eventHandler_ = std::make_shared<DistributedInputSinkTransport::DInputSinkEventHandler>(runner);
|
||||
mySessionName_ = "";
|
||||
DHLOGI("DistributedInputSinkTransport eventHandler_");
|
||||
}
|
||||
|
||||
DistributedInputSinkTransport::~DistributedInputSinkTransport()
|
||||
{
|
||||
DHLOGI("~DistributedInputSinkTransport");
|
||||
sessionDevMap_.clear();
|
||||
(void)RemoveSessionServer(DINPUT_PKG_NAME.c_str(), mySessionName_.c_str());
|
||||
}
|
||||
|
||||
DistributedInputSinkTransport::DInputSinkEventHandler::DInputSinkEventHandler(
|
||||
const std::shared_ptr<AppExecFwk::EventRunner> &runner) : AppExecFwk::EventHandler(runner)
|
||||
{
|
||||
}
|
||||
|
||||
static int32_t SessionOpened(int32_t sessionId, int32_t result)
|
||||
{
|
||||
return DistributedInput::DistributedInputSinkTransport::GetInstance().OnSessionOpened(sessionId, result);
|
||||
@@ -61,26 +81,6 @@ DistributedInputSinkTransport &DistributedInputSinkTransport::GetInstance()
|
||||
return instance;
|
||||
}
|
||||
|
||||
DistributedInputSinkTransport::DistributedInputSinkTransport()
|
||||
{
|
||||
std::shared_ptr<AppExecFwk::EventRunner> runner = AppExecFwk::EventRunner::Create(true);
|
||||
eventHandler_ = std::make_shared<DistributedInputSinkTransport::DInputSinkEventHandler>(runner);
|
||||
mySessionName_ = "";
|
||||
DHLOGI("DistributedInputSinkTransport eventHandler_");
|
||||
}
|
||||
|
||||
DistributedInputSinkTransport::~DistributedInputSinkTransport()
|
||||
{
|
||||
DHLOGI("~DistributedInputSinkTransport");
|
||||
sessionDevMap_.clear();
|
||||
(void)RemoveSessionServer(DINPUT_PKG_NAME.c_str(), mySessionName_.c_str());
|
||||
}
|
||||
|
||||
DistributedInputSinkTransport::DInputSinkEventHandler::DInputSinkEventHandler(
|
||||
const std::shared_ptr<AppExecFwk::EventRunner> &runner) : AppExecFwk::EventHandler(runner)
|
||||
{
|
||||
}
|
||||
|
||||
void DistributedInputSinkTransport::DInputSinkEventHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
{
|
||||
DHLOGI("ProcessEvent");
|
||||
@@ -119,12 +119,7 @@ int32_t DistributedInputSinkTransport::Init()
|
||||
.OnStreamReceived = StreamReceived
|
||||
};
|
||||
auto localNode = std::make_unique<NodeBasicInfo>();
|
||||
if (localNode == nullptr) {
|
||||
DHLOGE("Init unique_ptr localNode nullptr.");
|
||||
return FAILURE;
|
||||
}
|
||||
int32_t retCode = GetLocalNodeDeviceInfo(DINPUT_PKG_NAME.c_str(), localNode.get());
|
||||
|
||||
if (retCode != SUCCESS) {
|
||||
DHLOGE("Init could not get local device id.");
|
||||
return FAILURE;
|
||||
@@ -133,7 +128,6 @@ int32_t DistributedInputSinkTransport::Init()
|
||||
DHLOGI("Init device networkId is %s", networkId.c_str());
|
||||
mySessionName_ = SESSION_NAME_SINK + networkId.substr(0, INTERCEPT_STRING_LENGTH);
|
||||
|
||||
|
||||
int32_t ret = CreateSessionServer(DINPUT_PKG_NAME.c_str(), mySessionName_.c_str(), &iSessionListener);
|
||||
if (ret != SUCCESS) {
|
||||
DHLOGE("Init CreateSessionServer failed, error code %d.", ret);
|
||||
|
||||
@@ -60,7 +60,7 @@ ohos_unittest("distributed_input_sinktrans_test") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//foundation/bundlemanager/bundle_framework/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//utils/native/base:utils",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"//foundation/communication/dsoftbus/sdk:softbus_client",
|
||||
|
||||
@@ -43,7 +43,7 @@ ohos_shared_library("libdinput_inject") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//foundation/bundlemanager/bundle_framework/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//utils/native/base:utils",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"//third_party/openssl:libcrypto_static",
|
||||
|
||||
@@ -32,8 +32,6 @@ public:
|
||||
|
||||
int32_t UnregisterDistributedHardware(const std::string& devId, const std::string& dhId);
|
||||
int32_t PrepareRemoteInput();
|
||||
int32_t Init();
|
||||
bool Release();
|
||||
int32_t RegisterDistributedEvent(RawEvent* buffer, size_t bufferSize);
|
||||
int32_t StructTransJson(const InputDevice& pBuf, std::string& strDescriptor);
|
||||
|
||||
|
||||
@@ -35,15 +35,12 @@ public:
|
||||
int32_t openDevicesNode(const std::string& devId, const std::string& dhId,
|
||||
const std::string& parameters);
|
||||
|
||||
int32_t Init();
|
||||
|
||||
int32_t getDevice(const std::string& dhId, VirtualDevice*& device);
|
||||
void ReportEvent(const RawEvent rawEvent);
|
||||
int32_t CloseDeviceLocked(const std::string& dhId);
|
||||
void StartInjectThread();
|
||||
|
||||
private:
|
||||
bool Release();
|
||||
void AddDeviceLocked(const std::string& dhId, std::unique_ptr<VirtualDevice> device);
|
||||
int32_t CreateHandle(InputDevice event, const std::string& devId);
|
||||
void CloseAllDevicesLocked();
|
||||
|
||||
@@ -25,7 +25,12 @@ namespace DistributedInput {
|
||||
DistributedInputInject::DistributedInputInject()
|
||||
: isStartInjectThread_(false)
|
||||
{
|
||||
Init();
|
||||
inputNodeManager_ = std::make_unique<Distributed_input_node_manager>();
|
||||
}
|
||||
|
||||
DistributedInputInject::~DistributedInputInject()
|
||||
{
|
||||
isStartInjectThread_ = false;
|
||||
}
|
||||
|
||||
DistributedInputInject &DistributedInputInject::GetInstance()
|
||||
@@ -34,23 +39,6 @@ DistributedInputInject &DistributedInputInject::GetInstance()
|
||||
return instance;
|
||||
}
|
||||
|
||||
int32_t DistributedInputInject::Init()
|
||||
{
|
||||
inputNodeManager_ = std::make_unique<Distributed_input_node_manager>();
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
DistributedInputInject::~DistributedInputInject()
|
||||
{
|
||||
Release();
|
||||
}
|
||||
|
||||
bool DistributedInputInject::Release()
|
||||
{
|
||||
isStartInjectThread_ = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t DistributedInputInject::RegisterDistributedHardware(const std::string& devId, const std::string& dhId,
|
||||
const std::string& parameters)
|
||||
{
|
||||
|
||||
@@ -34,23 +34,11 @@ static const uint32_t INPUT_DEVICE_CLASS_TOUCH = static_cast<uint32_t>(DeviceCla
|
||||
|
||||
Distributed_input_node_manager::Distributed_input_node_manager()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
int32_t Distributed_input_node_manager::Init()
|
||||
{
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
Distributed_input_node_manager::~Distributed_input_node_manager()
|
||||
{
|
||||
Release();
|
||||
}
|
||||
|
||||
bool Distributed_input_node_manager::Release()
|
||||
{
|
||||
CloseAllDevicesLocked();
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t Distributed_input_node_manager::openDevicesNode(const std::string& devId, const std::string& dhId,
|
||||
|
||||
@@ -23,16 +23,6 @@
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
namespace DistributedInput {
|
||||
bool VirtualDevice::DoIoctl(int32_t fd, int32_t request, const uint32_t value)
|
||||
{
|
||||
int32_t rc = ioctl(fd, request, value);
|
||||
if (rc < 0) {
|
||||
DHLOGE("%s ioctl failed", __func__);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
VirtualDevice::VirtualDevice()
|
||||
: deviceName_(""), netWorkId_(""), busTtype_(0), vendorId_(0), productId_(0), version_(0)
|
||||
{
|
||||
@@ -53,6 +43,16 @@ VirtualDevice::~VirtualDevice()
|
||||
}
|
||||
}
|
||||
|
||||
bool VirtualDevice::DoIoctl(int32_t fd, int32_t request, const uint32_t value)
|
||||
{
|
||||
int32_t rc = ioctl(fd, request, value);
|
||||
if (rc < 0) {
|
||||
DHLOGE("%s ioctl failed", __func__);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VirtualDevice::CreateKey()
|
||||
{
|
||||
auto fun = [&](int32_t uiSet, const std::vector<uint32_t>& list) -> bool {
|
||||
|
||||
@@ -69,7 +69,7 @@ ohos_unittest("distributed_input_inner_sourceinject_test") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//foundation/bundlemanager/bundle_framework/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//utils/native/base:utils",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"//foundation/communication/dsoftbus/sdk:softbus_client",
|
||||
|
||||
@@ -72,7 +72,7 @@ ohos_shared_library("libdinput_source") {
|
||||
|
||||
deps = [
|
||||
"//foundation/distributedhardware/distributedinput/interfaces/inner_kits:libdinput_sdk",
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//foundation/bundlemanager/bundle_framework/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//utils/native/base:utils",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"//foundation/distributedhardware/distributedinput/services/source/transport:libdinput_source_trans",
|
||||
|
||||
@@ -262,9 +262,6 @@ bool DistributedInputSourceManager::InitAuto()
|
||||
}
|
||||
|
||||
handler_ = std::make_shared<DistributedInputSourceEventHandler>(runner_);
|
||||
if (handler_ == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
DHLOGI("init success");
|
||||
|
||||
@@ -483,7 +480,7 @@ int32_t DistributedInputSourceManager::Init()
|
||||
}
|
||||
|
||||
statuslistener_ = std::make_shared<DInputSourceListener>(this);
|
||||
DistributedInputSourceTransport::GetInstance().RegisteSourceRespCallback(statuslistener_);
|
||||
DistributedInputSourceTransport::GetInstance().RegisterSourceRespCallback(statuslistener_);
|
||||
|
||||
serviceRunningState_ = ServiceSourceRunningState::STATE_RUNNING;
|
||||
return SUCCESS;
|
||||
@@ -514,11 +511,6 @@ int32_t DistributedInputSourceManager::Release()
|
||||
|
||||
// 3. isstart callback
|
||||
std::shared_ptr<nlohmann::json> jsonArrayMsg = std::make_shared<nlohmann::json>();
|
||||
if (jsonArrayMsg == nullptr) {
|
||||
DHLOGE("Release jsonArrayMsg is null.");
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
nlohmann::json tmpJson;
|
||||
tmpJson[INPUT_SOURCEMANAGER_KEY_RESULT] = static_cast<int32_t>(DInputServerType::NULL_SERVER_TYPE);
|
||||
jsonArrayMsg->push_back(tmpJson);
|
||||
@@ -623,11 +615,6 @@ void DistributedInputSourceManager::handleStartServerCallback(const std::string&
|
||||
}
|
||||
if (isAllDevSwitchOff) {
|
||||
std::shared_ptr<nlohmann::json> jsonArrayMsg = std::make_shared<nlohmann::json>();
|
||||
if (jsonArrayMsg == nullptr) {
|
||||
DHLOGE("handleStartServerCallback jsonArrayMsg is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
nlohmann::json tmpJson;
|
||||
tmpJson[INPUT_SOURCEMANAGER_KEY_RESULT] = static_cast<int32_t>(DInputServerType::NULL_SERVER_TYPE);
|
||||
jsonArrayMsg->push_back(tmpJson);
|
||||
@@ -665,11 +652,6 @@ int32_t DistributedInputSourceManager::RemoveInputNode(const std::string& devId,
|
||||
int32_t DistributedInputSourceManager::DeleteDevice(const std::string& devId, const std::string& dhId)
|
||||
{
|
||||
std::shared_ptr<nlohmann::json> jsonArrayMsg = std::make_shared<nlohmann::json>();
|
||||
if (jsonArrayMsg == nullptr) {
|
||||
DHLOGE("UnregisterDistributedHardware jsonArrayMsg is null.");
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
nlohmann::json tmpJson;
|
||||
tmpJson[INPUT_SOURCEMANAGER_KEY_DEVID] = devId;
|
||||
tmpJson[INPUT_SOURCEMANAGER_KEY_HWID] = dhId;
|
||||
|
||||
@@ -99,7 +99,7 @@ ohos_unittest("distributed_input_sourcemanager_test") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//foundation/bundlemanager/bundle_framework/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//utils/native/base:utils",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"//foundation/communication/dsoftbus/sdk:softbus_client",
|
||||
|
||||
@@ -41,7 +41,7 @@ ohos_shared_library("libdinput_source_trans") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//foundation/bundlemanager/bundle_framework/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//utils/native/base:utils",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"//foundation/communication/dsoftbus/sdk:softbus_client",
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
int32_t Init();
|
||||
int32_t OpenInputSoftbus(const std::string &remoteDevId, const std::string &hwId);
|
||||
void CloseInputSoftbus(const std::string &remoteDevId, const std::string &hwId);
|
||||
void RegisteSourceRespCallback(std::shared_ptr<DInputSourceTransCallback> callback);
|
||||
void RegisterSourceRespCallback(std::shared_ptr<DInputSourceTransCallback> callback);
|
||||
|
||||
int32_t PrepareRemoteInput(const std::string& deviceId);
|
||||
int32_t UnprepareRemoteInput(const std::string& deviceId);
|
||||
|
||||
@@ -41,6 +41,19 @@ static SessionAttribute g_sessionAttr = {
|
||||
}
|
||||
};
|
||||
|
||||
DistributedInputSourceTransport::~DistributedInputSourceTransport()
|
||||
{
|
||||
std::unique_lock<std::mutex> sessionLock(operationMutex_);
|
||||
std::map<std::string, int32_t>::iterator iter = sessionDevMap_.begin();
|
||||
while (iter != sessionDevMap_.end()) {
|
||||
CloseSession(iter->second);
|
||||
}
|
||||
sessionDevMap_.clear();
|
||||
devHardwareMap_.clear();
|
||||
|
||||
(void)RemoveSessionServer(DINPUT_PKG_NAME.c_str(), mySessionName_.c_str());
|
||||
}
|
||||
|
||||
static int32_t SessionOpened(int32_t sessionId, int32_t result)
|
||||
{
|
||||
return DistributedInput::DistributedInputSourceTransport::GetInstance().OnSessionOpened(sessionId, result);
|
||||
@@ -108,18 +121,6 @@ int32_t DistributedInputSourceTransport::Init()
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
DistributedInputSourceTransport::~DistributedInputSourceTransport()
|
||||
{
|
||||
std::map<std::string, int32_t>::iterator iter = sessionDevMap_.begin();
|
||||
while (iter != sessionDevMap_.end()) {
|
||||
CloseSession(iter->second);
|
||||
}
|
||||
sessionDevMap_.clear();
|
||||
devHardwareMap_.clear();
|
||||
|
||||
(void)RemoveSessionServer(DINPUT_PKG_NAME.c_str(), mySessionName_.c_str());
|
||||
}
|
||||
|
||||
int32_t DistributedInputSourceTransport::CheckDeviceSessionState(const std::string &devId, const std::string &hwId)
|
||||
{
|
||||
std::unique_lock<std::mutex> sessionLock(operationMutex_);
|
||||
@@ -224,9 +225,9 @@ void DistributedInputSourceTransport::CloseInputSoftbus(const std::string &remot
|
||||
}
|
||||
}
|
||||
|
||||
void DistributedInputSourceTransport::RegisteSourceRespCallback(std::shared_ptr<DInputSourceTransCallback> callback)
|
||||
void DistributedInputSourceTransport::RegisterSourceRespCallback(std::shared_ptr<DInputSourceTransCallback> callback)
|
||||
{
|
||||
DHLOGI("RegisteSourceRespCallback");
|
||||
DHLOGI("RegisterSourceRespCallback");
|
||||
callback_ = callback;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ ohos_unittest("distributed_input_sourcetrans_test") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//foundation/bundlemanager/bundle_framework/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//utils/native/base:utils",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk",
|
||||
|
||||
@@ -45,7 +45,7 @@ ohos_shared_library("libdinput_sink_handler") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//foundation/bundlemanager/bundle_framework/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//utils/native/base:utils",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"${innerkits_path}:libdinput_sdk",
|
||||
|
||||
@@ -48,7 +48,7 @@ int32_t DistributedInputSinkHandler::InitSink(const std::string ¶ms)
|
||||
}
|
||||
|
||||
auto waitStatus = proxyConVar_.wait_for(lock, std::chrono::milliseconds(INPUT_LOADSA_TIMEOUT_MS),
|
||||
[this]() { return (DistributedInputClient::GetInstance().HasDInputSinkProxy()); });
|
||||
[this]() { return (DistributedInputClient::GetInstance().HasDInputSinkProxy()); });
|
||||
if (!waitStatus) {
|
||||
DHLOGE("dinput load sa timeout.");
|
||||
return FAILURE_DIS;
|
||||
@@ -86,13 +86,13 @@ void DistributedInputSinkHandler::SALoadSinkCb::OnLoadSystemAbilitySuccess(int32
|
||||
{
|
||||
currSystemAbilityId = systemAbilityId;
|
||||
currRemoteObject = remoteObject;
|
||||
DHLOGI("DistributedInputSinkHandler OnLoadSystemAbilitySuccess");
|
||||
DHLOGI("DistributedInputSinkHandler OnLoadSystemAbilitySuccess. systemAbilityId=%d", systemAbilityId);
|
||||
}
|
||||
|
||||
void DistributedInputSinkHandler::SALoadSinkCb::OnLoadSystemAbilityFail(int32_t systemAbilityId)
|
||||
{
|
||||
currSystemAbilityId = systemAbilityId;
|
||||
DHLOGE("DistributedInputSinkHandler OnLoadSystemAbilityFail");
|
||||
DHLOGE("DistributedInputSinkHandler OnLoadSystemAbilityFail. systemAbilityId=%d", systemAbilityId);
|
||||
}
|
||||
|
||||
IDistributedHardwareSink *GetSinkHardwareHandler()
|
||||
|
||||
@@ -63,7 +63,7 @@ ohos_unittest("distributed_input_sink_handler_test") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//foundation/bundlemanager/bundle_framework/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//utils/native/base:utils",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"${innerkits_path}:libdinput_sdk",
|
||||
|
||||
@@ -45,7 +45,7 @@ ohos_shared_library("libdinput_source_handler") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//foundation/bundlemanager/bundle_framework/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//utils/native/base:utils",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"${innerkits_path}:libdinput_sdk",
|
||||
|
||||
@@ -48,7 +48,7 @@ int32_t DistributedInputSourceHandler::InitSource(const std::string ¶ms)
|
||||
}
|
||||
|
||||
auto waitStatus = proxyConVar_.wait_for(lock, std::chrono::milliseconds(INPUT_LOADSA_TIMEOUT_MS),
|
||||
[this]() { return (DistributedInputClient::GetInstance().HasDInputSourceProxy()); });
|
||||
[this]() { return (DistributedInputClient::GetInstance().HasDInputSourceProxy()); });
|
||||
if (!waitStatus) {
|
||||
DHLOGE("dinput load sa timeout.");
|
||||
return FAILURE_DIS;
|
||||
@@ -94,11 +94,13 @@ void DistributedInputSourceHandler::SALoadSourceCb::OnLoadSystemAbilitySuccess(i
|
||||
{
|
||||
currSystemAbilityId = systemAbilityId;
|
||||
currRemoteObject = remoteObject;
|
||||
DHLOGI("DistributedInputSourceHandler OnLoadSystemAbilitySuccess. systemAbilityId=%d", systemAbilityId);
|
||||
}
|
||||
|
||||
void DistributedInputSourceHandler::SALoadSourceCb::OnLoadSystemAbilityFail(int32_t systemAbilityId)
|
||||
{
|
||||
currSystemAbilityId = systemAbilityId;
|
||||
DHLOGE("DistributedInputSourceHandler OnLoadSystemAbilityFail. systemAbilityId=%d", systemAbilityId);
|
||||
}
|
||||
|
||||
IDistributedHardwareSource *GetSourceHardwareHandler()
|
||||
|
||||
@@ -65,7 +65,7 @@ ohos_unittest("distributed_input_source_handler_test") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//foundation/bundlemanager/bundle_framework/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//utils/native/base:utils",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"${innerkits_path}:libdinput_sdk",
|
||||
|
||||
@@ -65,7 +65,7 @@ ohos_fuzztest("DistributedInputClientFuzzTest") {
|
||||
"${distributedinput_path}/sourcehandler:libdinput_source_handler",
|
||||
"${distributedinput_path}/sinkhandler:libdinput_sink_handler",
|
||||
"${distributedinput_path}/inputdevicehandler:libdinput_handler",
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//foundation/bundlemanager/bundle_framework/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ ohos_fuzztest("DistributedInputKitFuzzTest") {
|
||||
"${distributedinput_path}/sourcehandler:libdinput_source_handler",
|
||||
"${distributedinput_path}/sinkhandler:libdinput_sink_handler",
|
||||
"${distributedinput_path}/inputdevicehandler:libdinput_handler",
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//foundation/bundlemanager/bundle_framework/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ ohos_fuzztest("DistributedInputSinkTransportFuzzTest") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//foundation/bundlemanager/bundle_framework/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//utils/native/base:utils",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"//foundation/communication/dsoftbus/sdk:softbus_client",
|
||||
|
||||
@@ -49,7 +49,7 @@ ohos_fuzztest("DistributedInputSourceTransportFuzzTest") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//foundation/bundlemanager/bundle_framework/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//utils/native/base:utils",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk",
|
||||
|
||||
@@ -79,7 +79,7 @@ ohos_unittest("distributed_input_test") {
|
||||
"${distributedinput_path}/sourcehandler:libdinput_source_handler",
|
||||
"${distributedinput_path}/sinkhandler:libdinput_sink_handler",
|
||||
"${distributedinput_path}/inputdevicehandler:libdinput_handler",
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//foundation/bundlemanager/bundle_framework/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//utils/native/base:utils",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user