1 /* 2 * Copyright (C) 2018 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.settings.accessibility; 17 18 import android.media.AudioAttributes; 19 import android.os.Vibrator; 20 import android.os.VibrationEffect; 21 import android.provider.Settings; 22 23 import com.android.internal.logging.nano.MetricsProto.MetricsEvent; 24 import com.android.settings.R; 25 26 /** 27 * Fragment for picking accessibility shortcut service 28 */ 29 public class NotificationVibrationPreferenceFragment extends VibrationPreferenceFragment { 30 @Override getMetricsCategory()31 public int getMetricsCategory() { 32 return MetricsEvent.ACCESSIBILITY_VIBRATION_NOTIFICATION; 33 } 34 35 @Override getPreferenceScreenResId()36 protected int getPreferenceScreenResId() { 37 return R.xml.accessibility_notification_vibration_settings; 38 } 39 40 /** 41 * Get the setting string of the vibration intensity setting this preference is dealing with. 42 */ 43 @Override getVibrationIntensitySetting()44 protected String getVibrationIntensitySetting() { 45 return Settings.System.NOTIFICATION_VIBRATION_INTENSITY; 46 } 47 48 @Override getPreviewVibrationAudioAttributesUsage()49 protected int getPreviewVibrationAudioAttributesUsage() { 50 return AudioAttributes.USAGE_NOTIFICATION; 51 } 52 53 @Override getDefaultVibrationIntensity()54 protected int getDefaultVibrationIntensity() { 55 Vibrator vibrator = getContext().getSystemService(Vibrator.class); 56 return vibrator.getDefaultNotificationVibrationIntensity(); 57 } 58 } 59