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.testutils.shadow;
18 
19 import android.app.NotificationManager;
20 import android.net.Uri;
21 import android.service.notification.ZenModeConfig;
22 import android.util.ArraySet;
23 
24 import org.robolectric.annotation.Implementation;
25 import org.robolectric.annotation.Implements;
26 
27 import java.util.Set;
28 
29 @Implements(NotificationManager.class)
30 public class ShadowNotificationManager extends org.robolectric.shadows.ShadowNotificationManager {
31 
32     private int mZenMode;
33     private ZenModeConfig mZenModeConfig;
34     private Set<String> mNotificationPolicyGrantedPackages = new ArraySet<>();
35 
36     @Implementation
setZenMode(int mode, Uri conditionId, String reason)37     protected void setZenMode(int mode, Uri conditionId, String reason) {
38         mZenMode = mode;
39     }
40 
41     @Implementation
getZenMode()42     protected int getZenMode() {
43         return mZenMode;
44     }
45 
46     @Implementation
isNotificationPolicyAccessGrantedForPackage(String pkg)47     protected boolean isNotificationPolicyAccessGrantedForPackage(String pkg) {
48         return mNotificationPolicyGrantedPackages.contains(pkg);
49     }
50 
51     @Implementation
getZenModeConfig()52     public ZenModeConfig getZenModeConfig() {
53         return mZenModeConfig;
54     }
55 
setZenModeConfig(ZenModeConfig config)56     public void setZenModeConfig(ZenModeConfig config) {
57         mZenModeConfig = config;
58     }
59 
setNotificationPolicyAccessGrantedForPackage(String pkg)60     public void setNotificationPolicyAccessGrantedForPackage(String pkg) {
61         mNotificationPolicyGrantedPackages.add(pkg);
62     }
63 }
64