commit | 08308b2ee825a5d8938dd1931e0c8ef5d3c42ff0 | [log] [tgz] |
---|---|---|
author | Wilson Wu <wilsonwu@google.com> | Wed Mar 06 11:02:52 2024 +0000 |
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Thu Mar 07 20:54:55 2024 +0000 |
tree | c279b7a222e2af52ef2f66f2051bca9f7476510f | |
parent | 7147196c424e7b13dc142344a21bd09af91f34a0 [diff] |
Add fixed amplitude check for keyboard vibration Make sure the keybaord vibration settings only show up when fixed amplitude provided to avoid any unsync behavior with platform. Bug: 326027376 Test: atest KeyboardVibrationTogglePreferenceControllerTest (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:fd45101eee85da95a3de8d4ce2bfd01824e282c3) Merged-In: I3b4e06660e3eaa6ce537b72831073f092cba37e2 Change-Id: I3b4e06660e3eaa6ce537b72831073f092cba37e2
diff --git a/src/com/android/settings/accessibility/KeyboardVibrationTogglePreferenceController.java b/src/com/android/settings/accessibility/KeyboardVibrationTogglePreferenceController.java index 869443c..58aa0cc 100644 --- a/src/com/android/settings/accessibility/KeyboardVibrationTogglePreferenceController.java +++ b/src/com/android/settings/accessibility/KeyboardVibrationTogglePreferenceController.java
@@ -47,7 +47,7 @@ /** - * A preference controller to turn on/off keyboard vibration state with a single toggle. + * A preference controller to turn on/off keyboard vibration state with a single toggle. */ public class KeyboardVibrationTogglePreferenceController extends TogglePreferenceController implements DefaultLifecycleObserver { @@ -110,7 +110,9 @@ @Override public int getAvailabilityStatus() { if (Flags.keyboardCategoryEnabled() - && mContext.getResources().getBoolean(R.bool.config_keyboard_vibration_supported)) { + && mContext.getResources().getBoolean(R.bool.config_keyboard_vibration_supported) + && mContext.getResources().getFloat( + com.android.internal.R.dimen.config_keyboardHapticFeedbackFixedAmplitude) > 0) { return AVAILABLE; } return UNSUPPORTED_ON_DEVICE;
diff --git a/tests/robotests/src/com/android/settings/accessibility/KeyboardVibrationTogglePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/KeyboardVibrationTogglePreferenceControllerTest.java index cf12e34..2d5905e 100644 --- a/tests/robotests/src/com/android/settings/accessibility/KeyboardVibrationTogglePreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/KeyboardVibrationTogglePreferenceControllerTest.java
@@ -84,6 +84,9 @@ public void getAvailabilityStatus_featureSupported_available() { mSetFlagsRule.enableFlags(Flags.FLAG_KEYBOARD_CATEGORY_ENABLED); when(mResources.getBoolean(R.bool.config_keyboard_vibration_supported)).thenReturn(true); + when(mResources.getFloat( + com.android.internal.R.dimen.config_keyboardHapticFeedbackFixedAmplitude)) + .thenReturn(0.8f); assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE); }