• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 package com.android.car.developeroptions.notification;
18 
19 import static android.provider.Settings.Secure.NOTIFICATION_NEW_INTERRUPTION_MODEL;
20 
21 import android.content.Context;
22 import android.os.UserHandle;
23 import android.provider.Settings;
24 
25 import com.android.car.developeroptions.core.TogglePreferenceController;
26 
27 import com.google.common.annotations.VisibleForTesting;
28 
29 public class SilentStatusBarPreferenceController extends TogglePreferenceController {
30 
31     private static final String KEY = "hide_silent_icons";
32     private static final int MY_USER_ID = UserHandle.myUserId();
33     private NotificationBackend mBackend;
34 
SilentStatusBarPreferenceController(Context context)35     public SilentStatusBarPreferenceController(Context context) {
36         super(context, KEY);
37         mBackend = new NotificationBackend();
38     }
39 
40     @VisibleForTesting
setBackend(NotificationBackend backend)41     void setBackend(NotificationBackend backend) {
42         mBackend = backend;
43     }
44 
45     @Override
isChecked()46     public boolean isChecked() {
47         return mBackend.shouldHideSilentStatusBarIcons(mContext);
48     }
49 
50     @Override
setChecked(boolean isChecked)51     public boolean setChecked(boolean isChecked) {
52         mBackend.setHideSilentStatusIcons(isChecked);
53         return true;
54     }
55 
56     @Override
getAvailabilityStatus()57     public int getAvailabilityStatus() {
58         return Settings.Secure.getInt(
59                 mContext.getContentResolver(), NOTIFICATION_NEW_INTERRUPTION_MODEL, 1) != 0
60                 ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
61     }
62 
63 }
64 
65 
66