1 /*
2  * Copyright (C) 2020 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.systemui.statusbar;
18 
19 import android.graphics.Region;
20 import android.view.ViewGroup;
21 
22 import androidx.annotation.NonNull;
23 import androidx.annotation.Nullable;
24 
25 import com.android.systemui.statusbar.phone.StatusBarWindowCallback;
26 
27 import java.util.function.Consumer;
28 
29 /**
30  * Interface to control the state of the notification shade window. Not all methods of this
31  * interface will be used by each implementation of {@link NotificationShadeWindowController}.
32  */
33 public interface NotificationShadeWindowController extends RemoteInputController.Callback {
34 
35     /**
36      * Registers a {@link StatusBarWindowCallback} to receive notifications about status bar
37      * window state changes.
38      */
registerCallback(StatusBarWindowCallback callback)39     default void registerCallback(StatusBarWindowCallback callback) {}
40 
41     /**
42      * Unregisters a {@link StatusBarWindowCallback previous registered with
43      * {@link #registerCallback(StatusBarWindowCallback)}}
44      */
unregisterCallback(StatusBarWindowCallback callback)45     default void unregisterCallback(StatusBarWindowCallback callback) {}
46 
47     /** Notifies the registered {@link StatusBarWindowCallback} instances. */
notifyStateChangedCallbacks()48     default void notifyStateChangedCallbacks() {}
49 
50     /**
51      * Registers a listener to monitor scrims visibility.
52      *
53      * @param listener A listener to monitor scrims visibility
54      */
setScrimsVisibilityListener(Consumer<Integer> listener)55     default void setScrimsVisibilityListener(Consumer<Integer> listener) {}
56 
57     /**
58      * Adds the notification shade view to the window manager.
59      */
attach()60     default void attach() {}
61 
62     /** Requests this class to fetch the notification shade view. */
fetchWindowRootView()63     default void fetchWindowRootView() {}
64 
65     /** Gets the notification shade view. */
66     @Nullable
getWindowRootView()67     default ViewGroup getWindowRootView() {
68         return null;
69     }
70 
71     /** Sets the state of whether the keyguard is currently showing or not. */
setKeyguardShowing(boolean showing)72     default void setKeyguardShowing(boolean showing) {}
73 
74     /** Sets the state of whether the keyguard is currently occluded or not. */
setKeyguardOccluded(boolean occluded)75     default void setKeyguardOccluded(boolean occluded) {}
76 
77     /** Sets the state of whether the keyguard is currently needs input or not. */
setKeyguardNeedsInput(boolean needsInput)78     default void setKeyguardNeedsInput(boolean needsInput) {}
79 
80     /** Sets the state of whether the notification shade panel is currently visible or not. */
setPanelVisible(boolean visible)81     default void setPanelVisible(boolean visible) {}
82 
83     /** Sets the state of whether the notification shade is focusable or not. */
setNotificationShadeFocusable(boolean focusable)84     default void setNotificationShadeFocusable(boolean focusable) {}
85 
86     /** Sets the state of whether the bouncer is showing or not. */
setBouncerShowing(boolean showing)87     default void setBouncerShowing(boolean showing) {}
88 
89     /** Sets the state of whether the glanceable hub is showing or not. */
setGlanceableHubShowing(boolean showing)90     default void setGlanceableHubShowing(boolean showing) {}
91 
92     /** Sets the state of whether the backdrop is showing or not. */
setBackdropShowing(boolean showing)93     default void setBackdropShowing(boolean showing) {}
94 
95     /** Sets the state of whether the keyguard is fading away or not. */
setKeyguardFadingAway(boolean keyguardFadingAway)96     default void setKeyguardFadingAway(boolean keyguardFadingAway) {}
97 
98     /** Sets the state of whether the user activities are forced or not. */
setForceUserActivity(boolean forceUserActivity)99     default void setForceUserActivity(boolean forceUserActivity) {}
100 
101     /** Sets the state of whether an activity is launching or not. */
setLaunchingActivity(boolean launching)102     default void setLaunchingActivity(boolean launching) {}
103 
104     /** Get whether an activity is launching or not. */
isLaunchingActivity()105     default boolean isLaunchingActivity() {
106         return false;
107     }
108 
109     /** Sets the state of whether the scrim is visible or not. */
setScrimsVisibility(int scrimsVisibility)110     default void setScrimsVisibility(int scrimsVisibility) {}
111 
112     /** Sets the background blur radius of the notification shade window. */
setBackgroundBlurRadius(int backgroundBlurRadius)113     default void setBackgroundBlurRadius(int backgroundBlurRadius) {}
114 
115     /** Sets the state of whether heads up is showing or not. */
setHeadsUpShowing(boolean showing)116     default void setHeadsUpShowing(boolean showing) {}
117 
118     /** Gets whether the wallpaper is showing or not. */
isShowingWallpaper()119     default boolean isShowingWallpaper() {
120         return false;
121     }
122 
123     /** Sets whether the window was collapsed by force or not. */
setForceWindowCollapsed(boolean force)124     default void setForceWindowCollapsed(boolean force) {}
125 
126     /** Gets whether the panel is expanded or not. */
getPanelExpanded()127     default boolean getPanelExpanded() {
128         return false;
129     }
130 
131     /** Sets the state of whether the remote input is active or not. */
onRemoteInputActive(boolean remoteInputActive)132     default void onRemoteInputActive(boolean remoteInputActive) {}
133 
134     /** Sets the screen brightness level for when the device is dozing. */
setDozeScreenBrightness(int value)135     default void setDozeScreenBrightness(int value) {}
136 
137     /**
138      * Sets whether the screen brightness is forced to the value we use for doze mode by the status
139      * bar window. No-op if the device does not support dozing.
140      */
setForceDozeBrightness(boolean forceDozeBrightness)141     default void setForceDozeBrightness(boolean forceDozeBrightness) {}
142 
143     /** Sets the state of whether sysui is dozing or not. */
setDozing(boolean dozing)144     default void setDozing(boolean dozing) {}
145 
146     /** Sets the state of whether sysui is dreaming or not. */
setDreaming(boolean dreaming)147     default void setDreaming(boolean dreaming) {}
148 
149     /** Sets the state of whether plugin open is forced or not. */
setForcePluginOpen(boolean forcePluginOpen, Object token)150     default void setForcePluginOpen(boolean forcePluginOpen, Object token) {}
151 
152     /** Gets whether we are forcing plugin open or not. */
getForcePluginOpen()153     default boolean getForcePluginOpen() {
154         return false;
155     }
156 
157     /** Sets the state of whether the notification shade is touchable or not. */
setNotTouchable(boolean notTouchable)158     default void setNotTouchable(boolean notTouchable) {}
159 
160     /** Sets the region where touch is excluded from the parent window. */
setTouchExclusionRegion(Region region)161     default void setTouchExclusionRegion(Region region) {}
162 
163     /** Sets a {@link OtherwisedCollapsedListener}. */
setStateListener(OtherwisedCollapsedListener listener)164     default void setStateListener(OtherwisedCollapsedListener listener) {}
165 
166     /** Sets a {@link ForcePluginOpenListener}. */
setForcePluginOpenListener(ForcePluginOpenListener listener)167     default void setForcePluginOpenListener(ForcePluginOpenListener listener) {}
168 
169     /** Sets whether the system is in a state where the keyguard is going away. */
setKeyguardGoingAway(boolean goingAway)170     default void setKeyguardGoingAway(boolean goingAway) {}
171 
172     /**
173      * SystemUI may need top-ui to avoid jank when performing animations.  After the
174      * animation is performed, the component should remove itself from the list of features that
175      * are forcing SystemUI to be top-ui.
176      */
setRequestTopUi(boolean requestTopUi, String componentTag)177     default void setRequestTopUi(boolean requestTopUi, String componentTag) {}
178 
179     /**
180      * If {@link LightRevealScrim} obscures the UI.
181      * @param opaque if the scrim is opaque
182      */
setLightRevealScrimOpaque(boolean opaque)183     default void setLightRevealScrimOpaque(boolean opaque) {}
184 
185     /**
186      * Defer any application of window {@link WindowManager.LayoutParams} until {@code scope} is
187      * fully applied.
188      */
batchApplyWindowLayoutParams(@onNull Runnable scope)189     default void batchApplyWindowLayoutParams(@NonNull Runnable scope) {
190         scope.run();
191     }
192 
193     /**
194      * Custom listener to pipe data back to plugins about whether or not the status bar would be
195      * collapsed if not for the plugin.
196      * TODO: Find cleaner way to do this.
197      */
198     interface OtherwisedCollapsedListener {
setWouldOtherwiseCollapse(boolean otherwiseCollapse)199         void setWouldOtherwiseCollapse(boolean otherwiseCollapse);
200     }
201 
202     /**
203      * Listener to indicate forcePluginOpen has changed
204      */
205     interface ForcePluginOpenListener {
206         /**
207          * Called when mState.forcePluginOpen is changed
208          */
onChange(boolean forceOpen)209         void onChange(boolean forceOpen);
210     }
211 }
212