Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bdabd396 authored by Jiwon Kim's avatar Jiwon Kim
Browse files

Fixed Handler Leak on DistanceClassifier



A VelocityTracker object is not recycled in case of motionEvents.size()<3 at calculateDistances function.

private DistanceVectors calculateDistances() {
    // This code assumes that there will be no missed DOWN or UP events.
    VelocityTracker velocityTracker = VelocityTracker.obtain();
...
    if (motionEvents.size() < 3) {
        logDebug("Only " + motionEvents.size() + " motion events recorded.");
        return new DistanceVectors(0, 0, 0, 0);
	}
...
}

Test: Manual

Signed-off-by: default avatarJiwon Kim <jiwon88.kim@samsung.com>
Change-Id: Ifca0c25411f56a4de79d89d262d2b4e61045a8ed
parent 5e3a035a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -112,7 +112,6 @@ class DistanceClassifier extends FalsingClassifier {

    private DistanceVectors calculateDistances() {
        // This code assumes that there will be no missed DOWN or UP events.
        VelocityTracker velocityTracker = VelocityTracker.obtain();
        List<MotionEvent> motionEvents = getRecentMotionEvents();

        if (motionEvents.size() < 3) {
@@ -120,6 +119,8 @@ class DistanceClassifier extends FalsingClassifier {
            return new DistanceVectors(0, 0, 0, 0);
        }

        VelocityTracker velocityTracker = VelocityTracker.obtain();

        for (MotionEvent motionEvent : motionEvents) {
            velocityTracker.addMovement(motionEvent);
        }