From 952e1a6bd353ee3e18d8fffaf6a622eb637ae1d5 Mon Sep 17 00:00:00 2001 From: pengyanggit Date: Sat, 9 Jul 2022 10:50:38 +0800 Subject: [PATCH 1/5] Signed-off-by:pengyanggit Signed-off-by: pengyanggit Change-Id: I7dbe778874e6f665ee914b948d0ba321c65d340f Signed-off-by: pengyanggit --- frameworks/proxy/events/src/input_event.cpp | 5 +- service/event_dispatch/src/event_dispatch.cpp | 7 +- service/timer_manager/src/timer_manager.cpp | 17 ++++- .../src/input_windows_manager.cpp | 64 ++++++++++++++++--- util/socket/src/uds_session.cpp | 11 +++- 5 files changed, 88 insertions(+), 16 deletions(-) diff --git a/frameworks/proxy/events/src/input_event.cpp b/frameworks/proxy/events/src/input_event.cpp index 3a610f454d..b62b0a75b4 100755 --- a/frameworks/proxy/events/src/input_event.cpp +++ b/frameworks/proxy/events/src/input_event.cpp @@ -49,7 +49,10 @@ void InputEvent::Reset() actionTime_ = 0; } id_ = -1; - actionTime_ = (ts.tv_sec * 1000000 + (ts.tv_nsec / 1000)); + if (!AddInt64(ts.tv_sec * 1000000, ts.tv_nsec / 1000, actionTime_)) { + MMI_HILOGE("Int64 addition overflow"); + return; + } action_ = ACTION_UNKNOWN; actionStartTime_ = actionTime_; deviceId_ = -1; diff --git a/service/event_dispatch/src/event_dispatch.cpp b/service/event_dispatch/src/event_dispatch.cpp index 40f0161dad..b2bef3f2ce 100755 --- a/service/event_dispatch/src/event_dispatch.cpp +++ b/service/event_dispatch/src/event_dispatch.cpp @@ -147,7 +147,12 @@ bool EventDispatch::TriggerANR(int64_t time, SessionPtr sess) earliest = sess->GetEarliestEventTime(); } MMI_HILOGD("Current time: %{public}" PRId64 "", time); - if (time < (earliest + INPUT_UI_TIMEOUT_TIME)) { + int64_t endTime = 0; + if (!AddInt64(earliest, INPUT_UI_TIMEOUT_TIME, endTime)) { + MMI_HILOGE("Int64 addition overflow"); + return false; + } + if (time < endTime) { sess->isANRProcess_ = false; MMI_HILOGD("the event reports normally"); return false; diff --git a/service/timer_manager/src/timer_manager.cpp b/service/timer_manager/src/timer_manager.cpp index 0704d323fe..c2cd709761 100755 --- a/service/timer_manager/src/timer_manager.cpp +++ b/service/timer_manager/src/timer_manager.cpp @@ -23,6 +23,7 @@ constexpr int32_t MIN_INTERVAL = 50; constexpr int32_t MAX_INTERVAL = 4096; constexpr int32_t MAX_TIMER_COUNT = 32; constexpr int32_t NONEXISTENT_ID = -1; +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MMI_LOG_DOMAIN, "TimerManager" }; } // namespace int32_t TimerManager::AddTimer(int32_t intervalMs, int32_t repeatCount, std::function callback) @@ -91,7 +92,11 @@ int32_t TimerManager::AddTimerInternal(int32_t intervalMs, int32_t repeatCount, timer->intervalMs = intervalMs; timer->repeatCount = repeatCount; timer->callbackCount = 0; - timer->nextCallTime = GetMillisTime() + intervalMs; + auto nowTime = GetMillisTime(); + if (!AddInt64(nowTime, timer->intervalMs, timer->nextCallTime)) { + MMI_HILOGE("Int64 addition overflow"); + return NONEXISTENT_ID; + } timer->callback = callback; InsertTimerInternal(timer); return timerId; @@ -115,7 +120,10 @@ int32_t TimerManager::ResetTimerInternal(int32_t timerId) auto timer = std::move(*it); timers_.erase(it); auto nowTime = GetMillisTime(); - timer->nextCallTime = nowTime + timer->intervalMs; + if (!AddInt64(nowTime, timer->intervalMs, timer->nextCallTime)) { + MMI_HILOGE("Int64 addition overflow"); + return RET_ERR; + } timer->callbackCount = 0; InsertTimerInternal(timer); return RET_OK; @@ -181,7 +189,10 @@ void TimerManager::ProcessTimersInternal() curTimer->callback(); continue; } - curTimer->nextCallTime = nowTime + curTimer->intervalMs; + if (!AddInt64(nowTime, curTimer->intervalMs, curTimer->nextCallTime)) { + MMI_HILOGE("Int64 addition overflow"); + return; + } const auto& timer = InsertTimerInternal(curTimer); timer->callback(); } diff --git a/service/window_manager/src/input_windows_manager.cpp b/service/window_manager/src/input_windows_manager.cpp index 5eb6aab3dc..4a4b5270d2 100755 --- a/service/window_manager/src/input_windows_manager.cpp +++ b/service/window_manager/src/input_windows_manager.cpp @@ -326,8 +326,18 @@ const DisplayGroupInfo& InputWindowsManager::GetDisplayGroupInfo() bool InputWindowsManager::IsInHotArea(int32_t x, int32_t y, const std::vector &rects) const { for (const auto &item : rects) { - if (((x >= item.x) && (x < (item.x + item.width))) && - (y >= item.y) && (y < (item.y + item.height))) { + int32_t displayMaxX = 0; + int32_t displayMaxY = 0; + if (!AddInt32(item.x, item.width, displayMaxX)) { + MMI_HILOGE("Int32 addition overflow"); + return false; + } + if (!AddInt32(item.y, item.height, displayMaxY)) { + MMI_HILOGE("Int32 addition overflow"); + return false; + } + if (((x >= item.x) && (x < displayMaxX)) && + (y >= item.y) && (y < displayMaxY)) { return true; } } @@ -430,8 +440,16 @@ int32_t InputWindowsManager::UpdateMouseTarget(std::shared_ptr poi } auto physicalDisplayInfo = GetPhysicalDisplay(displayId); CHKPR(physicalDisplayInfo, ERROR_NULL_POINTER); - int32_t logicalX = pointerItem.GetDisplayX() + physicalDisplayInfo->x; - int32_t logicalY = pointerItem.GetDisplayY() + physicalDisplayInfo->y; + int32_t logicalX = 0; + int32_t logicalY = 0; + if (!AddInt32(pointerItem.GetDisplayX(), physicalDisplayInfo->x, logicalX)) { + MMI_HILOGE("Int32 addition overflow"); + return RET_ERR; + } + if (!AddInt32(pointerItem.GetDisplayY(), physicalDisplayInfo->y, logicalY)) { + MMI_HILOGE("Int32 addition overflow"); + return RET_ERR; + } IPointerDrawingManager::GetInstance()->DrawPointer(displayId, pointerItem.GetDisplayX(), pointerItem.GetDisplayY()); WindowInfo* touchWindow = nullptr; SelectWindowInfo(logicalX, logicalY, pointerEvent, touchWindow); @@ -481,8 +499,16 @@ int32_t InputWindowsManager::UpdateTouchScreenTarget(std::shared_ptrx; - int32_t logicalY = physicalY + physicDisplayInfo->y; + int32_t logicalX = 0; + int32_t logicalY = 0; + if (!AddInt32(physicalX, physicDisplayInfo->x, logicalX)) { + MMI_HILOGE("Int32 addition overflow"); + return RET_ERR; + } + if (!AddInt32(physicalY, physicDisplayInfo->y, logicalY)) { + MMI_HILOGE("Int32 addition overflow"); + return RET_ERR; + } WindowInfo *touchWindow = nullptr; auto targetWindowId = pointerEvent->GetTargetWindowId(); for (auto &item : displayGroupInfo_.windowsInfo) { @@ -573,11 +599,29 @@ bool InputWindowsManager::IsInsideDisplay(const DisplayInfo& displayInfo, int32_ void InputWindowsManager::FindPhysicalDisplay(const DisplayInfo& displayInfo, int32_t& physicalX, int32_t& physicalY, int32_t& displayId) { - int32_t logicalX = physicalX + displayInfo.x; - int32_t logicalY = physicalY + displayInfo.y; + int32_t logicalX = 0; + int32_t logicalY = 0; + if (!AddInt32(physicalX, displayInfo.x, logicalX)) { + MMI_HILOGE("Int32 addition overflow"); + return; + } + if (!AddInt32(physicalY, displayInfo.y, logicalY)) { + MMI_HILOGE("Int32 addition overflow"); + return; + } for (const auto &item : displayGroupInfo_.displaysInfo) { - if ((logicalX >= item.x && logicalX < item.x + item.width) && - (logicalY >= item.y && logicalY < item.y + item.height)) { + int32_t displayMaxX = 0; + int32_t displayMaxY = 0; + if (!AddInt32(item.x, item.width, displayMaxX)) { + MMI_HILOGE("Int32 addition overflow"); + return; + } + if (!AddInt32(item.y, item.height, displayMaxY)) { + MMI_HILOGE("Int32 addition overflow"); + return; + } + if ((logicalX >= item.x && logicalX < displayMaxX) && + (logicalY >= item.y && logicalY < displayMaxY)) { physicalX = logicalX - item.x; physicalY = logicalY - item.y; displayId = item.id; diff --git a/util/socket/src/uds_session.cpp b/util/socket/src/uds_session.cpp index 33db349d3c..979329e2d8 100755 --- a/util/socket/src/uds_session.cpp +++ b/util/socket/src/uds_session.cpp @@ -142,8 +142,17 @@ void UDSSession::DelEvents(int32_t id) break; } } + if (events_.empty()) { + isANRProcess_ = false; + return; + } + int64_t endTime = 0; + if (!AddInt64(events_.begin()->eventTime, INPUT_UI_TIMEOUT_TIME, endTime)) { + MMI_HILOGE("Int64 addition overflow"); + return; + } auto currentTime = GetSysClockTime(); - if (events_.empty() || (currentTime < (events_.begin()->eventTime + INPUT_UI_TIMEOUT_TIME))) { + if (currentTime < endTime) { isANRProcess_ = false; } } -- Gitee From f9717c6e738fa0d546f6f0c7d67fe43972ba0892 Mon Sep 17 00:00:00 2001 From: pengyanggit Date: Tue, 12 Jul 2022 11:29:12 +0800 Subject: [PATCH 2/5] Signed-off-by:pengyanggit Signed-off-by: pengyanggit Change-Id: I053aa12059e41ab057ecf6f8cdf0ed75f9ba3595 --- service/timer_manager/src/timer_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/timer_manager/src/timer_manager.cpp b/service/timer_manager/src/timer_manager.cpp index c2cd709761..b484894ef7 100755 --- a/service/timer_manager/src/timer_manager.cpp +++ b/service/timer_manager/src/timer_manager.cpp @@ -24,7 +24,7 @@ constexpr int32_t MAX_INTERVAL = 4096; constexpr int32_t MAX_TIMER_COUNT = 32; constexpr int32_t NONEXISTENT_ID = -1; constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MMI_LOG_DOMAIN, "TimerManager" }; -} // namespace +} // namespacegit int32_t TimerManager::AddTimer(int32_t intervalMs, int32_t repeatCount, std::function callback) { -- Gitee From 0f0cc476e9c8f7a9a0373a61f07579c664b6b595 Mon Sep 17 00:00:00 2001 From: pengyanggit Date: Tue, 12 Jul 2022 11:46:54 +0800 Subject: [PATCH 3/5] Signed-off-by:pengyanggit Signed-off-by: pengyanggit Change-Id: I39d6a4eb4d7133c138cde97084b08233189ef25f --- service/timer_manager/src/timer_manager.cpp | 402 ++++++++++---------- 1 file changed, 201 insertions(+), 201 deletions(-) diff --git a/service/timer_manager/src/timer_manager.cpp b/service/timer_manager/src/timer_manager.cpp index b484894ef7..d52bd91208 100755 --- a/service/timer_manager/src/timer_manager.cpp +++ b/service/timer_manager/src/timer_manager.cpp @@ -1,201 +1,201 @@ -/* - * 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 "timer_manager.h" - -namespace OHOS { -namespace MMI { -namespace { -constexpr int32_t MIN_DELAY = -1; -constexpr int32_t MIN_INTERVAL = 50; -constexpr int32_t MAX_INTERVAL = 4096; -constexpr int32_t MAX_TIMER_COUNT = 32; -constexpr int32_t NONEXISTENT_ID = -1; -constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MMI_LOG_DOMAIN, "TimerManager" }; -} // namespacegit - -int32_t TimerManager::AddTimer(int32_t intervalMs, int32_t repeatCount, std::function callback) -{ - return AddTimerInternal(intervalMs, repeatCount, callback); -} - -int32_t TimerManager::RemoveTimer(int32_t timerId) -{ - return RemoveTimerInternal(timerId); -} - -int32_t TimerManager::ResetTimer(int32_t timerId) -{ - return ResetTimerInternal(timerId); -} - -bool TimerManager::IsExist(int32_t timerId) -{ - return IsExistInternal(timerId); -} - -int32_t TimerManager::CalcNextDelay() -{ - return CalcNextDelayInternal(); -} - -void TimerManager::ProcessTimers() -{ - ProcessTimersInternal(); -} - -int32_t TimerManager::TakeNextTimerId() -{ - uint64_t timerSlot = 0; - uint64_t one = 1; - - for (const auto &timer : timers_) { - timerSlot |= (one << timer->id); - } - - for (int32_t i = 0; i < MAX_TIMER_COUNT; i++) { - if ((timerSlot & (one << i)) == 0) { - return i; - } - } - return NONEXISTENT_ID; -} - -int32_t TimerManager::AddTimerInternal(int32_t intervalMs, int32_t repeatCount, std::function callback) -{ - if (intervalMs < MIN_INTERVAL) { - intervalMs = MIN_INTERVAL; - } else if (intervalMs > MAX_INTERVAL) { - intervalMs = MAX_INTERVAL; - } - if (!callback) { - return NONEXISTENT_ID; - } - int32_t timerId = TakeNextTimerId(); - if (timerId < 0) { - return NONEXISTENT_ID; - } - auto timer = std::make_unique(); - timer->id = timerId; - timer->intervalMs = intervalMs; - timer->repeatCount = repeatCount; - timer->callbackCount = 0; - auto nowTime = GetMillisTime(); - if (!AddInt64(nowTime, timer->intervalMs, timer->nextCallTime)) { - MMI_HILOGE("Int64 addition overflow"); - return NONEXISTENT_ID; - } - timer->callback = callback; - InsertTimerInternal(timer); - return timerId; -} - -int32_t TimerManager::RemoveTimerInternal(int32_t timerId) -{ - for (auto it = timers_.begin(); it != timers_.end(); ++it) { - if ((*it)->id == timerId) { - timers_.erase(it); - return RET_OK; - } - } - return RET_ERR; -} - -int32_t TimerManager::ResetTimerInternal(int32_t timerId) -{ - for (auto it = timers_.begin(); it != timers_.end(); ++it) { - if ((*it)->id == timerId) { - auto timer = std::move(*it); - timers_.erase(it); - auto nowTime = GetMillisTime(); - if (!AddInt64(nowTime, timer->intervalMs, timer->nextCallTime)) { - MMI_HILOGE("Int64 addition overflow"); - return RET_ERR; - } - timer->callbackCount = 0; - InsertTimerInternal(timer); - return RET_OK; - } - } - return RET_ERR; -} - -bool TimerManager::IsExistInternal(int32_t timerId) -{ - for (auto it = timers_.begin(); it != timers_.end(); ++it) { - if ((*it)->id == timerId) { - return true; - } - } - return false; -} - -std::unique_ptr& TimerManager::InsertTimerInternal(std::unique_ptr& timer) -{ - for (auto it = timers_.begin(); it != timers_.end(); ++it) { - if ((*it)->nextCallTime > timer->nextCallTime) { - return *(timers_.insert(it, std::move(timer))); - } - } - timers_.push_back(std::move(timer)); - return *timers_.rbegin(); -} - -int32_t TimerManager::CalcNextDelayInternal() -{ - auto delay = MIN_DELAY; - if (!timers_.empty()) { - auto nowTime = GetMillisTime(); - const auto& item = *timers_.begin(); - if (nowTime >= item->nextCallTime) { - delay = 0; - } else { - delay = item->nextCallTime - nowTime; - } - } - return delay; -} - -void TimerManager::ProcessTimersInternal() -{ - if (timers_.empty()) { - return; - } - auto nowTime = GetMillisTime(); - for (;;) { - auto it = timers_.begin(); - if (it == timers_.end()) { - break; - } - if ((*it)->nextCallTime > nowTime) { - break; - } - auto curTimer = std::move(*it); - timers_.erase(it); - ++curTimer->callbackCount; - if ((curTimer->repeatCount >= 1) && (curTimer->callbackCount >= curTimer->repeatCount)) { - curTimer->callback(); - continue; - } - if (!AddInt64(nowTime, curTimer->intervalMs, curTimer->nextCallTime)) { - MMI_HILOGE("Int64 addition overflow"); - return; - } - const auto& timer = InsertTimerInternal(curTimer); - timer->callback(); - } -} -} // namespace MMI -} // namespace OHOS +/* + * 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 "timer_manager.h" + +namespace OHOS { +namespace MMI { +namespace { +constexpr int32_t MIN_DELAY = -1; +constexpr int32_t MIN_INTERVAL = 50; +constexpr int32_t MAX_INTERVAL = 4096; +constexpr int32_t MAX_TIMER_COUNT = 32; +constexpr int32_t NONEXISTENT_ID = -1; +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MMI_LOG_DOMAIN, "TimerManager" }; +} // namespacegit + +int32_t TimerManager::AddTimer(int32_t intervalMs, int32_t repeatCount, std::function callback) +{ + return AddTimerInternal(intervalMs, repeatCount, callback); +} + +int32_t TimerManager::RemoveTimer(int32_t timerId) +{ + return RemoveTimerInternal(timerId); +} + +int32_t TimerManager::ResetTimer(int32_t timerId) +{ + return ResetTimerInternal(timerId); +} + +bool TimerManager::IsExist(int32_t timerId) +{ + return IsExistInternal(timerId); +} + +int32_t TimerManager::CalcNextDelay() +{ + return CalcNextDelayInternal(); +} + +void TimerManager::ProcessTimers() +{ + ProcessTimersInternal(); +} + +int32_t TimerManager::TakeNextTimerId() +{ + uint64_t timerSlot = 0; + uint64_t one = 1; + + for (const auto &timer : timers_) { + timerSlot |= (one << timer->id); + } + + for (int32_t i = 0; i < MAX_TIMER_COUNT; i++) { + if ((timerSlot & (one << i)) == 0) { + return i; + } + } + return NONEXISTENT_ID; +} + +int32_t TimerManager::AddTimerInternal(int32_t intervalMs, int32_t repeatCount, std::function callback) +{ + if (intervalMs < MIN_INTERVAL) { + intervalMs = MIN_INTERVAL; + } else if (intervalMs > MAX_INTERVAL) { + intervalMs = MAX_INTERVAL; + } + if (!callback) { + return NONEXISTENT_ID; + } + int32_t timerId = TakeNextTimerId(); + if (timerId < 0) { + return NONEXISTENT_ID; + } + auto timer = std::make_unique(); + timer->id = timerId; + timer->intervalMs = intervalMs; + timer->repeatCount = repeatCount; + timer->callbackCount = 0; + auto nowTime = GetMillisTime(); + if (!AddInt64(nowTime, timer->intervalMs, timer->nextCallTime)) { + MMI_HILOGE("Int64 addition overflow"); + return NONEXISTENT_ID; + } + timer->callback = callback; + InsertTimerInternal(timer); + return timerId; +} + +int32_t TimerManager::RemoveTimerInternal(int32_t timerId) +{ + for (auto it = timers_.begin(); it != timers_.end(); ++it) { + if ((*it)->id == timerId) { + timers_.erase(it); + return RET_OK; + } + } + return RET_ERR; +} + +int32_t TimerManager::ResetTimerInternal(int32_t timerId) +{ + for (auto it = timers_.begin(); it != timers_.end(); ++it) { + if ((*it)->id == timerId) { + auto timer = std::move(*it); + timers_.erase(it); + auto nowTime = GetMillisTime(); + if (!AddInt64(nowTime, timer->intervalMs, timer->nextCallTime)) { + MMI_HILOGE("Int64 addition overflow"); + return RET_ERR; + } + timer->callbackCount = 0; + InsertTimerInternal(timer); + return RET_OK; + } + } + return RET_ERR; +} + +bool TimerManager::IsExistInternal(int32_t timerId) +{ + for (auto it = timers_.begin(); it != timers_.end(); ++it) { + if ((*it)->id == timerId) { + return true; + } + } + return false; +} + +std::unique_ptr& TimerManager::InsertTimerInternal(std::unique_ptr& timer) +{ + for (auto it = timers_.begin(); it != timers_.end(); ++it) { + if ((*it)->nextCallTime > timer->nextCallTime) { + return *(timers_.insert(it, std::move(timer))); + } + } + timers_.push_back(std::move(timer)); + return *timers_.rbegin(); +} + +int32_t TimerManager::CalcNextDelayInternal() +{ + auto delay = MIN_DELAY; + if (!timers_.empty()) { + auto nowTime = GetMillisTime(); + const auto& item = *timers_.begin(); + if (nowTime >= item->nextCallTime) { + delay = 0; + } else { + delay = item->nextCallTime - nowTime; + } + } + return delay; +} + +void TimerManager::ProcessTimersInternal() +{ + if (timers_.empty()) { + return; + } + auto nowTime = GetMillisTime(); + for (;;) { + auto it = timers_.begin(); + if (it == timers_.end()) { + break; + } + if ((*it)->nextCallTime > nowTime) { + break; + } + auto curTimer = std::move(*it); + timers_.erase(it); + ++curTimer->callbackCount; + if ((curTimer->repeatCount >= 1) && (curTimer->callbackCount >= curTimer->repeatCount)) { + curTimer->callback(); + continue; + } + if (!AddInt64(nowTime, curTimer->intervalMs, curTimer->nextCallTime)) { + MMI_HILOGE("Int64 addition overflow"); + return; + } + const auto& timer = InsertTimerInternal(curTimer); + timer->callback(); + } +} +} // namespace MMI +} // namespace OHOS -- Gitee From f3d712f0bff41a0e7060e3920809c414a4f2d415 Mon Sep 17 00:00:00 2001 From: pengyanggit Date: Tue, 12 Jul 2022 12:41:03 +0800 Subject: [PATCH 4/5] Signed-off-by:pengyanggit Signed-off-by: pengyanggit Change-Id: If819f22de2c5ffeacce16b8022ac204a7870c478 --- service/timer_manager/src/timer_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/timer_manager/src/timer_manager.cpp b/service/timer_manager/src/timer_manager.cpp index d52bd91208..7977448fbd 100755 --- a/service/timer_manager/src/timer_manager.cpp +++ b/service/timer_manager/src/timer_manager.cpp @@ -24,7 +24,7 @@ constexpr int32_t MAX_INTERVAL = 4096; constexpr int32_t MAX_TIMER_COUNT = 32; constexpr int32_t NONEXISTENT_ID = -1; constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MMI_LOG_DOMAIN, "TimerManager" }; -} // namespacegit +} // namespace int32_t TimerManager::AddTimer(int32_t intervalMs, int32_t repeatCount, std::function callback) { -- Gitee From f289cb897e2ffcf1ddb863f1cb2e474b7adfaf9a Mon Sep 17 00:00:00 2001 From: pengyanggit Date: Tue, 12 Jul 2022 22:28:36 +0800 Subject: [PATCH 5/5] Signed-off-by:pengyanggit Signed-off-by: pengyanggit Change-Id: Iee35efc27b9b6e0e86d234f0d0a422c0505d2594 --- frameworks/proxy/events/src/input_event.cpp | 2 +- service/timer_manager/src/timer_manager.cpp | 6 +++--- .../src/input_windows_manager.cpp | 20 +++++++++---------- util/socket/src/uds_session.cpp | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/frameworks/proxy/events/src/input_event.cpp b/frameworks/proxy/events/src/input_event.cpp index 3097d7e346..fa7e3121b0 100755 --- a/frameworks/proxy/events/src/input_event.cpp +++ b/frameworks/proxy/events/src/input_event.cpp @@ -50,7 +50,7 @@ void InputEvent::Reset() } id_ = -1; if (!AddInt64(ts.tv_sec * 1000000, ts.tv_nsec / 1000, actionTime_)) { - MMI_HILOGE("Int64 addition overflow"); + MMI_HILOGE("The addition of actionTime_ overflows"); return; } action_ = ACTION_UNKNOWN; diff --git a/service/timer_manager/src/timer_manager.cpp b/service/timer_manager/src/timer_manager.cpp index 7977448fbd..d92d819b83 100755 --- a/service/timer_manager/src/timer_manager.cpp +++ b/service/timer_manager/src/timer_manager.cpp @@ -94,7 +94,7 @@ int32_t TimerManager::AddTimerInternal(int32_t intervalMs, int32_t repeatCount, timer->callbackCount = 0; auto nowTime = GetMillisTime(); if (!AddInt64(nowTime, timer->intervalMs, timer->nextCallTime)) { - MMI_HILOGE("Int64 addition overflow"); + MMI_HILOGE("The addition of nextCallTime in TimerItem overflows"); return NONEXISTENT_ID; } timer->callback = callback; @@ -121,7 +121,7 @@ int32_t TimerManager::ResetTimerInternal(int32_t timerId) timers_.erase(it); auto nowTime = GetMillisTime(); if (!AddInt64(nowTime, timer->intervalMs, timer->nextCallTime)) { - MMI_HILOGE("Int64 addition overflow"); + MMI_HILOGE("The addition of nextCallTime in TimerItem overflows"); return RET_ERR; } timer->callbackCount = 0; @@ -190,7 +190,7 @@ void TimerManager::ProcessTimersInternal() continue; } if (!AddInt64(nowTime, curTimer->intervalMs, curTimer->nextCallTime)) { - MMI_HILOGE("Int64 addition overflow"); + MMI_HILOGE("The addition of nextCallTime in TimerItem overflows"); return; } const auto& timer = InsertTimerInternal(curTimer); diff --git a/service/window_manager/src/input_windows_manager.cpp b/service/window_manager/src/input_windows_manager.cpp index 29e28ba9b9..e5c51fb2d6 100755 --- a/service/window_manager/src/input_windows_manager.cpp +++ b/service/window_manager/src/input_windows_manager.cpp @@ -329,11 +329,11 @@ bool InputWindowsManager::IsInHotArea(int32_t x, int32_t y, const std::vector= item.x) && (x < displayMaxX)) && @@ -443,11 +443,11 @@ int32_t InputWindowsManager::UpdateMouseTarget(std::shared_ptr poi int32_t logicalX = 0; int32_t logicalY = 0; if (!AddInt32(pointerItem.GetDisplayX(), physicalDisplayInfo->x, logicalX)) { - MMI_HILOGE("Int32 addition overflow"); + MMI_HILOGE("The addition of logicalX overflows"); return RET_ERR; } if (!AddInt32(pointerItem.GetDisplayY(), physicalDisplayInfo->y, logicalY)) { - MMI_HILOGE("Int32 addition overflow"); + MMI_HILOGE("The addition of logicalY overflows"); return RET_ERR; } IPointerDrawingManager::GetInstance()->DrawPointer(displayId, pointerItem.GetDisplayX(), pointerItem.GetDisplayY()); @@ -502,11 +502,11 @@ int32_t InputWindowsManager::UpdateTouchScreenTarget(std::shared_ptrx, logicalX)) { - MMI_HILOGE("Int32 addition overflow"); + MMI_HILOGE("The addition of logicalX overflows"); return RET_ERR; } if (!AddInt32(physicalY, physicDisplayInfo->y, logicalY)) { - MMI_HILOGE("Int32 addition overflow"); + MMI_HILOGE("The addition of logicalY overflows"); return RET_ERR; } WindowInfo *touchWindow = nullptr; @@ -603,22 +603,22 @@ void InputWindowsManager::FindPhysicalDisplay(const DisplayInfo& displayInfo, in int32_t logicalX = 0; int32_t logicalY = 0; if (!AddInt32(physicalX, displayInfo.x, logicalX)) { - MMI_HILOGE("Int32 addition overflow"); + MMI_HILOGE("The addition of logicalX overflows"); return; } if (!AddInt32(physicalY, displayInfo.y, logicalY)) { - MMI_HILOGE("Int32 addition overflow"); + MMI_HILOGE("The addition of logicalY overflows"); return; } for (const auto &item : displayGroupInfo_.displaysInfo) { int32_t displayMaxX = 0; int32_t displayMaxY = 0; if (!AddInt32(item.x, item.width, displayMaxX)) { - MMI_HILOGE("Int32 addition overflow"); + MMI_HILOGE("The addition of displayMaxX overflows"); return; } if (!AddInt32(item.y, item.height, displayMaxY)) { - MMI_HILOGE("Int32 addition overflow"); + MMI_HILOGE("The addition of displayMaxY overflows"); return; } if ((logicalX >= item.x && logicalX < displayMaxX) && diff --git a/util/socket/src/uds_session.cpp b/util/socket/src/uds_session.cpp index e50db5acfa..be30af283a 100755 --- a/util/socket/src/uds_session.cpp +++ b/util/socket/src/uds_session.cpp @@ -148,7 +148,7 @@ void UDSSession::DelEvents(int32_t id) } int64_t endTime = 0; if (!AddInt64(events_.begin()->eventTime, INPUT_UI_TIMEOUT_TIME, endTime)) { - MMI_HILOGE("Int64 addition overflow"); + MMI_HILOGE("The addition of endTime overflows"); return; } auto currentTime = GetSysClockTime(); -- Gitee