From 6183a47ce63fe9f4e5b244146981cac18c9f5537 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=8B=87=E7=90=A6?= Date: Mon, 13 Jan 2025 02:16:50 +0000 Subject: [PATCH 1/5] =?UTF-8?q?sensor=E5=86=85=E5=AD=98=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杨勇琦 Change-Id: Icb7c64847dea59f1d64e0c82678786f87290199f --- services/include/sensor_data_processer.h | 2 +- services/src/sensor_data_processer.cpp | 27 +++-- utils/common/include/report_data_callback.h | 28 +++-- utils/common/src/report_data_callback.cpp | 111 ++++++++++++++------ 4 files changed, 109 insertions(+), 59 deletions(-) mode change 100644 => 100755 services/include/sensor_data_processer.h mode change 100644 => 100755 services/src/sensor_data_processer.cpp mode change 100644 => 100755 utils/common/include/report_data_callback.h mode change 100644 => 100755 utils/common/src/report_data_callback.cpp diff --git a/services/include/sensor_data_processer.h b/services/include/sensor_data_processer.h old mode 100644 new mode 100755 index 802cf040..c0794915 --- a/services/include/sensor_data_processer.h +++ b/services/include/sensor_data_processer.h @@ -54,7 +54,7 @@ private: uint64_t fifoCount); void SendRawData(std::unordered_map &cacheBuf, sptr channel, std::vector events); - void EventFilter(CircularEventBuf &eventsBuf); + void EventFilter(SensorData *event); ClientInfo &clientInfo_ = ClientInfo::GetInstance(); FlushInfoRecord &flushInfo_ = FlushInfoRecord::GetInstance(); std::mutex dataCountMutex_; diff --git a/services/src/sensor_data_processer.cpp b/services/src/sensor_data_processer.cpp old mode 100644 new mode 100755 index 55449e6b..6574c235 --- a/services/src/sensor_data_processer.cpp +++ b/services/src/sensor_data_processer.cpp @@ -263,11 +263,15 @@ int32_t SensorDataProcesser::CacheSensorEvent(const SensorData &data, sptrsensorTypeId; if (sensorId == SENSOR_TYPE_ID_HALL_EXT) { - PrintSensorData::GetInstance().PrintSensorDataLog("EventFilter", eventsBuf.circularBuf[eventsBuf.readPos]); + PrintSensorData::GetInstance().PrintSensorDataLog("EventFilter", *event); } std::vector> channelList = clientInfo_.GetSensorChannel(sensorId); for (auto &channel : channelList) { @@ -275,7 +279,7 @@ void SensorDataProcesser::EventFilter(CircularEventBuf &eventsBuf) SEN_HILOGW("Sensor status is not active"); continue; } - SendEvents(channel, eventsBuf.circularBuf[eventsBuf.readPos]); + SendEvents(channel, *event); } } @@ -285,19 +289,14 @@ int32_t SensorDataProcesser::ProcessEvents(sptr dataCallback std::unique_lock lk(ISensorHdiConnection::dataMutex_); ISensorHdiConnection::dataCondition_.wait(lk, [this] { return ISensorHdiConnection::dataReady_.load(); }); ISensorHdiConnection::dataReady_.store(false); - auto &eventsBuf = dataCallback->GetEventData(); - if (eventsBuf.eventNum <= 0) { + std::vector events; + dataCallback->GetEventData(events); + if (events.empty()) { SEN_HILOGE("Data cannot be empty"); return NO_EVENT; } - int32_t eventNum = eventsBuf.eventNum; - for (int32_t i = 0; i < eventNum; i++) { - EventFilter(eventsBuf); - eventsBuf.readPos++; - if (eventsBuf.readPos >= CIRCULAR_BUF_LEN) { - eventsBuf.readPos = 0; - } - eventsBuf.eventNum--; + for (size_t i = 0; i < events.size(); i++) { + EventFilter(events[i]); } return SUCCESS; } diff --git a/utils/common/include/report_data_callback.h b/utils/common/include/report_data_callback.h old mode 100644 new mode 100755 index 961f6147..4b5ba68c --- a/utils/common/include/report_data_callback.h +++ b/utils/common/include/report_data_callback.h @@ -16,19 +16,22 @@ #ifndef REPORT_DATA_CALLBACK_H #define REPORT_DATA_CALLBACK_H +#include + #include "refbase.h" #include "sensor_data_event.h" namespace OHOS { namespace Sensors { -constexpr int32_t CIRCULAR_BUF_LEN = 1024; -constexpr int32_t SENSOR_DATA_LENGTH = 64; - -struct CircularEventBuf { - struct SensorData *circularBuf; - int32_t readPos; - int32_t writePosition; - int32_t eventNum; + +struct SensorDataBlock { + struct SensorData *dataBuf = nullptr; + int32_t eventNum = 0; +}; + +struct SaveEventBuf { + std::vector blockList; + int32_t writeFullBlockNum; }; class ReportDataCallback : public RefBase { @@ -36,8 +39,13 @@ public: ReportDataCallback(); ~ReportDataCallback(); int32_t ReportEventCallback(SensorData *sensorData, sptr cb); - CircularEventBuf &GetEventData(); - CircularEventBuf eventsBuf_; + void GetEventData(std::vector &events); +private: + void FreeRedundantEventBuffer(); +private: + SaveEventBuf eventsBuf_; + std::vector recentWriteBlockNums_; + int32_t blockNumsUpdateIndex_ = 0; }; using ReportDataCb = int32_t (ReportDataCallback::*)(SensorData *sensorData, sptr cb); diff --git a/utils/common/src/report_data_callback.cpp b/utils/common/src/report_data_callback.cpp old mode 100644 new mode 100755 index cd4e0d04..a1468185 --- a/utils/common/src/report_data_callback.cpp +++ b/utils/common/src/report_data_callback.cpp @@ -23,63 +23,106 @@ namespace OHOS { namespace Sensors { using namespace OHOS::HiviewDFX; +static constexpr uint8_t EVENT_BLOCK_NUM = 64; +static constexpr uint8_t BLOCK_EVENT_BUF_LEN = 16; +static constexpr uint8_t RECENT_WRITE_BLOCK_NUM_SIZE = 5; + ReportDataCallback::ReportDataCallback() { - eventsBuf_.circularBuf = new (std::nothrow) SensorData[CIRCULAR_BUF_LEN]; - CHKPL(eventsBuf_.circularBuf); - eventsBuf_.readPos = 0; - eventsBuf_.writePosition = 0; - eventsBuf_.eventNum = 0; + eventsBuf_.blockList.resize(EVENT_BLOCK_NUM); + eventsBuf_.writeFullBlockNum = 0; + recentWriteBlockNums_.resize(RECENT_WRITE_BLOCK_NUM_SIZE); } ReportDataCallback::~ReportDataCallback() { - if (eventsBuf_.circularBuf != nullptr) { - delete[] eventsBuf_.circularBuf; - eventsBuf_.circularBuf = nullptr; + for (auto& block : eventsBuf_.blockList) { + if (block.dataBuf != nullptr) { + delete[] block.dataBuf; + block.dataBuf = nullptr; + } + block.eventNum = 0; } - eventsBuf_.circularBuf = nullptr; - eventsBuf_.readPos = 0; - eventsBuf_.writePosition = 0; - eventsBuf_.eventNum = 0; + eventsBuf_.writeFullBlockNum = 0; } int32_t ReportDataCallback::ReportEventCallback(SensorData *sensorData, sptr cb) { CHKPR(sensorData, ERROR); - if (cb == nullptr || cb->eventsBuf_.circularBuf == nullptr) { - SEN_HILOGE("Callback or circularBuf or event cannot be null"); + if (cb == nullptr) { + SEN_HILOGE("Callback cannot be null"); return ERROR; } - int32_t leftSize = CIRCULAR_BUF_LEN - cb->eventsBuf_.eventNum; - int32_t toEndLen = CIRCULAR_BUF_LEN - cb->eventsBuf_.writePosition; - if (leftSize < 0 || toEndLen < 0) { - SEN_HILOGE("Leftsize and toendlen cannot be less than zero"); + if (cb->eventsBuf_.writeFullBlockNum >= cb->eventsBuf_.blockList.size()) { + SEN_HILOGE("event buffer is full"); return ERROR; } - if (toEndLen == 0) { - cb->eventsBuf_.circularBuf[0] = *sensorData; - cb->eventsBuf_.writePosition = 1; - } else { - cb->eventsBuf_.circularBuf[cb->eventsBuf_.writePosition] = *sensorData; - cb->eventsBuf_.writePosition += 1; - } - cb->eventsBuf_.eventNum += 1; - if (cb->eventsBuf_.eventNum >= CIRCULAR_BUF_LEN) { - cb->eventsBuf_.eventNum = CIRCULAR_BUF_LEN; + auto& block = cb->eventsBuf_.blockList[cb->eventsBuf_.writeFullBlockNum]; + if (block.dataBuf == nullptr) { + block.dataBuf = new(std::nothrow) SensorData[BLOCK_EVENT_BUF_LEN]; + if (block.dataBuf == nullptr) { + SEN_HILOGE("new block buffer fail."); + return ERROR; + } + block.eventNum = 0; } - if (cb->eventsBuf_.writePosition >= CIRCULAR_BUF_LEN) { - cb->eventsBuf_.writePosition = 0; + if (block.eventNum < BLOCK_EVENT_BUF_LEN) { + block.dataBuf[block.eventNum] = *sensorData; + block.eventNum += 1; } - if (leftSize < 1) { - cb->eventsBuf_.readPos = cb->eventsBuf_.writePosition; + if (block.eventNum >= BLOCK_EVENT_BUF_LEN) { + cb->eventsBuf_.writeFullBlockNum++; } return ERR_OK; } -CircularEventBuf &ReportDataCallback::GetEventData() +void ReportDataCallback::GetEventData(std::vector &events) { - return eventsBuf_; + int32_t writeBlockNum = 0; + for (auto& block : eventsBuf_.blockList) { + if (block.dataBuf == nullptr) { + break; + } + if (block.eventNum <= 0) { + break; + } + writeBlockNum++; + for (int32_t i = 0; i < block.eventNum; ++i) { + events.push_back(&block.dataBuf[i]); + } + block.eventNum = 0; + } + eventsBuf_.writeFullBlockNum = 0; + recentWriteBlockNums_[blockNumsUpdateIndex_] = writeBlockNum; + blockNumsUpdateIndex_++; + if (blockNumsUpdateIndex_ >= recentWriteBlockNums_.size()) { + blockNumsUpdateIndex_ = 0; + } + if (!events.empty()) { + // clear excess memory + FreeRedundantEventBuffer(); + } +} + +void ReportDataCallback::FreeRedundantEventBuffer() +{ + int maxWriteBlockNum = 0; + for (auto num : recentWriteBlockNums_) { + maxWriteBlockNum = std::max(maxWriteBlockNum, num); + } + + // keep at least 1 block + if (maxWriteBlockNum <= 0) { + return; + } + + for (int index = maxWriteBlockNum; index < eventsBuf_.blockList.size(); ++index) { + if (eventsBuf_.blockList[index].dataBuf == nullptr) { + break; + } + delete[] eventsBuf_.blockList[index].dataBuf; + eventsBuf_.blockList[index].dataBuf = nullptr; + } } } // namespace Sensors } // namespace OHOS -- Gitee From 3307be2ab6f435d98e7718e63f8c998ab2148266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=8B=87=E7=90=A6?= Date: Thu, 23 Jan 2025 02:01:19 +0000 Subject: [PATCH 2/5] =?UTF-8?q?sensor=E5=86=85=E5=AD=98=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杨勇琦 Change-Id: I05181f738f77177abaab7d51dcafaa846e6278c5 --- .../coverage/report_data_callback_test.cpp | 27 +++++++------------ utils/common/include/report_data_callback.h | 5 +++- utils/common/src/report_data_callback.cpp | 4 --- 3 files changed, 13 insertions(+), 23 deletions(-) mode change 100644 => 100755 test/unittest/coverage/report_data_callback_test.cpp diff --git a/test/unittest/coverage/report_data_callback_test.cpp b/test/unittest/coverage/report_data_callback_test.cpp old mode 100644 new mode 100755 index e9320acb..6fdbcd4a --- a/test/unittest/coverage/report_data_callback_test.cpp +++ b/test/unittest/coverage/report_data_callback_test.cpp @@ -25,7 +25,7 @@ namespace Sensors { using namespace testing::ext; namespace { - SensorData* g_sensorData = new (std::nothrow) SensorData[CIRCULAR_BUF_LEN]; + SensorData* g_sensorData = new (std::nothrow) SensorData[BLOCK_EVENT_BUF_LEN]; } // namespace class SensorBasicDataChannelTest : public testing::Test { @@ -60,11 +60,10 @@ HWTEST_F(SensorBasicDataChannelTest, ReportDataCallbackTest_001, TestSize.Level1 ASSERT_EQ(ret, ERROR); sptr callback = new (std::nothrow) ReportDataCallback(); - if (callback->eventsBuf_.circularBuf != nullptr) { - delete[] callback->eventsBuf_.circularBuf; - callback->eventsBuf_.circularBuf = nullptr; + if (!callback->eventsBuf_.blockList.empty()) { + callback->eventsBuf_.blockList.clear(); } - callback->eventsBuf_.circularBuf = nullptr; + callback->eventsBuf_.blockList.clear(); ret = reportDataCallback.ReportEventCallback(g_sensorData, callback); ASSERT_EQ(ret, ERROR); } @@ -75,15 +74,10 @@ HWTEST_F(SensorBasicDataChannelTest, ReportDataCallbackTest_002, TestSize.Level1 ReportDataCallback reportDataCallback = ReportDataCallback(); sptr callback = new (std::nothrow) ReportDataCallback(); - callback->eventsBuf_.eventNum = CIRCULAR_BUF_LEN + 1; - callback->eventsBuf_.writePosition = 1; + + callback->eventsBuf_.writeFullBlockNum = -1; int32_t ret = reportDataCallback.ReportEventCallback(g_sensorData, callback); ASSERT_EQ(ret, ERROR); - - callback->eventsBuf_.eventNum = 1; - callback->eventsBuf_.writePosition = CIRCULAR_BUF_LEN + 1; - ret = reportDataCallback.ReportEventCallback(g_sensorData, callback); - ASSERT_EQ(ret, ERROR); } HWTEST_F(SensorBasicDataChannelTest, ReportDataCallbackTest_003, TestSize.Level1) @@ -91,8 +85,7 @@ HWTEST_F(SensorBasicDataChannelTest, ReportDataCallbackTest_003, TestSize.Level1 SEN_HILOGI("ReportDataCallbackTest_003 in"); ReportDataCallback reportDataCallback = ReportDataCallback(); sptr callback = new (std::nothrow) ReportDataCallback(); - callback->eventsBuf_.eventNum = CIRCULAR_BUF_LEN; - callback->eventsBuf_.writePosition = CIRCULAR_BUF_LEN; + callback->eventsBuf_.writeFullBlockNum = BLOCK_EVENT_BUF_LEN; int32_t ret = reportDataCallback.ReportEventCallback(g_sensorData, callback); ASSERT_EQ(ret, ERR_OK); } @@ -102,8 +95,7 @@ HWTEST_F(SensorBasicDataChannelTest, ReportDataCallbackTest_004, TestSize.Level1 SEN_HILOGI("ReportDataCallbackTest_004 in"); ReportDataCallback reportDataCallback = ReportDataCallback(); sptr callback = new (std::nothrow) ReportDataCallback(); - callback->eventsBuf_.eventNum = CIRCULAR_BUF_LEN; - callback->eventsBuf_.writePosition = 1; + callback->eventsBuf_.writeFullBlockNum = BLOCK_EVENT_BUF_LEN + 1; int32_t ret = reportDataCallback.ReportEventCallback(g_sensorData, callback); ASSERT_EQ(ret, ERR_OK); } @@ -113,8 +105,7 @@ HWTEST_F(SensorBasicDataChannelTest, ReportDataCallbackTest_005, TestSize.Level1 SEN_HILOGI("ReportDataCallbackTest_005 in"); ReportDataCallback reportDataCallback = ReportDataCallback(); sptr callback = new (std::nothrow) ReportDataCallback(); - callback->eventsBuf_.eventNum = CIRCULAR_BUF_LEN; - callback->eventsBuf_.writePosition = CIRCULAR_BUF_LEN - 1; + callback->eventsBuf_.writeFullBlockNum = BLOCK_EVENT_BUF_LEN - 1; int32_t ret = reportDataCallback.ReportEventCallback(g_sensorData, callback); ASSERT_EQ(ret, ERR_OK); } diff --git a/utils/common/include/report_data_callback.h b/utils/common/include/report_data_callback.h index 4b5ba68c..d252f14a 100755 --- a/utils/common/include/report_data_callback.h +++ b/utils/common/include/report_data_callback.h @@ -23,6 +23,9 @@ namespace OHOS { namespace Sensors { +constexpr uint8_t EVENT_BLOCK_NUM = 64; +constexpr uint8_t BLOCK_EVENT_BUF_LEN = 16; +constexpr uint8_t RECENT_WRITE_BLOCK_NUM_SIZE = 5; struct SensorDataBlock { struct SensorData *dataBuf = nullptr; @@ -40,10 +43,10 @@ public: ~ReportDataCallback(); int32_t ReportEventCallback(SensorData *sensorData, sptr cb); void GetEventData(std::vector &events); + SaveEventBuf eventsBuf_; private: void FreeRedundantEventBuffer(); private: - SaveEventBuf eventsBuf_; std::vector recentWriteBlockNums_; int32_t blockNumsUpdateIndex_ = 0; }; diff --git a/utils/common/src/report_data_callback.cpp b/utils/common/src/report_data_callback.cpp index a1468185..ac630035 100755 --- a/utils/common/src/report_data_callback.cpp +++ b/utils/common/src/report_data_callback.cpp @@ -23,10 +23,6 @@ namespace OHOS { namespace Sensors { using namespace OHOS::HiviewDFX; -static constexpr uint8_t EVENT_BLOCK_NUM = 64; -static constexpr uint8_t BLOCK_EVENT_BUF_LEN = 16; -static constexpr uint8_t RECENT_WRITE_BLOCK_NUM_SIZE = 5; - ReportDataCallback::ReportDataCallback() { eventsBuf_.blockList.resize(EVENT_BLOCK_NUM); -- Gitee From 150a1b21418855490434a8ea4d99b3eade789028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=8B=87=E7=90=A6?= Date: Fri, 24 Jan 2025 03:17:12 +0000 Subject: [PATCH 3/5] =?UTF-8?q?sensor=E5=86=85=E5=AD=98=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杨勇琦 Change-Id: I444c471c40299951057caef96f9d84120bcb3512 --- utils/common/src/report_data_callback.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/utils/common/src/report_data_callback.cpp b/utils/common/src/report_data_callback.cpp index ac630035..edf988e3 100755 --- a/utils/common/src/report_data_callback.cpp +++ b/utils/common/src/report_data_callback.cpp @@ -46,25 +46,25 @@ int32_t ReportDataCallback::ReportEventCallback(SensorData *sensorData, sptreventsBuf_.writeFullBlockNum >= cb->eventsBuf_.blockList.size()) { - SEN_HILOGE("event buffer is full"); + SEN_HILOGE("Event buffer more than the blockList size"); return ERROR; } auto& block = cb->eventsBuf_.blockList[cb->eventsBuf_.writeFullBlockNum]; if (block.dataBuf == nullptr) { block.dataBuf = new(std::nothrow) SensorData[BLOCK_EVENT_BUF_LEN]; if (block.dataBuf == nullptr) { - SEN_HILOGE("new block buffer fail."); + SEN_HILOGE("New block buffer fail"); return ERROR; } block.eventNum = 0; } if (block.eventNum < BLOCK_EVENT_BUF_LEN) { block.dataBuf[block.eventNum] = *sensorData; - block.eventNum += 1; + block.eventNum++; } if (block.eventNum >= BLOCK_EVENT_BUF_LEN) { cb->eventsBuf_.writeFullBlockNum++; @@ -77,9 +77,11 @@ void ReportDataCallback::GetEventData(std::vector &events) int32_t writeBlockNum = 0; for (auto& block : eventsBuf_.blockList) { if (block.dataBuf == nullptr) { + SEN_HILOGE("Data buf is null"); break; } if (block.eventNum <= 0) { + SEN_HILOGE("Get eventNum fail"); break; } writeBlockNum++; @@ -95,14 +97,13 @@ void ReportDataCallback::GetEventData(std::vector &events) blockNumsUpdateIndex_ = 0; } if (!events.empty()) { - // clear excess memory FreeRedundantEventBuffer(); } } void ReportDataCallback::FreeRedundantEventBuffer() { - int maxWriteBlockNum = 0; + int32_t maxWriteBlockNum = 0; for (auto num : recentWriteBlockNums_) { maxWriteBlockNum = std::max(maxWriteBlockNum, num); } -- Gitee From 7c19133818dbe522ceff67007689e2bb8761acfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=8B=87=E7=90=A6?= Date: Sat, 8 Feb 2025 01:52:20 +0000 Subject: [PATCH 4/5] =?UTF-8?q?Signed-off-by:=20=E6=9D=A8=E5=8B=87?= =?UTF-8?q?=E7=90=A6=20=20Change-Id:=20I6e2782?= =?UTF-8?q?e42d382a7c3bee0aee462a956600a36648?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/common/src/report_data_callback.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/common/src/report_data_callback.cpp b/utils/common/src/report_data_callback.cpp index edf988e3..3e18e546 100755 --- a/utils/common/src/report_data_callback.cpp +++ b/utils/common/src/report_data_callback.cpp @@ -113,7 +113,7 @@ void ReportDataCallback::FreeRedundantEventBuffer() return; } - for (int index = maxWriteBlockNum; index < eventsBuf_.blockList.size(); ++index) { + for (int32_t index = maxWriteBlockNum; index < eventsBuf_.blockList.size(); ++index) { if (eventsBuf_.blockList[index].dataBuf == nullptr) { break; } -- Gitee From 6ee7d97d69d819f5ca017b001820e53d39eebf59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=8B=87=E7=90=A6?= Date: Sat, 8 Feb 2025 02:09:28 +0000 Subject: [PATCH 5/5] =?UTF-8?q?Signed-off-by:=20=E6=9D=A8=E5=8B=87?= =?UTF-8?q?=E7=90=A6=20=20Change-Id:=20Ic8c1e2?= =?UTF-8?q?6e5943690b882dd708d2172e96c7a0c7a8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/unittest/coverage/report_data_callback_test.cpp | 2 +- utils/common/include/report_data_callback.h | 3 --- utils/common/src/report_data_callback.cpp | 6 +++++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/test/unittest/coverage/report_data_callback_test.cpp b/test/unittest/coverage/report_data_callback_test.cpp index 6fdbcd4a..6112c729 100755 --- a/test/unittest/coverage/report_data_callback_test.cpp +++ b/test/unittest/coverage/report_data_callback_test.cpp @@ -23,8 +23,8 @@ namespace OHOS { namespace Sensors { using namespace testing::ext; - namespace { + constexpr uint8_t BLOCK_EVENT_BUF_LEN = 16; SensorData* g_sensorData = new (std::nothrow) SensorData[BLOCK_EVENT_BUF_LEN]; } // namespace diff --git a/utils/common/include/report_data_callback.h b/utils/common/include/report_data_callback.h index d252f14a..e937c074 100755 --- a/utils/common/include/report_data_callback.h +++ b/utils/common/include/report_data_callback.h @@ -23,9 +23,6 @@ namespace OHOS { namespace Sensors { -constexpr uint8_t EVENT_BLOCK_NUM = 64; -constexpr uint8_t BLOCK_EVENT_BUF_LEN = 16; -constexpr uint8_t RECENT_WRITE_BLOCK_NUM_SIZE = 5; struct SensorDataBlock { struct SensorData *dataBuf = nullptr; diff --git a/utils/common/src/report_data_callback.cpp b/utils/common/src/report_data_callback.cpp index 3e18e546..519346b5 100755 --- a/utils/common/src/report_data_callback.cpp +++ b/utils/common/src/report_data_callback.cpp @@ -22,7 +22,11 @@ namespace OHOS { namespace Sensors { using namespace OHOS::HiviewDFX; - +namespace { +constexpr uint8_t EVENT_BLOCK_NUM = 64; +constexpr uint8_t BLOCK_EVENT_BUF_LEN = 16; +constexpr uint8_t RECENT_WRITE_BLOCK_NUM_SIZE = 5; +} ReportDataCallback::ReportDataCallback() { eventsBuf_.blockList.resize(EVENT_BLOCK_NUM); -- Gitee