Merge cherrypicks of ['googleplex-android-review.googlesource.com/26459632'] into 24Q2-release.

Change-Id: I439d6888ed42174a6dfdf69a9f6d4f6ca8542fe3
This commit is contained in:
Android Build Coastguard Worker
2024-03-07 20:58:00 +00:00
2 changed files with 7 additions and 2 deletions

View File

@@ -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
implements DefaultLifecycleObserver {
@@ -110,7 +110,9 @@ public class KeyboardVibrationTogglePreferenceController extends TogglePreferenc
@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;

View File

@@ -84,6 +84,9 @@ public class KeyboardVibrationTogglePreferenceControllerTest {
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);
}