• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.app.settings.SettingsEnums;
19 import android.media.AudioAttributes;
20 import android.os.Vibrator;
21 import android.provider.Settings;
22 
23 import com.android.settings.R;
24 
25 /**
26  * Fragment for picking accessibility shortcut service
27  */
28 public class RingVibrationPreferenceFragment extends VibrationPreferenceFragment {
29     @Override
getMetricsCategory()30     public int getMetricsCategory() {
31         return SettingsEnums.ACCESSIBILITY_VIBRATION_RING;
32     }
33 
34     @Override
getPreferenceScreenResId()35     protected int getPreferenceScreenResId() {
36         return R.xml.accessibility_ring_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.RING_VIBRATION_INTENSITY;
45     }
46 
47     @Override
getVibrationEnabledSetting()48     protected String getVibrationEnabledSetting() {
49         if (AccessibilitySettings.isRampingRingerEnabled(getContext())) {
50             return Settings.Global.APPLY_RAMPING_RINGER;
51         } else {
52             return Settings.System.VIBRATE_WHEN_RINGING;
53         }
54     }
55 
56     @Override
getPreviewVibrationAudioAttributesUsage()57     protected int getPreviewVibrationAudioAttributesUsage() {
58         return AudioAttributes.USAGE_NOTIFICATION_RINGTONE;
59     }
60 
61     @Override
getDefaultVibrationIntensity()62     protected int getDefaultVibrationIntensity() {
63         Vibrator vibrator = getContext().getSystemService(Vibrator.class);
64         return vibrator.getDefaultRingVibrationIntensity();
65     }
66 }
67