summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2020-12-17 18:35:41 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-12-17 18:35:41 +0000
commitdf1f2f384ca9ddb023ee658660262e914fa3d372 (patch)
tree839b11e58f0e18b7db77bf31aa30e0180b0ff5db
parent653f07816223f1e8b20dd58b92c8901ffba56ab4 (diff)
parent0b44441e7c17cb578055aadf41f80fcd1a592810 (diff)
Merge "Adding logging for the ML mBack gesture model." into rvc-qpr-dev am: 0b44441e7c
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13238787 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: Ib7fc9cb9473594e933d59625b7ebca69d4205bfd
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/EdgeBackGestureHandler.java60
1 files changed, 45 insertions, 15 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/EdgeBackGestureHandler.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/EdgeBackGestureHandler.java
index dc42997be0d3..603679afc109 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/EdgeBackGestureHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/EdgeBackGestureHandler.java
@@ -75,6 +75,7 @@ import com.android.systemui.tracing.nano.EdgeBackGestureHandlerProto;
import com.android.systemui.tracing.nano.SystemUiTraceProto;
import java.io.PrintWriter;
+import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -204,10 +205,15 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa
private BackGestureTfClassifierProvider mBackGestureTfClassifierProvider;
private Map<String, Integer> mVocab;
private boolean mUseMLModel;
+ // minimum width below which we do not run the model
+ private int mMLEnableWidth;
private float mMLModelThreshold;
private String mPackageName;
private float mMLResults;
+ private static final int MAX_LOGGED_PREDICTIONS = 10;
+ private ArrayDeque<String> mPredictionLog = new ArrayDeque<>();
+
private final GestureNavigationSettingsObserver mGestureNavigationSettingsObserver;
private final NavigationEdgeBackPlugin.BackCallback mBackCallback =
@@ -292,6 +298,11 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa
mBottomGestureHeight = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, gestureHeight,
dm);
+ // Set the minimum bounds to activate ML to 12dp or the minimum of configured values
+ mMLEnableWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12.0f, dm);
+ if (mMLEnableWidth > mEdgeWidthRight) mMLEnableWidth = mEdgeWidthRight;
+ if (mMLEnableWidth > mEdgeWidthLeft) mMLEnableWidth = mEdgeWidthLeft;
+
// Reduce the default touch slop to ensure that we can intercept the gesture
// before the app starts to react to it.
// TODO(b/130352502) Tune this value and extract into a constant
@@ -500,8 +511,8 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa
}
}
- private float getBackGesturePredictionsCategory(int x, int y) {
- if (!mVocab.containsKey(mPackageName)) {
+ private int getBackGesturePredictionsCategory(int x, int y, int app) {
+ if (app == -1) {
return -1;
}
@@ -519,20 +530,19 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa
new long[]{(long) mDisplaySize.x},
new long[]{(long) distanceFromEdge},
new long[]{(long) location},
- new long[]{(long) mVocab.get(mPackageName)},
+ new long[]{(long) app},
new long[]{(long) y},
};
mMLResults = mBackGestureTfClassifierProvider.predict(featuresVector);
- if (mMLResults == -1) return -1;
+ if (mMLResults == -1) {
+ return -1;
+ }
return mMLResults >= mMLModelThreshold ? 1 : 0;
}
private boolean isWithinTouchRegion(int x, int y) {
- boolean withinRange = false;
- float results = -1;
-
// Disallow if we are in the bottom gesture area
if (y >= (mDisplaySize.y - mBottomGestureHeight)) {
return false;
@@ -546,15 +556,33 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa
return false;
}
- if (mUseMLModel && (results = getBackGesturePredictionsCategory(x, y)) != -1) {
- withinRange = results == 1 ? true : false;
- } else {
- // Denotes whether we should proceed with the gesture.
- // Even if it is false, we may want to log it assuming
- // it is not invalid due to exclusion.
- withinRange = x <= mEdgeWidthLeft + mLeftInset
- || x >= (mDisplaySize.x - mEdgeWidthRight - mRightInset);
+ int app = -1;
+ if (mVocab != null) {
+ app = mVocab.getOrDefault(mPackageName, -1);
+ }
+ // Check if we are within the tightest bounds beyond which
+ // we would not need to run the ML model.
+ boolean withinRange = x <= mMLEnableWidth + mLeftInset
+ || x >= (mDisplaySize.x - mMLEnableWidth - mRightInset);
+ if (!withinRange) {
+ int results = -1;
+ if (mUseMLModel && (results = getBackGesturePredictionsCategory(x, y, app)) != -1) {
+ withinRange = results == 1;
+ } else {
+ // Denotes whether we should proceed with the gesture.
+ // Even if it is false, we may want to log it assuming
+ // it is not invalid due to exclusion.
+ withinRange = x <= mEdgeWidthLeft + mLeftInset
+ || x >= (mDisplaySize.x - mEdgeWidthRight - mRightInset);
+ }
+ }
+
+ // For debugging purposes
+ if (mPredictionLog.size() >= MAX_LOGGED_PREDICTIONS) {
+ mPredictionLog.removeFirst();
}
+ mPredictionLog.addLast(String.format("[%d,%d,%d,%f,%d]",
+ x, y, app, mMLResults, withinRange ? 1 : 0));
// Always allow if the user is in a transient sticky immersive state
if (mIsNavBarShownTransiently) {
@@ -753,6 +781,8 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa
pw.println(" mIsAttached=" + mIsAttached);
pw.println(" mEdgeWidthLeft=" + mEdgeWidthLeft);
pw.println(" mEdgeWidthRight=" + mEdgeWidthRight);
+ pw.println(" mIsNavBarShownTransiently=" + mIsNavBarShownTransiently);
+ pw.println(" mPredictionLog=" + String.join(";", mPredictionLog));
}
private boolean isGestureBlockingActivityRunning() {