summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Yeabkal Wubshit <yeabkal@google.com> 2024-10-11 05:31:18 +0000
committer Yeabkal Wubshit <yeabkal@google.com> 2024-10-11 16:30:26 +0000
commitbe573449742a40bd6c8fa3d063bc66fc416dd222 (patch)
treed2840ffc5b833738e6004fed467628826642e9bf
parentc5ebf7b1d5e21f26a3bfed35958b4a02c0c1e30c (diff)
Default to hardware vibration attribute for SCROLL_* feedback
In ag/29002964, we changed the default vibration attribute used for the SCROLL_* constants from hardware to touch. Although this is our goal in the long term, it's causing a bug (b/372380778), because there are older usages of the View.performHapticFeedback API that directly play the SCROLL_* constant without providing the input source. We will fix this in the long term via b/372820923. Bug: 372380778 Change-Id: I34c1b08bba1a0752ee190dd904b2d60395f98335 Test: atest HapticFeedbackVibrationProviderTest Flag: android.os.vibrator.haptic_feedback_input_source_customization_enabled
-rw-r--r--services/core/java/com/android/server/vibrator/HapticFeedbackVibrationProvider.java13
-rw-r--r--services/tests/vibrator/src/com/android/server/vibrator/HapticFeedbackVibrationProviderTest.java15
2 files changed, 8 insertions, 20 deletions
diff --git a/services/core/java/com/android/server/vibrator/HapticFeedbackVibrationProvider.java b/services/core/java/com/android/server/vibrator/HapticFeedbackVibrationProvider.java
index 006a5bb1d1d0..a235ba154579 100644
--- a/services/core/java/com/android/server/vibrator/HapticFeedbackVibrationProvider.java
+++ b/services/core/java/com/android/server/vibrator/HapticFeedbackVibrationProvider.java
@@ -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);
}
}
}
diff --git a/services/tests/vibrator/src/com/android/server/vibrator/HapticFeedbackVibrationProviderTest.java b/services/tests/vibrator/src/com/android/server/vibrator/HapticFeedbackVibrationProviderTest.java
index f7127df0ee33..3b2f532dddd7 100644
--- a/services/tests/vibrator/src/com/android/server/vibrator/HapticFeedbackVibrationProviderTest.java
+++ b/services/tests/vibrator/src/com/android/server/vibrator/HapticFeedbackVibrationProviderTest.java
@@ -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) {