1 /*
2  * Copyright (C) 2023 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 android.service.notification;
18 
19 import android.service.notification.ZenModeConfig.ConfigChangeOrigin;
20 
21 /**
22  * Responsible for making any service calls needed to apply the set of {@link ZenDeviceEffects} that
23  * make sense for the current platform.
24  * @hide
25  */
26 public interface DeviceEffectsApplier {
27     /**
28      * Applies the {@link ZenDeviceEffects} to the device.
29      *
30      * <p>The supplied {@code effects} represents the "consolidated" device effects, i.e. the
31      * union of the effects of all the {@link ZenModeConfig.ZenRule} instances that are currently
32      * active. If no rules are active (or no active rules specify custom effects) then {@code
33      * effects} will be all-default (i.e. {@link ZenDeviceEffects#hasEffects} will return {@code
34      * false}.
35      *
36      * <p>This will be called whenever the set of consolidated effects changes (normally through
37      * the activation or deactivation of zen rules).
38      *
39      * @param effects The effects that should be active and inactive.
40      * @param source The origin of the change. Because the application of specific effects can be
41      *               disruptive (e.g. lead to Activity recreation), that operation can in some
42      *               cases be deferred (e.g. until screen off). However, if the effects are
43      *               changing as a result of an explicit user action, then it makes sense to
44      *               apply them immediately regardless.
45      */
apply(ZenDeviceEffects effects, @ConfigChangeOrigin int source)46     void apply(ZenDeviceEffects effects, @ConfigChangeOrigin int source);
47 }
48