1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5  * except in compliance with the License. You may obtain a copy of the License at
6  *
7  *      http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software distributed under the
10  * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11  * KIND, either express or implied. See the License for the specific language governing
12  * permissions and limitations under the License.
13  */
14 
15 package com.android.systemui.statusbar.phone;
16 
17 import android.annotation.NonNull;
18 import android.view.View;
19 
20 import com.android.systemui.statusbar.StatusBarState;
21 import com.android.systemui.statusbar.notification.row.ActivatableNotificationView;
22 
23 /**
24  * {@link ShadeController} is an abstraction of the work that used to be hard-coded in
25  * {@link StatusBar}. The shade itself represents the concept of the status bar window state, and
26  * can be in multiple states: dozing, locked, showing the bouncer, occluded, etc. All/some of these
27  * are coordinated with {@link StatusBarKeyguardViewManager} via
28  * {@link com.android.systemui.keyguard.KeyguardViewMediator} and others.
29  */
30 public interface ShadeController {
31 
32     /**
33      * Shows the keyguard bouncer - the password challenge on the lock screen
34      *
35      * @param scrimmed true when the bouncer should show scrimmed, false when the user will be
36      * dragging it and translation should be deferred {@see KeyguardBouncer#show(boolean, boolean)}
37      */
showBouncer(boolean scrimmed)38     void showBouncer(boolean scrimmed);
39 
40     /**
41      * Make our window larger and the panel expanded
42      */
instantExpandNotificationsPanel()43     void instantExpandNotificationsPanel();
44 
45     /**
46      * Collapse the shade animated, showing the bouncer when on {@link StatusBarState#KEYGUARD} or
47      * dismissing {@link StatusBar} when on {@link StatusBarState#SHADE}.
48      */
animateCollapsePanels(int flags, boolean force)49     void animateCollapsePanels(int flags, boolean force);
50 
51     /**
52      * If the notifications panel is not fully expanded, collapse it animated.
53      *
54      * @return Seems to always return false
55      */
closeShadeIfOpen()56     boolean closeShadeIfOpen();
57 
58     /**
59      * Add a runnable for NotificationPanelView to post when the panel is expanded.
60      *
61      * @param action the action to post
62      */
postOnShadeExpanded(Runnable action)63     void postOnShadeExpanded(Runnable action);
64 
65     /**
66      * Add a runnable to be executed after the shade collapses. Post-collapse runnables are
67      * aggregated and run serially.
68      *
69      * @param action the action to execute
70      */
addPostCollapseAction(Runnable action)71     void addPostCollapseAction(Runnable action);
72 
73     /**
74      * Ask shade controller to set the state to {@link StatusBarState#KEYGUARD}, but only from
75      * {@link StatusBarState#SHADE_LOCKED}
76      */
goToKeyguard()77     void goToKeyguard();
78 
79     /**
80      * When the keyguard is showing and covered by something (bouncer, keyguard activity, etc.) it
81      * is occluded. This is controlled by {@link com.android.server.policy.PhoneWindowManager}
82      *
83      * @return whether the keyguard is currently occluded
84      */
isOccluded()85     boolean isOccluded();
86 
87     /**
88      * Notify the shade controller that the current user changed
89      *
90      * @param newUserId userId of the new user
91      */
setLockscreenUser(int newUserId)92     void setLockscreenUser(int newUserId);
93 
94     /**
95      * Dozing is when the screen is in AOD or asleep
96      *
97      * @return true if we are dozing
98      */
isDozing()99     boolean isDozing();
100 
101     /**
102      * Ask the display to wake up if currently dozing, else do nothing
103      *
104      * @param time when to wake up
105      * @param view the view requesting the wakeup
106      * @param why the reason for the wake up
107      */
wakeUpIfDozing(long time, View view, @NonNull String why)108     void wakeUpIfDozing(long time, View view, @NonNull String why);
109 
110     /**
111      * If secure with redaction: Show bouncer, go to unlocked shade.
112      *
113      * <p>If secure without redaction or no security: Go to {@link StatusBarState#SHADE_LOCKED}.</p>
114      *
115      * @param startingChild The view to expand after going to the shade.
116      */
goToLockedShade(View startingChild)117     void goToLockedShade(View startingChild);
118 
119     /**
120      * Adds a {@param runnable} to be executed after Keyguard is gone.
121      */
addAfterKeyguardGoneRunnable(Runnable runnable)122     void addAfterKeyguardGoneRunnable(Runnable runnable);
123 
124     /**
125      * Close the shade if it was open
126      *
127      * @return true if the shade was open, else false
128      */
collapsePanel()129     boolean collapsePanel();
130 
131     /**
132      * If {@param animate}, does the same as {@link #collapsePanel()}. Otherwise, instantly collapse
133      * the panel. Post collapse runnables will be executed
134      *
135      * @param animate
136      */
collapsePanel(boolean animate)137     void collapsePanel(boolean animate);
138 
139     /**
140      * Callback to tell the shade controller that an activity launch animation was canceled
141      */
onLaunchAnimationCancelled()142     void onLaunchAnimationCancelled();
143 
144     /**
145      * When notifications update, give the shade controller a chance to do thing in response to
146      * the new data set
147      */
updateAreThereNotifications()148     void updateAreThereNotifications();
149 
150     /**
151      * Callback to notify the shade controller that a {@link ActivatableNotificationView} has become
152      * inactive
153      */
onActivationReset()154     void onActivationReset();
155 
156 }
157