Merge changes from topic "back_gesture_model_qpr" into rvc-qpr-dev am: 898602efc6
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13005359 Change-Id: I8017c38ef9536b49ee2b7c1bed328c3e4ac1ec75
This commit is contained in:
@@ -433,6 +433,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.
|
||||
*/
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user