HIC: Improve AccelerationClassifier
Apply a bunch of improvements to the acceleration classifier:
- When dragging from the edges, we get some delay without
movement between the DOWN and MOVE, which confounds the
classifier. Now discounts data segments where the delay
does not match the expected 16ms.
- The distance ratio did not compensate for differences
in sampling. If it does it's equivalent to the speed
ratio however. The distance ratio was removed and the
impact of the speed ratio score doubled.
- If we cannot calculate the ratio, no longer penalize
the traces for this.
Bug: 27405075
Change-Id: I067eb4d478593afbb20354e5c85a05353e2b4184
(cherry picked from commit 6b312a09fc)
This commit is contained in:
@@ -62,36 +62,36 @@ public class AccelerationClassifier extends StrokeClassifier {
|
|||||||
@Override
|
@Override
|
||||||
public float getFalseTouchEvaluation(int type, Stroke stroke) {
|
public float getFalseTouchEvaluation(int type, Stroke stroke) {
|
||||||
Data data = mStrokeMap.get(stroke);
|
Data data = mStrokeMap.get(stroke);
|
||||||
return SpeedRatioEvaluator.evaluate(data.maxSpeedRatio)
|
return 2 * SpeedRatioEvaluator.evaluate(data.maxSpeedRatio);
|
||||||
+ DistanceRatioEvaluator.evaluate(data.maxDistanceRatio);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Data {
|
private static class Data {
|
||||||
public Point previousPoint;
|
|
||||||
public float previousSpeed;
|
static final float MILLIS_TO_NANOS = 1e6f;
|
||||||
public float previousDistance;
|
|
||||||
public float maxSpeedRatio;
|
Point previousPoint;
|
||||||
public float maxDistanceRatio;
|
float previousSpeed = 0;
|
||||||
|
float maxSpeedRatio = 0;
|
||||||
|
|
||||||
public Data(Point point) {
|
public Data(Point point) {
|
||||||
previousPoint = point;
|
previousPoint = point;
|
||||||
previousSpeed = previousDistance = 0.0f;
|
|
||||||
maxDistanceRatio = maxSpeedRatio = 0.0f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPoint(Point point) {
|
public void addPoint(Point point) {
|
||||||
float distance = previousPoint.dist(point);
|
float distance = previousPoint.dist(point);
|
||||||
float duration = (float) (point.timeOffsetNano - previousPoint.timeOffsetNano + 1);
|
float duration = (float) (point.timeOffsetNano - previousPoint.timeOffsetNano + 1);
|
||||||
float speed = distance / duration;
|
float speed = distance / duration;
|
||||||
if (previousDistance != 0.0f) {
|
|
||||||
maxDistanceRatio = Math.max(maxDistanceRatio, distance / previousDistance);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (duration > 20 * MILLIS_TO_NANOS || duration < 5 * MILLIS_TO_NANOS) {
|
||||||
|
// reject this segment and ensure we won't use data about it in the next round.
|
||||||
|
previousSpeed = 0;
|
||||||
|
previousPoint = point;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (previousSpeed != 0.0f) {
|
if (previousSpeed != 0.0f) {
|
||||||
maxSpeedRatio = Math.max(maxSpeedRatio, speed / previousSpeed);
|
maxSpeedRatio = Math.max(maxSpeedRatio, speed / previousSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
previousDistance = distance;
|
|
||||||
previousSpeed = speed;
|
previousSpeed = speed;
|
||||||
previousPoint = point;
|
previousPoint = point;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2015 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.systemui.classifier;
|
|
||||||
|
|
||||||
public class DistanceRatioEvaluator {
|
|
||||||
public static float evaluate(float value) {
|
|
||||||
float evaluation = 0.0f;
|
|
||||||
if (value <= 1.0) evaluation++;
|
|
||||||
if (value <= 0.5) evaluation++;
|
|
||||||
if (value > 4.0) evaluation++;
|
|
||||||
if (value > 7.0) evaluation++;
|
|
||||||
if (value > 14.0) evaluation++;
|
|
||||||
return evaluation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -19,6 +19,7 @@ package com.android.systemui.classifier;
|
|||||||
public class SpeedRatioEvaluator {
|
public class SpeedRatioEvaluator {
|
||||||
public static float evaluate(float value) {
|
public static float evaluate(float value) {
|
||||||
float evaluation = 0.0f;
|
float evaluation = 0.0f;
|
||||||
|
if (value == 0) return 0;
|
||||||
if (value <= 1.0) evaluation++;
|
if (value <= 1.0) evaluation++;
|
||||||
if (value <= 0.5) evaluation++;
|
if (value <= 0.5) evaluation++;
|
||||||
if (value > 9.0) evaluation++;
|
if (value > 9.0) evaluation++;
|
||||||
|
|||||||
Reference in New Issue
Block a user