From 183e9b78ce22ce80f9666bdd134fff5472e3851a Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Mon, 8 Mar 2021 20:20:12 -0800 Subject: [PATCH] Ensure that ML model results are still bounded by the gesture insets - In some cases, the ML model may return that it is a valid swipe even if it is out of the current inset bounds Bug: 178561216 Test: Enable ML model, rotate to landscape and try to swipe near the edges Merged-In: Iaecd11acf50a1a19fe5964e11e06fb564ca6988c Change-Id: Iaecd11acf50a1a19fe5964e11e06fb564ca6988c (cherry picked from commit 8afd10c9665c8f521ad8c076c2695d9fc6924368) --- .../phone/EdgeBackGestureHandler.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 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 603679afc1098..14f8363b43454 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/EdgeBackGestureHandler.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/EdgeBackGestureHandler.java @@ -560,20 +560,21 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa 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) { + + // 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. + boolean withinRange = x < mEdgeWidthLeft + mLeftInset + || x >= (mDisplaySize.x - mEdgeWidthRight - 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); + + // Check if we are within the tightest bounds beyond which we would not need to run the + // ML model + boolean withinMinRange = x < mMLEnableWidth + mLeftInset + || x >= (mDisplaySize.x - mMLEnableWidth - mRightInset); + if (!withinMinRange && mUseMLModel + && (results = getBackGesturePredictionsCategory(x, y, app)) != -1) { + withinRange = (results == 1); } }