Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/EdgeBackGestureHandler.java +45 −15 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 = Loading Loading @@ -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 Loading Loading @@ -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; } Loading @@ -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; Loading @@ -546,8 +556,18 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa return false; } if (mUseMLModel && (results = getBackGesturePredictionsCategory(x, y)) != -1) { withinRange = results == 1 ? true : false; 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 Loading @@ -555,6 +575,14 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa 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) { Loading Loading @@ -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() { Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/EdgeBackGestureHandler.java +45 −15 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 = Loading Loading @@ -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 Loading Loading @@ -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; } Loading @@ -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; Loading @@ -546,8 +556,18 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa return false; } if (mUseMLModel && (results = getBackGesturePredictionsCategory(x, y)) != -1) { withinRange = results == 1 ? true : false; 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 Loading @@ -555,6 +575,14 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa 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) { Loading Loading @@ -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() { Loading