HIC: Base on elapsed time instead of RTC
Bug: 27405075 Change-Id: I703a870cf230ddccc9c89a9507e3ee900609f592
This commit is contained in:
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.android.systemui.classifier;
|
package com.android.systemui.classifier;
|
||||||
|
|
||||||
|
import android.os.SystemClock;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,7 +33,7 @@ public class HistoryEvaluator {
|
|||||||
private long mLastUpdate;
|
private long mLastUpdate;
|
||||||
|
|
||||||
public HistoryEvaluator() {
|
public HistoryEvaluator() {
|
||||||
mLastUpdate = System.currentTimeMillis();
|
mLastUpdate = SystemClock.elapsedRealtime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addStroke(float evaluation) {
|
public void addStroke(float evaluation) {
|
||||||
@@ -69,15 +71,18 @@ public class HistoryEvaluator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void decayValue() {
|
private void decayValue() {
|
||||||
long currentTimeMillis = System.currentTimeMillis();
|
long time = SystemClock.elapsedRealtime();
|
||||||
|
|
||||||
|
if (time <= mLastUpdate) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// All weights are multiplied by HISTORY_FACTOR after each INTERVAL milliseconds.
|
// All weights are multiplied by HISTORY_FACTOR after each INTERVAL milliseconds.
|
||||||
float factor = (float) Math.pow(HISTORY_FACTOR,
|
float factor = (float) Math.pow(HISTORY_FACTOR, (time - mLastUpdate) / INTERVAL);
|
||||||
(float) (currentTimeMillis - mLastUpdate) / INTERVAL);
|
|
||||||
|
|
||||||
decayValue(mStrokes, factor);
|
decayValue(mStrokes, factor);
|
||||||
decayValue(mGestureWeights, factor);
|
decayValue(mGestureWeights, factor);
|
||||||
mLastUpdate = currentTimeMillis;
|
mLastUpdate = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void decayValue(ArrayList<Data> list, float factor) {
|
private void decayValue(ArrayList<Data> list, float factor) {
|
||||||
|
|||||||
Reference in New Issue
Block a user