Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6e62705a authored by Yeabkal Wubshit's avatar Yeabkal Wubshit
Browse files

Fix new Physical UX feature flagging

- Re-use the scroll-feedbacak api flag for widget scroll haptics: that
  way, it helps us to centralize the flagging/rollout of scroll haptic
  feedback.
- Create and use a new feature flag for the unflagged differential
  motion fling feature.

Bug: 293332089
Bug: 287914819
Test: atest DifferentialMotionFlingHelperTest
Test: manual flag flip to check features enabled/disabled as expected
Change-Id: I1da7052727c9fcebab2d28b66a65fb6727a16f48
parent 78dca6fa
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ import android.view.animation.LinearInterpolator;
import android.view.autofill.AutofillId;
import android.view.contentcapture.ContentCaptureManager;
import android.view.contentcapture.ContentCaptureSession;
import android.view.flags.Flags;
import android.view.inputmethod.BaseInputConnection;
import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.CorrectionInfo;
@@ -92,7 +93,6 @@ import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.SurroundingText;
import android.view.inspector.InspectableProperty;
import android.view.inspector.InspectableProperty.EnumEntry;
import android.widget.flags.Flags;
import android.widget.RemoteViews.InteractionHandler;

import com.android.internal.R;
@@ -4518,7 +4518,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
                    final int overscrollMode = getOverScrollMode();

                    if (!trackMotionScroll(delta, delta)) {
                        if (Flags.platformWidgetHapticScrollFeedback()) {
                        if (Flags.scrollFeedbackApi()) {
                            initHapticScrollFeedbackProviderIfNotExists();
                            mHapticScrollFeedbackProvider.onScrollProgress(
                                    event.getDeviceId(), event.getSource(), axis, delta);
@@ -4534,7 +4534,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
                        float overscroll = (delta - (motionViewRealTop - motionViewPrevTop))
                                / ((float) getHeight());
                        boolean hitTopLimit = delta > 0;
                        if (Flags.platformWidgetHapticScrollFeedback()) {
                        if (Flags.scrollFeedbackApi()) {
                            initHapticScrollFeedbackProviderIfNotExists();
                            mHapticScrollFeedbackProvider.onScrollLimit(
                                    event.getDeviceId(), event.getSource(), axis,
+12 −2
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import android.content.Context;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.ViewConfiguration;
import android.widget.flags.FeatureFlags;
import android.widget.flags.FeatureFlagsImpl;

import com.android.internal.annotations.VisibleForTesting;

@@ -50,6 +52,8 @@ public class DifferentialMotionFlingHelper {
    private final FlingVelocityThresholdCalculator mVelocityThresholdCalculator;
    private final DifferentialVelocityProvider mVelocityProvider;

    private final FeatureFlags mWidgetFeatureFlags;

    @Nullable private VelocityTracker mVelocityTracker;

    private float mLastFlingVelocity;
@@ -134,7 +138,8 @@ public class DifferentialMotionFlingHelper {
        this(context,
                target,
                DifferentialMotionFlingHelper::calculateFlingVelocityThresholds,
                DifferentialMotionFlingHelper::getCurrentVelocity);
                DifferentialMotionFlingHelper::getCurrentVelocity,
                /* widgetFeatureFlags= */ new FeatureFlagsImpl());
    }

    @VisibleForTesting
@@ -142,11 +147,13 @@ public class DifferentialMotionFlingHelper {
            Context context,
            DifferentialMotionFlingTarget target,
            FlingVelocityThresholdCalculator velocityThresholdCalculator,
            DifferentialVelocityProvider velocityProvider) {
            DifferentialVelocityProvider velocityProvider,
            FeatureFlags widgetFeatureFlags) {
        mContext = context;
        mTarget = target;
        mVelocityThresholdCalculator = velocityThresholdCalculator;
        mVelocityProvider = velocityProvider;
        mWidgetFeatureFlags = widgetFeatureFlags;
    }

    /**
@@ -156,6 +163,9 @@ public class DifferentialMotionFlingHelper {
     * @param axis the axis being processed by the target View.
     */
    public void onMotionEvent(MotionEvent event, int axis) {
        if (!mWidgetFeatureFlags.enablePlatformWidgetDifferentialMotionFling()) {
            return;
        }
        boolean flingParamsChanged = calculateFlingVelocityThresholds(event, axis);
        if (mFlingVelocityThresholds[0] == Integer.MAX_VALUE) {
            // Integer.MAX_VALUE means that the device does not support fling for the current
+3 −3
Original line number Diff line number Diff line
@@ -47,8 +47,8 @@ import android.view.ViewParent;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.animation.AnimationUtils;
import android.view.flags.Flags;
import android.view.inspector.InspectableProperty;
import android.widget.flags.Flags;

import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
@@ -1011,14 +1011,14 @@ public class ScrollView extends FrameLayout {
                    if (newScrollY != oldScrollY) {
                        super.scrollTo(mScrollX, newScrollY);
                        if (hitLimit) {
                            if (Flags.platformWidgetHapticScrollFeedback()) {
                            if (Flags.scrollFeedbackApi()) {
                                initHapticScrollFeedbackProviderIfNotExists();
                                mHapticScrollFeedbackProvider.onScrollLimit(
                                        event.getDeviceId(), event.getSource(), axis,
                                        /* isStart= */ newScrollY == 0);
                            }
                        } else {
                            if (Flags.platformWidgetHapticScrollFeedback()) {
                            if (Flags.scrollFeedbackApi()) {
                                initHapticScrollFeedbackProviderIfNotExists();
                                mHapticScrollFeedbackProvider.onScrollProgress(
                                        event.getDeviceId(), event.getSource(), axis, delta);
+8 −0
Original line number Diff line number Diff line
package: "android.widget.flags"

flag {
    namespace: "toolkit"
    name: "enable_platform_widget_differential_motion_fling"
    description: "Enables differential motion fling in platform widgets"
    bug: "293332089"
}
 No newline at end of file
+0 −8
Original line number Diff line number Diff line
package: "android.widget.flags"

flag {
    namespace: "widget"
    name: "platform_widget_haptic_scroll_feedback"
    description: "Enables haptic scroll feedback in platform widgets"
    bug: "287914819"
}
 No newline at end of file
Loading