diff --git a/service/touch_event_normalize/src/touch_gesture_detector.cpp b/service/touch_event_normalize/src/touch_gesture_detector.cpp index a6df6a91ac98259d4a021c2805bacf2d58d71fd5..a43aace93b4958bfda397c935b2274e61b20d7c2 100644 --- a/service/touch_event_normalize/src/touch_gesture_detector.cpp +++ b/service/touch_event_normalize/src/touch_gesture_detector.cpp @@ -447,7 +447,7 @@ TouchGestureDetector::SlideState TouchGestureDetector::ClacFingerMoveDirection(s } MMI_HILOGI("The pointerId:%{public}d,angle:%{public}.2f,direction:%{public}d", pointerId, angle, direction); } - if ((recognizedCount < downPoint_.size()) || InDiverseDirections(directions)) { + if ((recognizedCount < downPoint_.size()) || InDiverseDirections(directions) || directions.empty()) { return SlideState::DIRECTION_UNKNOW; } return *(directions.begin()); @@ -530,6 +530,10 @@ Point TouchGestureDetector::CalcGravityCenter(std::map &points) ySum += (current[1] + next[1]) * crossProduct; } area /= arrCount; + if (area == 0.0) { + MMI_HILOGW("Area is zero, cannot calculate gravity center"); + goto end; + } xSum /= count * area; ySum /= count * area; end: