diff options
| author | 2020-04-30 23:22:51 +0000 | |
|---|---|---|
| committer | 2020-04-30 23:22:51 +0000 | |
| commit | 6ff27423b86b9f6b05859f9f5e0390992fe41be1 (patch) | |
| tree | c09ca12c9faa355557c5b79267ef280aa5197b6c | |
| parent | cc850fcff37f932e1128f32c54c8fb5b74308d51 (diff) | |
| parent | a142e5210b05d71c4c87b207690766418e2b8178 (diff) | |
Merge "Add Flags to be able to run experiments for the Back Gesture Problem." into rvc-dev
3 files changed, 61 insertions, 9 deletions
diff --git a/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java b/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java index 837cc466a895..2b0fd663643d 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 @@ public final class SystemUiDeviceConfigFlags { * 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 final class SystemUiDeviceConfigFlags { */ 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 56a6db95badc..4786d41fef4b 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 @@ import android.provider.Settings; 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 @@ public class GestureNavigationSettingsObserver extends ContentObserver { 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 @@ public class GestureNavigationSettingsObserver extends ContentObserver { } 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 ba8a63428cf6..6748e3f76771 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.RemoteException; 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.ViewConfiguration; 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 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa // 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 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa 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 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa 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 |