summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Maryam Karimzadehgan <maryamk@google.com> 2020-10-28 15:36:50 -0700
committer Winson Chung <winsonc@google.com> 2020-11-16 18:56:28 +0000
commit0ed68db06c408cae61c05270282b45da086516d4 (patch)
tree7a05810e610919ce82bec3afe06540cc8679c34f
parent8c95065cb7230fabd7c6f5533d86f666a50823e7 (diff)
Add flag to get the name of the Model file from the flag in case we want
to try out different models. In addition, we should not log touches in the middle of the screen for logging so moving the block at the very beginning. Test: unittest, manual test Bug: 150170384 Change-Id: I6ecb556fea01f26323248b999d17c7b1d1b7eeb7 Merged-In: I6ecb556fea01f26323248b999d17c7b1d1b7eeb7
-rw-r--r--core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java5
-rw-r--r--packages/SystemUI/src/com/android/systemui/SystemUIFactory.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/EdgeBackGestureHandler.java33
3 files changed, 25 insertions, 15 deletions
diff --git a/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java b/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java
index 3c5eba78174f..40c21bddf41b 100644
--- a/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java
+++ b/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java
@@ -434,6 +434,11 @@ public final class SystemUiDeviceConfigFlags {
public static final String USE_BACK_GESTURE_ML_MODEL = "use_back_gesture_ml_model";
/**
+ * (string) The name of the ML model for Back Gesture.
+ */
+ public static final String BACK_GESTURE_ML_MODEL_NAME = "back_gesture_ml_model_name";
+
+ /**
* (float) Threshold for Back Gesture ML model prediction.
*/
public static final String BACK_GESTURE_ML_MODEL_THRESHOLD = "back_gesture_ml_model_threshold";
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java
index 4a77de2850dd..eebf70b7564c 100644
--- a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java
+++ b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java
@@ -190,7 +190,7 @@ public class SystemUIFactory {
* This method is overridden in vendor specific implementation of Sys UI.
*/
public BackGestureTfClassifierProvider createBackGestureTfClassifierProvider(
- AssetManager am) {
+ AssetManager am, String modelName) {
return new BackGestureTfClassifierProvider();
}
}
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 3271abe313f9..dc42997be0d3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/EdgeBackGestureHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/EdgeBackGestureHandler.java
@@ -137,7 +137,9 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa
&& (properties.getKeyset().contains(
SystemUiDeviceConfigFlags.BACK_GESTURE_ML_MODEL_THRESHOLD)
|| properties.getKeyset().contains(
- SystemUiDeviceConfigFlags.USE_BACK_GESTURE_ML_MODEL))) {
+ SystemUiDeviceConfigFlags.USE_BACK_GESTURE_ML_MODEL)
+ || properties.getKeyset().contains(
+ SystemUiDeviceConfigFlags.BACK_GESTURE_ML_MODEL_NAME))) {
updateMLModelState();
}
}
@@ -478,8 +480,10 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa
}
if (newState) {
+ String mlModelName = DeviceConfig.getString(DeviceConfig.NAMESPACE_SYSTEMUI,
+ SystemUiDeviceConfigFlags.BACK_GESTURE_ML_MODEL_NAME, "backgesture");
mBackGestureTfClassifierProvider = SystemUIFactory.getInstance()
- .createBackGestureTfClassifierProvider(mContext.getAssets());
+ .createBackGestureTfClassifierProvider(mContext.getAssets(), mlModelName);
mMLModelThreshold = DeviceConfig.getFloat(DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.BACK_GESTURE_ML_MODEL_THRESHOLD, 0.9f);
if (mBackGestureTfClassifierProvider.isActive()) {
@@ -529,21 +533,22 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa
boolean withinRange = false;
float results = -1;
+ // Disallow if we are in the bottom gesture area
+ if (y >= (mDisplaySize.y - mBottomGestureHeight)) {
+ return false;
+ }
+ // If the point is way too far (twice the margin), it is
+ // not interesting to us for logging purposes, nor we
+ // should process it. Simply return false and keep
+ // mLogGesture = false.
+ if (x > 2 * (mEdgeWidthLeft + mLeftInset)
+ && x < (mDisplaySize.x - 2 * (mEdgeWidthRight + mRightInset))) {
+ return false;
+ }
+
if (mUseMLModel && (results = getBackGesturePredictionsCategory(x, y)) != -1) {
withinRange = results == 1 ? true : false;
} else {
- // Disallow if we are in the bottom gesture area
- if (y >= (mDisplaySize.y - mBottomGestureHeight)) {
- return false;
- }
- // If the point is way too far (twice the margin), it is
- // not interesting to us for logging purposes, nor we
- // should process it. Simply return false and keep
- // mLogGesture = false.
- if (x > 2 * (mEdgeWidthLeft + mLeftInset)
- && x < (mDisplaySize.x - 2 * (mEdgeWidthRight + mRightInset))) {
- return false;
- }
// 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.