Add Flags to be able to run experiments for the Back Gesture Problem.
Test: manual atest, adb shell device_config put systemui back_gesture_bottom_height 1000
Bug: 148104018
Change-Id: I5b0e696ca2e015d2d9a1718785f4a140cfff083f
diff --git a/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java b/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java
index 837cc46..2b0fd66 100644
--- a/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java
+++ b/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java
@@ -210,7 +210,7 @@
* Allow touch passthrough above assist area during a session.
*/
public static final String ASSIST_TAP_PASSTHROUGH = "assist_tap_passthrough";
-
+
/**
* (bool) Whether to show handles when taught.
*/
@@ -393,6 +393,21 @@
*/
public static final String PIP_USER_RESIZE = "pip_user_resize";
+ /**
+ * (float) Bottom height in DP for Back Gesture.
+ */
+ public static final String BACK_GESTURE_BOTTOM_HEIGHT = "back_gesture_bottom_height";
+
+ /**
+ * (float) Edge width in DP where touch down is allowed for Back Gesture.
+ */
+ public static final String BACK_GESTURE_EDGE_WIDTH = "back_gesture_edge_width";
+
+ /**
+ * (float) Slop multiplier for Back Gesture.
+ */
+ public static final String BACK_GESTURE_SLOP_MULTIPLIER = "back_gesture_slop_multiplier";
+
private SystemUiDeviceConfigFlags() {
}
}
diff --git a/core/java/com/android/internal/policy/GestureNavigationSettingsObserver.java b/core/java/com/android/internal/policy/GestureNavigationSettingsObserver.java
index 56a6db9..4786d41 100644
--- a/core/java/com/android/internal/policy/GestureNavigationSettingsObserver.java
+++ b/core/java/com/android/internal/policy/GestureNavigationSettingsObserver.java
@@ -16,13 +16,17 @@
package com.android.internal.policy;
+import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.BACK_GESTURE_EDGE_WIDTH;
+
import android.content.ContentResolver;
import android.content.Context;
import android.content.res.Resources;
import android.database.ContentObserver;
import android.os.Handler;
import android.os.UserHandle;
+import android.provider.DeviceConfig;
import android.provider.Settings;
+import android.util.TypedValue;
/**
* @hide
@@ -30,14 +34,27 @@
public class GestureNavigationSettingsObserver extends ContentObserver {
private Context mContext;
private Runnable mOnChangeRunnable;
+ private Handler mMainHandler;
public GestureNavigationSettingsObserver(Handler handler, Context context,
Runnable onChangeRunnable) {
super(handler);
+ mMainHandler = handler;
mContext = context;
mOnChangeRunnable = onChangeRunnable;
}
+ private final DeviceConfig.OnPropertiesChangedListener mOnPropertiesChangedListener =
+ new DeviceConfig.OnPropertiesChangedListener() {
+ @Override
+ public void onPropertiesChanged(DeviceConfig.Properties properties) {
+ if (DeviceConfig.NAMESPACE_SYSTEMUI.equals(properties.getNamespace())
+ && mOnChangeRunnable != null) {
+ mOnChangeRunnable.run();
+ }
+ }
+ };
+
public void register() {
ContentResolver r = mContext.getContentResolver();
r.registerContentObserver(
@@ -49,10 +66,15 @@
r.registerContentObserver(
Settings.Secure.getUriFor(Settings.Secure.USER_SETUP_COMPLETE),
false, this, UserHandle.USER_ALL);
+ DeviceConfig.addOnPropertiesChangedListener(
+ DeviceConfig.NAMESPACE_SYSTEMUI,
+ runnable -> mMainHandler.post(runnable),
+ mOnPropertiesChangedListener);
}
public void unregister() {
mContext.getContentResolver().unregisterContentObserver(this);
+ DeviceConfig.removeOnPropertiesChangedListener(mOnPropertiesChangedListener);
}
@Override
@@ -77,8 +99,12 @@
}
private int getSensitivity(Resources userRes, String side) {
- final int inset = userRes.getDimensionPixelSize(
+ final float defaultInset = userRes.getDimension(
com.android.internal.R.dimen.config_backGestureInset);
+ final float backGestureInset = DeviceConfig.getFloat(DeviceConfig.NAMESPACE_SYSTEMUI,
+ BACK_GESTURE_EDGE_WIDTH, defaultInset);
+ final float inset = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, backGestureInset,
+ userRes.getDisplayMetrics());
final float scale = Settings.Secure.getFloatForUser(
mContext.getContentResolver(), side, 1.0f, UserHandle.USER_CURRENT);
return (int) (inset * scale);
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 ba8a634..6748e3f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/EdgeBackGestureHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/EdgeBackGestureHandler.java
@@ -34,8 +34,10 @@
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.UserHandle;
+import android.provider.DeviceConfig;
import android.provider.Settings;
import android.util.Log;
+import android.util.TypedValue;
import android.view.ISystemGestureExclusionListener;
import android.view.InputChannel;
import android.view.InputDevice;
@@ -50,6 +52,7 @@
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
+import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
import com.android.internal.policy.GestureNavigationSettingsObserver;
import com.android.systemui.Dependency;
import com.android.systemui.R;
@@ -144,9 +147,9 @@
// The right side edge width where touch down is allowed
private int mEdgeWidthRight;
// The bottom gesture area height
- private int mBottomGestureHeight;
+ private float mBottomGestureHeight;
// The slop to distinguish between horizontal and vertical motion
- private final float mTouchSlop;
+ private float mTouchSlop;
// Duration after which we consider the event as longpress.
private final int mLongPressTimeout;
private int mStartingQuickstepRotation = -1;
@@ -211,10 +214,6 @@
mPluginManager = pluginManager;
Dependency.get(ProtoTracer.class).add(this);
- // 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
- mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop() * 0.75f;
mLongPressTimeout = Math.min(MAX_LONG_PRESS_TIMEOUT,
ViewConfiguration.getLongPressTimeout());
@@ -233,8 +232,20 @@
mIsBackGestureAllowed =
!mGestureNavigationSettingsObserver.areNavigationButtonForcedVisible();
- mBottomGestureHeight = res.getDimensionPixelSize(
+ final float defaultGestureHeight = res.getDimension(
com.android.internal.R.dimen.navigation_bar_gesture_height);
+ final float gestureHeight = DeviceConfig.getFloat(DeviceConfig.NAMESPACE_SYSTEMUI,
+ SystemUiDeviceConfigFlags.BACK_GESTURE_BOTTOM_HEIGHT,
+ defaultGestureHeight);
+ mBottomGestureHeight = TypedValue.applyDimension(
+ TypedValue.COMPLEX_UNIT_DIP, gestureHeight, res.getDisplayMetrics());
+
+ // 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
+ final float backGestureSlop = DeviceConfig.getFloat(DeviceConfig.NAMESPACE_SYSTEMUI,
+ SystemUiDeviceConfigFlags.BACK_GESTURE_SLOP_MULTIPLIER, 0.75f);
+ mTouchSlop = ViewConfiguration.get(mContext).getScaledTouchSlop() * backGestureSlop;
}
@Override