1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.car.developeroptions.accessibility; 17 18 import android.app.settings.SettingsEnums; 19 import android.media.AudioAttributes; 20 import android.os.Vibrator; 21 import android.provider.Settings; 22 23 import com.android.car.developeroptions.R; 24 25 /** 26 * Fragment for picking accessibility shortcut service 27 */ 28 public class TouchVibrationPreferenceFragment extends VibrationPreferenceFragment { 29 @Override getMetricsCategory()30 public int getMetricsCategory() { 31 return SettingsEnums.ACCESSIBILITY_VIBRATION_TOUCH; 32 } 33 34 @Override getPreferenceScreenResId()35 protected int getPreferenceScreenResId() { 36 return R.xml.accessibility_touch_vibration_settings; 37 } 38 39 /** 40 * Get the setting string of the vibration intensity setting this preference is dealing with. 41 */ 42 @Override getVibrationIntensitySetting()43 protected String getVibrationIntensitySetting() { 44 return Settings.System.HAPTIC_FEEDBACK_INTENSITY; 45 } 46 47 @Override getVibrationEnabledSetting()48 protected String getVibrationEnabledSetting() { 49 return Settings.System.HAPTIC_FEEDBACK_ENABLED; 50 } 51 52 @Override getDefaultVibrationIntensity()53 protected int getDefaultVibrationIntensity() { 54 Vibrator vibrator = getContext().getSystemService(Vibrator.class); 55 return vibrator.getDefaultHapticFeedbackIntensity(); 56 } 57 58 @Override getPreviewVibrationAudioAttributesUsage()59 protected int getPreviewVibrationAudioAttributesUsage() { 60 return AudioAttributes.USAGE_ASSISTANCE_SONIFICATION; 61 } 62 } 63