修改告警

Signed-off-by: li-tiangang4 <litiangang4@huawei.com>
This commit is contained in:
li-tiangang4
2024-08-21 14:28:27 +08:00
parent 407a3c76a6
commit 1fa09bc580
19 changed files with 287 additions and 122 deletions
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
* Copyright (c) 2021-2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -60,14 +60,14 @@ private:
pthread_t collectThreadID_;
bool isCollectingEvents_;
bool isStartCollectEventThread;
bool isStartCollectEventThread_;
static void *CollectEventsThread(void *param);
void StartInputMonitorDeviceThread();
void StopInputMonitorDeviceThread();
// The event queue.
static const int inputDeviceBufferSize = 32;
InputDeviceEvent mEventBuffer[inputDeviceBufferSize] = {};
static const int inputDeviceBufferSize_ = 32;
InputDeviceEvent mEventBuffer_[inputDeviceBufferSize_] = {};
std::mutex operationMutex_;
std::unique_ptr<InputHub> inputHub_;
};
@@ -42,7 +42,7 @@ namespace DistributedHardware {
namespace DistributedInput {
IMPLEMENT_SINGLE_INSTANCE(DistributedInputHandler);
DistributedInputHandler::DistributedInputHandler()
: collectThreadID_(-1), isCollectingEvents_(false), isStartCollectEventThread(false)
: collectThreadID_(-1), isCollectingEvents_(false), isStartCollectEventThread_(false)
{
inputHub_ = std::make_unique<InputHub>(true);
this->m_listener = nullptr;
@@ -88,9 +88,9 @@ void DistributedInputHandler::StructTransJson(const InputDevice &pBuf, std::stri
int32_t DistributedInputHandler::Initialize()
{
if (!isStartCollectEventThread) {
if (!isStartCollectEventThread_) {
InitCollectEventsThread();
isStartCollectEventThread = true;
isStartCollectEventThread_ = true;
}
return DH_SUCCESS;
}
@@ -196,7 +196,7 @@ void DistributedInputHandler::StartInputMonitorDeviceThread()
return;
}
while (isCollectingEvents_) {
size_t count = inputHub_->StartCollectInputHandler(mEventBuffer, inputDeviceBufferSize);
size_t count = inputHub_->StartCollectInputHandler(mEventBuffer_, inputDeviceBufferSize_);
if (count > 0) {
DHLOGI("Count: %{public}zu", count);
for (size_t iCnt = 0; iCnt < count; iCnt++) {
@@ -212,18 +212,18 @@ void DistributedInputHandler::StartInputMonitorDeviceThread()
void DistributedInputHandler::NotifyHardWare(int iCnt)
{
switch (mEventBuffer[iCnt].type) {
switch (mEventBuffer_[iCnt].type) {
case DeviceType::DEVICE_ADDED:
if (this->m_listener != nullptr) {
std::string hdInfo;
StructTransJson(mEventBuffer[iCnt].deviceInfo, hdInfo);
StructTransJson(mEventBuffer_[iCnt].deviceInfo, hdInfo);
std::string subtype = "input";
this->m_listener->PluginHardware(mEventBuffer[iCnt].deviceInfo.descriptor, hdInfo, subtype);
this->m_listener->PluginHardware(mEventBuffer_[iCnt].deviceInfo.descriptor, hdInfo, subtype);
}
break;
case DeviceType::DEVICE_REMOVED:
if (this->m_listener != nullptr) {
this->m_listener->UnPluginHardware(mEventBuffer[iCnt].deviceInfo.descriptor);
this->m_listener->UnPluginHardware(mEventBuffer_[iCnt].deviceInfo.descriptor);
}
break;
default:
@@ -238,7 +238,7 @@ void DistributedInputHandler::StopInputMonitorDeviceThread()
return;
}
isCollectingEvents_ = false;
isStartCollectEventThread = false;
isStartCollectEventThread_ = false;
inputHub_->StopCollectInputHandler();
if (collectThreadID_ != (pthread_t)(-1)) {
DHLOGI("DistributedInputHandler::Wait collect thread exit");
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -64,14 +64,14 @@ HWTEST_F(DInputHandlerTest, FindDevicesInfoByType_001, testing::ext::TestSize.Le
dInputHandler.StartInputMonitorDeviceThread();
InputDevice inputDevice;
dInputHandler.mEventBuffer[0].type = DeviceType::DEVICE_ADDED;
dInputHandler.mEventBuffer[0].deviceInfo = inputDevice;
dInputHandler.mEventBuffer_[0].type = DeviceType::DEVICE_ADDED;
dInputHandler.mEventBuffer_[0].deviceInfo = inputDevice;
dInputHandler.NotifyHardWare(0);
dInputHandler.mEventBuffer[1].type = DeviceType::DEVICE_REMOVED;
dInputHandler.mEventBuffer[1].deviceInfo = inputDevice;
dInputHandler.mEventBuffer_[1].type = DeviceType::DEVICE_REMOVED;
dInputHandler.mEventBuffer_[1].deviceInfo = inputDevice;
dInputHandler.NotifyHardWare(1);
dInputHandler.mEventBuffer[2].type = DeviceType::FINISHED_DEVICE_SCAN;
dInputHandler.mEventBuffer[2].deviceInfo = inputDevice;
dInputHandler.mEventBuffer_[2].type = DeviceType::FINISHED_DEVICE_SCAN;
dInputHandler.mEventBuffer_[2].deviceInfo = inputDevice;
dInputHandler.NotifyHardWare(2);
std::map<std::string, std::string> ret = dInputHandler.QueryExtraInfo();
EXPECT_EQ(0, ret.size());