• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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.server.notification;
18 
19 import android.net.Uri;
20 import android.os.UserHandle;
21 import android.service.notification.ZenModeConfig;
22 
23 import java.io.PrintWriter;
24 
25 /**
26  * Condition provider used for custom manual rules (i.e. user-created rules without an automatic
27  * trigger).
28  */
29 public class CustomManualConditionProvider extends SystemConditionProviderService {
30 
31     private static final String SIMPLE_NAME = CustomManualConditionProvider.class.getSimpleName();
32 
33     @Override
isValidConditionId(Uri id)34     public boolean isValidConditionId(Uri id) {
35         return ZenModeConfig.isValidCustomManualConditionId(id);
36     }
37 
38     @Override
onBootComplete()39     public void onBootComplete() {
40         // Nothing to do.
41     }
42 
43     @Override
onUserSwitched(UserHandle user)44     public void onUserSwitched(UserHandle user) {
45         // Nothing to do because we won't ever call notifyConditions.
46     }
47 
48     @Override
onConnected()49     public void onConnected() {
50         // No need to keep subscriptions because we won't ever call notifyConditions
51     }
52 
53     @Override
onSubscribe(Uri conditionId)54     public void onSubscribe(Uri conditionId) {
55         // No need to keep subscriptions because we won't ever call notifyConditions
56     }
57 
58     @Override
onUnsubscribe(Uri conditionId)59     public void onUnsubscribe(Uri conditionId) {
60         // No need to keep subscriptions because we won't ever call notifyConditions
61     }
62 
63     @Override
dump(PrintWriter pw, NotificationManagerService.DumpFilter filter)64     public void dump(PrintWriter pw, NotificationManagerService.DumpFilter filter) {
65         pw.print("    "); pw.print(SIMPLE_NAME); pw.println(": ENABLED");
66     }
67 }
68