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 Change-Id: I3b4e06660e3eaa6ce537b72831073f092cba37e2
This commit is contained in:
@@ -47,7 +47,7 @@ import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
public class KeyboardVibrationTogglePreferenceController extends TogglePreferenceController
|
||||||
implements DefaultLifecycleObserver {
|
implements DefaultLifecycleObserver {
|
||||||
@@ -110,7 +110,9 @@ public class KeyboardVibrationTogglePreferenceController extends TogglePreferenc
|
|||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
if (Flags.keyboardCategoryEnabled()
|
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 AVAILABLE;
|
||||||
}
|
}
|
||||||
return UNSUPPORTED_ON_DEVICE;
|
return UNSUPPORTED_ON_DEVICE;
|
||||||
|
@@ -84,6 +84,9 @@ public class KeyboardVibrationTogglePreferenceControllerTest {
|
|||||||
public void getAvailabilityStatus_featureSupported_available() {
|
public void getAvailabilityStatus_featureSupported_available() {
|
||||||
mSetFlagsRule.enableFlags(Flags.FLAG_KEYBOARD_CATEGORY_ENABLED);
|
mSetFlagsRule.enableFlags(Flags.FLAG_KEYBOARD_CATEGORY_ENABLED);
|
||||||
when(mResources.getBoolean(R.bool.config_keyboard_vibration_supported)).thenReturn(true);
|
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);
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user