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 
17 package com.android.settings.accessibility;
18 
19 import android.content.Context;
20 import android.os.VibrationAttributes;
21 import android.provider.Settings;
22 
23 /** Preference controller for notification vibration intensity */
24 public class NotificationVibrationIntensityPreferenceController
25         extends VibrationIntensityPreferenceController {
26 
27     /** General configuration for notification vibration intensity settings. */
28     public static final class NotificationVibrationPreferenceConfig
29             extends VibrationPreferenceConfig {
30 
NotificationVibrationPreferenceConfig(Context context)31         public NotificationVibrationPreferenceConfig(Context context) {
32             super(context, Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
33                     VibrationAttributes.USAGE_NOTIFICATION);
34         }
35 
36         @Override
isRestrictedByRingerModeSilent()37         public boolean isRestrictedByRingerModeSilent() {
38             // Notifications never vibrate when the phone is in silent mode.
39             return true;
40         }
41     }
42 
NotificationVibrationIntensityPreferenceController(Context context, String preferenceKey)43     public NotificationVibrationIntensityPreferenceController(Context context,
44             String preferenceKey) {
45         super(context, preferenceKey, new NotificationVibrationPreferenceConfig(context));
46     }
47 
NotificationVibrationIntensityPreferenceController(Context context, String preferenceKey, int supportedIntensityLevels)48     protected NotificationVibrationIntensityPreferenceController(Context context,
49             String preferenceKey, int supportedIntensityLevels) {
50         super(context, preferenceKey, new NotificationVibrationPreferenceConfig(context),
51                 supportedIntensityLevels);
52     }
53 
54     @Override
getAvailabilityStatus()55     public int getAvailabilityStatus() {
56         return AVAILABLE;
57     }
58 }
59