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

Commit 7cc66497 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Default to hardware vibration attribute for SCROLL_* feedback" into main

parents 5239f08d be573449
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -148,8 +148,8 @@ public final class HapticFeedbackVibrationProvider {
            case HapticFeedbackConstants.SCROLL_TICK:
            case HapticFeedbackConstants.SCROLL_ITEM_FOCUS:
            case HapticFeedbackConstants.SCROLL_LIMIT:
                attrs = hapticFeedbackInputSourceCustomizationEnabled() ? TOUCH_VIBRATION_ATTRIBUTES
                        : HARDWARE_FEEDBACK_VIBRATION_ATTRIBUTES;
                // TODO(b/372820923): use touch attributes by default.
                attrs = HARDWARE_FEEDBACK_VIBRATION_ATTRIBUTES;
                break;
            case HapticFeedbackConstants.KEYBOARD_TAP:
            case HapticFeedbackConstants.KEYBOARD_RELEASE:
@@ -176,14 +176,15 @@ public final class HapticFeedbackVibrationProvider {
            int inputSource,
            @HapticFeedbackConstants.Flags int flags,
            @HapticFeedbackConstants.PrivateFlags int privFlags) {
        if (hapticFeedbackInputSourceCustomizationEnabled()
                && inputSource == InputDevice.SOURCE_ROTARY_ENCODER) {
        if (hapticFeedbackInputSourceCustomizationEnabled()) {
            switch (effectId) {
                case HapticFeedbackConstants.SCROLL_TICK,
                        HapticFeedbackConstants.SCROLL_ITEM_FOCUS,
                        HapticFeedbackConstants.SCROLL_LIMIT -> {
                    return getVibrationAttributesWithFlags(HARDWARE_FEEDBACK_VIBRATION_ATTRIBUTES,
                            effectId, flags);
                    VibrationAttributes attrs = inputSource == InputDevice.SOURCE_ROTARY_ENCODER
                            ? HARDWARE_FEEDBACK_VIBRATION_ATTRIBUTES
                            : TOUCH_VIBRATION_ATTRIBUTES;
                    return getVibrationAttributesWithFlags(attrs, effectId, flags);
                }
            }
        }
+1 −14
Original line number Diff line number Diff line
@@ -453,20 +453,7 @@ public class HapticFeedbackVibrationProviderTest {
    }

    @Test
    public void testVibrationAttribute_scrollFeedback_inputCustomizedFlag_useTouchUsage() {
        mSetFlagsRule.enableFlags(FLAG_HAPTIC_FEEDBACK_INPUT_SOURCE_CUSTOMIZATION_ENABLED);
        HapticFeedbackVibrationProvider provider = createProviderWithoutCustomizations();

        for (int effectId : SCROLL_FEEDBACK_CONSTANTS) {
            VibrationAttributes attrs = provider.getVibrationAttributes(effectId, /* flags */
                    0, /* privFlags */ 0);
            assertWithMessage("Expected USAGE_TOUCH for scroll effect " + effectId
                    + ", if no input customization").that(attrs.getUsage()).isEqualTo(USAGE_TOUCH);
        }
    }

    @Test
    public void testVibrationAttribute_scrollFeedback_noInputCustomizedFlag_useHardwareFeedback() {
    public void testVibrationAttribute_scrollFeedback_useHardwareFeedback() {
        HapticFeedbackVibrationProvider provider = createProviderWithoutCustomizations();

        for (int effectId : SCROLL_FEEDBACK_CONSTANTS) {